The problem
Lawyers and compliance teams drown in documents where the key facts — who the parties are, the dates, the amounts, the cited sections, the jurisdiction — are buried in prose. Named Entity Recognition automates the first pass: finding and typing these spans. General NER trained on news (person/organization/location) misses legal specifics: "Section 11" is not a person, and "Rs. 45,00,000" in Indian digit grouping confuses amount patterns tuned on Western formats. This project fine-tunes bert-base-uncased for token classification with the BIO scheme on a five-type legal schema (PARTY, DATE, AMOUNT, SECTION, COURT), starting from CoNLL-2003 and adding ~2,000 annotated Indian legal sentences with shipped annotation guidelines. The demo highlights entities in uploaded text with per-entity confidence.
How it works
- Legal text is tokenized with BERT's WordPiece tokenizer.
- bert-base-uncased produces a contextual embedding for every token.
- A dropout + linear token-classification head labels each token in the BIO scheme.
- WordPiece sub-tokens merge to word-level tags; adjacent B-/I- spans become entities.
- Rule-assisted post-processing normalizes Indian amount formats and citation shapes over the neural tags.
- Fine-tuning runs 3-5 epochs (lr 3e-5, batch 16) on the annotated legal set, with validation F1 for early stopping.
Tech stack:
- Python 3.10, PyTorch
- Hugging Face transformers (bert-base-uncased)
- CoNLL-2003 (base corpus)
- Annotated Indian legal set (~2,000 sentences)
- FastAPI/Flask (inference API)
- HTML/CSS/JavaScript (demo UI)
- Git
Dataset & Model Details
- Dataset: CoNLL-2003 (Tjong Kim Sang & De Meulder; Reuters news, PER/ORG/LOC/MISC) for general entity sense + ~2,000 manually annotated Indian legal sentences (agreements, notices) in BIO format for the legal schema. Split: train / validation / held-out test.
- Model input: legal text tokens. Output: BIO labels per token → entity spans with types.
- Architecture: bert-base-uncased (110M) → dropout → linear over BIO label set; WordPiece sub-token merging; rule-assisted Indian-format post-processing.
- Metric: entity-level precision / recall / F1 (strict span+type match) on the held-out legal test set, reported per entity type after training. No F1 figure is claimed before the fine-tuning run.
| Parameter | Value |
|---|---|
| Entity types | 5: PARTY, DATE, AMOUNT, SECTION, COURT |
| Tagging scheme | BIO |
| Base model | bert-base-uncased (110M params) |
| Training | 3-5 epochs, lr 3e-5 |
| Inference | CPU-friendly |
| Demo | Upload text + highlighted entities + API |
Project features
- [Five legal entity types] PARTY, DATE, AMOUNT, SECTION, COURT — the schema that matters in Indian agreements and notices.
- [BIO tagging] Begin/Inside/Outside scheme handles long multi-token entities like "Arbitration and Conciliation Act, 1996".
- [Indian-format handling] Lakh/crore amount grouping and "Section N" / "Act, Year" citation shapes via rule-assisted post-processing.
- [Annotation guidelines] Two-pass labeling protocol ships with the project; inter-annotator agreement reported.
- [Entity-level evaluation] Strict precision/recall/F1 (exact span + type) on a held-out legal test set, broken down per type.
- [Highlighting demo] Upload legal text; get color-coded entities, a sortable table and per-entity confidence.
- [Inference API] REST endpoint returning entity spans for integration into review tools.
What is included
- Annotation guidelines + ~2,000-sentence labeled legal set
- Fine-tuning notebook (training, validation, per-type evaluation)
- Trained BERT weights
- Inference API (entity spans as JSON)
- Test-set evaluation: entity-level P/R/F1 per type from the actual run
- Web demo with color-coded highlighting
- Project report PDF (methodology, error analysis, measured results)
- PPT presentation for final review
- Viva Q&A preparation document
Limitations & prerequisites
- Five entity types only; obligations, penalties and governing-law clauses are future scope.
- Long, convoluted sentences occasionally split entities — the per-type F1 table shows where.
- Trained on Indian legal English; other jurisdictions' formats need re-annotation.
- This is an extraction aid for review workflows, not legal advice.
- Fine-tuning benefits from a GPU; inference runs on CPU.
Frequently Asked Questions
Why not use an off-the-shelf NER model?
News-trained models miss legal specifics — they don't know "Section 11" is a SECTION or handle "Rs. 45,00,000" grouping. The legal schema and Indian-format handling are the project's whole point.
What is BIO tagging?
A per-token scheme: B- begins an entity, I- continues it, O is outside. It lets the model capture multi-token entities like full Act names exactly.
What data does it train on?
CoNLL-2003 for general entity sense plus ~2,000 hand-annotated Indian legal sentences (agreements, notices) with shipped annotation guidelines.
How is it evaluated?
Strict entity-level precision/recall/F1 — the span AND the type must match exactly — reported per entity type on a held-out legal test set. SECTION and AMOUNT typically trail PARTY, and the report shows why.
Can it find relations, like who owes what?
No — entity extraction only. Relation extraction (party→obligation links) is documented as future scope.
Is this project suitable for a final-year project?
Yes — for Computer Science, IT and AI/ML programs. It covers annotation methodology, BERT fine-tuning, sequence labeling and rigorous entity-level evaluation on domain data. Suitable for B.E./B.Tech final-year projects in Computer Science, Information Technology and AI/ML.
Components & software requirements
- Python 3.10, PyTorch
- Hugging Face transformers (bert-base-uncased)
- CoNLL-2003 (base corpus)
- Annotated Indian legal set (~2,000 sentences)
- FastAPI/Flask (inference API)
- HTML/CSS/JavaScript (demo UI)
- Git
Dataset & Model Details
- Dataset: CoNLL-2003 (Tjong Kim Sang & De Meulder; Reuters news, PER/ORG/LOC/MISC) for general entity sense + ~2,000 manually annotated Indian legal sentences (agreements, notices) in BIO format for the legal schema. Split: train / validation / held-out test.
- Model input: legal text tokens. Output: BIO labels per token → entity spans with types.
- Architecture: bert-base-uncased (110M) → dropout → linear over BIO label set; WordPiece sub-token merging; rule-assisted Indian-format post-processing.
- Metric: entity-level precision / recall / F1 (strict span+type match) on the held-out legal test set, reported per entity type after training. No F1 figure is claimed before the fine-tuning run.
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.