A simple demonstration of Retrieval-Augmented Generation (RAG) that showcases the difference between vanilla AI responses and grounded, context-aware answers.
This application demonstrates a basic RAG system that:
- Loads documents from a local folder
- Retrieves relevant documents based on user queries
- Provides both vanilla AI answers and grounded answers using retrieved context
- Shows how retrieval improves answer quality and accuracy
- Document Loading: Automatically loads text documents from the
sample_docs/folder - Simple Retrieval: Uses keyword-based scoring to find relevant documents
- Dual Response Mode:
- Vanilla answers without context
- Grounded answers using retrieved documents
- Interactive CLI: Easy-to-use command-line interface
- Clone or download this repository
- Ensure you have Python 3.6+ installed
- No additional dependencies required (uses only Python standard library)
Run the demo from the command line:
python demo.pyThe application will:
- Load all
.txtfiles from thesample_docs/folder - Prompt you to ask a question
- Show a vanilla AI response (without context)
- Retrieve relevant documents based on your query
- Show a grounded response using the retrieved context
Welcome to the Mini-RAG Demo.
Ask a question: How do I reset my password?
--- Without Retrieval (Vanilla AI) ---
I'm answering your question 'How do I reset my password?', but I don't have any documents to look at. My answer may be incomplete.
--- Retrieving Context ---
--- With Retrieval (Grounded Answer) ---
Answer based on retrieved docs for 'How do I reset my password?':
- From faq.txt (score 2): Students often ask how to reset passwords. Password reset links expire after 15 minutes for security reasons. Users must verify email ownership...
This answer is grounded in retrieved context.