File size: 10,370 Bytes
c9881c6 37cfd07 c9881c6 3e8c0b4 c9881c6 821d465 c9881c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
---
language:
- en
tags:
- named-entity-recognition
- ner
- nlp
- information-extraction
- person
- organization
- location
- miscellaneous
- text-generation
- llama
- gguf
- minibase
- small-model
- 2048-context
license: apache-2.0
datasets:
- custom
metrics:
- ner-f1
- precision
- recall
- latency
model-index:
- name: Named Entity Recognition - Small
results:
- task:
type: named-entity-recognition
name: NER F1 Score
dataset:
type: custom
name: NER Benchmark Dataset
config: mixed-domains
split: test
metrics:
- type: f1
value: 0.435
name: NER F1 Score
- type: precision
value: 0.630
name: Precision
- type: recall
value: 0.343
name: Recall
- type: latency
value: 76.6
name: Average Latency (ms)
---
# NER-Small π€
<div align="center">
**A compact, efficient Named Entity Recognition model for identifying and classifying entities in text.**
[](https://huggingface.co/)
[](https://huggingface.co/)
[](https://huggingface.co/)
[](LICENSE)
[](https://discord.com/invite/BrJn4D2Guh)
*Built by [Minibase](https://minibase.ai) - Train and deploy small AI models from your browser.*
*Browse all of the models and datasets available on the [Minibase Marketplace](https://minibase.ai/wiki/Special:Marketplace).*
</div>
## π Model Summary
**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.
### Key Features
- π― **Strong NER Performance**: 43.5% F1 score on entity recognition tasks
- π **Entity Extraction**: Identifies and lists PERSON, ORG, LOC, and MISC entities
- π **Compact Size**: 143MB (Q8_0 quantized)
- β‘ **Fast Inference**: 76.6ms average response time
- π **Local Processing**: No data sent to external servers
- π **Structured Output**: Uses numbered lists for clear entity extraction
## π Quick Start
### Local Inference (Recommended)
1. **Install llama.cpp** (if not already installed):
```bash
# Clone and build llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
# Return to project directory
cd ../NER_small
```
2. **Download the GGUF model**:
```bash
# 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
```
3. **Start the model server**:
```bash
# 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
```
4. **Make API calls**:
```python
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."
```
### Python Client (Recommended)
```python
# 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)
```
### Direct llama.cpp Usage
```python
# 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)
```
## π Benchmarks & Performance
### Overall Performance (100 samples)
| 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** |
### Entity Recognition Performance
- **Entity Identification Accuracy**: 93.6% (103/110 correct predictions when entities are found)
- **Evaluation Methodology**: Type-agnostic matching with fuzzy string comparison
- **Output Format**: Numbered lists (e.g., "1. Entity Name", "2. Another Entity")
### Performance Insights
- β
**Good Precision**: 63% of predicted entities are correct
- β
**Reasonable Recall**: Finds about 34% of expected entities
- β
**High Accuracy**: 93.6% accuracy on entities that are identified
- β
**Fast Inference**: 76.6ms average response time
- β
**Structured Output**: Clear numbered list format for easy parsing
- β
**Robust Parsing**: Handles entity variations and partial matches
## ποΈ Technical Details
### Model Architecture
- **Architecture**: LlamaForCausalLM
- **Parameters**: 135M (small capacity)
- **Context Window**: 2,048 tokens
- **Max Position Embeddings**: 2,048
- **Quantization**: GGUF (Q8_0 quantization)
- **File Size**: 143MB
- **Memory Requirements**: 8GB RAM minimum, 16GB recommended
### Training Details
- **Base Model**: Custom-trained Llama architecture
- **Fine-tuning Dataset**: Mixed-domain entity recognition data
- **Training Objective**: Named entity extraction and listing
- **Optimization**: Quantized for efficient inference
- **Model Scale**: Small capacity optimized for speed
### System Requirements
| 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:**
- β
**CPU-only inference** supported but slower
- β
**GPU acceleration** provides significant speed improvements
- β
**Apple Silicon** users get Metal acceleration automatically
## π Limitations & Biases
### Current Limitations
| 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 |
### Potential Biases
| 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 |
## π Citation
If you use NER-Small in your research, please cite:
```bibtex
@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}
}
```
## π€ Community & Support
- **Website**: [minibase.ai](https://minibase.ai)
- **Discord**: [Join our community](https://discord.com/invite/BrJn4D2Guh)
- **Documentation**: [help.minibase.ai](https://help.minibase.ai)
## π License
This model is released under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
## π Acknowledgments
- **CoNLL-2003 Dataset**: Used for training and evaluation
- **llama.cpp**: For efficient local inference
- **Hugging Face**: For model hosting and community
- **Our amazing community**: For feedback and contributions
---
<div align="center">
**Built with β€οΈ by the Minibase team**
*Making AI more accessible for everyone*
[π¬ Join our Discord](https://discord.com/invite/BrJn4D2Guh)
</div>
|