Human-Guided Parametric-vs-Retrieval Gating is a proof-of-concept system for controlling how a language model answers user queries. It decides, per query, whether to:
- Answer from the model’s parametric memory (fast but potentially stale)
- Retrieve and cite supporting documents
- Run computations
- Clarify the question
- Escalate / abstain when it cannot safely answer
The objective is to maximize truthfulness and citation quality while keeping latency and token costs within budget. This system is designed to be multilingual (English, Hindi, Urdu, and Spanish) and to train its decision policy from human-labelled data.
app/ # Streamlit data labelling app and evaluation dashboard
data/ # Datasets and data cards
features/ # Feature extraction modules used by the gating policy
policy/ # Data loading and training code for the gating controller
orchestrator/ # Code that ties the policy, retrieval, and tools together
truth/ # Adapters for truthfulness and citation checking metrics
evals/ # Evaluation scripts (hallucination rate, citation precision, freshness SLA)
ci/ # Continuous integration configuration and quality gates
scripts/ # Helper scripts for data collection, training, and evaluation
tests/ # Unit tests
-
Install dependencies Built with Python 3. Requires
numpy,pandas,fastapi, and optionallytorch+transformersfor model training and inference. Install with:pip install -r requirements.txt
-
Launch the data studio Start the Streamlit app for collecting labels:
streamlit run app/data_studio.py
-
Train the gating policy After collecting labelled queries, create a dataset and train the policy:
python scripts/train_policy.py --data=data/curated/labels.jsonl --out=policy/model
-
Run the orchestrator API Launch the FastAPI service to answer queries:
uvicorn orchestrator.pipeline:app --reload
Access the
/answerendpoint to submit queries. -
Evaluate performance Use scripts in
evals/to benchmark against baseline strategies. Reports include metrics such as:- Stale hallucination rate
- Citation precision
- Freshness SLA compliance
- Multilingual: Designed for English, Hindi, Urdu, and Spanish.
- Extensible: Policies and feature extractors are modular for experimentation.
- Evaluation-first: Emphasizes metrics that directly measure truthfulness, freshness, and cost trade-offs.
- CI Integration: Quality gates and workflows included under
ci/.
This project is under active development and not production-ready. Many components contain placeholders that should be replaced with stronger retrieval modules, advanced verification tools, and more robust training strategies. It serves as a framework to explore research ideas around freshness-aware retrieval gating.