Skip to main content

CLI for evaluating large language models with Quotient

Project description

quotientai

PyPI version

Overview

quotientai is an SDK and CLI for logging data to Quotient, and running hallucination and document attribution detections for retrieval and search-augmented AI systems.

Installation

pip install quotientai

Usage

Create an API key on Quotient and set it as an environment variable called QUOTIENT_API_KEY. Then follow the examples below or see our docs for a more comprehensive walkthrough.

Send your first log and detect hallucinations. Run the code below and see your Logs and Detections on your Quotient Dashboard.

from quotientai import QuotientAI

quotient = QuotientAI()
quotient_logger = quotient.logger.init(
    # Required
    app_name="my-app",
    environment="dev",
    # dynamic labels for slicing/dicing analytics e.g. by customer, feature, etc
    tags={"model": "gpt-4o", "feature": "customer-support"},
    hallucination_detection=True,
    hallucination_sample_rate=1.0,
)

log_id = logger.log(
    user_query="How do I cook a goose?",
    model_output="The capital of France is Paris",
    documents=["Here is an excellent goose recipe..."]
)

print(log_id)

You can also use the async client if you need to create logs asynchronously.

from quotientai import AsyncQuotientAI
import asyncio

quotient = AsyncQuotientAI()

quotient_logger = quotient.logger.init(
    # Required
    app_name="my-app",
    environment="dev",
    # dynamic labels for slicing/dicing analytics e.g. by customer, feature, etc
    tags={"model": "gpt-4o", "feature": "customer-support"},
    hallucination_detection=True,
    inconsistency_detection=True,
)


async def main():
    # Mock retrieved documents
    retrieved_documents = [{"page_content": "Sample document"}]

    log_id = await quotient_logger.log(
        user_query="Sample input",
        model_output="Sample output",
        # Page content from Documents from your retriever used to generate the model output
        documents=[doc["page_content"] for doc in retrieved_documents],
        # Message history from your chat history
        message_history=[
            {"role": "system", "content": "You are an expert on geography."},
            {"role": "user", "content": "What is the capital of France?"},
            {"role": "assistant", "content": "The capital of France is Paris"},
        ],
        # Instructions for the model to follow
        instructions=[
            "You are a helpful assistant that answers questions about the world.",
            "Answer the question in a concise manner. If you are not sure, say 'I don't know'.",
        ],
        # Tags can be overridden at log time
        tags={"model": "gpt-4o-mini", "feature": "customer-support"},
    )

    print(log_id)


# Run the async function
asyncio.run(main())

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

quotientai-0.3.2.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

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

quotientai-0.3.2-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file quotientai-0.3.2.tar.gz.

File metadata

  • Download URL: quotientai-0.3.2.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for quotientai-0.3.2.tar.gz
Algorithm Hash digest
SHA256 b91b779d3d166d008c3cf7d702e1f47d30b141c05917cafeac73f612cb8e7757
MD5 7e5bad4aafd5b2f1fbf8d2592f5894f7
BLAKE2b-256 647ddef6c4f71fa2e8e4ee3833af403b3846ba7de703a91fdefe9fe8c08bd4db

See more details on using hashes here.

File details

Details for the file quotientai-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: quotientai-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for quotientai-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9e1b4e57d319ba0a22217f6f19caf784eda085f5f2682829693f83e92d95024b
MD5 ddbd4c48a050841c48800e038d8f6d55
BLAKE2b-256 a7cb6c887a68f4a6eefca3c859facc8976751b53cca595c41a4191dcf366f9a0

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