█

AI/TLDR

मुझे पिलाएं कॉफ़ी
मुझे एक कॉफ़ी पिलाएँ

TrustRAG

"reliable input, trusted output" के सिद्धांत पर बना एक कॉन्फ़िगरेबल, मॉड्यूलर Python RAG फ्रेमवर्क, जिसमें citations, reranking और Gradio स्टूडियो शामिल हैं

RAG Frameworks & Platformsओपन सोर्स
भाषा
Python
$conda create -n trustrag python=3.12.0
संक्षेप में

TrustRAG क्या है?

TrustRAG "reliable input, trusted output" के सिद्धांत पर बना एक कॉन्फ़िगरेबल, मॉड्यूलर Python RAG फ्रेमवर्क, जिसमें citations, reranking और Gradio स्टूडियो शामिल हैं. यह Retrieval & Knowledge (RAG) टूल्स की RAG Frameworks & Platforms श्रेणी में आता है; ओपन सोर्स है और Python में लिखा गया है। शुरू करने के लिए: environment बनाएं और इंस्टॉल करें.

सारांश

TrustRAG, Key Laboratory of Network Data Science and Technology के GoMate टीम द्वारा बनाया गया, Python के लिए एक कॉन्फ़िगरेबल और मॉड्यूलर retrieval-augmented generation (RAG) फ्रेमवर्क है। इसका ध्येय-वाक्य है "reliable input, trusted output": retrieval-based question answering में उच्च-गुणवत्ता और भरोसेमंद जवाब देना ही लक्ष्य है, और पाइपलाइन का हर चरण एक अलग मॉड्यूल है, जिसे आप अपने परिदृश्य के हिसाब से बदल या ट्यून कर सकते हैं।

The Chat tab of TrustRAG Studio: model, top-k and RAG mode settings on the left, a cited answer in the middle, and reformulated queries, selected evidence and a claim attribution panel on the right
TrustRAG Studio's chat view shows the answer with numbered citations next to the rewritten queries and the evidence each claim came from.TrustRAG README ↗

यह पैकेज ऐसे मॉड्यूलों के सेट के रूप में व्यवस्थित है जो RAG चेन के चरणों से मेल खाते हैं: दस्तावेज़ पार्सिंग और chunking, query rewriting, retrieval, reranking, दस्तावेज़ चुनने के लिए judger, संदर्भ को सारांशित करने के लिए refiner, generator, prompts, और जवाबों को उनके evidence से जोड़ने वाली citation। आप इन हिस्सों को सीधे import करके अपनी पाइपलाइन जोड़ सकते हैं, या तैयार RagApplication class और उसके Gradio फ्रंट एंड, TrustRAG Studio, से शुरू कर सकते हैं, जो knowledge base को मैनेज करता है और उस पर चैट करता है।

सामान्य retrieval QA से आगे, प्रोजेक्ट में RAPTOR recursive tree retriever, GLM-4V-Flash पर बना multimodal RAG उदाहरण, DuckDuckGo और SearXNG को सपोर्ट करने वाला web-search इंजन, और DeepResearch पाइपलाइन शामिल है। यह पाइपलाइन सवाल को sub-queries में बाँटती है और एक token budget व action-depth limit के भीतर search, read, reflect, coding और answer क्रियाओं के लूप से गुजरकर एक research report तैयार करती है। इस फ्रेमवर्क का वर्णन arXiv पेपर "TrustRAG: An Information Assistant with Retrieval Augmented Generation" (arXiv:2502.13719) में किया गया है।

यह क्या करता है

TrustRAG framework diagram: a RAG chain of query processing, query transformation, retrieval, rerank and judge, prompt engineering, generation, citation and post-processing, fed by an unstructured data pipeline of ingestion, parsing, chunking, indexing and a vector database
The framework diagram maps each stage of the RAG chain to the modules that implement it.TrustRAG README ↗
  • text, docx, ppt, excel, html, pdf और md फ़ाइलों की मॉड्यूलर पार्सिंग, MinerU-आधारित PDF पार्सिंग के साथ, और एक TextChunker जो InfiniFlow huqie tokenizer इस्तेमाल करता है
  • BM25, dense और hybrid retrievers, जिनके weights कॉन्फ़िगर किए जा सकते हैं, साथ में index बनाना, incremental additions और सेव किए गए indexes, plus एक RAPTOR recursive tree retriever
  • BGE cross-encoders से लेकर LLM-आधारित pointwise, pairwise और setwise reranking तक के rerankers, एक HyDE query rewriter, और दस्तावेज़ की प्रासंगिकता के लिए एक BGE judge
  • Citation generation, जो answer के वाक्यों को मिले evidence से जोड़ता है
  • Milvus और Qdrant जैसे vector database engines, और DuckDuckGo व SearXNG के लिए एक web-search इंजन
  • TrustRAG Studio, एक Gradio ऐप जिससे corpus अपलोड करना, chunk size सेट करना और RAG या केवल-LLM मोड में चैट करना संभव है, साथ में deployment के लिए एक Dockerfile

शुरू करें

TrustRAG को PyPI से या source से इंस्टॉल किया जा सकता है। README कोड में pipeline बनाने (parse, chunk, index, retrieve, rerank, generate) और फिर अपने दस्तावेज़ों पर TrustRAG Studio वेब ऐप चलाने की प्रक्रिया बताता है।

Environment बनाएं और इंस्टॉल करें

conda environment ज़रूरी नहीं है। पैकेज को PyPI से इंस्टॉल करें।

bashbash
conda create -n trustrag python=3.12.0
conda activate trustrag
pip install trustrag

या source से इंस्टॉल करें

Apps, examples और configs पाने के लिए repository clone करें, फिर उसे editable mode में इंस्टॉल करें।

