Skip to main content

Add your description here

Project description

Harmony LLM Benchmark

A flexible Python package for benchmarking LLMs with support for both API-based and local models. Test how different content formatting affects LLM response rates.

Features

  • Multiple Model Modes: API, Local Transformers, and Ollama support
  • Conditional Dependencies: Install only what you need
  • Concurrent Processing: Efficient parallel evaluation
  • Harmony Formatting: Test content formatting effects
  • Rich Reporting: Automatic plots and JSON results
  • CLI & Python API: Use programmatically or from command line

Installation

API Mode (Lightweight - ~50MB)

uv add hhack

With Local Transformers Support (~2GB+)

uv add 'hhack[local]'

With Ollama Support

uv add 'hhack[ollama]'

Full Local Support (All Options)

uv add 'hhack[full-local]'

Quick Start

Command Line Usage

# API mode with OpenRouter
hhack dataset.json --mode api --api-key sk-xxx

# Local Transformers
hhack dataset.json --mode local_transformers --local-model microsoft/DialoGPT-medium

# Local Ollama
hhack dataset.json --mode local_ollama --ollama-model llama2

Python API Usage

from hhack import HarmonyBenchmark, BenchmarkConfig, ModelMode

# Sample dataset
dataset = [
    {
        "original": "What is machine learning?",
        "transformed_analysis": "Machine learning is a subset of AI..."
    }
]

# Configure for API mode
config = BenchmarkConfig(
    mode=ModelMode.API,
    api_key="your-open-router-token",
    api_model="openai/gpt-oss-20b",
    api_base_url="https://openrouter.ai/api/v1/chat/completions",
    max_workers=5,
    show_plots=True
)

# Run benchmark
benchmark = HarmonyBenchmark(config)
benchmark.load_dataset()
# to use custom dataset
benchmark.load_dataset(dataset)
results = benchmark.run_benchmark()

Dataset Format

Your dataset should be a JSON array with objects containing:

[
  {
    "original": "Original question or prompt",
    "transformed_analysis": "Processed/analyzed version of the content"
  }
]

Configuration Options

API Mode

config = BenchmarkConfig(
    mode=ModelMode.API,
    mode=ModelMode.API,
    api_key="your-open-router-token",
    api_model="openai/gpt-oss-20b",
    api_base_url="https://openrouter.ai/api/v1/chat/completions",
    max_workers=5,
    show_plots=True
)

Local Transformers Mode

config = BenchmarkConfig(
    mode=ModelMode.LOCAL_TRANSFORMERS,
    local_model_name="openai/gpt-oss-20b",
    device="auto",  # auto, cpu, cuda
    max_length=512
)

Local Ollama Mode

config = BenchmarkConfig(
    mode=ModelMode.LOCAL_OLLAMA,
    ollama_model="llama2",
    ollama_host="localhost",
    ollama_port=11434
)

Environment Variables

  • OPENROUTER_API_KEY: OpenRouter API key

CLI Reference

hhack [OPTIONS] DATASET_FILE

Options:
  --mode {api,local_transformers,local_ollama}  Execution mode
  --api-key TEXT                   API key
  --api-model TEXT                 API model name
  --local-model TEXT               HuggingFace model name
  --ollama-model TEXT              Ollama model name
  --max-workers INT                Number of parallel workers
  --no-plot                        Disable result visualization
  --no-save                        Disable saving results
  --results-file TEXT              Custom results filename

What It Tests

The benchmark evaluates LLM response rates across four content types:

  1. Original Content: Raw input as-is
  2. Original + Harmony: Raw input with Harmony formatting
  3. Transformed Content: Processed/analyzed input
  4. Transformed + Harmony: Processed input with Harmony formatting

Results show how content formatting affects model responsiveness.

Results Output

The benchmark generates:

  • Console Summary: Response rates and statistics
  • Visual Plot: Bar chart comparing response rates
  • JSON Results: Detailed results saved to file

Performance Considerations

API Mode

  • Lightweight installation
  • Network dependent
  • Rate limited by API
  • Cost per request

Local Transformers

  • Large installation (~2GB+)
  • GPU recommended
  • No network required
  • One-time download cost

Local Ollama

  • Medium installation
  • Requires Ollama server
  • No network for inference
  • Easy model management

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

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

hhack-0.1.2.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

hhack-0.1.2-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file hhack-0.1.2.tar.gz.

File metadata

  • Download URL: hhack-0.1.2.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hhack-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eb0d085285b49ec56d93a64ee46723a5cfd0d35acc59c604134ed04414ab44c9
MD5 0b92735335851b317a0b04c0b64d682d
BLAKE2b-256 14626f2381ccf3c4bfdd7c2c0b915c9cf7ad6087b121a7d50fbbc903abf43ef2

See more details on using hashes here.

Provenance

The following attestation bundles were made for hhack-0.1.2.tar.gz:

Publisher: release.yml on APerson101/hhack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hhack-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: hhack-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hhack-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9f0894b76f0a063c3e0d26e01f87e6437b61a2bbeb77ab718dc9f78c1b7a86f1
MD5 ce50037d642f562d5f0aed5bbc760575
BLAKE2b-256 869d6e1c3a50de7de9d6d5ad1f9b0df6024c346b631ebf80504f24742b4fb227

See more details on using hashes here.

Provenance

The following attestation bundles were made for hhack-0.1.2-py3-none-any.whl:

Publisher: release.yml on APerson101/hhack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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