Spaces:
Sleeping
Sleeping
Download api/rag/__init__.py from hodoly163/krishibondhu-api: direct link, hf CLI and curl.
- Browser
- Download file 919 Bytes
-
https://huggingface.co/spaces/hodoly163/krishibondhu-api/resolve/main/api/rag/__init__.py
- Command line
-
hf download hf://spaces/hodoly163/krishibondhu-api/api/rag/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/hodoly163/krishibondhu-api/resolve/main/api/rag/__init__.py
919 Bytes
| """KrishiBondhu RAG — lightweight, zero-dependency retrieval over the in-repo | |
| disease knowledge base. | |
| Techniques implemented (disclosed honestly for submission): | |
| - Naive RAG: retrieve-then-generate; chunks injected as silent context. | |
| - Semantic / variable chunking: split on semantic boundaries (headings + | |
| sentence windows), not fixed token lengths. | |
| - Contextual RAG (Anthropic-style): each chunk is prepended with a short | |
| document-level context summary before scoring/generation. | |
| - TF-IDF cosine vector store: in-memory numpy vectors over the KB | |
| (JSON-seeded, no external service required). | |
| - Graph RAG (light): crop -> disease -> treatment entity graph extracted | |
| from the KB; multi-hop neighbours boost retrieval + are cited. | |
| Only stdlib + numpy (already a backend dependency). | |
| """ | |
| from .store import retrieve, get_graph_neighbors, TECHNIQUES | |
| __all__ = ["retrieve", "get_graph_neighbors", "TECHNIQUES"] | |