Skip to main content

A framework that enables efficient extraction of structured data from unstructured text using large language models (LLMs).

Project description

LLM Extractinator logo

LLM Extractinator

Turn unstructured text into Pydantic-validated structured data using local LLMs via Ollama.

Python License Docs Tests PyPI Streamlit

⚠️ Prototype: this project is under active development. Interfaces, task formats, and directory names may change. Always inspect and validate the generated output before using it downstream.

LLM Extractinator lets you turn unstructured text (reports, notes, CSV text columns) into structured, Pydantic-validated data using local LLMs (via Ollama). It comes with:

  • a Studio (Streamlit app) for no-code configuration
  • a CLI (extractinate) for repeatable runs
  • a parser builder (build-parser) to generate Pydantic models
  • task JSON files to describe what to extract and from where

📚 Docs: https://diagnijmegen.github.io/llm_extractinator/


1. Prerequisites

This project expects a local LLM endpoint, currently Ollama.

Install Ollama

Linux:

curl -fsSL https://ollama.com/install.sh | sh

Windows / macOS: download from https://ollama.com/download

Make sure the Ollama service is running before you try to extract.


2. Installation

We recommend using a fresh environment:

conda create -n llm_extractinator python=3.11
conda activate llm_extractinator

Install from PyPI:

pip install llm_extractinator

Or install from source:

git clone https://github.com/DIAGNijmegen/llm_extractinator.git
cd llm_extractinator
pip install -e .

3. Quick start

A. Run with Docker (recommended for GPU systems)

You can run LLM Extractinator entirely via Docker, which includes Python, Ollama, and the Streamlit app in one container.

Make sure Docker is installed.
For GPU acceleration, also install the NVIDIA Container Toolkit.

Create local directories that will be mounted inside the container:

mkdir -p data examples tasks output ollama_models

Windows / PowerShell:

# Remove `--gpus all` if you don't have a GPU
docker run --rm --gpus all `
  -p 127.0.0.1:8501:8501 `
  -p 11434:11434 `
  -v ${PWD}/data:/app/data `
  -v ${PWD}/examples:/app/examples `
  -v ${PWD}/tasks:/app/tasks `
  -v ${PWD}/output:/app/output `
  -v ${PWD}/ollama_models:/root/.ollama `
  lmmasters/llm_extractinator:latest

Linux / macOS:

docker run --rm --gpus all \
  -p 127.0.0.1:8501:8501 \
  -p 11434:11434 \
  -v $(pwd)/data:/app/data \
  -v $(pwd)/examples:/app/examples \
  -v $(pwd)/tasks:/app/tasks \
  -v $(pwd)/output:/app/output \
  -v $(pwd)/ollama_models:/root/.ollama \
  lmmasters/llm_extractinator:latest

Note: The -v ${PWD}/ollama_models:/root/.ollama mount persists Ollama models between container runs, so you don't need to re-pull models each time. You can omit this mount if you don't mind re-downloading models.

This launches the Streamlit Studio on http://127.0.0.1:8501.
To open an interactive shell instead of the app, append shell to the command.

See docs/docker.md for full details.


B. Studio (local install)

Overview of the Studio

Run the interactive UI:

launch-extractinator

This starts the Streamlit-based Studio (usually at http://localhost:8501) where you can:

  • create/select datasets
  • design a parser/output model
  • create task JSON files
  • run tasks and view logs

Anything you configure here can also be run from the CLI.


C. CLI

Run a task by ID:

extractinate --task_id 1 --model_name "phi4"

Common options:

  • --task_dir tasks/ — where your task JSON files live
  • --data_dir data/ — where your CSV/JSON input lives
  • --output_dir output/ — where to write extracted results
  • --run_name my_first_run — for easier tracking

See docs/cli.md for the full reference.


D. Python

You can also call it from Python:

from llm_extractinator import extractinate

extractinate(
    task_id=1,
    model_name="phi4",
    output_dir="output/",
)

4. Tasks

Tasks describe what to extract and from where. By convention they live in tasks/ and are named:

Task001_products.json
Task002_reports.json
...

A minimal task might look like:

{
  "Description": "Extract product data from CSV",
  "Data_Path": "products.csv",
  "Input_Field": "text",
  "Parser_Format": "product_parser.py"
}
  • Data_Path: relative to your data directory
  • Input_Field: column/key that contains the text
  • Parser_Format: Python file in tasks/parsers/ that defines the Pydantic model

You can author these in Studio or by hand.


5. Parser builder

If you don’t want to write Pydantic models by hand:

build-parser

Export the generated model to:

tasks/parsers/<name>.py

Then reference that filename in the task JSON.


6. Documentation

See the docs/ directory (or the published site) for:

  • data preparation
  • parser UI
  • CLI flags and examples
  • Studio walkthrough
  • manual/advanced running

7. Contributing

Pull requests are welcome. Please keep the CLI and the docs in sync (especially task naming and required fields).


8. Citation

If you use this tool, please cite:

https://doi.org/10.1093/jamiaopen/ooaf109

Project details


Download files

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

Source Distribution

llm_extractinator-0.5.13.tar.gz (46.1 kB view details)

Uploaded Source

Built Distribution

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

llm_extractinator-0.5.13-py3-none-any.whl (43.0 kB view details)

Uploaded Python 3

File details

Details for the file llm_extractinator-0.5.13.tar.gz.

File metadata

  • Download URL: llm_extractinator-0.5.13.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for llm_extractinator-0.5.13.tar.gz
Algorithm Hash digest
SHA256 64bebdabfc0b06a1b44b39137e0b5e68563c78166d04f53bd70dd885371e01bc
MD5 c1f6222f67c41dddbe9690efafd5dbe1
BLAKE2b-256 d603c6879f46ed9fea110d460bd69e657d7a3f27502a274764545a21dc42a7f6

See more details on using hashes here.

File details

Details for the file llm_extractinator-0.5.13-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_extractinator-0.5.13-py3-none-any.whl
Algorithm Hash digest
SHA256 b2616c49eb9e56c46f1c8d2f87b3c581109ce5b60881dde28dbd96ba7533467b
MD5 5adb9545edafc66dac2069adbe7a8068
BLAKE2b-256 fb346b6b58719df3d3a9f5a76977ade418cda0e1c7e429827f778ec021afb867

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page