Repository navigation
Knowledge Base
The system answers only from six public documents. They live in data/raw/; their extracted text is in data/knowledge_base/nutrition_knowledge_base.json (810 chunks); the vector store built from it is app/chroma_storage/ (not in git).
| Document | Publisher | Year | Domain | Kenya-specific | Chunks |
|---|---|---|---|---|---|
| Kenya Nutrition Action Plan 2018-2022 | Kenya Ministry of Health | 2018 | nutrition | yes | 284 |
| Kenya Food Composition Tables | FAO / Kenya MoH | 2018 | nutrition | yes | 209 |
| National Guidelines for Healthy Diets and Physical Activity | Kenya Ministry of Health | 2017 | nutrition | yes | 146 |
| General Principles of Food Hygiene | FAO/WHO Codex | 2023 | food_safety | no | 94 |
| Kenya Nutrient Profile Model (KNPM) | Kenya Ministry of Health | 2025 | nutrition | yes | 63 |
| WHO healthy diet fact sheet | WHO | 2024 | nutrition | no | 14 |
By domain: 716 chunks nutrition, 94 chunks food_safety. Authority, year, domain and Kenya relevance are set per document in data/scripts/source_metadata.py.
data/raw/*.pdf
-> ingest_documents.py extract text (PyMuPDF), clean, split into sentence-based chunks of 100-220 words
-> data/knowledge_base/nutrition_knowledge_base.json
-> build_vector_store.py embed each chunk (all-mpnet-base-v2), store in ChromaDB collection "nutrition_kb"
-> app/chroma_storage/
Each chunk record has chunk_id (<pdf file name without extension>_<n>), text, source_document, authority, year, domain and kenya_relevance. These fields are stored in ChromaDB as metadata (kenya_relevance as a string).
You do not need the PDFs for this. Run python data/scripts/build_vector_store.py (Getting Started). Chunks whose text is unchanged are not re-embedded, so re-running only embeds new or edited chunks; use --reset after a re-ingest so chunks that no longer exist do not linger. Then restart the server: the BM25 index is built at startup and never refreshed.
The collection keeps Chroma's default (L2) distance setting, which the retriever was written against; the script deliberately does not change it.
- Put the PDF in
data/raw/. - Add an entry to
SOURCE_METADATAindata/scripts/source_metadata.py(authority, year, domain, Kenya relevance). - Run
python data/scripts/ingest_documents.pyfrom the repository root. It uses NLTK sentence tokenisation, so the NLTKpunktdata must be installed (python -m nltk.downloader punkt punkt_tab); without it the script falls back to a crude split. - Rebuild the vector store with
--reset, then restart the server.
Re-ingesting rewrites the JSON and changes chunk boundaries and IDs, which makes the committed evaluation test set (Evaluation) refer to chunks that no longer match.
-
Numbers are stripped.
clean_text()removes standalone integers (to drop page numbers), which also damages tables of values. The food-composition document is mostly tables, so numeric answers from it are unreliable. -
English only, and only the
nutritionandfood_safetydomains exist. - Coverage is small. Questions outside these six documents get an "not enough information" answer, by design.
- Licences. The documents are public, but redistribution terms differ. The FAO/WHO text carries a Creative Commons non-commercial notice. Check each publisher's terms before redistributing PDFs or extracted text (Known Issues and Limitations).
Documentation last verified against the code on 2026-11-05. Evaluation figures are historical, see Evaluation. Educational tool, not medical advice.
Use it
How it works
- Architecture
- Retrieval Pipeline
- LLM Layer
- Prompts and Lessons
- Grounding Verification
- Knowledge Base
- Data and Logging
Quality
Develop