Skip to main content

A framework to analyse the consistency of repeated requests to an LLM or LLM based Agent

Project description

Setup Poetry, check formatting and style, and run the tests

LLM Response Analysis Framework

Welcome to a LLM Response Analysis Framework! This tool is designed to dive deep into the heart of Language Models (LLMs) and their intriguing responses. Designed for researchers, developers, and LLM enthusiasts, the framework offers a way to examine the consistency of Large Language Models and Agents build on them.

Features | Screenshots | Getting Started | Development

Features

  • Dynamic LLM Integration Seamlessly connect with various LLM providers and models to fetch responses using a flexible architecture.

  • LangChain Structured Output Chain Analysis Seamlessly connect with a LangChain Structured Output and check for the consistency of responses. See this documentation for further information.

  • Semantic Similarity Calculation Understand the nuanced differences between responses by calculating their semantic distances.

  • Diverse Response Analysis Group, count, and analyze responses to highlight both their uniqueness and redundancy.

  • Rich Presentation Utilize beautiful tables and text differences to present analysis results in an understandable and visually appealing manner.

Screenshots

Below are some screenshots showcasing the framework in action:

GPT-3.5 Example

GPT-3.5 Analysis

GPT-4 Example

GPT-4 Analysis

LangChain Structure Output example (using gpt-4o)

LangChain Structure Output example

These visuals provide a glimpse into how the framework processes and presents data from different LLM versions, highlighting the flexibility and depth of analysis possible with this tool.

Getting Started

Prerequisites

  • Ensure you have Python 3.10 or higher installed on your system.

Installation

Option 1. pipx is recommended

Use pipx for det rather than install it on the base python. pipx is awesome for installing and running Python applications in isolated environments.

Get pipx here: https://pipx.pypa.io/stable/

Install det using pipx:

pipx install det

Option 2. If you live danagerously, chaos is your middle name, or you don't want to use pipx

I understand that this approach heavily depends on the state of my system, it may not work and may result in pythonic module hell induced headaches .

Are you sure you want to do this?

I really know what I'm doing or plan on throwing away my computer

OK, no more checking - fill your boots.

Install det using pip:

pip install det

Configuration

Before using det, configure your LLM and embeddings provider API keys

export OPENAI_API_KEY=sk-makeSureThisIsaRealKey

Basic Usage

To get a list of all the arguments and their descriptions, use:

det --help

a basic analysis of OpenAI's gpt-4o-mini model

det check-responses \
  --iterations 2 \
  --llm-provider OpenAI \
  --llm-model gpt-4o-mini \
  --embeddings-provider OpenAI \
  --embeddings-model text-embedding-ada-002

LangChain Structured Output Chains

a LangChain Structured Output example

note, this requires the prompt details /resources/prompt.json and a pydantic output class /resources/risk_definition.py

det check-chain \
  --iterations 20 \
  --embeddings-provider OpenAI \
  --embeddings-model text-embedding-ada-002 \
  --prompt-config ./resources/prompts.json \
  --prompt-group RiskDefinition \
  --input-variables-str "risk_statement=There is a risk that failure to enforce multi-factor authentication can cause unauthorized access to user accounts to occur, leading to account takeover that could lead to financial fraud and identity theft issues for customers."

Development

Prerequisites

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/thompsonson/det.git
    cd det
    
  2. Set up the Poetry environment:

    poetry install
    
  3. Activate the Poetry shell:

    poetry shell
    

You're now ready to start development on the det project!

Documentation

The documentation is in the module headings. I'll probably move it out at some point but that's good for now :)

Support and Contribution

For support, please open an issue on the GitHub repository. Contributions are welcome.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

det-0.4.2.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

det-0.4.2-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file det-0.4.2.tar.gz.

File metadata

  • Download URL: det-0.4.2.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/6.8.0-1014-azure

File hashes

Hashes for det-0.4.2.tar.gz
Algorithm Hash digest
SHA256 cb79db28094898c9dedb6d031b382a60b3327765f64a128786625af977106433
MD5 f1ecdc23fbd3fa47937c953a33dd3d1f
BLAKE2b-256 d3357125e7e12de422d3ec09fcddbfb011ffedc11d63571965bec5b9517f4c66

See more details on using hashes here.

File details

Details for the file det-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: det-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/6.8.0-1014-azure

File hashes

Hashes for det-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a35adaa20cb1a1ea6ac6c3a7f7afa066ee9c4bbe9c22f15c1c963ba074ea9fce
MD5 1f3a1bfbb4e4f013d677743cc0352317
BLAKE2b-256 f19eacf28952393a24ed1bfa0d36669fb44bd20d7c0a01d234955a0e5ba6759d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page