Transformer-based named-entity recognition tool for Swarmauri with JSON-serialized grouped entity output.
Project description
Swarmauri Tool Entity Recognition
swarmauri_tool_entityrecognition is the Swarmauri named-entity recognition
tool built on Hugging Face transformers. It wraps the pipeline("ner")
inference surface and returns a JSON-encoded dictionary of detected entity
tokens grouped by entity label.
Why Use Swarmauri Tool Entity Recognition
- Add transformer-based entity extraction to tool-calling or agent workflows.
- Return a simple serialized entity payload that can be passed across tool boundaries without introducing custom object types.
- Use Hugging Face token-classification models when you want a hosted-model-like NER interface in local Python workflows.
- Combine entity extraction with other Swarmauri tools for routing, classification, or post-processing pipelines.
FAQ
What does this tool return?
A dictionary with one key,entities, whose value is a JSON string containing grouped entity tokens.
What model does it use?
The current implementation callspipeline("ner"), so the default model is whichever Hugging Face pipeline resolves for local environment defaults.
Does it return full entity spans?
Not directly. It groups model output tokens by label. Downstream consumers may need to reconstruct phrase spans.
Does it download weights on first use?
Yes. Hugging Face model assets are downloaded on first execution if they are not already cached.
Features
- Hugging Face transformer-based named-entity recognition.
- Swarmauri
ToolBaseintegration for direct tool invocation. - JSON-encoded entity grouping keyed by model labels such as
B-ORG,I-ORG,B-PER,B-LOC, or similar. - Suitable for LLM tool-calling, preprocessing, and extraction workflows.
- Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_tool_entityrecognition
pip install swarmauri_tool_entityrecognition
Usage
import json
from swarmauri_tool_entityrecognition import EntityRecognitionTool
tool = EntityRecognitionTool()
result = tool(text="Apple Inc. is an American multinational technology company.")
entities = json.loads(result["entities"])
print(entities)
Examples
Extract labeled entity tokens
import json
from swarmauri_tool_entityrecognition import EntityRecognitionTool
tool = EntityRecognitionTool()
result = tool(text="Tim Cook spoke in New York on behalf of Apple Inc.")
print(json.loads(result["entities"]))
Pass tool output into downstream processing
import json
from swarmauri_tool_entityrecognition import EntityRecognitionTool
tool = EntityRecognitionTool()
payload = tool(text="Microsoft opened a new office in London.")
grouped = json.loads(payload["entities"])
for label, tokens in grouped.items():
print(label, tokens)
Related Packages
- swarmauri_parser_entityrecognition
- swarmauri_tool_sentimentanalysis
- swarmauri_parser_textblob
- swarmauri_parser_bertembedding
Swarmauri Foundations
More Documentation
Best Practices
- Cache Hugging Face assets in CI or deployment environments to avoid repeated downloads.
- Reconstruct contiguous entity spans if your application needs phrase-level entities instead of grouped tokens.
- Pin or subclass with a specific NER model if you need deterministic behavior across environments.
- Treat the returned JSON string as a transport format and normalize it before indexing or analytics.
License
This project is licensed under the Apache-2.0 License.
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 swarmauri_tool_entityrecognition-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_tool_entityrecognition-0.11.0.dev1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3784fa576c37d8daa26d1769e7670815a762f89330da40464bcebb46c7f01f8
|
|
| MD5 |
1b07fb694dcd8dcce81c9eb0a904c59c
|
|
| BLAKE2b-256 |
3a6a85f99a60fe52a69635988dde1b5f156fef24bcd538a3aa875135ea75237e
|
File details
Details for the file swarmauri_tool_entityrecognition-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_entityrecognition-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edd5be0480496ac47c881725e0afa418fa55b8bd8b3ecefe89139661360e087a
|
|
| MD5 |
2e2f0458a517d6712fa5401dac04d460
|
|
| BLAKE2b-256 |
ff0e57c6305dee804e257b4009b2a8f8147233f3e68a41789538a3c066b8e4c5
|