Portfolio / Case study

LexiMatch AI

Finding the "why" behind the "what", next-generation explainable AI for legal precedent discovery, matching legal reasoning rather than keywords.

Domain
Legal Tech · Research
Type
Two-stage retrieval engine
Benchmark
COLIEE 2025 corpus
Property
Explainable · Facet-aware
Abstract

LexiMatch AI is an advanced, two-stage legal case-retrieval framework built by CodeREM Labs to find truly analogous precedents by matching legal reasoning, not surface keywords. It automatically breaks complex judgments into structured facets, facts, issues, decisions and reasoning, and compares query facets directly against candidate facets for nuanced, like-for-like matching. Every result arrives with an interpretable rationale and a party-stance label, achieving 94%+ candidate recall with 100% explainability.

01 · The challenge

Keyword search can't tell what from why.

Legal professionals burn enormous billable hours sifting through irrelevant precedents returned by keyword search. Traditional lexical tools like BM25 fail the moment a key legal argument is phrased differently, and modern vector-based neural search blurs the line between a case's facts and the judge's final decision, behaving like a black box.

Standard tools simply cannot distinguish between what happened in a case and why it matters. The result is irrelevant hits, missed analogous precedents, and wasted effort, exactly the work that should be fastest for a machine.

02 · Approach

Structure the judgment, then match facet to facet.

A two-stage pipeline: high-recall retrieval first, then fine-grained, explainable re-ranking across legal facets.

  1. Designed an Automated Document Structuring (Facetization) pipeline using a deterministic LLM to segment raw judgments into distinct facets: facts, issues, decision and reasoning.
  2. Built a Hybrid Search Architecture running parallel lexical (BM25) and semantic (dense ANN) search, fused with Reciprocal Rank Fusion into a high-recall candidate pool.
  3. Developed a Section-Aware Re-ranking stage scoring across structured facets, with query-wise Z-score normalization to fix the scale mismatch between keyword scores and cosine similarities.
  4. Implemented dynamically learned section weights that prioritize crucial elements, like legal reasoning, in the final ranking.
  5. Engineered explainable outputs returning the exact matched section plus an LLM-generated rationale, with party-stance detection labeling support, opposition or neutrality.

03 · The engine

Like-for-like, reasoning to reasoning.

By moving beyond whole-document matching, LexiMatch compares specific query facets against candidate facets, so legal professionals can trust every result with full transparency.

01

Facetization

A deterministic LLM segments unstructured judgments into facts, issues, decision and reasoning, giving the engine the structure courts already think in.

02

Facet-level matching

Compares the reasoning of the query directly to the reasoning of a candidate, like-for-like, instead of blurring a whole document into one vector.

03

Hybrid search

Parallel BM25 lexical and dense ANN semantic search, combined with Reciprocal Rank Fusion to keep recall high without losing precision.

04

Section-aware re-ranking

Query-wise Z-score normalization reconciles keyword and cosine scales, while learned section weights push legal reasoning to the top.

05

Explainable outputs

Every result returns the exact matched section text alongside a concise, LLM-generated rationale, no black boxes.

06

Party-stance detection

Labels whether a retrieved case supports, opposes or is neutral to a specific party's position, context a citation alone can't give.

It bridges traditional search and modern AI, high accuracy, with a rationale you can read.

04 · Results & impact

Recall, precision and trust, together.

94%+

Candidate recall

A high-recall candidate pool maintained via hybrid search with offline caching.

Precision gain

Consistent gains over both strong lexical and state-of-the-art neural baselines on the COLIEE 2025 corpus.

Sub-linear

Scoring efficiency

Offline section-level embeddings and ANN indexing drastically cut scoring operations and cost.

100%

Explainability

Every result includes the matched section text and an LLM-generated rationale with party-stance labels.

05 · Engineering

A retrieval stack tuned for law.

LexiMatch pairs a deterministic LLM facetizer with a hybrid retrieval core, BM25/Lucene for lexical signal and FAISS dense ANN for semantics, fused by Reciprocal Rank Fusion. A section-aware re-ranker with learned weights produces the final order, and an LLM rationale layer makes every decision legible. It is served from a FastAPI backend over PostgreSQL.

PythonFastAPILLM (GPT-4)BM25 / LuceneDense ANN (FAISS)Reciprocal Rank FusionLangChainPostgreSQL

06 · Outcome

Results lawyers can actually trust.

By matching legal reasoning facet-to-facet and explaining every match, LexiMatch AI delivers high-accuracy precedent discovery without the black box, backed by consistent precision gains over strong lexical and neural baselines on the COLIEE 2025 benchmark.

The result is a tool legal professionals can rely on: every result carries the section that triggered it, a clear rationale, and a party-stance label, full transparency, from query to citation.

Cite this case studyCodeREM Labs (2026). LexiMatch AI: A two-stage, explainable facet-matching framework for legal precedent retrieval. CodeREM Labs Product Case Studies. Available at coderemlabs.com/portfolio.

Need explainable AI you can defend?

Well begun is half done.

Free consultation · No commitment required · Response within 24h · Global availability