{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreig55ta3es3hsxk4rvrwyctqjao2qwweggwt6g2yv6rvso7chg6f5q",
    "uri": "at://did:plc:pgryn3ephfd2xgft23qokfzt/app.bsky.feed.post/3mjfz7wehjtg2"
  },
  "path": "/t/cdrag-rag-with-llm-guided-document-retrieval-outperforms-standard-cosine-retrieval-on-legal-qa/175230#post_1",
  "publishedAt": "2026-04-13T19:42:56.000Z",
  "site": "https://discuss.huggingface.co",
  "tags": [
    "isaacus/legal-rag-bench · Datasets at Hugging Face",
    "GitHub - BartAmin/Clustered-Dynamic-RAG: CDRAG is a new retrieval framework that uses hierarchical document clustering and LLM-guided cluster selection to allocate the retrieval budget intelligently across a corpus, benchmarked against standard top-K RAG on 100 legal questions from the Legal RAG Bench dataset. · GitHub"
  ],
  "textContent": "Hi all,\n\nI developed an addition on a CRAG (Clustered RAG) framework that uses LLM-guided cluster-aware retrieval. Standard RAG retrieves the top-K most similar documents from the entire corpus using cosine similarity. While effective, this approach is blind to the semantic structure of the document collection and may under-retrieve documents that are relevant at a higher level of abstraction.\n\n**CDRAG (Clustered Dynamic RAG)** addresses this with a two-stage retrieval process:\n\n  1. Pre-cluster all (embedded) documents into semantically coherent groups\n\n  2. Extract LLM-generated keywords per cluster to summarise content\n\n  3. At query time, route the query through an LLM that selects relevant clusters and allocates a document budget across them\n\n  4. Perform cosine similarity retrieval within those clusters only\n\n\n\n\nThis allows the retrieval budget to be distributed intelligently across the corpus rather than spread blindly over all documents.\n\nEvaluated on 100 legal questions from the legal RAG bench dataset ( isaacus/legal-rag-bench · Datasets at Hugging Face ), scored by an LLM judge:\n\n  * **Faithfulness** : +12% over standard RAG\n\n  * **Overall quality** : +8%\n\n  * Outperforms on 5/6 metrics\n\n\n\n\nCode and full writeup available on GitHub. Interested to hear whether others have explored similar cluster-routing approaches. For more information, visit: GitHub - BartAmin/Clustered-Dynamic-RAG: CDRAG is a new retrieval framework that uses hierarchical document clustering and LLM-guided cluster selection to allocate the retrieval budget intelligently across a corpus, benchmarked against standard top-K RAG on 100 legal questions from the Legal RAG Bench dataset. · GitHub",
  "title": "CDRAG: RAG with LLM-guided document retrieval — outperforms standard cosine retrieval on legal QA"
}