<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Being-Creative-with-AI%2FC4%2FBuilding-a-Basic-RAG-system%2FEnglish</id>
		<title>Being-Creative-with-AI/C4/Building-a-Basic-RAG-system/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=Being-Creative-with-AI%2FC4%2FBuilding-a-Basic-RAG-system%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Being-Creative-with-AI/C4/Building-a-Basic-RAG-system/English&amp;action=history"/>
		<updated>2026-05-21T21:06:07Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=Being-Creative-with-AI/C4/Building-a-Basic-RAG-system/English&amp;diff=57810&amp;oldid=prev</id>
		<title>Ketkinaina: Created page with &quot;'''Title of the script: Building a basic RAG System.'''   '''Author: EduPyamids'''  '''Keywords: RAG, Retrieval Augmented Generation, Python, LangChain, ChromaDB, Hugging Face...&quot;</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=Being-Creative-with-AI/C4/Building-a-Basic-RAG-system/English&amp;diff=57810&amp;oldid=prev"/>
				<updated>2026-05-20T10:08:05Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;Title of the script: Building a basic RAG System.&amp;#039;&amp;#039;&amp;#039;   &amp;#039;&amp;#039;&amp;#039;Author: EduPyamids&amp;#039;&amp;#039;&amp;#039;  &amp;#039;&amp;#039;&amp;#039;Keywords: RAG, Retrieval Augmented Generation, Python, LangChain, ChromaDB, Hugging Face...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''Title of the script: Building a basic RAG System.''' &lt;br /&gt;
