Document intelligence · Legal
SPECTER
A legal answer is only as good as its source. SPECTER is a bilingual legal document intelligence system that checks every claim against the page before showing it.
- Role
- Product, retrieval, ingestion
- Client
- Pakistani legal practice
- Status
- Completed · 2025
- Delivery
- Web application

01Context
A corpus that punishes shortcuts.
Pakistani case law does not arrive as clean text. Judgments are scanned, re-scanned and photographed. FIRs are handwritten forms in Urdu. Citations are abbreviated, and the same case can appear under several reporter series.
A general-purpose retrieval stack flattens all of that into fixed-size chunks. The answer may read well, but the link between a sentence and the page it came from is gone — which is the only part a lawyer can check.
Three scripts
Urdu, English and Roman-Urdu queries over the same index.
No text layer
Documents with tables, numbered paragraphs and scans that defeat a standard OCR pass.
Client data
Names, CNICs and phone numbers that cannot reach a third-party log.
02Problem
What made this hard.
The difficulty is not building a chat interface over documents. It is producing an answer that a lawyer can verify in one click, on a corpus where the source document may be a photograph of a handwritten form.
Bilingual ingestion
OCR, translation and normalisation have to happen before retrieval, without destroying the page geometry.
Structure
Chunks must follow sections and clauses, not an arbitrary token window.
Grounding
Every claim must map to a passage, and every passage to a page.
Model choice
Four providers were benchmarked rather than assuming one was best.
03Architecture
Five lanes, one page anchor.
Ingestion produces three things: text, structure and a page anchor. The index stores all three. Retrieval narrows the corpus with metadata filters and hybrid search, reranking cuts the candidate set, and the answer layer is not permitted to use anything outside it.
what arrives
- Scanned FIRs
- Judgment PDFs
- Court records
- Statutes
file → text
- Type triage
- OCR / VLM pass
- Layout + tables
- Urdu → English
text → vectors
- Structure chunking
- Embeddings
- Vector index
- Page anchor
query → evidence
- Hybrid search
- Rerank + cut
- Model routing
- Citation check
evidence → answer
- Ask + court filters
- Matter + diary
- Source viewer
- Lawyer review
04Ingestion
Getting the page into the pipeline.
The OCR and translation pipeline digitises Urdu FIRs into structured English for downstream processing, keeping the original page region attached to each extracted block. Layout extraction separates headings, tables and body text before anything is chunked.
When a scan defeats the OCR pass, the pipeline falls back to a vision model for that region rather than the whole document. The fallback is logged, so a bad page is visible in the run record instead of quietly becoming a bad answer.
05Retrieval
Search wide, then cut hard.
Embeddings are generated with sentence-transformer models and stored in a vector index — FAISS, Pinecone, LanceDB or pgVector depending on the deployment. Lexical and vector search run together; a reranker then cuts the candidate set to passages that can actually support an answer.
OpenAI, Claude, Llama and Qwen were benchmarked on summarisation and bilingual reasoning. Prompts are built around citation grounding: the model receives selected passages and must answer from them. An answer that cannot be tied to a passage is not returned.
06Application
Built for the person checking the answer.
The interface is a source viewer first. Filters narrow by court — Supreme Court, Islamabad High Court, Lahore High Court — and by law, case law or both. A question written in Roman Urdu is handled as readily as one in English.
Access follows the matter, not the firm. Row-level security, per-firm encryption keys, masked CNIC and phone numbers in logs, and Clerk sign-in with matter-level permissions were part of the build, not a later hardening pass. When a hearing is confirmed, it goes onto a diary with calendar subscription.
07Delivery
What shipped.
SPECTER was built and delivered by Fenvolt as a working web application: ingestion, retrieval, the matter workspace, the source viewer and citation verification. A question in English, Urdu or Roman Urdu returns an answer whose numbered claims open the passage they came from.
The system is a research aid, not legal advice. Every citation opens the original judgment, and anything that cannot be tied to a passage is withheld rather than shown.

Stack
- Python
- FastAPI
- FAISS
- Pinecone
- LanceDB
- pgvector
- LangChain
- Qwen3-VL
- OpenAI
- Claude
- Llama
- Clerk
- PostgreSQL
Role — AI/ML engineering, retrieval architecture, ingestion pipeline
Next study
Document-Parser
Open source · Parsing
Have a corpus that
refuses to behave?
Describe the documents, the volume and what a correct answer looks like. We will tell you whether retrieval is the right tool before proposing a build.
Start a project