Skip to main content

A simple NER agent

Project description

ner-agent

A simple, language-agnostic Named Entity Recognition (NER) agent powered by LLMs.

Features

  • Multilingual: Supports English, Chinese, Japanese, Korean, French, German, Russian, Spanish, and more.
  • Entity Types: Recognizes PERSON, NORP (nationalities, religions, political groups, languages), LOCATION, DATETIME, NUMERIC, and PROPER_NOUN (events, works, organizations, products, etc.).
  • Easy Integration: Use as a Python library with a simple async API.
  • Tested: Includes comprehensive test cases for multiple languages and entity types.

Installation

pip install ner-agent

Or clone and install locally:

git clone https://github.com/allen2c/ner-agent.git
cd ner-agent
pip install .

Python 3.11+ required.

Usage

import asyncio
from ner_agent import NerAgent

async def main():
    agent = NerAgent()
    text = "Elon Musk visited Tesla's Gigafactory in Austin on March 15, 2024, announcing a 20% increase."
    result = await agent.run(text)
    for entity in result.entities:
        print(entity)

asyncio.run(main())

Output:

name='PERSON' value='Elon Musk' start=0 end=9
name='PROPER_NOUN' value='Tesla' start=18 end=23
name='LOCATION' value='Gigafactory' start=26 end=37
...

Entity Types

  • PERSON: People, including fictional characters.
  • NORP: Nationalities, religious groups, political groups, languages.
  • LOCATION: Geopolitical entities, facilities, places.
  • DATETIME: Dates, times, periods, ages.
  • NUMERIC: Numbers, money, quantities, percentages, ordinals/cardinals.
  • PROPER_NOUN: Named events, works, laws, products, organizations, companies, etc.

Testing

To run the tests:

pytest

Configuration

  • By default, uses OpenAI-compatible LLMs via openai-agents.
  • You can configure the model and OpenAI client (see tests/conftest.py for examples).

License

MIT License


For more details, see ner_agent/init.py and the tests.

If you need more advanced usage or want to contribute, please check the GitHub repository.

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

ner_agent-0.3.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

ner_agent-0.3.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file ner_agent-0.3.0.tar.gz.

File metadata

  • Download URL: ner_agent-0.3.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.11.13 Darwin/24.6.0

File hashes

Hashes for ner_agent-0.3.0.tar.gz
Algorithm Hash digest
SHA256 161fe5f1d4064b84aefb11af1dd10bb327698d36a79d4ec53c1c6556959573f5
MD5 34afb13a73306076774e34312f8bf0fb
BLAKE2b-256 74c17d0cd15a10923bfdeb620722236f1ac5f3a87d5123369827af1aaad32cb0

See more details on using hashes here.

File details

Details for the file ner_agent-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ner_agent-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.11.13 Darwin/24.6.0

File hashes

Hashes for ner_agent-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b94b97a3061065eeb72d6ae4961e3c9f7fb2d4811ae77d463f0b538a4e7d9a77
MD5 3a93ae7902336b0bdd10f67db01aac81
BLAKE2b-256 83a801e8bd128ac33e73b08b7ac79c5a29b867511638d14cdcd9e0b72def9dff

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