Skip to main content

Solar-as-Judge

Solar-as-Judge Demo

Solar-as-Judge is a powerful Python package for evaluating and comparing AI-generated responses. It leverages the Upstage API to provide accurate and consistent judgments on the quality of AI outputs.

Features

  • Evaluate individual AI responses on a scale of 1-5
  • Compare two AI responses and determine a winner
  • Utilize ground truth for more accurate evaluations
  • Ensure consistency through multiple trials

Installation

pip install solar-as-judge

Quick Start

Single Answer Scoring

import solar_as_judge as saj

prompt = "Please extract one keyword from this text: I love you so much"
ground_truth = "love"
answer = "love"

score = saj.get_judge_score(prompt, answer, ground_truth)
print(f"Score: {score}")

A/B Testing

import solar_as_judge as saj

prompt = "Please extract one keyword from this text: I love you so much"
ground_truth = "love"

A_answer = "love"
B_answer = "so much"

a_score, b_score = saj.judge(prompt, A_answer, B_answer, ground_truth)
print(f"Scores: A={a_score}, B={b_score}")

API Reference

saj.get_judge_score(prompt, answer, ground_truth_answer, judge_llm=None, trials=3)

Evaluates a single AI response.

  • Returns: Integer score (1-5)

saj.judge(prompt, A_answer, B_answer, ground_truth=None, judge_llm=None, trials=7)

Evaluates and compares two AI responses.

  • Returns: Tuple of scores (A_score, B_score)

saj.get_winner(prompt, A_answer, B_answer, ground_truth_answer, judge_llm=None, trials=3)

Determines the winner between two AI responses.

  • Returns: String ("A" or "B")

Configuration

Set the UPSTAGE_API_KEY environment variable with your key from the Upstage console.

Examples

Check out the test.py file in the repository for more usage examples and test cases.

Contributing

We welcome contributions! Please see our Contributing Guidelines for more details.

License

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

Support

For issues, feature requests, or questions, please open an issue on our GitHub repository.

Metadata

Release files for solar-as-judge 0.3.0

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

Source distribution (sdist)

Source distribution for solar-as-judge 0.3.0
File Size Uploaded
solar_as_judge-0.3.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for solar-as-judge 0.3.0
File Interpreter ABI Platform
solar_as_judge-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / solar_as_judge-0.3.0.tar.gz

Download URL solar_as_judge-0.3.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
10c1d7e207efbd2d0e541884d8a02199bc98f022976dba63defc9b4f31c89406
BLAKE2b-256 checksum
How to use checksums
f88c480f07facb29c8f1b2279477c8c7fdf8bc8dcecf1af4d91715421c0223a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.6

Release files / solar_as_judge-0.3.0-py3-none-any.whl

Download URL solar_as_judge-0.3.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34715573b92f2fefea5abab6f3415a8114073c2af347146ce4a9911310c7f2c7
BLAKE2b-256 checksum
How to use checksums
9ab6f0085d5b157d18c5bd6ba147a92eef1472c52b73cbb05867d41ed8d67723
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1

1 release file

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