Atikova Waste RAG
A retrieval-augmented question-answering system for Türkiye's waste-management
system. It answers in Turkish, English, Persian and Arabic, and every answer is
grounded in the sourced corpus published at
sosa123454321/atovika-waste-tr.
What this repo contains. The underlying weights are third-party open models served from Cloudflare Workers AI, so no weights are duplicated here. This repo is the serving contract: the model card, the exact pipeline configuration, the prompt templates, the corpus manifest, and runnable clients. Versioning that is what makes a RAG system reproducible; a 2 GB copy of the encoder would not.
Live endpoint
curl -s -X POST https://atikova.com/api/rag/query \
-H 'Content-Type: application/json' \
-d '{"question":"Türkiye ne kadar belediye atığı üretiyor?"}'
{
"answer": "Türkiye yılda 34,4 milyon ton belediye atığı üretiyor (2024) …",
"sources": [{ "title": "Municipal waste generated: 34.4 million tonnes / year", "url": "…", "kind": "stat", "score": 0.81 }],
"provider": "workers-ai",
"model": "@cf/mistralai/mistral-small-3.1-24b-instruct",
"retrieved": 6
}
Pipeline
| Stage | Model | Notes |
|---|---|---|
| Embeddings | @cf/baai/bge-m3 |
Multilingual, 1024 dimensions. One space covers Turkish, English, Persian and Arabic, which is why a single index serves all four site languages. |
| Vector store | Cloudflare KV | A manifest plus chunked vector blocks. Cloudflare Vectorize is not available on the account's API token, and at a few hundred documents a brute-force cosine scan costs one manifest read plus a handful of block reads. |
| Reranking | @cf/baai/bge-reranker-base |
Cross-encoder over the top ~12 candidates before generation. Falls back to embedding order if unavailable. |
| Generation | @cf/mistralai/mistral-small-3.1-24b-instruct |
Primary. Answers correctly from Turkish context. |
| Fallback | @cf/meta/llama-3.1-8b-instruct-fp8 |
Used only if the primary fails. |
| Last resort | extractive | If every model is unavailable the endpoint returns the retrieved passages verbatim instead of failing. |
Why Mistral leads
@cf/meta/llama-3.1-8b-instruct — the obvious first choice — was deprecated on
2026-05-30. Its direct successor -fp8 is fast but misread a Turkish figure in
testing, returning "1,4 milyon ton" for a passage stating 34.4 Mt. On a system whose
entire purpose is trustworthy citation, that is disqualifying, so the multilingual
24B Mistral model is preferred and the smaller model is only a fallback.
Retrieval configuration
{
"embedding_model": "@cf/baai/bge-m3",
"embedding_dim": 1024,
"top_k_before_rerank": 12,
"top_k_after_rerank": 6,
"chunk_chars": 2000,
"vector_precision": 5,
"index_location": "Cloudflare KV: atovika:rag:manifest + atovika:rag:vec:<n>",
"corpus_docs": 64,
"rerank_model": "@cf/baai/bge-reranker-base"
}
Vectors are rounded to five decimals before storage: cosine ranking is unaffected at this scale and the payload shrinks substantially.
Prompt contract
See prompts.json. The system prompt forbids invention explicitly:
Answer ONLY from the numbered context passages provided. If the context does not contain the answer, say so plainly and suggest what data would be needed. Never invent statistics. Quote figures exactly as they appear, with their year and source when given. Answer in the same language as the question.
Passages are supplied as [n] title\nbody\nURL, and the cited passage indices are
returned to the caller alongside the answer so every claim can be checked.
Corpus
Built from src/lib/knowledge.ts and the auto-published news feed. Turkish and
English bodies are indexed for every document, so retrieval works in either language
regardless of the query language.
| Type | Count | Content |
|---|---|---|
stat |
20 | Türkiye waste indicators, each with publisher, year and URL |
solution |
20 | The ranked intervention roadmap |
problem |
2 | The gap narrative |
source |
22 | Auto-published news and trend digests |
Primary references: European Environment Agency country profile 2025, TÜİK waste statistics 2024, WWF-Türkiye, EJOSAT, CMS Law.
Intended use
Use it for orientation on Türkiye's municipal waste system, the recovery gap, biogas/composting options and the intervention roadmap, with citations.
Do not use it for regulatory or investment decisions without checking the linked primary source, as an official statement by any cited institution, or as an estimate of the waste profile of a specific parcel of waste.
Limitations
- The corpus is a curated subset of public data, not an exhaustive survey.
- Figures carry their own reference years (2015–2025); the system is instructed to always state the year, but the corpus is not a live feed.
- News items are machine summarised from public headlines and can be incomplete.
- Retrieval is lexical-agnostic dense search; exact numeric queries over unseen ranges will retrieve the nearest documented figure rather than compute one.
- Vector search is brute-force over a small corpus; scaling past a few thousand documents calls for a proper ANN index.
Reproducing an index
curl -X POST https://atikova.com/api/admin/actions \
-H "x-admin-key: $ADMIN_KEY" -H 'Content-Type: application/json' \
-d '{"action":"seed"}' # load the sourced corpus
curl -X POST https://atikova.com/api/admin/actions \
-H "x-admin-key: $ADMIN_KEY" -H 'Content-Type: application/json' \
-d '{"action":"build-index"}' # embed and write the vector blocks
Citation
@misc{atovika_waste_rag,
title = {Atikova Waste RAG: grounded question answering on Türkiye's waste system},
author = {Atikova},
year = {2026},
url = {https://atikova.com/insights},
note = {Retrieval corpus: https://huggingface.co/datasets/sosa123454321/atovika-waste-tr}
}
KAG layer (knowledge graph + retrieval)
This repo also configures KAG — knowledge-augmented generation. Next to the vector index, the
assistant links the question to entities in a sourced knowledge graph (100 checked sources in
the dataset, folder kag/), takes the facts one hop
around them — each with a verbatim evidence quote and its source — and answers from facts and
passages together, citing both. See kag_config.json.
curl -s -X POST https://atikova.com/api/kag/query -H 'Content-Type: application/json' \
-d '{"question":"Sıfır Atık Yönetmeliği hangi kurumu kapsıyor?"}'
Explorer: https://atikova.com/api/kag/graph · Space: https://huggingface.co/spaces/sosa123454321/atikova-kag · site page: https://atikova.com/knowledge