How it works · Lex.NY4 steps · question to cited answer
The pipeline

From a plain question to a cited answer.

Every Lex.NY answer is the output of a four-stage pipeline, and each stage produces a verifiable artifact: an embedding, a ranked list of real sources, a citation-graph traversal, and a streamed draft tied to numbered authorities. No stage can hallucinate, because nothing reaches the model that wasn’t pulled from a real document first. Try it on the right →

1

Embed the question

mxbai-embed-large · 1024-dimensional

Your question is converted into a 1024-dimensional vector by mxbai-embed-large — the same model used to embed every document in the corpus. Embedding the question the identical way is what lets retrieval match on meaning instead of keywords.

question → 1024-d vector
2

Search the corpus with pgvector on Aurora

ANN over 3.5M embeddings · IVFFlat

The vector becomes an approximate-nearest-neighbor query against a 3.5-million-row pgvector index living in AWS Aurora PostgreSQL. It returns the closest opinions (1.32M indexed) and statute sections (~40K indexed) by cosine distance, blended with a keyword score so an exact section number still ranks. Pre-warmed into memory, this is sub-second.

pgvector ANN → top opinions + statutes
3

Expand the citation graph — in the same database

Recursive CTEs · 4.9M CITES + 648K APPLIES edges

Pure vector search finds documents that read alike. The citation graph finds the ones that control. Every opinion's CITES (4.9M opinion-to-opinion) and APPLIES (648K opinion-to-statute) edges are stored as relational tables in the same Aurora database and traversed with recursive CTEs — surfacing a controlling Court of Appeals case that keyword similarity would have buried. No separate graph database to drift out of sync.

recursive CTE → controlling + co-cited authority
4

Draft under a strict-citation prompt

Hosted LLM · streaming · [n] markers required

Everything retrieved becomes a numbered context block. A fast hosted model drafts the answer under a system prompt that requires a [n] marker after every factual claim and forbids inventing a case name, citation, or statute number. If the context didn't cover the question, the model must say so. The answer streams back token-by-token.

strict-citation prompt → streamed, cited answer

Why this pipeline, not just “ask a chatbot”

Retrieval before generation

A general chatbot has read most published NY cases but has no way to know which still control — it will confidently cite a decision reversed in 2019. Lex.NY retrieves the actual documents first; the model only summarizes what was already pulled, with markers.

Graph over vectors

Vector search rewards textual similarity. Real research rewards citation centrality. Traversing the CITES / APPLIES edges in Aurora is how Lex.NY surfaces controlling precedent that pure similarity would rank below a similar-sounding but rarely-cited dissent.

One database, not a stack of services

Embeddings, the relational citation graph, and full-text search all live in a single AWS Aurora cluster. Fewer moving parts means nothing falls out of sync, and the whole retrieval path is one IAM-authenticated connection.

Strict-citation system prompt

The model is told, with no wiggle room, that every factual claim about NY law needs a [n] marker pointing into the context block, and that inventing a citation is forbidden. When the context doesn't cover the question, it must say so plainly.

By the numbers

1.32M
Opinions indexed
40K
Statute sections
3.5M
Vector embeddings
4.9M
Citation edges
648K
APPLIES edges
9.4K
Judges profiled
1714
Earliest opinion
2026
Latest opinion

The latency budget

Step 1 · embed query (mxbai)~0.4 sStep 2 · pgvector ANN on Aurora (warm)0.1 – 1.0 sStep 3 · citation-graph CTE expansion0.1 – 0.5 sStep 4 · strict-citation drafting (streamed)3 – 6 sTotal, warm~5 – 10 s

When Lex.NY refuses to answer

If the best vector similarity in step 2 falls below threshold and the citation graph surfaces nothing on point, Lex.NY skips the model entirely and tells you the corpus doesn’t cover your question.

That’s deliberate. A model that always answers is a model that sometimes invents. The abstain branch is what makes the strict-citation guarantee real.

Built on AWS Aurora PostgreSQL · Deployed on Vercel · github.com/banksythequantLab/lex-ny