openjury 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openjury-0.1.0/.gitignore +15 -0
- openjury-0.1.0/LICENSE +194 -0
- openjury-0.1.0/PKG-INFO +175 -0
- openjury-0.1.0/README.md +144 -0
- openjury-0.1.0/pyproject.toml +85 -0
- openjury-0.1.0/src/openjury/__init__.py +35 -0
- openjury-0.1.0/src/openjury/config.py +201 -0
- openjury-0.1.0/src/openjury/env.py +37 -0
- openjury-0.1.0/src/openjury/juror.py +198 -0
- openjury-0.1.0/src/openjury/jury_engine.py +220 -0
- openjury-0.1.0/src/openjury/logger.py +15 -0
- openjury-0.1.0/src/openjury/output_format.py +271 -0
- openjury-0.1.0/src/openjury/prompt_templates.py +94 -0
- openjury-0.1.0/src/openjury/voting.py +236 -0
- openjury-0.1.0/tests/__init__.py +1 -0
- openjury-0.1.0/tests/conftest.py +132 -0
- openjury-0.1.0/tests/test_custom_voting.py +175 -0
- openjury-0.1.0/tests/test_error_handling.py +50 -0
- openjury-0.1.0/tests/test_juror.py +138 -0
- openjury-0.1.0/tests/test_jury_engine.py +122 -0
- openjury-0.1.0/tests/test_models.py +61 -0
- openjury-0.1.0/tests/test_verdict.py +67 -0
- openjury-0.1.0/tests/test_voting.py +182 -0
openjury-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner.
|
|
54
|
+
|
|
55
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
56
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
57
|
+
subsequently incorporated within the Work.
|
|
58
|
+
|
|
59
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
60
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
61
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
62
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
63
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
64
|
+
Work and such Derivative Works in Source or Object form.
|
|
65
|
+
|
|
66
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
(except as stated in this section) patent license to make, have made,
|
|
70
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
71
|
+
where such license applies only to those patent claims licensable
|
|
72
|
+
by such Contributor that are necessarily infringed by their
|
|
73
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
74
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
75
|
+
institute patent litigation against any entity (including a
|
|
76
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
77
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
78
|
+
or contributory patent infringement, then any patent licenses
|
|
79
|
+
granted to You under this License for that Work shall terminate
|
|
80
|
+
as of the date such litigation is filed.
|
|
81
|
+
|
|
82
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
83
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
84
|
+
modifications, and in Source or Object form, provided that You
|
|
85
|
+
meet the following conditions:
|
|
86
|
+
|
|
87
|
+
(a) You must give any other recipients of the Work or
|
|
88
|
+
Derivative Works a copy of this License; and
|
|
89
|
+
|
|
90
|
+
(b) You must cause any modified files to carry prominent notices
|
|
91
|
+
stating that You changed the files; and
|
|
92
|
+
|
|
93
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
94
|
+
that You distribute, all copyright, patent, trademark, and
|
|
95
|
+
attribution notices from the Source form of the Work,
|
|
96
|
+
excluding those notices that do not pertain to any part of
|
|
97
|
+
the Derivative Works; and
|
|
98
|
+
|
|
99
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
100
|
+
distribution, then any Derivative Works that You distribute must
|
|
101
|
+
include a readable copy of the attribution notices contained
|
|
102
|
+
within such NOTICE file, excluding those notices that do not
|
|
103
|
+
pertain to any part of the Derivative Works, in at least one
|
|
104
|
+
of the following places: within a NOTICE text file distributed
|
|
105
|
+
as part of the Derivative Works; within the Source form or
|
|
106
|
+
documentation, if provided along with the Derivative Works; or,
|
|
107
|
+
within a display generated by the Derivative Works, if and
|
|
108
|
+
wherever such third-party notices normally appear. The contents
|
|
109
|
+
of the NOTICE file are for informational purposes only and
|
|
110
|
+
do not modify the License. You may add Your own attribution
|
|
111
|
+
notices within Derivative Works that You distribute, alongside
|
|
112
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
113
|
+
that such additional attribution notices cannot be construed
|
|
114
|
+
as modifying the License.
|
|
115
|
+
|
|
116
|
+
You may add Your own copyright statement to Your modifications and
|
|
117
|
+
may provide additional or different license terms and conditions
|
|
118
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
119
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
120
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
121
|
+
the conditions stated in this License.
|
|
122
|
+
|
|
123
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
124
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
125
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
126
|
+
this License, without any additional terms or conditions.
|
|
127
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
128
|
+
the terms of any separate license agreement you may have executed
|
|
129
|
+
with Licensor regarding such Contributions.
|
|
130
|
+
|
|
131
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
132
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
133
|
+
except as required for describing the origin of the Work and
|
|
134
|
+
reproducing the content of the NOTICE file.
|
|
135
|
+
|
|
136
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
137
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
138
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
139
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
140
|
+
implied, including, without limitation, any warranties or conditions
|
|
141
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
142
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
143
|
+
appropriateness of using or redistributing the Work and assume any
|
|
144
|
+
risks associated with Your exercise of permissions under this License.
|
|
145
|
+
|
|
146
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
147
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
148
|
+
unless required by applicable law (such as deliberate and grossly
|
|
149
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
150
|
+
liable to You for damages, including any direct, indirect, special,
|
|
151
|
+
incidental, or consequential damages of any character arising as a
|
|
152
|
+
result of this License or out of the use or inability to use the
|
|
153
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
154
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
155
|
+
other commercial damages or losses), even if such Contributor
|
|
156
|
+
has been advised of the possibility of such damages.
|
|
157
|
+
|
|
158
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
159
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
160
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
161
|
+
or other liability obligations and/or rights consistent with this
|
|
162
|
+
License. However, in accepting such obligations, You may act only
|
|
163
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
164
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
165
|
+
defend, and hold each Contributor harmless for any liability
|
|
166
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
167
|
+
of your accepting any such warranty or additional liability.
|
|
168
|
+
|
|
169
|
+
END OF TERMS AND CONDITIONS
|
|
170
|
+
|
|
171
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
172
|
+
|
|
173
|
+
To apply the Apache License to your work, attach the following
|
|
174
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
175
|
+
replaced with your own identifying information. (Don't include
|
|
176
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
177
|
+
comment syntax for the file format. We also recommend that a
|
|
178
|
+
file or class name and description of purpose be included on the
|
|
179
|
+
same "printed page" as the license notice for easier identification
|
|
180
|
+
within third-party archives.
|
|
181
|
+
|
|
182
|
+
Copyright [2025] [robiscoding]
|
|
183
|
+
|
|
184
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
185
|
+
you may not use this file except in compliance with the License.
|
|
186
|
+
You may obtain a copy of the License at
|
|
187
|
+
|
|
188
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
189
|
+
|
|
190
|
+
Unless required by applicable law or agreed to in writing, software
|
|
191
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
192
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
193
|
+
See the License for the specific language governing permissions and
|
|
194
|
+
limitations under the License.
|
openjury-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openjury
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for evaluating multiple model outputs using configurable LLM-based jurors
|
|
5
|
+
Project-URL: Homepage, https://github.com/robiscoding/openjury
|
|
6
|
+
Project-URL: Repository, https://github.com/robiscoding/openjury
|
|
7
|
+
Project-URL: Issues, https://github.com/robiscoding/openjury/issues
|
|
8
|
+
Author-email: robiscoding <robiscodingg@gmail.com>
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,evaluation,langchain,llm,llm-as-a-judge,machine-learning,model-comparison,model-consensus,openai
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Requires-Dist: langchain-openai>=0.1.0
|
|
20
|
+
Requires-Dist: langchain>=0.1.0
|
|
21
|
+
Requires-Dist: openai>=1.0.0
|
|
22
|
+
Requires-Dist: pydantic>=2.0.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: isort>=5.12.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: twine>=4.0.0; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# OpenJury 🏛️
|
|
33
|
+
|
|
34
|
+
**A Python SDK for evaluating and comparing multiple model outputs using configurable LLM-based jurors.**
|
|
35
|
+
|
|
36
|
+
[](https://www.python.org/downloads/)
|
|
37
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Overview
|
|
42
|
+
|
|
43
|
+
**OpenJury** is a post-inference ensemble framework that evaluates and compares multiple model outputs using configurable LLM-based jurors. It enables structured model assessment, ranking, and A/B testing directly into your Python apps, research workflows, or ML platforms.
|
|
44
|
+
|
|
45
|
+
At its core, OpenJury is a decision-level, LLM-driven evaluation system that aggregates juror scores using flexibile voting strategies (e.g. weighted, ranked, consensus, etc.). This makes it a powerful and extensible solution for nuanced, after-inference comparison of generated outputs across models, prompts, versions, or datasets.
|
|
46
|
+
|
|
47
|
+
### Why use an LLM Jury?
|
|
48
|
+
|
|
49
|
+
AI models can generate fluent, convincing outputs, but fluency != correctness. Whether you're building a customer service agent, a code review assist, or a content generator, you need to know which response is best, correct, or how models compare with quality and consistency. Human evaluation doesn't scale, which is why LLM-based jurors are widely used.
|
|
50
|
+
|
|
51
|
+
But relying on a single LLM (like GPT-4o) to evaluate model outputs, although common, is expensive and can introduce [intra-model bias](https://arxiv.org/abs/2404.13076). Research by Cohere [shows](https://arxiv.org/abs/2404.18796) that using a panel of smaller, diverse models not only cuts cost but also leads to more reliable and less biased evaluations.
|
|
52
|
+
|
|
53
|
+
OpenJury puts this into practice: instead of a single judge, it uses multiple jurors to score and explain outputs. The result? Better evlautions and lower costs, all configurable with a declarative interface.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Key Features
|
|
59
|
+
|
|
60
|
+
- **Python SDK:** Simple integration, flexible configuration
|
|
61
|
+
- **Multi-Criteria Evaluation:** Define custom criteria with weights and scoring
|
|
62
|
+
- **Advanced Voting Methods:** Majority, average, weighted, ranked, consensus, or your own
|
|
63
|
+
- **Parallel Processing:** Evaluate at scale, concurrently
|
|
64
|
+
- **Rich Output:** Scores, explanations, voting breakdowns, and confidence metrics
|
|
65
|
+
- **Extensible:** Plug in your own jurors, voting logic, and evaluation strategies
|
|
66
|
+
- **Dev Experience:** One-command setup, Makefile workflow, and modern code quality tools
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
**Requirements:** Python 3.11 or newer
|
|
73
|
+
|
|
74
|
+
### Recommended (PyPI)
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install openjury
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### From Source (for development/contribution)
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/robiscoding/openjury.git
|
|
84
|
+
cd openjury
|
|
85
|
+
pip install -e .
|
|
86
|
+
uv pip install -e ".[dev]" # (optional) dev dependencies
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Quick Start
|
|
90
|
+
|
|
91
|
+
### Set Environment Variables
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
export OPENROUTER_API_KEY="your-api-key"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
or if you're using OpenAI:
|
|
98
|
+
```bash
|
|
99
|
+
export LLM_PROVIDER="openai"
|
|
100
|
+
export OPENAI_API_KEY="your-api-key"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Basic Usage
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from openjury import OpenJury, JuryConfig
|
|
107
|
+
|
|
108
|
+
config = JuryConfig.from_json_file("jury_config.json")
|
|
109
|
+
jury = OpenJury(config)
|
|
110
|
+
verdict = jury.evaluate(
|
|
111
|
+
prompt="Write a Python function to reverse a string",
|
|
112
|
+
responses=[
|
|
113
|
+
"def reverse(s): return s[::-1]",
|
|
114
|
+
"def reverse(s): return ''.join(reversed(s))"
|
|
115
|
+
]
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
print(f"Winner: {verdict.final_verdict.winner}")
|
|
119
|
+
print(f"Confidence: {verdict.final_verdict.confidence:.2%}")
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Configuration Example (jury_config.json)
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"name": "Code Quality Jury",
|
|
127
|
+
"criteria": [
|
|
128
|
+
{"name": "correctness", "weight": 2.0, "max_score": 5},
|
|
129
|
+
{"name": "readability", "weight": 1.5, "max_score": 5}
|
|
130
|
+
],
|
|
131
|
+
"jurors": [
|
|
132
|
+
{"name": "Senior Developer", "system_prompt": "You are a senior developer. You are tasked with reviewing the code and providing a score and explanation for the correctness and readability of the code.", "model_name": "qwen/qwen-2.5-coder-32b", "weight": 2.0},
|
|
133
|
+
{"name": "Code Reviewer", "system_prompt": "You are a code reviewer. You are tasked with reviewing the code and providing a score and explanation for the correctness and readability of the code.", "model_name": "llama3/llama-3.1-8b-instruct", "weight": 1.0}
|
|
134
|
+
],
|
|
135
|
+
"voting_method": "weighted"
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Examples
|
|
140
|
+
|
|
141
|
+
You can find more examples in the [examples](examples) directory.
|
|
142
|
+
|
|
143
|
+
### Use Cases
|
|
144
|
+
|
|
145
|
+
#### Model Evaluation & Comparison
|
|
146
|
+
- Compare outputs from different models (e.g., GPT-4 vs Claude vs custom models)
|
|
147
|
+
- Run A/B tests across prompt variations, fine-tuned models, or versions
|
|
148
|
+
|
|
149
|
+
#### Content & Response Quality
|
|
150
|
+
- Evaluate generated code for correctness and readability
|
|
151
|
+
- Score long-form content (blogs, papers, explanations) for clarity, tone, or coherence
|
|
152
|
+
|
|
153
|
+
#### Automated Grading & Assessment
|
|
154
|
+
- Grade student answers or interview responses at scale
|
|
155
|
+
- Score generated outputs against rubric-style criteria
|
|
156
|
+
|
|
157
|
+
#### Production Monitoring & QA
|
|
158
|
+
- Monitor output quality in production systems
|
|
159
|
+
- Detect degradation or drift between model versions
|
|
160
|
+
|
|
161
|
+
#### Custom Evaluation Workflows
|
|
162
|
+
- Integrate LLM-based judgment into human-in-the-loop pipelines
|
|
163
|
+
- Use configurable jurors and voting for domain-specific tasks
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
OpenJury is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Contributing
|
|
174
|
+
|
|
175
|
+
Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for details.
|
openjury-0.1.0/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# OpenJury 🏛️
|
|
2
|
+
|
|
3
|
+
**A Python SDK for evaluating and comparing multiple model outputs using configurable LLM-based jurors.**
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
**OpenJury** is a post-inference ensemble framework that evaluates and compares multiple model outputs using configurable LLM-based jurors. It enables structured model assessment, ranking, and A/B testing directly into your Python apps, research workflows, or ML platforms.
|
|
13
|
+
|
|
14
|
+
At its core, OpenJury is a decision-level, LLM-driven evaluation system that aggregates juror scores using flexibile voting strategies (e.g. weighted, ranked, consensus, etc.). This makes it a powerful and extensible solution for nuanced, after-inference comparison of generated outputs across models, prompts, versions, or datasets.
|
|
15
|
+
|
|
16
|
+
### Why use an LLM Jury?
|
|
17
|
+
|
|
18
|
+
AI models can generate fluent, convincing outputs, but fluency != correctness. Whether you're building a customer service agent, a code review assist, or a content generator, you need to know which response is best, correct, or how models compare with quality and consistency. Human evaluation doesn't scale, which is why LLM-based jurors are widely used.
|
|
19
|
+
|
|
20
|
+
But relying on a single LLM (like GPT-4o) to evaluate model outputs, although common, is expensive and can introduce [intra-model bias](https://arxiv.org/abs/2404.13076). Research by Cohere [shows](https://arxiv.org/abs/2404.18796) that using a panel of smaller, diverse models not only cuts cost but also leads to more reliable and less biased evaluations.
|
|
21
|
+
|
|
22
|
+
OpenJury puts this into practice: instead of a single judge, it uses multiple jurors to score and explain outputs. The result? Better evlautions and lower costs, all configurable with a declarative interface.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Key Features
|
|
28
|
+
|
|
29
|
+
- **Python SDK:** Simple integration, flexible configuration
|
|
30
|
+
- **Multi-Criteria Evaluation:** Define custom criteria with weights and scoring
|
|
31
|
+
- **Advanced Voting Methods:** Majority, average, weighted, ranked, consensus, or your own
|
|
32
|
+
- **Parallel Processing:** Evaluate at scale, concurrently
|
|
33
|
+
- **Rich Output:** Scores, explanations, voting breakdowns, and confidence metrics
|
|
34
|
+
- **Extensible:** Plug in your own jurors, voting logic, and evaluation strategies
|
|
35
|
+
- **Dev Experience:** One-command setup, Makefile workflow, and modern code quality tools
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
**Requirements:** Python 3.11 or newer
|
|
42
|
+
|
|
43
|
+
### Recommended (PyPI)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install openjury
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### From Source (for development/contribution)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/robiscoding/openjury.git
|
|
53
|
+
cd openjury
|
|
54
|
+
pip install -e .
|
|
55
|
+
uv pip install -e ".[dev]" # (optional) dev dependencies
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
### Set Environment Variables
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
export OPENROUTER_API_KEY="your-api-key"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
or if you're using OpenAI:
|
|
67
|
+
```bash
|
|
68
|
+
export LLM_PROVIDER="openai"
|
|
69
|
+
export OPENAI_API_KEY="your-api-key"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Basic Usage
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from openjury import OpenJury, JuryConfig
|
|
76
|
+
|
|
77
|
+
config = JuryConfig.from_json_file("jury_config.json")
|
|
78
|
+
jury = OpenJury(config)
|
|
79
|
+
verdict = jury.evaluate(
|
|
80
|
+
prompt="Write a Python function to reverse a string",
|
|
81
|
+
responses=[
|
|
82
|
+
"def reverse(s): return s[::-1]",
|
|
83
|
+
"def reverse(s): return ''.join(reversed(s))"
|
|
84
|
+
]
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
print(f"Winner: {verdict.final_verdict.winner}")
|
|
88
|
+
print(f"Confidence: {verdict.final_verdict.confidence:.2%}")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Configuration Example (jury_config.json)
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"name": "Code Quality Jury",
|
|
96
|
+
"criteria": [
|
|
97
|
+
{"name": "correctness", "weight": 2.0, "max_score": 5},
|
|
98
|
+
{"name": "readability", "weight": 1.5, "max_score": 5}
|
|
99
|
+
],
|
|
100
|
+
"jurors": [
|
|
101
|
+
{"name": "Senior Developer", "system_prompt": "You are a senior developer. You are tasked with reviewing the code and providing a score and explanation for the correctness and readability of the code.", "model_name": "qwen/qwen-2.5-coder-32b", "weight": 2.0},
|
|
102
|
+
{"name": "Code Reviewer", "system_prompt": "You are a code reviewer. You are tasked with reviewing the code and providing a score and explanation for the correctness and readability of the code.", "model_name": "llama3/llama-3.1-8b-instruct", "weight": 1.0}
|
|
103
|
+
],
|
|
104
|
+
"voting_method": "weighted"
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Examples
|
|
109
|
+
|
|
110
|
+
You can find more examples in the [examples](examples) directory.
|
|
111
|
+
|
|
112
|
+
### Use Cases
|
|
113
|
+
|
|
114
|
+
#### Model Evaluation & Comparison
|
|
115
|
+
- Compare outputs from different models (e.g., GPT-4 vs Claude vs custom models)
|
|
116
|
+
- Run A/B tests across prompt variations, fine-tuned models, or versions
|
|
117
|
+
|
|
118
|
+
#### Content & Response Quality
|
|
119
|
+
- Evaluate generated code for correctness and readability
|
|
120
|
+
- Score long-form content (blogs, papers, explanations) for clarity, tone, or coherence
|
|
121
|
+
|
|
122
|
+
#### Automated Grading & Assessment
|
|
123
|
+
- Grade student answers or interview responses at scale
|
|
124
|
+
- Score generated outputs against rubric-style criteria
|
|
125
|
+
|
|
126
|
+
#### Production Monitoring & QA
|
|
127
|
+
- Monitor output quality in production systems
|
|
128
|
+
- Detect degradation or drift between model versions
|
|
129
|
+
|
|
130
|
+
#### Custom Evaluation Workflows
|
|
131
|
+
- Integrate LLM-based judgment into human-in-the-loop pipelines
|
|
132
|
+
- Use configurable jurors and voting for domain-specific tasks
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
OpenJury is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Contributing
|
|
143
|
+
|
|
144
|
+
Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for details.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "openjury"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Python SDK for evaluating multiple model outputs using configurable LLM-based jurors"
|
|
5
|
+
authors = [{ name = "robiscoding", email = "robiscodingg@gmail.com" }]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = {text = "Apache-2.0"}
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
keywords = [
|
|
10
|
+
"llm",
|
|
11
|
+
"evaluation",
|
|
12
|
+
"ai",
|
|
13
|
+
"model-consensus",
|
|
14
|
+
"llm-as-a-judge",
|
|
15
|
+
"model-comparison",
|
|
16
|
+
"openai",
|
|
17
|
+
"langchain",
|
|
18
|
+
"machine-learning"
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"License :: OSI Approved :: Apache Software License",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
dependencies = [
|
|
30
|
+
"langchain>=0.1.0",
|
|
31
|
+
"langchain-openai>=0.1.0",
|
|
32
|
+
"openai>=1.0.0",
|
|
33
|
+
"pydantic>=2.0.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[build-system]
|
|
37
|
+
requires = ["hatchling"]
|
|
38
|
+
build-backend = "hatchling.build"
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
dev = [
|
|
42
|
+
"pytest>=7.0.0",
|
|
43
|
+
"pytest-cov>=4.0.0",
|
|
44
|
+
"black>=23.0.0",
|
|
45
|
+
"isort>=5.12.0",
|
|
46
|
+
"mypy>=1.0.0",
|
|
47
|
+
"twine>=4.0.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/robiscoding/openjury"
|
|
52
|
+
Repository = "https://github.com/robiscoding/openjury"
|
|
53
|
+
Issues = "https://github.com/robiscoding/openjury/issues"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build.targets.wheel]
|
|
57
|
+
packages = ["src/openjury"]
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build.targets.sdist]
|
|
60
|
+
include = ["/src", "/tests", "/README.md", "/LICENSE"]
|
|
61
|
+
|
|
62
|
+
[tool.black]
|
|
63
|
+
line-length = 88
|
|
64
|
+
target-version = ['py311']
|
|
65
|
+
include = '\.pyi?$'
|
|
66
|
+
|
|
67
|
+
[tool.isort]
|
|
68
|
+
profile = "black"
|
|
69
|
+
multi_line_output = 3
|
|
70
|
+
|
|
71
|
+
[tool.mypy]
|
|
72
|
+
python_version = "3.11"
|
|
73
|
+
warn_return_any = true
|
|
74
|
+
warn_unused_configs = true
|
|
75
|
+
disallow_untyped_defs = true
|
|
76
|
+
|
|
77
|
+
[tool.pytest.ini_options]
|
|
78
|
+
testpaths = ["tests"]
|
|
79
|
+
python_files = ["test_*.py"]
|
|
80
|
+
python_classes = ["Test*"]
|
|
81
|
+
python_functions = ["test_*"]
|
|
82
|
+
|
|
83
|
+
[tool.twine]
|
|
84
|
+
repository = "pypi"
|
|
85
|
+
repository-test = "testpypi"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""OpenJury: A modular framework for evaluating multiple model outputs using LLM-based jurors."""
|
|
2
|
+
|
|
3
|
+
from openjury.config import (
|
|
4
|
+
CriterionConfig,
|
|
5
|
+
JurorConfig,
|
|
6
|
+
JuryConfig,
|
|
7
|
+
ResponseCandidate,
|
|
8
|
+
VotingCriteria,
|
|
9
|
+
)
|
|
10
|
+
from openjury.juror import Juror
|
|
11
|
+
from openjury.jury_engine import OpenJury
|
|
12
|
+
from openjury.output_format import Verdict, VerdictFormatter
|
|
13
|
+
from openjury.voting import (
|
|
14
|
+
JurorEvaluation,
|
|
15
|
+
VotingAggregator,
|
|
16
|
+
VotingMethod,
|
|
17
|
+
VotingResult,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
|
21
|
+
__all__ = [
|
|
22
|
+
"OpenJury",
|
|
23
|
+
"Juror",
|
|
24
|
+
"JurorConfig",
|
|
25
|
+
"JuryConfig",
|
|
26
|
+
"CriterionConfig",
|
|
27
|
+
"VerdictFormatter",
|
|
28
|
+
"Verdict",
|
|
29
|
+
"VotingMethod",
|
|
30
|
+
"VotingAggregator",
|
|
31
|
+
"JurorEvaluation",
|
|
32
|
+
"VotingResult",
|
|
33
|
+
"VotingCriteria",
|
|
34
|
+
"ResponseCandidate",
|
|
35
|
+
]
|