google/langextract
A Python library for extracting structured information from unstructured text using LLMs with precise source grounding and interactive visualization.
What it solves
LangExtract は、非構造化テキストドキュメントから構造化情報を抽出するための Python ライブラリです。臨床ノートやレポートのような雑多で自由形式のテキストを整理されたデータに変換し、抽出された情報がすべて元テキストに根拠付けされていることを保証し、容易に検証できるようにします。
How it works
このライブラリは Large Language Models(LLM)と few‑shot プロンプト戦略を利用します。ユーザーはプロンプトと、テキストを構造化エンティティにマッピングする高品質な例を数件提示することで抽出タスクを定義します。長文書に対応するため、テキストのチャンク化、並列処理、複数回の抽出パスを組み合わせてリコール率を向上させます。
Who it’s for
モデルのファインチューニングなしで非構造化テキストを構造化データセットに変換したい開発者や研究者向けです。医療レポートや文学分析など、領域特化型ドキュメントでトレーサビリティと精度が求められるケースに特に有用です。
Highlights
- Precise Source Grounding: Maps extractions to exact character intervals in the source text for visual traceability.
- Reliable Structured Outputs: Uses controlled generation (in supported models) and few-shot examples to enforce consistent schemas.
- Long Document Optimization: Uses parallel processing and multiple passes to overcome the "needle-in-a-haystack" problem.
- Interactive Visualization: Generates self-contained HTML files to visualize extracted entities within their original context.
- Flexible LLM Support: Compatible with cloud models (Gemini, OpenAI) and local models via Ollama.
- Extensible Provider System: Allows users to add custom LLM providers via a plugin system.