Skip to main content

Lightweight verbatim span extraction -- the RAG-agnostic core of verbatim-rag

Project description

verbatim-core

Lightweight verbatim span extraction -- the RAG-agnostic core of verbatim-rag.

Extract exact, verbatim text spans from documents that answer a question. No vector databases, no embeddings, no heavy ML dependencies -- just openai and pydantic.

Installation

pip install verbatim-core

Quick Start

from verbatim_core import VerbatimTransform

vt = VerbatimTransform()
response = vt.transform(
    question="What is the main finding?",
    context=[
        {"content": "The study found that X leads to Y.", "title": "Paper A"},
        {"content": "Results show Z is statistically significant.", "title": "Paper B"},
    ],
)

print(response.answer)

# Access individual highlights and citations
for doc in response.documents:
    for highlight in doc.highlights:
        print(f"  [{highlight.start}:{highlight.end}] {highlight.text}")

What This Package Includes

  • VerbatimTransform -- question + context -> cited, grounded answer
  • LLMSpanExtractor -- extract verbatim spans using an LLM
  • LLMClient -- unified OpenAI API wrapper (sync + async)
  • TemplateManager -- response formatting with multiple template strategies
  • @verbatim_enhance -- decorator to enhance existing RAG functions
  • CLI (verbatim-enhance) -- batch processing from the command line

Model-Based Extraction

For ModernBERT or Zilliz semantic highlight extractors (adds torch, transformers):

pip install verbatim-core[model]

Environment

export OPENAI_API_KEY=your_api_key_here

Full RAG System

For the complete RAG pipeline with vector indexing, embeddings, and document processing, install the full package:

pip install verbatim-rag

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

verbatim_core-0.2.1.tar.gz (44.0 kB view details)

Uploaded Source

Built Distribution

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

verbatim_core-0.2.1-py3-none-any.whl (58.6 kB view details)

Uploaded Python 3

File details

Details for the file verbatim_core-0.2.1.tar.gz.

File metadata

  • Download URL: verbatim_core-0.2.1.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for verbatim_core-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5a87c2c6cb179cae297419ba1cee2af9bea7b3c71aa5dd05e4b212d98c5ca021
MD5 43ac2d75f7ed10eed14778d40d188e85
BLAKE2b-256 2f3ac041bc144374c03aabd1c98e61727e1816236431f1501e42382d77c1521c

See more details on using hashes here.

File details

Details for the file verbatim_core-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: verbatim_core-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 58.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for verbatim_core-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d647de328b4d8cafa3a05f8e5e0eb29b3966b99ce6c940f7ddc4e06b3243abb8
MD5 ef63d9e6b745c19022655552e66ef2a2
BLAKE2b-256 6849edf2a8661e9043d45386dc8bda630bbb0212c6eb4318044e6f75819cbd32

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