LegalLegal Retrieval Quality

Legal Retrieval Quality

How Baudhik AI retrieves legal documents — amendments, cross-references, Devanagari, and tool routing

Baudhik AI's retrieval pipeline is tuned for Nepali legal documents. Several systems work together to ensure the right provisions, amendments, and cross-references are surfaced when you ask a legal question.

Provision-version-aware retrieval

Nepali statutes are amended over time. When a provision is amended, both the current and historical versions exist as separate documents. Baudhik AI's retrieval pipeline:

  1. Identifies version relationships between provisions (via target_id metadata)
  2. Injects sibling chunks — other versions of the same provision — into the candidate pool
  3. Lets the reranker see the current and historical text together
  4. Returns the most relevant version, with context from related versions

The reranker sees both the amended and original text, so it can pick the current operative version while still understanding what changed. Configurable caps limit how many sibling chunks are injected per provision and per query.

Admins can manage provision version groups through the admin API at /api/admin/provision-version-groups.

Citation-mapped chunk fallback

Legal documents cross-reference other provisions, schedules, and acts. When a document declares cross-reference targets via #BAUDHIK_METADATA target_id, Baudhik AI:

  1. Stores the citation mappings at indexing time in a document_citation_mapping table
  2. At query time, fetches related chunks from the mapped targets
  3. Injects them into the candidate pool before reranking

This means when you ask about a provision that references another section, the referenced section's text is available to the LLM even if it was not directly matched by the search query.

The fallback mode is configurable:

  • auto — always inject mapped targets
  • on_demand — only when the primary search results are insufficient

Devanagari retrieval quality

The chunker and search pipeline are tuned for Devanagari script:

  • Chunk boundaries respect Devanagari sentence structure
  • Search guidance handles Nepali statutory vocabulary
  • Alternative phrasings are generated for Nepali legal terms
  • The never-quit rule ensures the LLM reformulates and retries if the first search misses

Tool precedence routing

When multiple legal tools are enabled, Baudhik AI routes questions to the right tool:

Legal Dictionary — for term definitions and translations. If the term is ambiguous, the dictionary returns closest matches and asks the user to confirm.

Internal Search — for statute content, provisions, and regulatory text. This is always the first stop for legal questions.

Najir Search — for Supreme Court precedents and judicial interpretation. Called only when the statutory answer is incomplete and court interpretation is needed.

Web Search — for information outside the knowledge base, used as a last resort.

The LLM follows this precedence automatically based on the question type. Statute content questions never go to the dictionary — they go to internal search directly.