Documentation/Entity Extraction

Entity Extraction

Experimental5 credits

Zero-shot entity extraction using NER-inspired approach. Extract any entity type without training - just provide labels or let AI generate them automatically.

Production Recommendation

This is a direct endpoint for development and testing. For production workloads, use the Data Intelligence Pipeline -- it provides structured Data Packages with quality metrics, is async by default, and is covered by Enterprise SLAs.

Overview

Zero-shot entity extraction using NER-inspired approach. Extract any entity type without training - just provide labels or let AI generate them automatically.

Key features:

  • Three label modes: user, generated, hybrid
  • Custom regex extractors for domain-specific patterns
  • LLM refinement for accuracy
  • Handles unlimited text length with chunking

API Reference

POSThttps://api.latence.ai/api/v1/extraction/extract
Extract entities from text

Request Parameters

ParameterTypeRequiredDefaultDescription
textstringInput text
config.label_modestringLabel mode: user, generated, hybrid
config.user_labelsarrayEntity labels to extract
config.thresholdnumberConfidence threshold (0.0-1.0)
custom_labelsarrayCustom regex extractors

Response Fields

FieldTypeDescription
entitiesarray
entity_countnumber
unique_labelsarray
successboolean
usageobject

Response Example

200 OKJSON
{
  "entities": [
    {"text": "Apple Inc.", "label": "organization", "start": 0, "end": 10, "score": 0.98},
    {"text": "Cupertino", "label": "location", "start": 30, "end": 39, "score": 0.95}
  ],
  "entity_count": 2,
  "unique_labels": ["organization", "location"],
  "success": true,
  "usage": { "credits": 0.5 }
}

Code Examples

from latence import Latence

client = Latence(api_key="YOUR_API_KEY")

# Zero-shot entity extraction with user-provided labels
result = client.experimental.extraction.extract(
    text="Apple Inc. is headquartered in Cupertino, California.",
    config={
        "label_mode": "user",  # or "generated", "hybrid"
        "user_labels": ["organization", "location"],
        "threshold": 0.3
    }
)

for entity in result.entities:
    print(f"{entity.text}: {entity.label} (score: {entity.score:.2f})")

# Let AI generate labels automatically
result = client.experimental.extraction.extract(
    text="Your business document here...",
    config={"label_mode": "generated"}
)

Explore Tutorials & Notebooks

Deep-dive examples and interactive notebooks in our GitHub repository

View on GitHub

Looking for production-grade processing?

The Data Intelligence Pipeline chains services automatically and returns structured Data Packages.