§1 The Pipeline
Your question never crosses this line
§2 Why 544 Passages, Not 500-Token Windows
The default way to chunk documents for retrieval is mechanical: slice the text into fixed windows of a few hundred tokens, with some overlap so nothing falls between the cracks. It works, and it is also why so many retrieval systems cite "chunk 47" and hand you a passage that starts mid-sentence.
The Constitution of India makes that laziness inexcusable, because it ships with its own structure. The document is organised into Parts, the Parts into Articles, and long Articles into numbered clauses. Every Article opens with a marginal note that names what it does, in the drafters' own words. Those are the chunk boundaries. Each Article is the atomic citable unit, so it becomes one chunk, with its marginal note leading the text. Articles that run past roughly 450 words are split at numbered clause boundaries, and the citation travels with the split: a result can say Article 356 · clauses (1)–(3) instead of a byte offset. The Preamble is its own chunk. Schedules 1 through 5 are included. The result is 544 citation-ready passages, and every one of them is a complete thought with a name a citizen, a journalist, or a High Court already understands.
That is why a result here says Article 21, Part III instead of "chunk 47." A student can quote it. A teacher can assign it. A lawyer would recognise the citation. The retrieval system speaks the same language as the document it searches.
§3 The Economics of Zero
First, precision: this is not a "local LLM" doing the answering. The core is a local embedding model, all-MiniLM-L6-v2 as quantized ONNX, about 23 MB, loaded by Transformers.js from Hugging Face's CDN and cached in your browser's Cache API after the first visit. Your question is embedded in a web worker, and because the vectors are L2-normalized, cosine similarity is a plain dot product. Retrieval cannot hallucinate. There is an optional in-browser summarizer (LaMini-Flan-T5-77M) that also runs entirely on your device and carries its own disclaimer in the interface, but the quoted passages and explainers never pass through it.
| Cost line | Typical hosted RAG | This site |
|---|---|---|
| Query embedding | API call, metered per token | $0, computed in your browser |
| Vector search | Hosted vector DB, monthly fee | $0, a dot product over one static JSON file |
| Answer generation | LLM call, cents per query | $0, curated explainers written once at build time |
| Keys & rate limits | Keys to protect, quotas to hit | None exist |
| Cost if it goes viral | Scales with every visitor | Flat. The origin serves about 2–3 MB of static files (the index plus the HTML). The model comes from Hugging Face's CDN, and repeat visitors cost roughly nothing. |
The index itself is built offline by two Node scripts, build-corpus.js and build-embeddings.js, which embed all 544 passages (384 dimensions, mean pooling, L2-normalized, quantized to 5 decimals) into a single static file at data/index.json. The only real cost a visitor pays is the one-time model download on the first search, cached by the browser afterward. That is the honest tradeoff, and for a public tool it is the right one: a site that costs money per query dies the day it goes viral. This one cannot, because its marginal cost per query is zero at ten visitors and zero at ten million.
§4 When to Use This Pattern, and When Not To
Use it for small, public, read-heavy corpora: documentation sites, legal and policy texts, product manuals, FAQ knowledge bases. Anywhere under a few thousand chunks where the content is not secret and the questions repeat.
Do not use it for private data (the whole index ships to every visitor), for large corpora (the index download outgrows its welcome), or when users need generated prose rather than retrieved passages. Engineering maturity is matching the architecture to the problem, not to the hype cycle.
§5 What Is Curated vs. Computed
Honesty about the seams: the AI here does retrieval and question-matching, nothing else. Every one of the 544 passages carries a plain-language explainer written by a person at build time and shipped as static text. On top of that sit 30 curated questions and answers that act as a semantic router: your question is compared against the embedded curated questions, and when the cosine similarity reaches 0.60 or higher, the human-written short answer appears above the retrieved passages. The Constitution's words are quoted exactly from the source text. Each layer is labeled in the interface, so you always know who is talking: 1950, or 2026.
§6 Sources, and Two Honest Caveats
The working text is the official English text of the Constitution of India via the Wikisource 2020 edition, which includes all 104 amendments, downloaded Part by Part. The authoritative reference remains the Government of India's own publication at legislative.gov.in. If they ever disagree, the government text wins.
Caveat one: the printed text is not always the living law. Where the Supreme Court has struck down an amendment but the print retains the words, this site shows the printed text. The famous example is the 99th Amendment's National Judicial Appointments Commission articles, struck down in 2015 yet still present on the page. The passages quote what is printed, and the plain-words explainers flag where the Court has said otherwise.
Caveat two: some of the law is not in the document at all. Judge-made law, like the right to privacy from Puttaswamy or the basic structure doctrine, does not appear in the text you can search here. Where a curated answer rests on judgments rather than the document, the answer says so plainly.
Retrieval that citizens can quote, at a cost that virality cannot kill. The architecture is the product decision.
The entire build is open source: github.com/swapniltamse/ask-the-constitution-india