AI & Tooling/ 2025/ 8 MIN READ

Local RAG That Doesn’t Collapse: Ollama + Nomic + a Real Vector Store

Most RAG demos look polished until the documents are private and the model is small. This insight walks through a local stack — Ollama, nomic-embed-text, and a real vector store — that kept answering against my own notes without leaking data or pretending the model was the hard part.

Local RAG That Doesn’t Collapse: Ollama + Nomic + a Real Vector Store
Cover · AI & Tooling
Key takeaways
  • 01Pin one embedding model for documents and queries
  • 02Classify every failure as retrieval or generation
  • 03Log retrieved chunks before you tune prompts
NA
Naol Adugna
Intermediate Software Developer

A hosted RAG demo looks impressive for about twenty minutes. The moment the documents are yours, the model is small enough to run on a laptop, and the answers have to survive real questions, most of that polish evaporates. This is the version that survived.

The actual goal

I didn’t want another chatbot that could summarize a PDF. I wanted a private knowledge loop: ingest my own notes and code comments, keep everything on the machine, and still get answers that were grounded enough to trust. A 1B-parameter model forced honesty. If retrieval was weak, the model had nowhere to hide.

Design constraint

Everything had to stay local. No external embedding API, no cloud vector store, no per-token bill while iterating. If it couldn’t run offline, it didn’t count.

Stack that actually shipped

  1. 01Ollama serving a 1B instruct model for generation
  2. 02nomic-embed-text (also via Ollama) for every embedding — documents and queries
  3. 03A local vector database for storage + similarity search
  4. 04Simple chunking with overlap, tuned by hand against a small eval set
  5. 05A thin retrieval → prompt → generate loop with logging of every retrieved chunk

Why nomic-embed-text mattered

The single most important consistency rule: the exact same embedding model must be used for both the knowledge base and the incoming question. Switching models (or even changing prefixes / normalization) silently moves the vectors into a different space. Similarity search still returns something; it’s just the wrong something.

The expensive mistake

Embedding documents with one model and queries with another produces results that look plausible and are quietly worse. Pin one embedding model and reuse it everywhere. Debugging this after the fact wastes a full day.

What the tests actually showed

Failure modes split cleanly into two buckets. Retrieval failures (the right chunk never came back) are expensive — no amount of prompt engineering fixes missing context. Generation failures (the chunk was present but ignored or hallucinated around) are cheaper and usually yield to tighter context ordering or a better system prompt.

  • →Chunk boundaries are a retrieval decision, not a formatting decision
  • →Top-k is a dial: too low starves the model, too high dilutes it
  • →A 1B model needs the most relevant chunk first
  • →Every wrong answer should be classified as retrieval or generation before any other change
  • →Log the retrieved chunks for every query — otherwise you are guessing
python
# Simplified retrieval + generation loop
query_emb = embed(query)  # same nomic model
chunks = vector_db.search(query_emb, top_k=4)
context = "\n\n".join(c.text for c in chunks)
prompt = f"Context:\n{context}\n\nQuestion: {query}\nAnswer:"

Where the small model wins and loses

For factual lookup grounded in clean retrieved context, the 1B model is fast, private, and accurate enough. It falls apart on multi-hop reasoning, long documents that require holding several chunks in tension, and anything that needs strong instruction following under noise. The lever is almost never “bigger model.” It is retrieval quality and prompt structure.

“With RAG, most of the intelligence lives in the retrieval, not the model.”

— Working notes from local runs

What I would change next time

  1. 01Build a small evaluation set before any tuning
  2. 02Log every query + its retrieved chunks from day one
  3. 03Treat chunk size and overlap as first-class experiments
  4. 04Stay fully local until retrieval hit-rate is measured and acceptable
  5. 05Only then consider hybrid or larger models
···

Takeaway

A local RAG stack built on Ollama, nomic-embed-text, and a proper vector store is not a toy. It is a private, cheap, fully controlled system that works the moment you treat retrieval as the hard problem. The 1B model is rarely the bottleneck people assume it is — mismatched embeddings, bad chunking, and untested prompts are.

Share this insight