bashbash
git clone https://github.com/gomate-community/TrustRAG.git
cd TrustRAG
pip install -e .

Hybrid retriever कॉन्फ़िगर करें

HybridRetrieverConfig एक BM25 config और एक dense-embedding config को मिलाता है, जिनमें से हर एक का अपना weight होता है, क्योंकि दोनों scores एक ही पैमाने पर नहीं होते।

pythonpython
from trustrag.modules.retrieval.bm25s_retriever import BM25RetrieverConfig
from trustrag.modules.retrieval.dense_retriever import DenseRetrieverConfig
from trustrag.modules.retrieval.hybrid_retriever import HybridRetriever, HybridRetrieverConfig

bm25_config = BM25RetrieverConfig(
    method='lucene',
    index_path='indexs/description_bm25.index',
    k1=1.6,
    b=0.7
)
dense_config = DenseRetrieverConfig(
    model_name_or_path=embedding_model_path,
    dim=1024,
    index_path='indexs/dense_cache'
)
hybrid_config = HybridRetrieverConfig(
    bm25_config=bm25_config,
    dense_config=dense_config,
    bm25_weight=0.7,
    dense_weight=0.3
)
hybrid_retriever = HybridRetriever(config=hybrid_config)

Index बनाएं और retrieve करें

अपने chunked corpus से index बनाएं और उसे सेव करें (या बाद के रन में load_index() कॉल करें), फिर उस पर query चलाएं।

pythonpython
hybrid_retriever.build_from_texts(corpus)
hybrid_retriever.save_index()

results = hybrid_retriever.retrieve("Alipay", top_k=10)
for result in results:
    print(f"Text: {result['text']}, Score: {result['score']}")

Rerank करें और जवाब generate करें

BGE reranker से retrieve किए गए passages को rerank करें और उन्हें context के रूप में generator को दें।

pythonpython
from trustrag.modules.reranker.bge_reranker import BgeReranker, BgeRerankerConfig
from trustrag.modules.generator.llm import GLM4Chat

bge_reranker = BgeReranker(BgeRerankerConfig(model_name_or_path='llms/bge-reranker-large'))
glm4_chat = GLM4Chat(llm_model_path)

search_docs = hybrid_retriever.retrieve(question, top_k=10)
search_docs = bge_reranker.rerank(query=question, documents=[doc['text'] for doc in search_docs])
content = '\n'.join([f'Information[{idx}]:' + doc['text'] for idx, doc in enumerate(search_docs)])
answer = glm4_chat.chat(prompt=question, content=content)

TrustRAG Studio लॉन्च करें

application config में अपने docs फ़ोल्डर, embedding model और reranker का पाथ दें, फिर Gradio ऐप शुरू करें और ब्राउज़र में 127.0.0.1:7860 खोलें।

bashbash
python app.py
The Corpus tab of TrustRAG Studio with knowledge-base, chunk size and chunk overlap settings, a table of uploaded documents, and a file upload area
The Corpus tab manages the knowledge base: chunking settings, the document list and file uploads.TrustRAG README ↗

DeepResearch पाइपलाइन चलाएं

DeepResearch मॉड्यूल में LLM API और search settings के लिए .env.example दिया गया है; उसे कॉपी करें, भरें और पाइपलाइन चलाएं।

bashbash
cd trustrag/modules/deepresearch
cp .env.example .env
python pipeline.py

कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।

कब इस्तेमाल करें

  • निजी दस्तावेज़ संग्रह पर एक question-answering assistant बनाएं, जिसके जवाब उनके स्रोतों के हवाले के साथ मिलें
  • हर बार एक मॉड्यूल बदलकर retrieval और reranking रणनीतियों (BM25, dense, hybrid, RAPTOR, LLM rerankers) के साथ प्रयोग करें
  • गैर-डेवलपर्स को एक वेब UI दें, जहाँ वे knowledge base अपलोड करके RAG या केवल-LLM मोड में उस पर चैट कर सकें
  • iterative search, read और reflect लूप के ज़रिए वेब सर्च से research reports तैयार करें

How TrustRAG compares

TrustRAG alongside other open-source rag frameworks & platforms tools AI/TLDR tracks, ranked by GitHub stars.

टूलस्टारयह क्या करता है
Dify★ 162kLLM और RAG ऐप विज़ुअल कैनवास पर बनाने के लिए ओपन सोर्स प्लेटफ़ॉर्म
graphify★ 156kकोड, डॉक्स, PDF और इमेज वाले फ़ोल्डर को एक ऐसे नॉलेज ग्राफ़ में बदलें जिसमें query की जा सके
RAGFlow★ 95.1kगहरी डॉक्यूमेंट समझ और स्रोत से जुड़े, ट्रेस किए जा सकने वाले उद्धरणों वाला ओपन सोर्स RAG engine
Context7★ 65.8kनवीनतम, वर्ज़न-विशिष्ट लाइब्रेरी डॉक्स सीधे आपके कोडिंग एजेंट के प्रॉम्प्ट में
Pathway★ 61.9kडेटा बदलने के साथ-साथ अपडेट रहने वाली Python ETL और RAG पाइपलाइन
LightRAG★ 41kग्राफ़-आधारित RAG, जो आपके दस्तावेज़ों को क्वेरी योग्य नॉलेज ग्राफ़ में बदल देता है
PageIndex★ 40.9kVectorless, reasoning-based RAG जो लंबे डॉक्युमेंट से tree index बनाता है
TrustRAG★ 1.3k"reliable input, trusted output" के सिद्धांत पर बना एक कॉन्फ़िगरेबल, मॉड्यूलर Python RAG फ्रेमवर्क, जिसमें citations, reranking और Gradio स्टूडियो शामिल हैं