Skip to main content

Named Entity Recognition for Early Modern English documents (1500-1800)

Project description

EarlyModernNER

Named Entity Recognition for Early Modern English documents (1500-1800).

Overview

EarlyModernNER extracts four types of entities from historical texts:

Entity Type Description Examples
TOPONYM Place names London, Jamaica, West Indies
PERSON Individual people Oliver Cromwell, Governor Modyford
ORGANIZATION Institutions East India Company, Parliament
COMMODITY Trade goods & materials sugar, tobacco, silk

Performance

Evaluated on 100 gold-standard annotated documents:

Entity Type Precision Recall F1
TOPONYM 0.93 0.82 0.87
PERSON 0.93 0.69 0.80
ORGANIZATION 0.93 0.46 0.62
COMMODITY 0.85 0.80 0.83
Overall 0.89 0.77 0.83

Quick Start

Installation

pip install earlymodernner

Or install from source:

git clone https://github.com/polayj/earlymodernner.git
cd earlymodernner
pip install -e .

Model adapters (~680MB total) are automatically downloaded from Hugging Face Hub on first use.

Usage

# Process a single file
python -m earlymodernner --input document.txt --output results.jsonl

# Process a directory
python -m earlymodernner --input /path/to/docs/ --output results.jsonl

# Output as CSV
python -m earlymodernner --input docs/ --output results.csv --csv

# Pre-download adapters (optional, for offline use)
python -m earlymodernner --download

Output Format

JSONL (default):

{
  "doc_id": "document_name",
  "text": "The sugar trade between Jamaica and Bristol...",
  "entities": [
    {"text": "Jamaica", "type": "TOPONYM"},
    {"text": "Bristol", "type": "TOPONYM"},
    {"text": "sugar", "type": "COMMODITY"}
  ]
}

CSV (with --csv):

doc_id,entity_text,entity_type
document_name,Jamaica,TOPONYM
document_name,Bristol,TOPONYM
document_name,sugar,COMMODITY

Requirements

  • Python 3.9+
  • CUDA-compatible GPU with 8GB+ VRAM
  • See requirements.txt for dependencies

Project Structure

earlymodernner/
├── earlymodernner/          # Main package
│   ├── __main__.py          # CLI entry point
│   ├── pipeline.py          # Inference pipeline
│   ├── constants.py         # Entity types & prompts
│   └── adapters/            # Trained LoRA adapters
├── dev/                     # Training & development tools
│   ├── train_lora.py        # Training script
│   ├── evaluate.py          # Evaluation script
│   ├── training.md          # Training documentation
│   └── config/              # Training configurations
├── docs/                    # Documentation
│   ├── usage.md             # Detailed usage guide
│   └── corpus.md            # Training corpus details
└── results/                 # Default output directory

Documentation

How It Works

EarlyModernNER uses an ensemble approach with four specialized models:

  1. Each entity type has its own fine-tuned LoRA adapter
  2. Documents are processed by all four adapters
  3. Results are merged using priority-based cascade (TOPONYM → COMMODITY → PERSON → ORGANIZATION)
  4. Overlapping entities are resolved by giving priority to higher-performing models

Technical details:

  • Base model: Qwen3-4B-Instruct
  • Fine-tuning: QLoRA (4-bit quantization)
  • Training: Silver-standard annotations + synthetic hard negatives

Citation

@software{earlymodernner,
  title = {EarlyModernNER: Named Entity Recognition for Early Modern English},
  author = {Polay, Jacob},
  year = {2026},
  url = {https://github.com/polayj/earlymodernner}
}

License

MIT License

Author

Jacob Polay, MA Student, University of Saskatchewan

Acknowledgments

  • Built on Qwen models
  • Uses PEFT for efficient fine-tuning
  • Training data from Old Bailey Online, PCEEC2, Royal Society Corpus, EEBO, and Archive.org

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

earlymodernner-0.2.0.tar.gz (45.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

earlymodernner-0.2.0-py3-none-any.whl (51.3 kB view details)

Uploaded Python 3

File details

Details for the file earlymodernner-0.2.0.tar.gz.

File metadata

  • Download URL: earlymodernner-0.2.0.tar.gz
  • Upload date:
  • Size: 45.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for earlymodernner-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dcc89d65b4625ff51a550bc6181b5e9fb47cccdb648f7460518ba9f39c97505e
MD5 4ca707c320045706a9c9433ba9c03a35
BLAKE2b-256 61357278bf22862bdcf274777b6ccdd303f2a096a34270ac0181f2b5000a4b65

See more details on using hashes here.

File details

Details for the file earlymodernner-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: earlymodernner-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 51.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for earlymodernner-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e3163f80b48d5da434ec8fb3ed7425570feb8b6f34a85e16cc5cf9f693a42c3
MD5 03bb98aedc2331f5b12be4bdad495a1c
BLAKE2b-256 b0f17de7342b08e044c683d03f7280911509d8c3d4c8312fe1fbf21fb838bf7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page