Leakage-aware legal analytics pipeline that turns long judgments into structured, evaluation-ready case features.
Sanitized Portfolio Report
Leakage-Aware Evaluation in Legal NLP
A paraphrased case study on extracting structured legal features from lengthy judgments while controlling target leakage and hindsight bias.
Fast Scan
What this report proves
A recruiter-readable summary of the legal NLP signal, model-design choices, evidence, and privacy boundary.
IRAC-inspired extraction, temporal filtering, Legal-BERT embeddings, XGBoost baselines, Hierarchical Attention Network design, and JSON QA.
Extraction architecture, HAN design, baseline paths, feature logic, label validation, and evaluation-risk diagrams.
No raw legal excerpts, party names, academic identifiers, evaluator notes, or unredacted source pages are published.
PII-Safe Publication Note
This page is a rewritten public case study. It removes personal names, academic identifiers, emails, raw legal excerpts, evaluator details, and submission metadata. The report describes the methods and lessons learned without reproducing private coursework pages or unredacted source material.
The most important lesson here was that a model can look impressive for the wrong reason. I became more skeptical of headline scores once I saw how easily judgment text can leak the answer. The better portfolio signal is the evaluation discipline: define what the model is allowed to know, then test against that boundary.
Executive Summary
The project studied how legal judgments can be converted into structured analytical features for litigation-risk modelling. A core challenge is that judgments already contain the final outcome, so a naive model can accidentally learn from hindsight cues instead of pre-decision facts. The portfolio version therefore emphasizes leakage control, temporal isolation, legal feature engineering, and careful evaluation rather than raw model scores.
The pipeline combines rule-based preprocessing, legal-domain NLP, IRAC-inspired extraction, row-level normalization, and benchmark models such as tree-based classifiers and legal text embeddings. The most important design principle is to separate facts available before a decision from language that reveals the decision itself.
Portfolio Signal Snapshot
This case study is positioned for legal-tech, NLP, risk analytics, and applied machine-learning review. It highlights data quality, target-leakage control, and evaluation design rather than presenting a model as legal advice.
Problem Context
Legal documents are long, unevenly structured, and rhetorically complex. The same case can contain claims, counterclaims, facts, procedural history, legal reasoning, damages, and final orders. A useful analytics workflow must convert this material into consistent features without collapsing all text into one ambiguous document vector.
Document Length
Relevant facts may be distributed across many sections, while outcome language can appear near the end or inside judicial reasoning.
Target Leakage
If the model sees phrases that reveal judgment, liability, or relief granted, performance can be misleading.
Party Structure
Claims and counterclaims may point in opposite directions, so case-level labels need careful normalization.
Analytical Objectives
- Extract structured metadata, party relationships, factual context, and outcome labels from lengthy legal texts.
- Apply an IRAC-inspired structure so issues, rules, application, and conclusions are not treated as interchangeable text.
- Reduce target leakage by removing or isolating language that would only be known after judgment.
- Compare traditional machine-learning baselines with legal-domain embedding approaches.
- Present findings honestly, with limitations around corpus size, annotation ambiguity, and real-world generalization.
Sanitized Extraction Flow
The original report contained a data extraction architecture diagram. This public version recreates the workflow at the method level while excluding raw judgment screenshots, case examples, and submission metadata.
Unstructured Judgment to ML-Ready Case Rows
Curated Figure Gallery
The figures below preserve the original modelling evidence while using light-background recreations for the architecture diagrams that were too dense on dark slide canvases. Raw judgment screenshots, case pages, and report metadata are not published.
Short Demo Clip
This silent walkthrough focuses on the evaluation path: ingestion, IRAC extraction, temporal filtering, feature rows, leakage audit, baselines, and case-level metrics.
Judgment text to leakage-aware evaluation
The clip makes the senior-review point visible: metrics matter only after the information boundary and target-leakage risks are controlled.
Transcript
Judgment text is normalized, IRAC extraction and temporal filtering separate pre-decision facts from outcome language, feature rows are audited for leakage, and baseline models are compared before case-level metrics are framed as evaluation evidence.
Pipeline Design
1. Text Ingestion and Normalization
The first step standardizes document text so headings, paragraph breaks, dates, monetary references, and party labels can be processed consistently. This step reduces noise before feature extraction.
2. Case and Party Rows
Instead of treating a judgment as one flat object, the design can represent claims, parties, and counterclaims as structured rows. This helps prevent mixed signals when a case contains multiple directions of liability or relief.
3. IRAC-Inspired Extraction
The pipeline separates issue statements, legal rules, factual application, and conclusions. For modelling, pre-decision factual material is more appropriate than final judicial conclusions because the latter can reveal the label.
4. Temporal Isolation
Features should approximate what would have been knowable before the case outcome. This requires careful treatment of dates, procedural history, and explicit decision language.
5. Embeddings and Baselines
Legal-domain embeddings can capture semantic patterns in case facts. Traditional models such as boosted trees remain useful as baselines because they make feature importance and failure modes easier to inspect.
Model Architecture Notes
The source report compared a traditional baseline, a legal-domain transformer baseline, and a custom hierarchical architecture. The portfolio version keeps the model comparison without publishing raw screenshots or unsupported performance claims.
Leakage Controls
Leakage control is the strongest part of the project from a portfolio perspective. The model should not be rewarded for reading the answer inside the judgment. The public writeup therefore foregrounds the safeguards rather than presenting performance numbers without context.
- Remove or isolate sections that directly describe the final decision, relief awarded, or liability finding.
- Normalize target labels symmetrically so claims and counterclaims are not accidentally coded in inconsistent directions.
- Separate factual summaries from judicial conclusions where the document structure supports it.
- Check whether high-performing features are actually proxies for the final outcome.
- Evaluate at both row level and case level to avoid overstating performance on duplicated or related examples.
Technical Notes From Source Report
Decision Framework
The central modelling question was not simply which algorithm to use. It was how to preserve legal structure so the model learns from pre-dispute facts rather than accidental hints embedded in the final judgment.
| Decision Area | Naive Option | Selected Approach | Reasoning |
|---|---|---|---|
| Prediction unit | One row per document | Party-level rows with case-level aggregation | Captures multi-party disputes and makes evaluation closer to real decision-making. |
| Feature source | Use the whole judgment text | Separate pre-dispute facts from outcome language | Controls hindsight bias and avoids inflated performance from leaked target signals. |
| Model baseline | Jump directly to transformer models | Compare XGBoost, Legal-BERT, and HAN-style representations | Creates a fair baseline ladder and exposes whether complexity adds practical value. |
| Quality assurance | Trust generated JSON as-is | Automated audits plus human review | Reduces entity omissions, malformed labels, and leakage-prone extraction errors. |
Qualitative Modelling Priority Chart
Evaluation Approach
Extraction Quality
Check whether the pipeline correctly identifies parties, dates, claim direction, factual context, and outcome labels.
Model Comparison
Compare legal embeddings, bag-of-words style features, and structured variables against simple baselines.
Robustness
Inspect errors where the model relies on summary bias, procedural language, or outcome-adjacent wording.
Limitations
- Legal outcomes are shaped by facts, evidence, procedure, and legal interpretation. A text model can support analysis but should not be framed as legal advice.
- Judgment text is written after the outcome is known, so leakage control is inherently difficult.
- Small or domain-specific corpora can make model performance unstable across case types.
- Public reporting intentionally avoids raw excerpts and sensitive metadata, so the writeup focuses on method design rather than reproducing data samples.
Recommended Next Improvements
- Build a transparent annotation guide for facts, issues, outcomes, and leakage-prone sections.
- Add document-section classifiers to separate factual narrative from legal conclusion more consistently.
- Run temporal validation where later cases are predicted from earlier training data.
- Add model cards that describe intended use, prohibited use, evaluation scope, and residual risks.
Selected Sources From Original Report
The original bibliography covered legal judgment prediction, legal-domain encoders, weak supervision, hierarchical attention, and realistic evaluation risks. The portfolio version lists selected references most directly tied to the public case study.
Recruiter Signal
This project demonstrates careful applied machine learning: feature extraction from messy documents, domain-specific NLP, leakage-aware evaluation, and honest communication of model limits. It is relevant for data science, NLP, risk analytics, and applied AI roles where correctness matters more than a flashy demo.