A local document question-answering app that combines semantic retrieval with a locally hosted language model. Add text in the browser, retrieve relevant passages from ChromaDB, and generate an answer with Ollama.
Browser (HTML/CSS/JavaScript)
↓ same-origin HTTP
FastAPI (/documents and /ask)
↓ paragraph chunks + embeddings
ChromaDB (persistent local vector store)
↓ top matching passages
Ollama (nomic-embed-text + qwen2.5:0.5b)
↓ answer and retrieved evidence
Browser
The app sends prompts and text to the local Ollama service. It has no hosted service or API key dependency. Model output can still be inaccurate; check the displayed passages before relying on an answer.
- Python 3.10 or newer
- Ollama installed and running
- Models pulled locally:
ollama pull nomic-embed-text
ollama pull qwen2.5:0.5bFrom the project directory:
python -m venv .venv
# Windows PowerShell
.venv\Scripts\Activate.ps1
# macOS/Linux: source .venv/bin/activate
pip install -r requirements.txt
ollama serveIn another terminal, start the API:
uvicorn main:app --reloadOpen http://127.0.0.1:8000. Use Add to your library to save a library name and text, then ask a question. The interface fills the library filter after saving. Re-submitting a library replaces its prior passages. Use different names to keep libraries separate.
profile.txt is intentionally excluded from Git because it may contain personal data. Create it locally, then run:
python build_knowledge_base.pyImported passages use the library name local-profile; enter that name in the search filter, or leave the filter empty to search all saved libraries.
GET /— browser interfacePOST /documents— add or replace a named library
{"user_name":"my-notes","content":"I use Python for data analysis.\n\nMy project uses FastAPI."}GET /ask?question=Which%20framework%3F&user=my-notes— retrieve passages and generate an answer. Theuserfilter is optional.GET /docs— interactive OpenAPI documentation
The /ask response includes answer, context_used, and filtered_by_user. When there is no retrieved context, the API returns a safe fallback without asking the model to invent an answer.
For a recruiter demo, start Ollama and the API, add a short fictional or non-sensitive document in the browser, ask one answerable and one unanswerable question, and show the retrieved passages under each answer. Take a screenshot of the browser at http://127.0.0.1:8000 after adding demo text. Do not add personal profiles, the local ChromaDB directory, virtual environments, credentials, or generated runtime files to Git.
- The small
qwen2.5:0.5bmodel may choose the wrong fact or miss an answer. Retrieved passages are shown so results can be checked. - Text is split on blank lines; this is a lightweight paragraph chunker, not a general file parser.
- The app is designed as a local single-machine demo. It has no authentication, access control, or production deployment hardening.
- Fine-tuning and performance tuning are outside this project's current scope.