ContractNER_Dataset / README.md
lucasorrentino
docs: move authors to top
d892bd1
|
Raw
History Blame Contribute Delete
4.97 kB
metadata
language:
  - en
license: apache-2.0
tags:
  - named-entity-recognition
  - legal
  - contracts
  - information-extraction
  - ner
task_categories:
  - token-classification
task_ids:
  - named-entity-recognition
pretty_name: ContractNER
size_categories:
  - 1K<n<10K

ContractNER Dataset

Developed at Agile Lab by Luca Sorrentino and Annalisa Belia, with Irene Donato as project lead.


Named entity recognition dataset built from real legal contracts sourced from SEC EDGAR filings. Designed to train and evaluate models for fine-grained entity extraction from contract text.

Used to fine-tune lucasorrentino/Contractner, which achieves 72.5% micro F1 on the test split.

Dataset Structure

Splits

Split Samples Annotations
train 3,082 ~14,000
test 158 ~730

Total: 3,240 annotated contract chunks after stratified reduction from ~5,000 raw segments.

Data Format

Each line is a JSON object with the following fields:

{
  "id": "3669",
  "text": "On the Closing Date, the Company agrees to sell up to $2.5 million of Shares...",
  "ner": [[60, 64, "Principal"], [188, 198, "Address"]],
  "tokenized_text": ["On", "the", "Closing", "Date", ",", "the", "Company", "..."]
}
Field Type Description
id string Unique sample identifier
text string Raw contract text chunk
ner list of [start_tok, end_tok, label] Token-indexed entity spans (inclusive)
tokenized_text list of strings Whitespace-tokenized words

Spans in ner use token indices into tokenized_text. To convert to character offsets, align tokens back to the original text.

Entity Schema

18 entity types covering the main elements of commercial contracts:

Document Metadata

Label Description Example
EffectiveDate Contract start date "January 1, 2026"
TerminationDate Contract end or expiration date "December 31, 2027"
RenewalTerm Renewal periods or conditions "automatically renews for one-year terms"
Title Official document title "EMPLOYMENT AGREEMENT"

Actors & Roles

Label Description Example
Parties Legal entities entering the agreement "Tech Solutions Inc."
Role Professional titles and positions "Chief Technology Officer"

Contact Information

Label Description Example
Address Physical addresses "1540 Broadway, New York, NY 10036"
PII_Ref Personal identifiable information references "(212) 555-0100"

Financial Values

Label Description Example
Salary Compensation amounts (with currency) "$250,000.00"
Price Goods or services prices "$1,500 per unit"
Principal Loan principal amounts "$2.5 million"
Shares Stock or equity quantities "10,000 shares"
Percentage Percentage values "50%"
Ratio Financial ratios "1.25:1"
Rent Lease or rental amounts "$8,500 per month"

Legal and Regulatory

Label Description Example
Court Judicial bodies and tribunals "State of Delaware"
Act Legislative acts and laws "Securities Exchange Act of 1934"
Regulation Regulatory references "Rule 10b5-1"

Usage

from datasets import load_dataset

dataset = load_dataset("lucasorrentino/ContractNER")

# Access train and test splits
train = dataset["train"]
test  = dataset["test"]

# Example: inspect annotations
sample = train[0]
print(sample["text"][:200])
for start_tok, end_tok, label in sample["ner"]:
    span = sample["tokenized_text"][start_tok:end_tok + 1]
    print(f"  {label}: {' '.join(span)}")

Loading with GLiNER

This dataset pairs directly with lucasorrentino/Contractner:

from gliner import GLiNER
from datasets import load_dataset

model   = GLiNER.from_pretrained("lucasorrentino/Contractner")
dataset = load_dataset("lucasorrentino/ContractNER")

labels = [
    "Parties", "EffectiveDate", "Role", "Salary", "TerminationDate",
    "Principal", "Percentage", "Act", "Regulation", "Title"
]

sample   = dataset["test"][0]
entities = model.predict_entities(sample["text"], labels, threshold=0.9)
for e in entities:
    print(f"{e['text']} => {e['label']} ({e['score']:.2f})")

Source Data

Contracts sourced from SEC EDGAR public filings (U.S. Securities and Exchange Commission). Original annotation schema based on Adibhatla et al. (2023) — ContractNER corpus.

Preprocessing:

  • Removed RevolvingCredit class (too rare and ambiguous)
  • Stratified reduction to balance class representation
  • 80/20 train/test split

License

Apache 2.0