Inspiration
Finding a word in an old book does not necessarily mean that the book’s author used that word in the intended sense. A match may occur inside a quotation, a later editorial layer, a linguistic example, an attribution to an earlier speaker, or an unrelated meaning.
TAKHRIJ was created to bridge the gap between finding strings and establishing defensible historical attestations. Instead of simply returning search results, it asks which matches genuinely count as independent authorial evidence—and documents why.
What it does
A researcher submits:
- a target Arabic form
- the intended sense under investigation
- a historical cutoff year The server then binds the claim to an exact corpus release and a declared list of books, preventing those boundaries from changing after the search begins.
TAKHRIJ:
- Normalizes the target without destroying the original Arabic text.
- Enumerates explicit orthographic and morphological variants.
- Retrieves exact token matches from the declared corpus.
- Uses Gemini to classify each match along two independent axes:
- whether it carries the intended meaning
- whether it is independent authorial use, quotation, attribution, mention, allusion, or uncertain
- Runs a Devil’s Advocate agent that audits the search trace, identifies potentially missing variants, and can trigger a second bounded retrieval pass.
- Sends the resulting evidence dossier through a deterministic Issuance Gate. The Gate independently verifies quotations, sources, offsets, dates, corpus boundaries, and the evidence-to-verdict calculation before a report can be released. The final dossier shows raw matches, matches before the cutoff, qualifying historical evidence, excluded contexts, and the limits of the conclusion.
How we built it
TAKHRIJ combines probabilistic semantic judgement with deterministic evidence controls. The application uses:
- Google ADK for the dynamic multi-agent workflow
- Vertex AI Gemini 3.5 Flash for structured semantic and evidence-role judgements
- Cloud Run for the live bilingual web application and worker
- Firestore for jobs, leases, progress, and final dossiers
- Pub/Sub for asynchronous job delivery
- read-only SQLite for deterministic corpus retrieval
- Flask, Python, JavaScript, and HTML for the service and interface
- Cloud Build and Artifact Registry for deployment ADK is load-bearing. The Morphologist, Assessor, and Devil’s Advocate operate as distinct agent roles, while normalization, retrieval, quotation extraction, span verification, and verdict calculation remain deterministic tools. The model is never allowed to decide whether a string physically exists in the corpus. Gemini interprets context; code establishes the evidence trail. The public hosted demo runs the real Gemini and ADK adjudication workflow over three repository-authored CC0 synthetic texts, explicitly marked and never treated as historical evidence. The embedded video shows a separate licence-gated Cloud Run execution over five declared books. In that recorded run, the Devil’s Advocate adds a missing variant and re-runs the bounded search. No qualifying earlier evidence appears, so the verdict correctly holds. A verdict flips only when the adversarial pass surfaces qualifying counterevidence. The verdict holds—and that is the finding: a word preserved in the Qur’an, yet not independently adopted in the declared corpus before the cutoff. Attestation is not use. The production corpus path remains licence-gated. TAKHRIJ will not publicly distribute or serve a derived corpus index until the necessary written permission is available.
Challenges we faced
Preventing fabricated evidence
A language model can produce persuasive explanations, but historical evidence must be reproducible. TAKHRIJ therefore never trusts the model to supply quotations, offsets, dates, or source identities from memory. Every quoted span is extracted from the indexed source and verified byte-for-byte. The Issuance Gate reconstructs the verdict from the stored classifications and deterministic claim predicate. If the evidence trail is incomplete or internally inconsistent, no dossier is issued.
Separating meaning from evidence role
A match can carry the intended meaning while appearing only inside a quotation or linguistic example. Conversely, an independently written word may carry an unrelated meaning. TAKHRIJ models these as two independent classifications instead of collapsing them into one score.
Arabic variation
Arabic words may appear with diacritics, prefixes, conjunctions, articles, and orthographic variation. The system enumerates explicit variants while preserving a visible record of exactly what was searched. The Devil’s Advocate can challenge this list and require another pass.
Making negative results honest
“No earlier match in the declared corpus” is not the same as “the word did not exist.” Every report includes a boundary statement explaining what the selected release, book list, date proxy, and search method can—and cannot—establish.
Corpus licensing
The safest technical path was also an important research decision: the hosted demonstration uses synthetic fixture content, while real OpenITI processing remains local-only until distribution permission covers the derived index and public service.
Accomplishments that we are proud of
- A complete live Gemini and Google ADK adjudication workflow running on Cloud Run
- A Devil’s Advocate capable of detecting omitted Arabic variants and triggering reconsideration
- Deterministic verification of quotations, sources, offsets, dates, and verdict inputs
- A bilingual Arabic-English research interface
- Exact and reproducible corpus boundaries attached to every claim
- Honest handling of uncertainty through an
INCONCLUSIVEverdict - 94 passing automated tests with 86% branch coverage
- Clear licensing and epistemic boundaries built directly into the product
What we learned
The central lesson is that retrieval and historical proof are different tasks. Gemini is valuable for interpreting context, identifying semantic uncertainty, and challenging an analysis. Deterministic tools are essential for verifying quotations, enforcing corpus boundaries, and keeping the final evidence trail internally consistent. We also learned that an adversarial agent is most useful when it can do more than comment. In TAKHRIJ, the Devil’s Advocate can expose a missing variant and force the evidence workflow to reconsider its conclusion. A negative result can be meaningful when its boundaries are explicit. The absence of qualifying evidence inside a frozen research contract is not proof of universal absence—but it can still reveal that an attested word remained isolated rather than becoming independent usage.
What’s next for TAKHRIJ
With written corpus-distribution permission, the next phase will:
- activate the production-ready corpus ingestion and delivery path
- expand beyond single-token searches
- add richer manuscript, edition, composition, and author-date metadata
- support additional Arabic corpora and other historical languages
- invite historians and philologists to evaluate the classification contract and evidence reports TAKHRIJ does not attempt to replace scholarly judgement. It makes the evidence trail explicit, reproducible, adversarially tested, and much harder to overstate.
Built With
- artifact-registry
- cloud-build
- cloud-run
- docker
- firestore
- flask
- gemini-3.5-flash
- google-adk
- google-cloud
- html5
- javascript
- pubsub
- python
- sqlite
- vertex-ai
Log in or sign up for Devpost to join the conversation.