Skip to content

Getting Started

PantheraNestah edited this page Nov 5, 2026 · 1 revision

Getting Started

This page takes you from a fresh clone to a working /query call. Short version: README.

Prerequisites

  • Python 3.12 (the version this was tested on; others are untested).
  • A few GB of free disk space: PyTorch, plus three Hugging Face models downloaded on first start (all-mpnet-base-v2, cross-encoder/ms-marco-MiniLM-L-6-v2, cross-encoder/nli-MiniLM2-L6-H768).
  • Internet access on first start.
  • An API key for at least one LLM provider.

1. Install

git clone https://github.com/PantheraNestah/nutripepper-rag.git
cd nutripepper-rag
python3.12 -m venv .venv && source .venv/bin/activate

Without a GPU (tested path)

requirements.txt pins NVIDIA CUDA and Triton packages (nvidia-*, cuda-*, triton). They do not install on a machine without a GPU and take several GB. Install CPU PyTorch first, then everything else except those lines:

pip install torch==2.12.0 --index-url https://download.pytorch.org/whl/cpu
grep -vE '^(nvidia-|cuda-|triton)' requirements.txt | grep -v '^torch==' > /tmp/requirements.nogpu.txt
pip install -r /tmp/requirements.nogpu.txt
pip check          # should report no broken requirements

With a GPU

pip install -r requirements.txt is the intended path. It has not been tested on a GPU machine.

Notes on the requirements file

  • It also contains packages the code does not use (for example google-generativeai, Jupyter and pipreqs). They are harmless but add size.
  • pytest is not listed. Install it to run the tests (Testing).

2. Configure

cp .env.example .env

Set the API key for each provider your tiers use. Only providers actually used by a tier need a key; a missing key only fails when that tier is first called.

Anthropic only (default). Set ANTHROPIC_API_KEY. Nothing else is needed.

DeepSeek only. Set DEEPSEEK_API_KEY and add:

LLM_MODEL_COMPLEX=deepseek:deepseek-flash:high
LLM_MODEL_MEDIUM=deepseek:deepseek-flash:low
LLM_MODEL_EASY=deepseek:deepseek-flash:low

Mixed. Set both keys and override only the tiers you want to move. Tiers with no line stay on Anthropic. Full reference: Configuration.

3. Build the vector store

The vector store (app/chroma_storage/) is gitignored, so a fresh clone does not have it and the first retrieval fails with No ChromaDB collections found. The repository does include the extracted text (data/knowledge_base/nutrition_knowledge_base.json, 810 chunks), so you can build the store without the PDFs. From anywhere:

python data/scripts/build_vector_store.py

It embeds the chunks with all-mpnet-base-v2 (downloaded on first use; about 20 minutes on a CPU-only machine, measured at 22) and creates the collection nutrition_kb in app/chroma_storage/. Chunks are matched by ID and unchanged ones are skipped, so re-running is safe and quick (about half a minute when nothing changed); add --reset to delete the collection first. Options: --kb and --output to use other paths, --batch-size to tune memory. The ingestion step and how to add documents are in Knowledge Base.

4. Run

uvicorn app.main:app --host 127.0.0.1 --port 8000

./run.sh does the same with --host 0.0.0.0 --reload. That listens on every network interface, and the API has no authentication, so use it only on a trusted network. --reload is for development.

What happens at startup

  1. The SQLite tables are created if they do not exist.
  2. Models and indexes are preloaded in a worker thread: the vector store, the BM25 index, the embedding model, the re-ranker and the verification model. On a CPU this takes about 50 s including imports. You will see [Warmup] retriever ready in ... and [Warmup] verifier ready in ... in the log.
  3. The server starts accepting requests.

Set PRELOAD_MODELS=false to skip step 2. Startup is then quick, but the first request pays the loading cost (minutes on a CPU).

5. Smoke test

curl -s -X POST http://127.0.0.1:8000/query \
  -H 'Content-Type: application/json' \
  -d '{"user_query": "What are good sources of iron for a toddler?"}'

Every response carries an X-Process-Time header. In the server log you should see the retrieval stages, a line like [LLM] tier=medium -> anthropic:claude-haiku-5-5:medium, and, some seconds later, [Logger] Verification complete.

If something fails, see Operations and Troubleshooting.

Clone this wiki locally