Skip to main content

A library for benchmarking document QA systems

Project description

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.

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

docqa_bench-0.1.13.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

docqa_bench-0.1.13-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file docqa_bench-0.1.13.tar.gz.

File metadata

  • Download URL: docqa_bench-0.1.13.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.0 CPython/3.10.14 Linux/6.5.0-1023-azure

File hashes

Hashes for docqa_bench-0.1.13.tar.gz
Algorithm Hash digest
SHA256 7635e30c26f61df3d4c40bd5449f9308f2c220dfeef672e3148b8af33c706158
MD5 9cdff50ab2ab13987b462165519664c8
BLAKE2b-256 6b4909d1b394ddcef8ca9ba64eacff96aaeb9ab1716c4f189744203f0c03782f

See more details on using hashes here.

File details

Details for the file docqa_bench-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: docqa_bench-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.0 CPython/3.10.14 Linux/6.5.0-1023-azure

File hashes

Hashes for docqa_bench-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 4ca611694550ca254f2d7510f655b66b9ec9804ac5c10f7c1c10988401d8b843
MD5 c5f85ec783889ed0b83ef92d30d826be
BLAKE2b-256 dea0e792ced53bd130db343e7debe752e7161660b4978d935cd88d6b5862ca23

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