Skip to main content

DELM logo

Data Extraction with Language Models


DELM is a Python toolkit for extracting structured data from unstructured text using language models.

📖 Full Documentation

Features

  • Multiple input formats: TXT, HTML, MD, DOCX, PDF, CSV, Excel, Parquet, Feather
  • Flexible schemas: Simple key-value → nested objects → multiple schemas
  • Multiple LLM providers: OpenAI, Anthropic, Google, Groq, Together AI, Fireworks AI
  • Cost management: Automatic cost tracking, caching, and budget limits
  • Built for scale: Batch processing with parallel execution and checkpointing

Installation

pip install delm

Quick Start

Define your extraction schema and extract structured data in just a few lines:

from delm import DELM, Schema, ExtractionVariable

# Define what to extract
schema = Schema.simple(
    variables_list=[
        ExtractionVariable(
            name="company",
            description="Company name mentioned",
            data_type="string",
            required=True,
        ),
        ExtractionVariable(
            name="price",
            description="Price value if mentioned",
            data_type="number",
            required=False,
        ),
    ]
)

# Initialize and extract
delm = DELM(
    schema=schema,
    provider="openai",
    model="gpt-4o-mini",
)

# Extract from any supported file format
results = delm.extract("data/earnings_calls.txt")
print(results)

# Check costs
print(delm.get_cost_summary())

Schema Types

DELM supports three schema types for different extraction needs:

Simple Schema

Extract key-value pairs from text:

schema = Schema.simple(
    variables_list=[
        ExtractionVariable(name="author", data_type="string"),
        ExtractionVariable(name="date", data_type="date"),
    ]
)

Nested Schema

Extract lists of structured objects:

schema = Schema.nested(
    container_name="products",
    variables_list=[
        ExtractionVariable(name="name", data_type="string"),
        ExtractionVariable(name="price", data_type="number"),
        ExtractionVariable(name="features", data_type="[string]"),
    ]
)

Multiple Schemas

Extract multiple different schemas simultaneously:

schema = Schema.multiple({
    "companies": Schema.nested(
        container_name="companies",
        variables_list=[...],
    ),
    "products": Schema.nested(
        container_name="products",
        variables_list=[...],
    ),
})

Supported Data Types

Type Description Example
string Text values "Apple Inc."
number Floating-point 150.5
integer Whole numbers 2024
boolean True/False true
date Date strings "2025-09-15"
[string] List of strings ["oil", "gas"]
[number] List of numbers [100, 200]

Advanced Features

Custom Prompts

delm = DELM(
    schema=schema,
    provider="openai",
    model="gpt-4o-mini",
    prompt_template="""You are a financial data extraction expert.

Extract the following information:
{variables}

Text to analyze:
{text}""",
)

Process CSV/Structured Data

delm = DELM(
    schema=schema,
    provider="openai",
    model="gpt-4o-mini",
    target_column="transcript_text",  # Column containing text to process
)

results = delm.extract("earnings_data.csv")

Cost Tracking & Limits

delm = DELM(
    schema=schema,
    provider="openai",
    model="gpt-4o-mini",
    track_cost=True,
    max_budget=10.0,  # Stop if cost exceeds $10
)

results = delm.extract("data.txt")
summary = delm.get_cost_summary()
print(f"Total cost: ${summary['total_cost']:.2f}")

Batch Processing

delm = DELM(
    schema=schema,
    provider="openai",
    model="gpt-4o-mini",
    batch_size=50,      # Process 50 records per batch
    max_workers=5,      # Use 5 parallel workers
)

results = delm.extract("large_dataset.csv")

Configuration Options

For a complete list of configuration options, see the documentation.

Common parameters:

  • provider: LLM provider ("openai", "anthropic", "google", etc.)
  • model: Model name ("gpt-4o-mini", "claude-3-sonnet-20240229", etc.)
  • temperature: Generation temperature (default: 0.0)
  • batch_size: Records per batch (default: 10)
  • max_workers: Concurrent workers (default: 1)
  • track_cost: Enable cost tracking (default: True)
  • max_budget: Maximum cost limit in dollars (default: None)
  • target_column: Column name for CSV/tabular data (default: None)

Documentation

📖 Full Documentation

Learn more about:

File Format Support

Format Extensions Additional Dependencies
Text .txt None
HTML/Markdown .html, .htm, .md beautifulsoup4
Word .docx python-docx
PDF .pdf marker-pdf
CSV .csv pandas
Excel .xlsx openpyxl
Parquet .parquet pyarrow
Feather .feather pyarrow

Contributing

We welcome contributions! Please see our documentation for guidelines.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

delm-1.2.0.tar.gz (75.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

delm-1.2.0-py3-none-any.whl (83.9 kB view details)

Uploaded Python 3

File details

Details for the file delm-1.2.0.tar.gz.

File metadata

  • Download URL: delm-1.2.0.tar.gz
  • Upload date:
  • Size: 75.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for delm-1.2.0.tar.gz
Algorithm Hash digest
SHA256 25c68f1bc5566e336a91e5b50c22a94bb85b8cf6e89d0ef13259d3b2b3cf8f0f
MD5 1ba0ffaf88c1da07484f7ca65fe41f52
BLAKE2b-256 b90b85f10bc49839ce5fb76e80b427aa2c63f1128efd13315b2745e2043213ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for delm-1.2.0.tar.gz:

Publisher: publish.yml on Center-for-Applied-AI/delm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delm-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: delm-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 83.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for delm-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37245213476195d4a4a1b4b2cd5c3b796f22e047a5523211eb858984449bba61
MD5 6575f13534f3873b815d0342cbad6aee
BLAKE2b-256 00e26525459c596f7ace947046cce8ad8b7d500ead54ecf728bb78eebc861b51

See more details on using hashes here.

Provenance

The following attestation bundles were made for delm-1.2.0-py3-none-any.whl:

Publisher: publish.yml on Center-for-Applied-AI/delm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 files

1.1.0

2 files

1.0.3

2 files

1.0.1

2 files

1.0.0

2 files

0.1.4

2 files

0.1.3

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page