Built to order

Named Entity Recognition for Legal Documents using BERT

This project extracts structured facts from Indian legal text — parties, dates, amounts, cited sections and courts — with a BERT token classifier using the BIO tagging scheme. Built on CoNLL-2003 for general entity sense plus ~2,000 manually annotated Indian legal sentences, it handles lakh/crore amount formats and Act citations that news-trained NER misses. Evaluation reports entity-level precision/recall/F1 on a held-out legal test set. Suitable for B.E./B.Tech final-year projects in Computer Science, Information Technology and AI/ML.

Named Entity Recognition for Legal Documents using BERT — project thumbnail preview
More project photos (2)

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

  1. Legal text is tokenized with BERT's WordPiece tokenizer.
  2. bert-base-uncased produces a contextual embedding for every token.
  3. A dropout + linear token-classification head labels each token in the BIO scheme.
  4. WordPiece sub-tokens merge to word-level tags; adjacent B-/I- spans become entities.
  5. Rule-assisted post-processing normalizes Indian amount formats and citation shapes over the neural tags.
  6. 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.

Download abstract (PDF)

Related guides

All guides
Illustration of object tracking showing video frames with bounding boxes and persistent ID labels following people and vehicles, comparing motion prediction and appearance matching.B.E./B.Tech Computer Science and Electronics students building video analytics projects — people counting, vehicle tracking, sports analysis — who have detection working and need

Object Tracking: DeepSORT and ByteTrack Explained

Detection finds objects per frame; tracking keeps their identities across frames. This guide explains tracking-by-detection, Kalman motion models, DeepSORT's appearance embeddings vs ByteTrack's low-confidence box recovery, tracking metrics (HOTA, IDF1, ID switches), and the tuning parameters that determine real-world quality.

Read guide
Illustration of image segmentation showing U-Net's U-shaped encoder-decoder with skip connections producing pixel masks, alongside Mask R-CNN detecting instances with masks.B.E./B.Tech Computer Science and AI/ML students moving from image classification or detection to pixel-level understanding — medical imaging, defect detection, autonomous driving

Image Segmentation: U-Net and Mask R-CNN

When projects need pixel-level answers, segmentation delivers. This guide explains semantic vs instance vs panoptic segmentation, U-Net's encoder-decoder with skip connections, Mask R-CNN's parallel mask head, Dice and IoU evaluation, paired augmentation, and how to choose the right architecture for your data and question.

Read guide
Illustration of Whisper speech-to-text showing sound waves flowing into a neural network and emerging as transcribed text with timestamps and speaker labels.B.E./B.Tech Computer Science and AI/ML students adding speech-to-text to projects — voice assistants, meeting transcription, accessibility tools

Whisper for Speech-to-Text in Student Projects

Whisper transcribes speech in dozens of languages with no training required. This guide covers how it works, choosing among model sizes, running it locally with faster-whisper, handling hour-long audio, timestamps and speaker diarization, multilingual quirks, and honest evaluation with word error rate.

Read guide
Get a quotation