Information extractor using spaCy + SpanBERT
Project description
information_extractor
Overview
information_extractor is a Python package that combines spaCy, coreferee, and SpanBERT to extract structured relationships between entities in natural language text. It's purpose-built for anyone who wants to bridge NER, coreference resolution, and relation extraction into one streamlined pipeline.
Features
✅ Entity Linking & Coreference Resolution
- Uses
spaCywithcorefereeto resolve pronouns and link entity mentions. - Flexible support for multiple entity types:
PERSON,ORG,LOC,DATE, etc.
✅ Relation Extraction with SpanBERT
- Uses fine-tuned SpanBERT model trained on TACRED.
- Handles subject/object marking and context-aware classification.
- Confidence scoring and de-duplication of extracted relations.
- GPU acceleration supported out of the box.
✅ CLI Interface
ie --text "Barack Obama was born in Hawaii." [--deps]
--deps: Downloads and installs required pretrained models if not present.
Installation
pip install information_extractor
Optional: Download model dependencies
Run the following once to download SpanBERT, spaCy model, coreferee model:
ie --deps
Alternatively, you can import and run the dependency script directly:
from information_extractor.dependency import setup_dependencies
setup_dependencies()
Example Usage
from information_extractor.pipeline import RelationExtractor
text = "Sundar Pichai is the CEO of Google. He lives in California."
extractor = RelationExtractor()
results = extractor.extract(text)
for relation in results:
print(relation)
Sample Output
[
{
"subject": "Sundar Pichai",
"object": "Google",
"relation": "per:employee_of",
"confidence": 0.92
},
...
]
Project Structure
information_extractor/
├── assets/
│ └── pretrained_spanbert/
├── dependency.py # Downloads all model dependencies
├── pipeline.py # Core logic for NLP + SpanBERT
├── main.py # CLI entrypoint
Pretrained Assets
Models are downloaded from hosted GitHub release assets:
- ✅
SpanBERTweights & config - ✅
en_core_web_mdspaCy model - ✅
coreferee_model_enfor coreference resolution - ✅
torchwheel for reproducibility
Citation
This project builds on the work of Facebook Research. If you use SpanBERT, please cite:
@article{joshi2019spanbert,
title={{SpanBERT}: Improving Pre-training by Representing and Predicting Spans},
author={Mandar Joshi and Danqi Chen and Yinhan Liu and Daniel S. Weld and Luke Zettlemoyer and Omer Levy},
journal={arXiv preprint arXiv:1907.10529},
year={2019}
}
License
MIT. See LICENSE for full terms.
Note: This project redistributes pretrained model weights for convenience under fair use for research.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file information_extractor-0.2.0.tar.gz.
File metadata
- Download URL: information_extractor-0.2.0.tar.gz
- Upload date:
- Size: 32.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4703acc60ee4a730fecfece24654f9a41cd509f60056807a1eb9de57d67557a
|
|
| MD5 |
62b8e0bef02d51100f5ba6dd76bb9c1e
|
|
| BLAKE2b-256 |
1a834d3e7bf6fe265b6b277de172fa74ae5471863a39d9e3d684d4d04be6a91a
|
Provenance
The following attestation bundles were made for information_extractor-0.2.0.tar.gz:
Publisher:
publish.yml on rajatasusual/information_extractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
information_extractor-0.2.0.tar.gz -
Subject digest:
a4703acc60ee4a730fecfece24654f9a41cd509f60056807a1eb9de57d67557a - Sigstore transparency entry: 197044102
- Sigstore integration time:
-
Permalink:
rajatasusual/information_extractor@3f0a7640e4db7f49e854e153b743cd0e2395089c -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/rajatasusual
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3f0a7640e4db7f49e854e153b743cd0e2395089c -
Trigger Event:
release
-
Statement type:
File details
Details for the file information_extractor-0.2.0-py3-none-any.whl.
File metadata
- Download URL: information_extractor-0.2.0-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e96ce3573753cfb4673f3fa837f979e6a4afbe78b0815e25d4553cf6e55cd476
|
|
| MD5 |
9cd0c2b8db59568e72feb29a9af95dbc
|
|
| BLAKE2b-256 |
ede1a02944f96986c877fd1cf8619034851505bd4f413bbd7fd84d585fb94194
|
Provenance
The following attestation bundles were made for information_extractor-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on rajatasusual/information_extractor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
information_extractor-0.2.0-py3-none-any.whl -
Subject digest:
e96ce3573753cfb4673f3fa837f979e6a4afbe78b0815e25d4553cf6e55cd476 - Sigstore transparency entry: 197044104
- Sigstore integration time:
-
Permalink:
rajatasusual/information_extractor@3f0a7640e4db7f49e854e153b743cd0e2395089c -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/rajatasusual
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3f0a7640e4db7f49e854e153b743cd0e2395089c -
Trigger Event:
release
-
Statement type: