Skip to main content

example workflow

DocQA-Bench

DocQA-Bench is a library for benchmarking document question-answering systems. It provides a flexible framework for evaluating various components of a QA pipeline, including document chunking, embedding generation, vector storage, question generation, and answer generation.

Features

  • Modular design allowing easy swapping of components
  • Support for custom document preprocessing
  • Integration with OpenAI's GPT models for question and answer generation
  • Customizable chunking strategies
  • Vector store integration for efficient similarity search
  • F1 score evaluation for answer quality
  • Asynchronous processing for improved performance

Installation

You can install DocQA-Bench using pip:

pip install docqa-bench

Quick Start

Check out the example.py file in the root directory for a demonstration of how to use docqa_bench. This example shows how to:

Set up the necessary components Create a benchmark Run the benchmark on preprocessed content Handle and display the results

To run the example: python example.py

Usage

Here's a basic example of how to use DocQA-Bench:

import asyncio
from docqa_bench import (
    Benchmark, PreprocessedDocument, SimpleChunker, OpenAIEmbedder,
    ChromaStore, OpenAIQuestionGenerator, OpenAIAnswerGenerator, F1Evaluator
)

async def run_benchmark(content: str):
    document = PreprocessedDocument(content)
    chunker = SimpleChunker(chunk_size=1000, chunk_overlap=200)
    embedder = OpenAIEmbedder("text-embedding-ada-002")
    vector_store = ChromaStore("benchmark_collection")
    question_generator = OpenAIQuestionGenerator("gpt-4o-mini")
    answer_generator = OpenAIAnswerGenerator("gpt-4o-mini")
    evaluator = F1Evaluator()

    benchmark = Benchmark(
        document, chunker, embedder, vector_store,
        question_generator, answer_generator, evaluator
    )
    
    results = await benchmark.run()
    print(results)

asyncio.run(run_benchmark("Your document content here"))

Components

DocQA-Bench consists of several modular components:

  • Document: Represents the input document. Use PreprocessedDocument for already processed text.
  • Chunker: Splits the document into manageable pieces. SimpleChunker is provided out of the box.
  • Embedder: Generates vector representations of text. OpenAIEmbedder uses OpenAI's embedding model.
  • VectorStore: Stores and retrieves vector representations. ChromaStore is provided as a default implementation.
  • QuestionGenerator: Generates questions based on the document content. OpenAIQuestionGenerator uses OpenAI's GPT model.
  • AnswerGenerator: Generates answers to questions. OpenAIAnswerGenerator uses OpenAI's GPT model.
  • Evaluator: Evaluates the quality of generated answers. F1Evaluator is provided as a default implementation.

Customization

You can create custom implementations of any component by subclassing the respective base classes in the docqa_bench.core module.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Support

If you encounter any problems or have any questions, please open an issue on the GitHub repository.

Metadata

Release files for docqa-bench 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for docqa-bench 0.1.13
File Size Uploaded Provenance
docqa_bench-0.1.13.tar.gz 8.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for docqa-bench 0.1.13
File Interpreter ABI Platform
docqa_bench-0.1.13-py3-none-any.whl Python 3 none any Details

Total release size: 21.0 kB

Release files / docqa_bench-0.1.13.tar.gz

Download URL docqa_bench-0.1.13.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7635e30c26f61df3d4c40bd5449f9308f2c220dfeef672e3148b8af33c706158
BLAKE2b-256 checksum
How to use checksums
6b4909d1b394ddcef8ca9ba64eacff96aaeb9ab1716c4f189744203f0c03782f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.0 CPython/3.10.14 Linux/6.5.0-1023-azure

Release files / docqa_bench-0.1.13-py3-none-any.whl

Download URL docqa_bench-0.1.13-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ca611694550ca254f2d7510f655b66b9ec9804ac5c10f7c1c10988401d8b843
BLAKE2b-256 checksum
How to use checksums
dea0e792ced53bd130db343e7debe752e7161660b4978d935cd88d6b5862ca23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.0 CPython/3.10.14 Linux/6.5.0-1023-azure

Security for docqa-bench 0.1.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page