LangExtract

Active
GitHub Python Apache-2.0

Description

A Python library by Google for extracting structured information from unstructured text using LLMs with precise source grounding and interactive visualization, designed for data annotation and knowledge extraction workflows.

Key Features

  • Precise source grounding — Every extraction maps to exact source text location with visual highlighting for traceability and verification
  • Controlled structured outputs — Few-shot example enforced output schema, leveraging Gemini controlled generation for robust results
  • Long document optimization — Text chunking, parallel processing, and multi-pass strategy to overcome needle-in-a-haystack challenges
  • Interactive visualization — Self-contained HTML file for browsing thousands of extracted entities in their original context
  • Flexible model support — Google Gemini cloud models and Ollama local models with custom model provider support
  • Any-domain adaptability — Define extraction tasks for any domain with just a few examples, no model fine-tuning required

Use Cases

💡 Clinical document extraction — Extract medications, dosages, diagnoses and patient info from medical records and clinical notes
💡 Academic literature structuring — Extract characters, emotions, relationships from full papers for literary analysis and knowledge graph construction
💡 Automated report parsing — Auto-parse radiology reports and other professional reports to extract key findings and conclusions
💡 Data annotation & knowledge extraction — High-quality annotations for training datasets supporting NER, relation extraction, and NLP tasks
💡 Document understanding pipeline — Front-end processing module for RAG systems, extracting structured metadata from unstructured documents

Strengths & Limitations

Strengths

  • Actively maintained, recent updates
  • High community interest (38.5k stars)
  • Permissive open-source license (Apache-2.0)
  • Responsive to issues, low backlog

Quick Start

```python
import langextract as lx

result = lx.extract(
    text_or_documents="Lady Juliet gazed longingly at the stars, her heart aching for Romeo",
    prompt_description="Extract characters, emotions, and relationships in order of appearance.",
    examples=[lx.data.ExampleData(
        text="ROMEO. But soft! What light through yonder window breaks?",
        extractions=[lx.data.Extraction(
            extraction_class="character",
            extraction_text="ROMEO",
            attributes={"emotional_state": "wonder"}
        )]
    )],
    model_id="gemini-3.5-flash",
)
lx.io.save_annotated_documents([result], output_name="results.jsonl")
```

Related Projects

Docstrange

1.5k · Python
Stale B

Extract and convert data from any document (PDFs, images, Word, PPT, URLs) into multiple formats including Markdown, JSON, and CSV.

pythonragtools +2
  • · Multi-format conversion — transforms PDF, DOCX, PPTX, XLSX, images, and URLs into Markdown, JSON, CSV, and HTML
  • · 7B parameter model — upgraded core model for significantly higher accuracy and deeper document understanding
  • · Advanced OCR pipeline — extracts text from scanned documents, phone photos, and receipts with high accuracy

Jupyter AI

4.4k · Python
Active A

An open-source JupyterLab extension that connects AI agents to computational notebooks, enabling code generation, error explanation, and document Q&A.

pythonagenttools +2
  • · Native chat UI for collaborating with frontier AI agents — Claude, Codex, Gemini, Copilot, and more via ACP
  • · Built-in Jupyter MCP server enabling agents to read/write files and run terminal commands
  • · Permission system with approval gates before file writes or command execution

WrenAI

17.5k · Python
Active A

Open-source text-to-SQL and text-to-chart GenBI agent with a semantic layer. Ask your database questions in natural language and get accurate SQL, charts, and BI insights. Supports 12+ data sources and any LLM.

llmtypescriptagent +2
  • · Open context layer providing business semantics, examples, and governance for AI agents
  • · Agent-driven design with CLI-embedded workflow guides loaded on demand
  • · Modeling Definition Language (MDL) for models, relationships, cubes, metrics, and RLAC/CLAC