This project implements a simple Retrieval-Augmented Generation (RAG) pipeline using custom mock embeddings instead of pre-trained ones. It enables users to load a local .txt document and ask questions, retrieving relevant chunks and generating simulated LLM responses.
A command-line chatbot that:
- Loads a local text file
- Splits the content into chunks
- Generates mock embeddings
- Stores chunks in a simple in-memory vector store
- Retrieves the top K relevant chunks based on cosine similarity
- Augments the query with retrieved content
- Simulates an LLM response using a mock function
This project is ideal for learning the inner workings of document retrieval, vector similarity, and chatbot logic โ without relying on external APIs or heavy libraries.
- ๐ Load any
.txtfile from your local machine - โ๏ธ Custom chunking function to split large text
- ๐งฎ Mock embedding generator using ASCII transformations
- ๐ง Simple vector store with cosine similarity retrieval
- ๐ค Augmented prompt construction and fake LLM response generation
- ๐ Continuous Q&A chat loop until user exits
- Python (Standard Library)
- No external libraries or frameworks
- Load & Chunk Document
- Text is split into readable-sized chunks (default 100 chars).
- Generate Mock Embeddings
- Each character in the chunk is converted to a float using a simple formula.
- Vector Storage
- Chunks and embeddings are stored in a basic list of tuples.
- Query & Retrieval
- User's question is also embedded and cosine similarity is computed.
- Top K relevant chunks are retrieved.
- Prompt Augmentation
- A fake LLM prompt is created using retrieved context and query.
- Mock Response
- Simulated answer is printed with reference to matched content.