ML NLP Skill
Guide for OCR, NER, and reranking capabilities in LlamaFarm.
When to Load
Load this skill when the user:
- Wants to extract text from images or PDFs (OCR)
- Asks about named entity recognition (NER)
- Needs to rerank search results
- Wants to identify people, organizations, or locations in text
- Asks about document processing pipelines
- Needs to improve RAG retrieval quality with reranking
API Overview
| Endpoint |
Method |
Description |
/v1/ocr |
POST |
Extract text from images/documents |
/v1/ner |
POST |
Extract named entities from text |
/v1/rerank |
POST |
Rerank documents by relevance to query |
OCR Backend Selection
| Backend |
Speed |
Accuracy |
Languages |
Best For |
surya |
Medium |
Very High |
90+ |
General purpose, best quality |
easyocr |
Medium |
High |
80+ |
Good balance, wide language support |
paddleocr |
Fast |
High |
80+ |
CJK languages, structured docs |
tesseract |
Fast |
Moderate |
100+ |
Simple documents, legacy systems |
NER Models
| Model |
Speed |
Entities |
Best For |
dslim/bert-base-NER |
Fast |
PER, ORG, LOC, MISC |
General English NER |
Jean-Baptiste/camembert-ner |
Fast |
PER, ORG, LOC, MISC |
French NER |
flair/ner-english-large |
Medium |
PER, ORG, LOC, MISC |
Higher accuracy English |
Reranking Overview
Reranking improves search quality by re-scoring retrieved results with a cross-encoder model. Typical pattern:
RAG retrieve top-50 → Rerank → Return top-10
This significantly improves precision over embedding-only retrieval.
Quick Start
OCR
curl -X POST http://localhost:14345/v1/ocr \
-F "file=@document.png" \
-F "backend=surya"
NER
curl -X POST http://localhost:14345/v1/ner \
-H "Content-Type: application/json" \
-d '{
"text": "John Smith works at Google in Mountain View.",
"model": "dslim/bert-base-NER"
}'
Rerank
curl -X POST http://localhost:14345/v1/rerank \
-H "Content-Type: application/json" \
-d '{
"query": "How to configure authentication?",
"documents": [
"Authentication is configured via the auth section...",
"The logging system supports multiple outputs...",
"Set up OAuth by adding provider credentials..."
],
"top_k": 2
}'
Progressive Disclosure
For detailed guidance:
- ocr.md - Backend comparison, file types, preprocessing, batch OCR
- ner.md - Entity types, model selection, confidence thresholds
- reranking.md - RAG integration, model selection, performance tuning
1---2name: ml-nlp3description: OCR, Named Entity Recognition, and reranking. Extract text from images, identify entities in text, and rerank search results for relevance.4---56# ML NLP Skill78Guide for OCR, NER, and reranking capabilities in LlamaFarm.910## When to Load1112Load this skill when the user:13- Wants to extract text from images or PDFs (OCR)14- Asks about named entity recognition (NER)15- Needs to rerank search results16- Wants to identify people, organizations, or locations in text17- Asks about document processing pipelines18- Needs to improve RAG retrieval quality with reranking1920## API Overview2122| Endpoint | Method | Description |23|----------|--------|-------------|24| `/v1/ocr` | POST | Extract text from images/documents |25| `/v1/ner` | POST | Extract named entities from text |26| `/v1/rerank` | POST | Rerank documents by relevance to query |2728## OCR Backend Selection2930| Backend | Speed | Accuracy | Languages | Best For |31|---------|-------|----------|-----------|----------|32| `surya` | Medium | Very High | 90+ | General purpose, best quality |33| `easyocr` | Medium | High | 80+ | Good balance, wide language support |34| `paddleocr` | Fast | High | 80+ | CJK languages, structured docs |35| `tesseract` | Fast | Moderate | 100+ | Simple documents, legacy systems |3637## NER Models3839| Model | Speed | Entities | Best For |40|-------|-------|----------|----------|41| `dslim/bert-base-NER` | Fast | PER, ORG, LOC, MISC | General English NER |42| `Jean-Baptiste/camembert-ner` | Fast | PER, ORG, LOC, MISC | French NER |43| `flair/ner-english-large` | Medium | PER, ORG, LOC, MISC | Higher accuracy English |4445## Reranking Overview4647Reranking improves search quality by re-scoring retrieved results with a cross-encoder model. Typical pattern:4849```50RAG retrieve top-50 → Rerank → Return top-1051```5253This significantly improves precision over embedding-only retrieval.5455## Quick Start5657### OCR5859```bash60curl -X POST http://localhost:14345/v1/ocr \61 -F "file=@document.png" \62 -F "backend=surya"63```6465### NER6667```bash68curl -X POST http://localhost:14345/v1/ner \69 -H "Content-Type: application/json" \70 -d '{71 "text": "John Smith works at Google in Mountain View.",72 "model": "dslim/bert-base-NER"73 }'74```7576### Rerank7778```bash79curl -X POST http://localhost:14345/v1/rerank \80 -H "Content-Type: application/json" \81 -d '{82 "query": "How to configure authentication?",83 "documents": [84 "Authentication is configured via the auth section...",85 "The logging system supports multiple outputs...",86 "Set up OAuth by adding provider credentials..."87 ],88 "top_k": 289 }'90```9192## Progressive Disclosure9394For detailed guidance:95- **ocr.md** - Backend comparison, file types, preprocessing, batch OCR96- **ner.md** - Entity types, model selection, confidence thresholds97- **reranking.md** - RAG integration, model selection, performance tuning