Lion Cipher Lab
Build a local RAG pipeline over your own documents
- AI Security
- Intermediate
- ~60 min
- Free · no account required
Why it matters
A raw language model answers from a blurry average of everything it read during training. Ask it about YOUR refund policy, YOUR lab notes, or last week's meeting and it will often produce something fluent, confident, and wrong -- a made-up answer with no source behind it. That failure has a name: hallucination. Retrieval-augmented generation is the standard engineering fix, and it is refreshingly simple in shape: before the model answers, you search your own documents for the passages most relevant to the question, then you hand those passages to the model and tell it to answer only from…
What you'll learn
- what RAG (retrieval-augmented generation) is and the hallucination problem it solves
- loading your own text and PDF documents into a pipeline
- chunking: splitting long documents into passages small enough to retrieve and fit a model's context window
- embedding chunks with a local model (sentence-transformers) and storing them in a local vector database (Chroma)
- retrieval: turning a question into a vector and pulling back the most relevant chunks
- grounding: building a prompt that forces a local model (Ollama) to answer only from the retrieved chunks
- adding citations so every answer points back to the source passage
- proving RAG reduces hallucination by watching the model refuse when the answer is not in your documents
Steps in this lab
- The problem, and the shape of the fix (what RAG is)
- The seven words you need, defined once
- Install the stack: Ollama, then three Python libraries
- Put your documents somewhere and load them
- Chunk the documents into retrievable passages
- Embed every chunk and store it in a local vector database
- Retrieve the passages most relevant to a question
- Ground a local model in the retrieved chunks and generate the answer
- Prove it reduces hallucination: ask what your documents do NOT contain
- Add real citations so every answer is checkable
- What you built, the knobs to turn next, and where it goes