A compact, efficient Named Entity Recognition model for identifying and classifying entities in text.
Built by Minibase - Train and deploy small AI models from your browser. Browse all of the models and datasets available on the Minibase Marketplace.
Minibase-NER-Small is a specialized language model fine-tuned for Named Entity Recognition (NER) tasks. It automatically identifies and extracts named entities from text, outputting them in structured numbered lists for entities like persons, organizations, locations, and miscellaneous terms.
Install llama.cpp (if not already installed):
# Clone and build llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
# Return to project directory
cd ../NER_small
Download the GGUF model:
# Download model files from HuggingFace
wget https://huggingface.co/Minibase/NER-Small/resolve/main/model.gguf
wget https://huggingface.co/Minibase/NER-Small/resolve/main/ner_inference.py
wget https://huggingface.co/Minibase/NER-Small/resolve/main/config.json
wget https://huggingface.co/Minibase/NER-Small/resolve/main/tokenizer_config.json
wget https://huggingface.co/Minibase/NER-Small/resolve/main/generation_config.json
Start the model server:
# Start llama.cpp server with the GGUF model
../llama.cpp/llama-server \
-m model.gguf \
--host 127.0.0.1 \
--port 8000 \
--ctx-size 2048 \
--n-gpu-layers 0 \
--chat-template
Make API calls:
import requests
# NER tagging via REST API
response = requests.post("http://127.0.0.1:8000/completion", json={
"prompt": "Instruction: Identify and tag all named entities in the following text. Use BIO format with entity types: PERSON, ORG, LOC, MISC.\n\nInput: John Smith works at Google in New York.\n\nResponse: ",
"max_tokens": 512,
"temperature": 0.1
})
result = response.json()
print(result["content"])
# Output: "John B-PERSON\nSmith I-PERSON\nworks O\nat O\nGoogle B-ORG\nin O\nNew York B-LOC\nI-LOC\n."
# Download and use the provided Python client
from ner_inference import NERClient
# Initialize client (connects to local server)
client = NERClient()
# Tag entities in text
text = "Apple Inc. was founded by Steve Jobs in Cupertino, California."
entities = client.extract_entities(text)
print(entities)
# Output: [
# {"text": "Apple Inc.", "type": "ORG", "start": 0, "end": 9},
# {"text": "Steve Jobs", "type": "PERSON", "start": 24, "end": 34},
# {"text": "Cupertino", "type": "LOC", "start": 38, "end": 47},
# {"text": "California", "type": "LOC", "start": 49, "end": 59}
# ]
# Batch processing
texts = [
"Microsoft announced a new CEO.",
"Paris is the capital of France."
]
all_entities = client.extract_entities_batch(texts)
print(all_entities)
# Alternative: Use llama.cpp directly without server
import subprocess
import json
def extract_entities_with_llama_cpp(text: str) -> str:
prompt = f"Instruction: Identify and tag all named entities in the following text. Use BIO format with entity types: PERSON, ORG, LOC, MISC.\n\nInput: {text}\n\nResponse: "
# Run llama.cpp directly
cmd = [
"../llama.cpp/llama-cli",
"-m", "model.gguf",
"--prompt", prompt,
"--ctx-size", "2048",
"--n-predict", "512",
"--temp", "0.1",
"--log-disable"
]
result = subprocess.run(cmd, capture_output=True, text=True, cwd=".")
return result.stdout.strip()
# Usage
result = extract_entities_with_llama_cpp("John Smith works at Google in New York.")
print(result)
| Metric | Score | Description |
|---|---|---|
| NER F1 Score | 43.5% | Overall entity recognition performance |
| Precision | 63.0% | Accuracy of positive predictions |
| Recall | 34.3% | Ability to find all relevant entities |
| Accuracy | 93.6% | Accuracy on identified entities (103/110 correct) |
| Average Latency | 76.6ms | Response time performance |
| Component | Minimum | Recommended |
|---|---|---|
| Operating System | Linux, macOS, Windows | Linux or macOS |
| RAM | 8GB | 16GB |
| Storage | 150MB free space | 500MB free space |
| Python | 3.8+ | 3.10+ |
| Dependencies | llama.cpp | llama.cpp, requests |
Notes:
| Limitation | Description | Impact |
|---|---|---|
| Variable Output Quality | Sometimes produces garbled or incomplete responses | May miss entities in certain contexts |
| No Entity Type Labels | Outputs entity names but not their types | Requires post-processing for type classification |
| Context Window | Limited to 2,048 token context window | Cannot process very long documents |
| Language Scope | Primarily trained on English text | Limited performance on other languages |
| Inconsistent Extraction | Performance varies by input complexity | May miss entities in complex sentences |
| Bias Type | Description | Mitigation |
|---|---|---|
| Output Format Inconsistency | Sometimes outputs structured lists, sometimes garbled text | Improved prompt engineering and training |
| Entity Recognition Patterns | May favor certain entity patterns over others | Diverse training data and evaluation |
| Domain Specificity | Performance varies across different text types | Multi-domain training and fine-tuning |
If you use NER-Small in your research, please cite:
@misc{ner-small-2025,
title={NER-Small: A Compact Named Entity Recognition Model},
author={Minibase AI Team},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/Minibase/NER-Small}
}
This model is released under the Apache License 2.0.
Built with ❤️ by the Minibase team
Making AI more accessible for everyone