&lt;br /&gt;
'''Author: EduPyamids'''&lt;br /&gt;
&lt;br /&gt;
'''Keywords: RAG, Retrieval Augmented Generation, Python, LangChain, ChromaDB, Hugging Face Embeddings, Vector Database, AI, Similarity Search, Ubuntu, Linux, Pandas, Question Answering, Text Retrieval, Local RAG, Free AI Tools, Machine Learning, EduPyramids, video tutorial.'''&lt;br /&gt;
&lt;br /&gt;
{|border=1&lt;br /&gt;
|-&lt;br /&gt;
|| '''Visual Cue'''&lt;br /&gt;
|| '''Narration'''&lt;br /&gt;
|-&lt;br /&gt;
|| '''Slide 1'''&lt;br /&gt;
&lt;br /&gt;
'''Title Slide'''&lt;br /&gt;
|| Welcome to this '''Spoken Tutorial '''on '''Building a basic RAG System'''. &lt;br /&gt;
|-&lt;br /&gt;
|| '''Slide 2'''&lt;br /&gt;
&lt;br /&gt;
'''Learning Objectives'''&lt;br /&gt;
|| In this tutorial, we will learn how to-&lt;br /&gt;
* Build a simple '''RAG system'''.&lt;br /&gt;
* Retrieve and display answers from a '''dataset'''.&lt;br /&gt;
|-&lt;br /&gt;
|| '''Slide 3'''&lt;br /&gt;
&lt;br /&gt;
'''Disclaimer Slide'''&lt;br /&gt;
&lt;br /&gt;
As '''AI''' tools constantly evolve, if you are unable to locate any icon or encounter difficulty at any step, you may use any conversational '''AI''' '''Chatbot''' for guidance.&lt;br /&gt;
|| As '''AI''' tools constantly evolve, if you are unable to locate any icon or encounter difficulty at any step, you may use any conversational '''AI''' '''Chatbot''' for guidance.&lt;br /&gt;
|-&lt;br /&gt;
|| '''Slide 4'''&lt;br /&gt;
&lt;br /&gt;
'''System Requirements'''&lt;br /&gt;
|| To record this tutorial, I am using: &lt;br /&gt;
* '''Ubuntu 24.04 LTS'''&lt;br /&gt;
Learners will also need a working internet connection&lt;br /&gt;
|-&lt;br /&gt;
|| '''Slide 5'''&lt;br /&gt;
&lt;br /&gt;
'''Prerequisites'''&lt;br /&gt;
&lt;br /&gt;
[https://edupyramids.org/ https://EduPyramids.org]&lt;br /&gt;
|| To follow this tutorial, &lt;br /&gt;
* Learners should have '''Python''' installed on their system. &lt;br /&gt;
* A basic understanding of using the '''terminal'''. &lt;br /&gt;
&lt;br /&gt;
For the Prerequisites of this tutorial, visit the website shown on your screen&lt;br /&gt;
|- &lt;br /&gt;
|| '''Slide 6'''&lt;br /&gt;
&lt;br /&gt;
'''Code files'''&lt;br /&gt;
&lt;br /&gt;
The following code file is required to practice this tutorial* '''rag-command.txt'''&lt;br /&gt;
&lt;br /&gt;
This file is provided in the Code Files link of this tutorial page&lt;br /&gt;
&lt;br /&gt;
Please download and extract the file.&lt;br /&gt;
|| The following '''code file''' is required to practice this '''tutorial'''.&lt;br /&gt;
&lt;br /&gt;
This '''file '''is provided in the '''Code Files link '''of this '''tutorial''' page.&lt;br /&gt;
&lt;br /&gt;
Please '''download''' and extract the '''file'''.&lt;br /&gt;
|-&lt;br /&gt;
|| &lt;br /&gt;
|| In this tutorial, we will use a completely free setup.&lt;br /&gt;
&lt;br /&gt;
No '''API key''' or billing is required&lt;br /&gt;
|-&lt;br /&gt;
|| &lt;br /&gt;
|| Let us get started.&lt;br /&gt;
|-&lt;br /&gt;
|| Press '''Ctrl, Alt and T '''keys together to open the terminal.&lt;br /&gt;
|| Press '''Ctrl, Alt '''and''' T''' keys together to open the '''terminal.'''&lt;br /&gt;
|-&lt;br /&gt;
|| Type: '''cd rag_project''' and press '''Enter'''.&lt;br /&gt;
|| Type: '''cd rag_project''' and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
This '''command''' moves into the project folder.&lt;br /&gt;
|-&lt;br /&gt;
|| Type: '''source venv/bin/activate''' and press '''enter'''.&lt;br /&gt;
|| To activate the environment type this '''command''' and press''' Enter.'''&lt;br /&gt;
&lt;br /&gt;
You should now see '''(venv)''' in the '''terminal.'''&lt;br /&gt;
|-&lt;br /&gt;
|| Type: &lt;br /&gt;
&lt;br /&gt;
'''nano sample_data.csv''' and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
Point the cursor on the GNU editor.&lt;br /&gt;
&lt;br /&gt;
Question,Answer&lt;br /&gt;
&lt;br /&gt;
What is the return policy?,Items can be returned within 24 hours.&lt;br /&gt;
&lt;br /&gt;
Are vegetables returnable?,Perishable items cannot be returned.&lt;br /&gt;
&lt;br /&gt;
When will I get my refund?,Refunds take 3 to 5 business days.&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl + O''', then Enter to save.&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl + X''' to exit.&lt;br /&gt;
|| Now let us create a''' dataset file'''.&lt;br /&gt;
&lt;br /&gt;
Type the '''command''' and press '''Enter'''.&lt;br /&gt;
&lt;br /&gt;
'''GNU nano editor''' opens.&lt;br /&gt;
&lt;br /&gt;
Pause the tutorial and enter this data.&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl + O''', then '''Enter''' to save.&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl + X''' to exit.&lt;br /&gt;
|-&lt;br /&gt;
|| '''Type:''' '''nano basic_rag_demo.py''' and press '''Enter'''.&lt;br /&gt;
|| Now create a '''Python''' file&lt;br /&gt;
&lt;br /&gt;
Type this '''command''' to create a '''Python file''' and press '''Enter'''.&lt;br /&gt;
|-&lt;br /&gt;
|| '''Type:'''&lt;br /&gt;
&lt;br /&gt;
'''import pandas as pd'''&lt;br /&gt;
&lt;br /&gt;
'''from langchain_community.vectorstores import Chroma'''&lt;br /&gt;
&lt;br /&gt;
'''from langchain_community.embeddings import HuggingFaceEmbeddings'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''# Load dataset'''&lt;br /&gt;
&lt;br /&gt;
'''data = pd.read_csv(&amp;quot;sample_data.csv&amp;quot;)'''&lt;br /&gt;
&lt;br /&gt;
'''# Combine Question and Answer'''&lt;br /&gt;
&lt;br /&gt;
'''documents = (data[&amp;quot;Question&amp;quot;] + &amp;quot; &amp;quot; + data[&amp;quot;Answer&amp;quot;]).tolist()'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''# Create embeddings (free model)'''&lt;br /&gt;
&lt;br /&gt;
'''embeddings = HuggingFaceEmbeddings(model_name=&amp;quot;all-MiniLM-L6-v2&amp;quot;)'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''# Store in vector database'''&lt;br /&gt;
&lt;br /&gt;
'''db = Chroma.from_texts(documents, embeddings)'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''# Take user query'''&lt;br /&gt;
&lt;br /&gt;
'''query = input(&amp;quot;Enter your question: &amp;quot;)'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''# Retrieve similar result'''&lt;br /&gt;
&lt;br /&gt;
'''results = db.similarity_search(query, k=1)'''&lt;br /&gt;
&lt;br /&gt;
'''context = results[0].page_content'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''# Display context'''&lt;br /&gt;
&lt;br /&gt;
'''print(&amp;quot;\nRetrieved Context:&amp;quot;)'''&lt;br /&gt;
&lt;br /&gt;
'''print(context)'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''# Extract answer'''&lt;br /&gt;
&lt;br /&gt;
'''if &amp;quot;?&amp;quot; in context:'''&lt;br /&gt;
&lt;br /&gt;
'''answer = context.split(&amp;quot;?&amp;quot;)[-1].strip()'''&lt;br /&gt;
&lt;br /&gt;
'''else:'''&lt;br /&gt;
&lt;br /&gt;
'''answer = context'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''print(&amp;quot;\nAnswer:&amp;quot;)'''&lt;br /&gt;
&lt;br /&gt;
'''print(answer)'''&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl + O''', then Enter to save.&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl + X''' to exit&lt;br /&gt;
|| Pause the tutorial and type this '''code''' carefully.&lt;br /&gt;
&lt;br /&gt;
This script creates '''embeddings''' and retrieves similar answers from data.&lt;br /&gt;
&lt;br /&gt;
'''Embeddings''' help find similar meanings, not just exact keyword matches&lt;br /&gt;
&lt;br /&gt;
'''Chroma''' acts as a lightweight '''vector''' '''database''' for storing '''embeddings'''.&lt;br /&gt;
&lt;br /&gt;
The system retrieves the most relevant match from the stored data.&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl + O''', then '''Enter''' to save.&lt;br /&gt;
&lt;br /&gt;
Press '''Ctrl + X''' to exit.&lt;br /&gt;
|-&lt;br /&gt;
|| Type: '''python basic_rag_demo.py '''and press '''Enter'''.&lt;br /&gt;
|| Now run the '''program. '''&lt;br /&gt;
&lt;br /&gt;
Type the following '''command''' and press '''Enter'''.&lt;br /&gt;
|-&lt;br /&gt;
|| Type: Can I return vegetables? &lt;br /&gt;
|| Type: Can I return vegetables? &lt;br /&gt;
|-&lt;br /&gt;
|| Highlight the relevant context.&lt;br /&gt;
|| The system retrieves relevant context.&lt;br /&gt;
|-&lt;br /&gt;
|| Highlight the displayed answer.&lt;br /&gt;
|| Then it displays the answer.&lt;br /&gt;
|-&lt;br /&gt;
|| Output highlighted&lt;br /&gt;
|| Notice that the system finds the closest matching data.&lt;br /&gt;
&lt;br /&gt;
The system then extracts the answer from the retrieved context.&lt;br /&gt;
|-&lt;br /&gt;
|| &lt;br /&gt;
|| You have successfully built a simple '''RAG''' '''system'''.&lt;br /&gt;
&lt;br /&gt;
This system works completely free without any '''API key.'''&lt;br /&gt;
|-&lt;br /&gt;
|| &lt;br /&gt;
|| With this, we come to the end of this tutorial.&lt;br /&gt;
|-&lt;br /&gt;
|| '''Slide 7'''&lt;br /&gt;
&lt;br /&gt;
'''Summary'''&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we learnt how to:&lt;br /&gt;
* Build a simple '''RAG system'''.&lt;br /&gt;
* Retrieve and display answers from a '''dataset'''.&lt;br /&gt;
|| In this tutorial, we learnt how to* Build a simple '''RAG system'''.&lt;br /&gt;
* Retrieve and display answers from a '''dataset'''.&lt;br /&gt;
|-&lt;br /&gt;
|| '''Slide 8'''&lt;br /&gt;
&lt;br /&gt;
'''Acknowledgement'''&lt;br /&gt;
&lt;br /&gt;
'''Domain Inputs: Bhavani Shankar R and Saisudha Sugavanam'''&lt;br /&gt;
&lt;br /&gt;
'''Script Writer: Ketki Naina'''&lt;br /&gt;
&lt;br /&gt;
'''Admin Reviewer: Arthi Varadarajan'''&lt;br /&gt;
&lt;br /&gt;
'''Quality Reviewer: Sakina Sidhwa'''&lt;br /&gt;
&lt;br /&gt;
'''Novice Reviewer: Misbah Samir'''&lt;br /&gt;
&lt;br /&gt;
'''AI Narration: Debosmita Mukherjee'''&lt;br /&gt;
&lt;br /&gt;
'''Screen recording:'''&lt;br /&gt;
&lt;br /&gt;
'''Video Editor: Arvind Pillai'''&lt;br /&gt;
&lt;br /&gt;
'''Web Developer: Ankita Singhal'''&lt;br /&gt;
|| Thank you for joining.&lt;br /&gt;
|-&lt;br /&gt;
|| '''Slide 9'''&lt;br /&gt;
&lt;br /&gt;
'''Acknowledgement'''&lt;br /&gt;
&lt;br /&gt;
This '''Spoken''' '''Tutorial''' is brought to you by '''EduPyramids Educational Services Private Limited''' at SINE, IIT Bombay. &lt;br /&gt;
|| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Ketkinaina</name></author>	</entry>

	</feed>