AI Case Reasoning for US Immigration Law
Knowledge Graph, Similar Cases & Defense Strategies
My Role
- Ontology structures every case down to atomic facts
- Rank precedents by votes from shared facts
- Index fact leaves in vector DB, not documents
Approach at a Glance
Details- 1Case Base from Public Decisions
- 2Case Ontology
- 3Structured Indexing in a Neo4j Knowledge Graph
- 4Custom Similar-Case Algorithm: Voting by Facts
- 5Defense Strategy Suggestions
- 6Drafting Help
Executive Summary
An AI platform for immigration attorneys that turns decades of US immigration case law into practical help for the case in front of them. A lawyer describes the facts, and the system:
- finds past cases with similar fact patterns,
- shows which defense strategies won and which lost in those cases,
- helps draft the documents.
It is built on three layers:
- A case base: millions of public immigration decisions going back to the 1980s.
- A case ontology: a structure for storing every case as a graph in Neo4j, from the case down to its individual facts, with a vocabulary drawn from about 8,200 legal-dictionary terms.
- A custom similar-case algorithm: each case is broken down into atomic facts, which become the leaves of the graph and are indexed in a vector database. A new case's atomic facts are matched against them, and past cases are ranked by how many similar facts they hold.
Retrieval found relevant cases with 85% accuracy. The platform reached an MVP piloted with immigration lawyers. We delivered it as an independent contractor team. On this project I was the architect, tech lead and product owner, working with one developer and my partner as project manager.
Client Profile
The client hired us to build a platform for immigration law firms. Its users are attorneys and paralegals preparing cases for immigration courts and appeals. Two parts of their work take most of the time:
- Research: finding comparable past decisions, meaning cases with similar facts and how they were argued and decided, can take hours per case, across decades of decisions.
- Drafting: briefs and petitions follow recurring structures and arguments, but are rewritten largely from scratch each time.
Keyword search over case law isn't enough. Two cases can share almost no words and still turn on the same legal question, while cases with similar wording can be legally irrelevant to each other. Lawyers need search by meaning and legal concept, plus insight into which strategies actually worked.
Technical Approach
-
Case Base from Public Decisions – We collected and parsed millions of public immigration decisions going back to the 1980s into structured records: facts, legal issues, arguments and outcomes. This became the platform's memory of how similar situations were argued and decided.
-
Case Ontology – We developed an ontology for the cases themselves: a schema that breaks every decision into the same structure, from the case through its legal issues and arguments down to the individual facts. Its vocabulary comes from a comprehensive legal dictionary we scraped, about 8,200 terms with definitions, sub-definitions and cross-references, so the same legal concept is named the same way across decades of decisions.
-
Structured Indexing in a Neo4j Knowledge Graph – Each case is stored in Neo4j according to the ontology. The LLM extracts atomic facts from each decision: single, self-contained statements of what happened in the case. They become the leaves of the graph, and each one is indexed in a vector database, so it can be found by meaning rather than wording. Using LangChain's graph question-answering, the LLM can also query the graph directly and follow the relationships between cases, issues and facts.
-
Custom Similar-Case Algorithm: Voting by Facts – Instead of comparing whole documents, the search works fact by fact. The atomic facts of a new case are matched against the indexed fact leaves in the vector database, and each match votes for the case it belongs to. Past cases are ranked by how many similar facts they hold. A case that shares several key facts ranks above one that is only worded similarly. The algorithm found relevant cases with 85% accuracy.
-
Defense Strategy Suggestions – For the retrieved cases, the system compares the arguments that led to winning and losing outcomes, and suggests strategies supported by how similar cases were actually decided.
-
Drafting Help – Using the retrieved cases, the strategies and the concepts from the ontology, the LLM helps draft case documents, so lawyers start from a grounded draft rather than a blank page.
Business Outcome
The platform reached an MVP piloted with immigration lawyers. It gave them concept-aware access to millions of past immigration decisions, finding relevant cases with 85% accuracy, along with strategy suggestions based on real outcomes and a head start on drafting.
The project shows how far a three-person team could take legal AI in 2023–2024 by structuring every case with an ontology and searching it fact by fact. Ranking cases by the facts they share, rather than by how similar their text looks, is closer to how lawyers judge whether a precedent is relevant.
Technologies
Planning something similar?
Tell me about it on a short call. New projects can start within 2 weeks