● Portfolio project · AI engineering

A private document assistant that cites its sources and admits when it doesn't know.

I built a question-answering app that runs entirely on one computer. It searches a set of documents, answers only from what it finds, shows the passage it used, and declines when the documents don't cover the question.

This page explains what I built, why, and the engineering decisions behind it.

My role
Solo: design, build, tests, evaluation
Built with
Python, LangChain, Ollama, Chroma, Streamlit
Runs on
A laptop, with no cloud services
Status
v1.0.0 released · open source (MIT)
localhost:8501● llama3.2:3b

Scripted replay of the app's behavior on its sample documents

01 / Why I built it

Three problems I wanted to solve.

Retrieval-augmented generation (RAG) lets a language model answer from a specific set of documents instead of from memory. Tutorials make it look simple, but three problems usually get skipped.

01 — Trust

AI assistants make things up

A model will answer confidently even when it has nothing to go on. With company documents, a wrong answer that sounds right is worse than no answer. I wanted an assistant that shows its evidence and says so when it has none.

02 — Privacy

Some documents can't leave the building

Contracts, handbooks and client files often can't be sent to a third-party API. So everything runs locally, including both AI models and the search index.

03 — Reliability

Demos break when used for real

Most examples stop once the first answer works. I wanted to cover what comes after: failure recovery, start-up checks, automated tests and measured quality.

02 / What it does

What a user sees.

The app is a simple web interface. Behind it is a pipeline that I designed so each step can be checked and tested on its own.

→

Ask questions in plain language

A chat interface built with Streamlit. It shows each step as it happens: searching, checking the evidence, answering.

→

Answers show their source

Every answer includes the source link and the exact excerpt it came from, so a person can verify it in seconds.

→

An honest “I don't know”

If the documents don't support an answer, the assistant declines instead of guessing.

→

Upload PDFs

Text is extracted on the machine and cited down to the page. Uploading the same file twice is detected and skipped.

→

A readiness check

One command confirms the configuration, documents, local AI server, models and index are all ready, and explains what to fix if not.

→

Configured without code changes

Models, chunk sizes, search limits and thresholds are set in a .env file.

03 / How it works: adding documents

Adding documents can't break the working system.

Before the assistant can search documents, it splits them into chunks and converts each chunk into an embedding, a numeric representation stored in a vector database. That process can fail partway through, for example on a corrupt file or when the model server stops.

01

Upload

JSONL records or text PDFs, up to 20 MB each

02

Extract

Page text read locally; original file not kept

03

Validate

Every record checked before indexing

04

Chunk

1,000 characters, 200 overlapping

05

Embed → staging

Built in a separate, temporary index

06

Swap in

Replaces the live index only on full success

Why it matters: the new index is built separately and swapped in only once the whole build succeeds. If anything fails, the previous documents and index are restored, so users never search a half-built index.

04 / How it works: answering

It checks the evidence before it answers.

A basic RAG app retrieves some text and asks the model to answer from it, whether or not that text is relevant. I added an agent step: a separate judgement of whether the evidence actually supports an answer. If it doesn't, the agent rewrites the search once and tries again. If the evidence is still weak, it declines.

[1]

Only one retry

An agent that keeps retrying can loop, slow down and use unpredictable compute. One retry keeps the behavior predictable and testable.

[2]

The judgement outranks the similarity score

Text can look similar to a question without answering it. A high search score never overrides an “insufficient evidence” verdict.

[3]

Citations the model can't invent

Source links come from the stored document records, not from the model's text, so the assistant can't cite a page that doesn't exist.

[4]

Clear progress without internal reasoning

The interface shows what the agent is doing without exposing the model's internal reasoning.

sufficient insufficient sufficient still no Question Search documents Enoughevidence? Rewrite search Search again Judge again Answer + verified citations Decline
05 / Key decisions

Decisions I made, and what each one costs.

Every design choice has a downside. I wrote them down so the reasoning behind each choice can be reviewed along with the result.

DecisionWhat it givesWhat it costs
Local models (Ollama)Private, works offline, no per-request feesSpeed and answer quality depend on the hardware
Chroma vector databaseSimple to run, persists on diskSingle machine; not built for many users at once
Evidence check before answeringRetry and decline behavior can be testedOne extra model call per question
At most one retryNo loops or unpredictable delaysA second attempt might occasionally find an answer
Citations from stored recordsSources can't be inventedStill only as good as the search results
Rebuild, then swapA failed update never breaks the working indexNeeds temporary extra disk space
Page-level PDF extractionUploads are searchable right away, with page citationsScanned PDFs need OCR first
06 / Testing and results

How I checked that it works.

I built an evaluation tool that asks the assistant questions with known answers and scores the results. It fails the run if any score drops below a set threshold, and records the model versions and settings so runs can be compared.

The release run below used six questions. Four have answers in the documents and two deliberately don't. It shows the guardrails behave as designed; it doesn't claim general accuracy, which would need a much larger question set.

0%
Found the right document
Retrieval hit rate · target ≥ 75%
0%
Answered correctly
Answer correctness · target ≥ 75%
0
Made-up claims
Unsupported claims · target 0
2/2
Correct declines
Off-topic questions refused
cases 6/6 passedchat model llama3.2:3bembedding model mxbai-embed-largehardware Windows laptop · CPU only
run it yourself
# download the two local models
$ ollama pull mxbai-embed-large
$ ollama pull llama3.2:3b

# check that everything is ready
$ python -m local_rag.readiness

# build the index, then start the app
$ python -m local_rag.ingestion
$ streamlit run app.py

Automated checks on every change

Python 3.11Python 3.12 Ubuntu● pass● pass Windows● pass● pass
89 unit, interface and failure-recovery tests
Build fails if test coverage drops below 85%
Formatting and lint checks (Ruff)
Pinned dependencies, checked for conflicts
Same checks run locally with one command
07 / Takeaways

What this project shows, and what comes next.

Skills demonstrated

Building AI applications

Retrieval, embeddings, agent flows and guardrails against hallucinated answers.

LangChainOllamaChromaPydantic

Measuring AI quality

An evaluation tool with defined metrics, thresholds and reproducible reports.

Reliable data pipelines

Validation, isolated builds, rollback on failure and duplicate detection.

Software engineering practice

Automated tests, CI on two operating systems, clear docs, and tradeoffs written down.

GitHub ActionsRuffcoverageStreamlit

Known limits and next steps

Thanks for reading

Want to see the details or talk about a project?

The full source, documentation and evaluation records are on GitHub. I'm open to roles and freelance work building practical AI tools.