Skip to main content
Open in Kaggle  Open in Colab  Download Notebook
This documentation page is also available as an interactive notebook. You can launch the notebook in Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the above links.
Identify and extract people, organizations, locations, dates, and other entities from text using LLMs.

Problem

You have unstructured text containing important information—names, companies, dates, locations—that you need to extract and structure for analysis, search, or integration with other systems.

Solution

What’s in this recipe:
  • Extract entities as structured JSON
  • Use OpenAI’s structured output for reliable parsing
  • Access extracted entities as queryable columns
You use structured output to get entities in a consistent JSON format. The entities are stored as JSON columns that you can query and filter.

Setup

WARNING: Ignoring invalid distribution ~orch (/opt/miniconda3/envs/pixeltable/lib/python3.11/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/miniconda3/envs/pixeltable/lib/python3.11/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/miniconda3/envs/pixeltable/lib/python3.11/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/miniconda3/envs/pixeltable/lib/python3.11/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/miniconda3/envs/pixeltable/lib/python3.11/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/miniconda3/envs/pixeltable/lib/python3.11/site-packages)
Note: you may need to restart the kernel to use updated packages.
Created directory ‘entities_demo’.
<pixeltable.catalog.dir.Dir at 0x306118050>

Define entity extraction schema

Create extraction pipeline

Created table ‘articles’.
Added 0 column values with 0 errors.
No rows affected.
Added 0 column values with 0 errors.
No rows affected.

Extract entities from text

Inserting rows into `articles`: 3 rows [00:00, 404.21 rows/s]
Inserted 3 rows with 0 errors.
3 rows inserted, 12 values computed.

Explanation

Structured output ensures reliable extraction: By using OpenAI’s structured output (response_format), the model always returns valid JSON matching the schema. No post-processing or error handling needed. Common entity types:
Customizing the schema: Modify the entity_schema to extract domain-specific entities—product SKUs, legal terms, medical conditions, etc.

See also

Last modified on June 24, 2026