عن المشروع

LangExtract is a Python library that uses large language models to extract structured information from unstructured text documents according to user-defined instructions. It is designed for materials such as clinical notes or reports, identifying and organizing key details while ensuring extracted data corresponds to the source text. Key capabilities described in the README: - Precise source grounding: every extraction is mapped to its exact character span in the source text, enabling visual highlighting for traceability and verification. Extractions that cannot be located in the source receive char_interval = None and can be filtered out. - Reliable structured outputs: output schema is driven by few-shot examples, with controlled generation supported on models such as Gemini. - Long-document handling: text chunking, parallel processing, and multiple extraction passes aim to improve recall on large documents. - Interactive visualization: generates a self-contained interactive HTML file to review extracted entities in their original context. - Flexible model support: cloud models such as the Google Gemini family, OpenAI models via an optional dependency, and local open-source models through a built-in Ollama interface. A plugin system allows custom model providers to be registered and distributed as separate packages. - Domain adaptability: extraction tasks are defined with a prompt and a few examples, without model fine-tuning. Typical usage involves defining a prompt and example extractions, calling lx.extract with text or document URLs, saving results to JSONL, and generating an HTML visualization. Options include extraction_passes, max_workers, and max_char_buffer for scaling to longer documents, plus Vertex AI and OpenAI batch processing configurations for large workloads. Installation is available from PyPI (pip install langextract), from source with pyproject.toml, or via Docker. Cloud models require an API key, configurable through environment variables, a .env file, direct parameters, or Vertex AI service accounts. The project includes testing and development tooling such as pytest, tox, pylint, and pre-commit hooks.