A fully local, offline RAG (retrieval-augmented generation) system for interview Q&A. No training required — it retrieves the closest matching Q&A pairs to a question and asks a small local model to phrase the answer.
User question
-> embed it (all-minilm via Ollama)
-> find closest Q&A pairs (in-memory cosine similarity search)
-> hand those pairs + the question to a small local chat model (phi3 via Ollama)
-> return the generated answer
- InterviewPrepSLM.Core — the actual RAG engine. No console/UI code here,
so it can be reused inside a Web API, an agent tool, a background service,
anything.
Models/QAPair.cs— the Q&A data shapeRetrieval/CosineSimilarity.cs— vector comparison, pure functionRetrieval/InMemoryVectorStore.cs— brute-force nearest-neighbor searchQAAgent.cs— orchestrator: embed → search → generate
- InterviewPrepSLM.Console — a console host you can run and chat with directly.
- InterviewPrepSLM.Tests — xUnit tests for the retrieval logic, using a fake embedding generator so tests don't need Ollama running.
- data/qa-pairs.json — your Q&A pairs. Add as many as you want; the
schema is
question,answer,category(optional),tags(optional).
-
Install Ollama (runs models fully offline once downloaded): https://ollama.com/download
-
Pull the two models this project uses:
ollama pull all-minilm ollama pull phi3all-minilmturns text into vectors for search.phi3writes the final answer. Both run on CPU; a GPU just makes them faster. -
Restore and build:
dotnet restore dotnet build -
Run the tests (no Ollama needed for these — they use a fake embedder):
dotnet test -
Run the console app (Ollama must be running in the background):
dotnet run --project InterviewPrepSLM.Console
Edit data/qa-pairs.json — each entry just needs question and answer.
category and tags are optional and not used by search yet, but are there
if you want to filter or group later.
Any agent/tool framework just needs to call QAAgent.AskAsync(question) —
that's the entire public surface. Wrap it in a Web API controller, an MCP
tool, or a plain method call; the RAG logic doesn't care about the caller.
- More than a few thousand Q&A pairs: swap
InMemoryVectorStorefor a real vector store (e.g. pgvector, Qdrant, Azure AI Search) behind the sameIVectorStoreinterface — nothing else in the app changes. - Want a different model or provider:
QAAgentdepends onIEmbeddingGenerator<string, Embedding<float>>andIChatClient, both fromMicrosoft.Extensions.AI. OllamaSharp implements both, but so do other providers (Azure OpenAI, OpenAI, etc.) — swap the implementation inProgram.csonly. - Want the model to actually "learn" your material rather than retrieve it: that's fine-tuning, a separate step from this RAG setup. Worth doing once you have a larger, well-reviewed dataset — this RAG pipeline is a good source of that data since you'll see which retrieved answers needed the most rephrasing.
OllamaSharp and the Microsoft.Extensions.AI abstractions it implements
are both actively evolving. If a method name doesn't match what's in this
code, check IntelliSense or the OllamaSharp GitHub repo — the shape shown
here matches the versions current as of mid-2026.