clear-eval 1.0.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.
@@ -0,0 +1,201 @@
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. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright 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
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: clear_eval
3
+ Version: 1.0.0
4
+ Summary: A python API sdk facilitating Error Analysis via LLM-as-a-Judge
5
+ Author-email: Lilach Eden <lilache@il.ibm.com>, Asaf Yehudai <asaf.yehudai@ibm.com>
6
+ License: Apache-2.0
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: python-dotenv
13
+ Requires-Dist: langchain
14
+ Requires-Dist: langgraph
15
+ Requires-Dist: langchain_openai
16
+ Requires-Dist: langchain_ibm
17
+ Requires-Dist: ibm_watsonx_ai>=1.2.8
18
+ Requires-Dist: openai
19
+ Requires-Dist: pyyaml
20
+ Requires-Dist: pandas
21
+ Requires-Dist: tqdm
22
+ Requires-Dist: pyyaml
23
+ Requires-Dist: streamlit
24
+ Requires-Dist: matplotlib
25
+ Requires-Dist: seaborn
26
+ Requires-Dist: langchain_community
27
+ Requires-Dist: numpy
28
+ Requires-Dist: argparse
29
+ Dynamic: license-file
30
+
31
+ # CLEAR: Error Analysis via LLM-as-a-Judge Made Easy
32
+
33
+ **CLEAR (Comprehensive LLM Error Analysis and Reporting)** is an interactive, open-source package for **LLM-based error analysis**. It helps surface meaningful, recurring issues in model outputs by combining automated evaluation with powerful visualization tools.
34
+
35
+ The workflow consists of two main phases:
36
+
37
+ 1. **Analysis**
38
+ Generates textual feedback for each instance; Identifies system-level error categories from these critiques and quantifies their frequencies.
39
+
40
+ 2. **Interactive Dashboard**
41
+ An intuitive dashboard provides a comprehensive view of model behavior. Users can:
42
+ - Explore aggregate visualizations of identified issues
43
+ - Apply dynamic filters to focus on specific error types or score ranges
44
+ - Drill down into individual examples that illustrate specific failure patterns
45
+
46
+ CLEAR makes it easier to diagnose model shortcomings and prioritize targeted improvements.
47
+
48
+ You can run CLEAR as a full pipeline, or reuse specific stages (generation, evaluation, or just UI).
49
+
50
+
51
+
52
+ ## 🚀 Quickstart
53
+
54
+ Requires Python 3.10+ and the necessary credentials for a supported provider.
55
+
56
+ 1. ### **Clone the repo and set up a virtual environment:**
57
+
58
+ ```bash
59
+ git clone https://github.com/IBM/CLEAR.git
60
+ cd CLEAR
61
+ python3 -m venv .venv
62
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
63
+ pip install -e .
64
+ ```
65
+
66
+ 2. ### Set provider type and credentials
67
+ CLEAR requires a supported LLM provider and credentials to run analysis. [See supported providers ↓](#supported-providers-and-credentials)
68
+ > ⚠️ Using a private proxy or openai deployment? You must configure your model names explicitly (see below). Otherwise, default model names will be used automatically for supported providers.
69
+
70
+ 3. ### **Run on sample data:**
71
+
72
+ The sample dataset is a small subset of the **GSM8K math problems**.
73
+ For running on the sample data and default configuration, you simpy have to set your provider and run
74
+ ```bash
75
+ run-clear-eval-analysis --provider=openai # or rits, watsonx
76
+ ```
77
+
78
+ This will:
79
+ - Run the full CLEAR pipeline
80
+ - Save results under: `results/gsm8k/sample_output/`
81
+
82
+ 4. ### **View results in the interactive dashboard:**
83
+
84
+ ```bash
85
+ run-clear-eval-dashboard
86
+ ```
87
+
88
+ Or set the port with
89
+ ```bash
90
+ run-clear-eval-dashboard --port <port>
91
+ ```
92
+ Then:
93
+ - Upload the generated ZIP file from `results/gsm8k/sample_output/`
94
+ - Explore issues, scores, filters, and drill into examples
95
+
96
+ 5. ### **To explore the dashboard without running any analysis:**
97
+ Run the dashboard:
98
+ ```bash
99
+ run-clear-eval-dashboard
100
+ ```
101
+
102
+ Then you can load the pre-generated sample output zip from [here](results/input_for_ui), without running any analysis.
103
+
104
+
105
+ ---
106
+
107
+
108
+ ## 📂 Analyzing your own data
109
+
110
+ ### 📄 Input Data Format
111
+
112
+ CLEAR takes a **CSV file** as input, with each row representing a single instance to be evaluated.
113
+
114
+ #### Required Columns
115
+
116
+ | Column | Used When | Description |
117
+ |----------------|-------------------------------------|-------------------------------------------------------------------|
118
+ | `id` | Always | Unique identifier for the instance |
119
+ | `model_input` | Always | Prompt provided to the generation model |
120
+ | `response` | Using pre-generated responses | Pre-generated model response (ignored if generation is enabled) |
121
+ | `ground_truth` | Performing reference based analysis | Ground-truth answer for evaluation (optional) |
122
+ | _others_ | `--input_columns` is used | Additional input columns to show in dashboard (e.g. `question`) |
123
+
124
+ ---
125
+
126
+ ### 🚀 Running the analysis
127
+
128
+ CLEAR can be run via the CLI or Python API.
129
+
130
+ #### Option 1: CLI commands
131
+
132
+ Each stage has its own entry point:
133
+
134
+ ```bash
135
+ run-clear-eval-analysis --config_path path/to/config.yaml # run full pypeline
136
+ run-clear-eval-generation --config_path path/to/config.yaml # run generation only
137
+ run-clear-eval-evaluation --config_path path/to/config.yaml # Assume generation responses are given, run evaluation
138
+ ```
139
+
140
+ - If `--config_path` is specified, **all parameters are taken from the config** unless explicitly overridden
141
+ - CLI flags passed directly override corresponding config values
142
+
143
+ #### Option 2: Python API
144
+
145
+ ```python
146
+ from clear_eval.analysis_runner import run_clear_eval_analysis, run_clear_eval_generation, run_clear_eval_evaluation
147
+
148
+ run_clear_eval_analysis(
149
+ config_path="configs/sample_run_config.yaml"
150
+ )
151
+ ```
152
+
153
+ You may also pass overrides instead of using a config file:
154
+
155
+ ```python
156
+ from clear_eval.analysis_runner import run_clear_eval_analysis
157
+
158
+ run_clear_eval_analysis(
159
+ run_name="my_data",
160
+ provider="openai",
161
+ data_path="my_data.csv",
162
+ gen_model_name="gpt-3.5-turbo",
163
+ eval_model_name="gpt-4",
164
+ output_dir="results/gsm8k/",
165
+ perform_generation=False,
166
+ input_columns=["question"]
167
+ )
168
+ ```
169
+ ### 📊 Launching the Dashboard
170
+
171
+ ```bash
172
+ run-clear-eval-dashboard
173
+ ```
174
+
175
+ Upload the ZIP file generated in your `--output-dir` when prompted.
176
+
177
+ ### 🎛 Supported CLI Arguments
178
+
179
+ Arguments can be provided via:
180
+ - A YAML config file (`--config_path`)
181
+ - CLI flags
182
+ - Python function parameters (when using the API)
183
+
184
+ > ⚠️ **Boolean arguments** (`perform_generation`, `is_reference_based`, `resume_enabled`)
185
+ > These must be set explicitly to `true` or `false` in YAML, CLI, or Python.
186
+ > On the CLI, use `--flag True` or `--flag False` (case-insensitive).
187
+
188
+ > ⚠️ **Naming Convention**
189
+ > Parameter names use `snake_case` in YAML and Python, but use `--kebab-case` in CLI.
190
+ > For example:
191
+ > - YAML: `perform_generation: true`
192
+ > - Python: `perform_generation=True`
193
+ > - CLI: `--perform-generation True`
194
+
195
+ | Argument | Description | Default |
196
+ |----------------------|--------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
197
+ | `--config_path` | Path to a YAML config file (all values loaded unless overridden by CLI args) | |
198
+ | `--run_name` | Unique run name (used in result file names) | |
199
+ | `--data_path` | Path to input CSV file | |
200
+ | `--output_dir` | Output directory to write results | |
201
+ | `--provider` | Model provider: `openai`, `watsonx`, `rits` | |
202
+ | `--eval_model_name` | Name of judge model (e.g. `gpt-4o`) | |
203
+ | `--gen_model_name` | Name of the generator model to evaluate. If not running generations - the generator name to display. | |
204
+ | `--perform_generation` | Whether to generate responses or use existing `response` column | True |
205
+ | `--is_reference_based` | Use reference-based evaluation (requires `ground_truth` column in input) | False |
206
+ | `--resume_enabled` | Whether to reuse intermediate outputs from previous runs stored in output_dir | True |
207
+ | `--evaluation_criteria` | Custom criteria dictionary for scoring individual records: `{"criteria_name1":"criteria_desc1", ...}`supported for yaml config and python. | None |
208
+ | `--input_columns` | Comma-separated list of additional input fields (other than `model_input`) to appear in the results and dashboard (e.g. `question`) | None |
209
+
210
+ ---
211
+
212
+ ## 🔑Supported providers and credentials
213
+
214
+ Depending on your selected `--provider`:
215
+
216
+ | Provider | Required Environment Variables |
217
+ |------------|---------------------------------------------------------------------|
218
+ | `openai` | `OPENAI_API_KEY`, [`OPENAI_API_BASE` if using proxy ] | |
219
+ | `watsonx` | `WATSONX_APIKEY`, `WATSONX_URL`, `WATSONX_SPACE_ID` or `PROJECT_ID` |
220
+ | `rits` | `RITS_API_KEY` |
221
+
222
+ ---
223
+
@@ -0,0 +1,193 @@
1
+ # CLEAR: Error Analysis via LLM-as-a-Judge Made Easy
2
+
3
+ **CLEAR (Comprehensive LLM Error Analysis and Reporting)** is an interactive, open-source package for **LLM-based error analysis**. It helps surface meaningful, recurring issues in model outputs by combining automated evaluation with powerful visualization tools.
4
+
5
+ The workflow consists of two main phases:
6
+
7
+ 1. **Analysis**
8
+ Generates textual feedback for each instance; Identifies system-level error categories from these critiques and quantifies their frequencies.
9
+
10
+ 2. **Interactive Dashboard**
11
+ An intuitive dashboard provides a comprehensive view of model behavior. Users can:
12
+ - Explore aggregate visualizations of identified issues
13
+ - Apply dynamic filters to focus on specific error types or score ranges
14
+ - Drill down into individual examples that illustrate specific failure patterns
15
+
16
+ CLEAR makes it easier to diagnose model shortcomings and prioritize targeted improvements.
17
+
18
+ You can run CLEAR as a full pipeline, or reuse specific stages (generation, evaluation, or just UI).
19
+
20
+
21
+
22
+ ## 🚀 Quickstart
23
+
24
+ Requires Python 3.10+ and the necessary credentials for a supported provider.
25
+
26
+ 1. ### **Clone the repo and set up a virtual environment:**
27
+
28
+ ```bash
29
+ git clone https://github.com/IBM/CLEAR.git
30
+ cd CLEAR
31
+ python3 -m venv .venv
32
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
33
+ pip install -e .
34
+ ```
35
+
36
+ 2. ### Set provider type and credentials
37
+ CLEAR requires a supported LLM provider and credentials to run analysis. [See supported providers ↓](#supported-providers-and-credentials)
38
+ > ⚠️ Using a private proxy or openai deployment? You must configure your model names explicitly (see below). Otherwise, default model names will be used automatically for supported providers.
39
+
40
+ 3. ### **Run on sample data:**
41
+
42
+ The sample dataset is a small subset of the **GSM8K math problems**.
43
+ For running on the sample data and default configuration, you simpy have to set your provider and run
44
+ ```bash
45
+ run-clear-eval-analysis --provider=openai # or rits, watsonx
46
+ ```
47
+
48
+ This will:
49
+ - Run the full CLEAR pipeline
50
+ - Save results under: `results/gsm8k/sample_output/`
51
+
52
+ 4. ### **View results in the interactive dashboard:**
53
+
54
+ ```bash
55
+ run-clear-eval-dashboard
56
+ ```
57
+
58
+ Or set the port with
59
+ ```bash
60
+ run-clear-eval-dashboard --port <port>
61
+ ```
62
+ Then:
63
+ - Upload the generated ZIP file from `results/gsm8k/sample_output/`
64
+ - Explore issues, scores, filters, and drill into examples
65
+
66
+ 5. ### **To explore the dashboard without running any analysis:**
67
+ Run the dashboard:
68
+ ```bash
69
+ run-clear-eval-dashboard
70
+ ```
71
+
72
+ Then you can load the pre-generated sample output zip from [here](results/input_for_ui), without running any analysis.
73
+
74
+
75
+ ---
76
+
77
+
78
+ ## 📂 Analyzing your own data
79
+
80
+ ### 📄 Input Data Format
81
+
82
+ CLEAR takes a **CSV file** as input, with each row representing a single instance to be evaluated.
83
+
84
+ #### Required Columns
85
+
86
+ | Column | Used When | Description |
87
+ |----------------|-------------------------------------|-------------------------------------------------------------------|
88
+ | `id` | Always | Unique identifier for the instance |
89
+ | `model_input` | Always | Prompt provided to the generation model |
90
+ | `response` | Using pre-generated responses | Pre-generated model response (ignored if generation is enabled) |
91
+ | `ground_truth` | Performing reference based analysis | Ground-truth answer for evaluation (optional) |
92
+ | _others_ | `--input_columns` is used | Additional input columns to show in dashboard (e.g. `question`) |
93
+
94
+ ---
95
+
96
+ ### 🚀 Running the analysis
97
+
98
+ CLEAR can be run via the CLI or Python API.
99
+
100
+ #### Option 1: CLI commands
101
+
102
+ Each stage has its own entry point:
103
+
104
+ ```bash
105
+ run-clear-eval-analysis --config_path path/to/config.yaml # run full pypeline
106
+ run-clear-eval-generation --config_path path/to/config.yaml # run generation only
107
+ run-clear-eval-evaluation --config_path path/to/config.yaml # Assume generation responses are given, run evaluation
108
+ ```
109
+
110
+ - If `--config_path` is specified, **all parameters are taken from the config** unless explicitly overridden
111
+ - CLI flags passed directly override corresponding config values
112
+
113
+ #### Option 2: Python API
114
+
115
+ ```python
116
+ from clear_eval.analysis_runner import run_clear_eval_analysis, run_clear_eval_generation, run_clear_eval_evaluation
117
+
118
+ run_clear_eval_analysis(
119
+ config_path="configs/sample_run_config.yaml"
120
+ )
121
+ ```
122
+
123
+ You may also pass overrides instead of using a config file:
124
+
125
+ ```python
126
+ from clear_eval.analysis_runner import run_clear_eval_analysis
127
+
128
+ run_clear_eval_analysis(
129
+ run_name="my_data",
130
+ provider="openai",
131
+ data_path="my_data.csv",
132
+ gen_model_name="gpt-3.5-turbo",
133
+ eval_model_name="gpt-4",
134
+ output_dir="results/gsm8k/",
135
+ perform_generation=False,
136
+ input_columns=["question"]
137
+ )
138
+ ```
139
+ ### 📊 Launching the Dashboard
140
+
141
+ ```bash
142
+ run-clear-eval-dashboard
143
+ ```
144
+
145
+ Upload the ZIP file generated in your `--output-dir` when prompted.
146
+
147
+ ### 🎛 Supported CLI Arguments
148
+
149
+ Arguments can be provided via:
150
+ - A YAML config file (`--config_path`)
151
+ - CLI flags
152
+ - Python function parameters (when using the API)
153
+
154
+ > ⚠️ **Boolean arguments** (`perform_generation`, `is_reference_based`, `resume_enabled`)
155
+ > These must be set explicitly to `true` or `false` in YAML, CLI, or Python.
156
+ > On the CLI, use `--flag True` or `--flag False` (case-insensitive).
157
+
158
+ > ⚠️ **Naming Convention**
159
+ > Parameter names use `snake_case` in YAML and Python, but use `--kebab-case` in CLI.
160
+ > For example:
161
+ > - YAML: `perform_generation: true`
162
+ > - Python: `perform_generation=True`
163
+ > - CLI: `--perform-generation True`
164
+
165
+ | Argument | Description | Default |
166
+ |----------------------|--------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
167
+ | `--config_path` | Path to a YAML config file (all values loaded unless overridden by CLI args) | |
168
+ | `--run_name` | Unique run name (used in result file names) | |
169
+ | `--data_path` | Path to input CSV file | |
170
+ | `--output_dir` | Output directory to write results | |
171
+ | `--provider` | Model provider: `openai`, `watsonx`, `rits` | |
172
+ | `--eval_model_name` | Name of judge model (e.g. `gpt-4o`) | |
173
+ | `--gen_model_name` | Name of the generator model to evaluate. If not running generations - the generator name to display. | |
174
+ | `--perform_generation` | Whether to generate responses or use existing `response` column | True |
175
+ | `--is_reference_based` | Use reference-based evaluation (requires `ground_truth` column in input) | False |
176
+ | `--resume_enabled` | Whether to reuse intermediate outputs from previous runs stored in output_dir | True |
177
+ | `--evaluation_criteria` | Custom criteria dictionary for scoring individual records: `{"criteria_name1":"criteria_desc1", ...}`supported for yaml config and python. | None |
178
+ | `--input_columns` | Comma-separated list of additional input fields (other than `model_input`) to appear in the results and dashboard (e.g. `question`) | None |
179
+
180
+ ---
181
+
182
+ ## 🔑Supported providers and credentials
183
+
184
+ Depending on your selected `--provider`:
185
+
186
+ | Provider | Required Environment Variables |
187
+ |------------|---------------------------------------------------------------------|
188
+ | `openai` | `OPENAI_API_KEY`, [`OPENAI_API_BASE` if using proxy ] | |
189
+ | `watsonx` | `WATSONX_APIKEY`, `WATSONX_URL`, `WATSONX_SPACE_ID` or `PROJECT_ID` |
190
+ | `rits` | `RITS_API_KEY` |
191
+
192
+ ---
193
+
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "clear_eval"
7
+ version = "1.0.0"
8
+ description = "A python API sdk facilitating Error Analysis via LLM-as-a-Judge"
9
+ readme = "README.md"
10
+ authors = [{ name = "Lilach Eden", email = "lilache@il.ibm.com"},
11
+ {name = "Asaf Yehudai", email = "asaf.yehudai@ibm.com"}]
12
+ license = { text = "Apache-2.0" }
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Operating System :: OS Independent",
16
+ ]
17
+ dependencies = [
18
+ "python-dotenv",
19
+ "langchain",
20
+ "langgraph",
21
+ "langchain_openai",
22
+ "langchain_ibm",
23
+ "ibm_watsonx_ai>=1.2.8",
24
+ "openai",
25
+ "pyyaml",
26
+ "pandas",
27
+ "tqdm",
28
+ "pyyaml",
29
+ "streamlit",
30
+ "matplotlib",
31
+ "seaborn",
32
+ "langchain_community",
33
+ "numpy",
34
+ "argparse"
35
+ ]
36
+ requires-python = ">=3.10"
37
+
38
+ [tool.setuptools]
39
+ package-dir = {"" = "src"}
40
+ packages = ["clear_eval"]
41
+
42
+ [tool.setuptools.package-data]
43
+ clear_eval = ["*.yaml"]
44
+ where = ["src"]
45
+
46
+ [project.scripts]
47
+ run-analysis = "clear_eval.cli:main"
48
+ run-clear-eval-analysis = "clear_eval.cli:main"
49
+ run-clear-eval-generation = "clear_eval.cli:run_generation_cli"
50
+ run-clear-eval-evaluation = "clear_eval.cli:run_evaluation_cli"
51
+ run-clear-eval-aggregation = "clear_eval.cli:run_aggregation_cli"
52
+ run-clear-eval-dashboard = "clear_eval.cli:run_dashboard_cli"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,29 @@
1
+ import os
2
+ from clear_eval.pipeline.full_pipeline import run_eval_pipeline, run_generation_pipeline, run_aggregation_pipeline
3
+ from clear_eval.pipeline.config_loader import load_config
4
+ from clear_eval.logging_config import setup_logging
5
+ setup_logging()
6
+
7
+ script_dir = os.path.dirname(os.path.abspath(__file__))
8
+
9
+ DEFAULT_CONFIG_PATH = os.path.join(script_dir, "pipeline", "setup", "default_config.yaml")
10
+
11
+ def run_clear_eval_analysis(config_path=None, **kwargs):
12
+ config_dict = load_config(DEFAULT_CONFIG_PATH, config_path, **kwargs)
13
+ run_eval_pipeline(config_dict)
14
+
15
+ def run_analysis_pipeline(config_path=None, **kwargs):
16
+ run_clear_eval_analysis(config_path, **kwargs)
17
+
18
+ def run_clear_eval_evaluation(config_path=None, **kwargs):
19
+ config_dict = load_config(DEFAULT_CONFIG_PATH, config_path, **kwargs)
20
+ config_dict["perform_generation"] = False
21
+ run_eval_pipeline(config_dict)
22
+
23
+ def run_clear_eval_generation(config_path=None, **kwargs):
24
+ config_dict = load_config(DEFAULT_CONFIG_PATH, config_path, **kwargs)
25
+ run_generation_pipeline(config_dict)
26
+
27
+ def run_clear_eval_aggregation(config_path=None, **kwargs):
28
+ config_dict = load_config(DEFAULT_CONFIG_PATH, config_path, **kwargs)
29
+ run_aggregation_pipeline(config_dict)
@@ -0,0 +1,51 @@
1
+ import argparse
2
+ import json
3
+
4
+
5
+ def parse_dict(arg: str) -> dict:
6
+ try:
7
+ return json.loads(arg)
8
+ except json.JSONDecodeError as e:
9
+ raise argparse.ArgumentTypeError(f"Invalid JSON format: {e}")
10
+
11
+ def str2bool(v):
12
+ if isinstance(v, bool):
13
+ return v
14
+ if v.lower() in ("yes", "true", "t", "1"):
15
+ return True
16
+ elif v.lower() in ("no", "false", "f", "0"):
17
+ return False
18
+ raise argparse.ArgumentTypeError("Boolean value expected.")
19
+
20
+ def parse_args():
21
+ parser = argparse.ArgumentParser()
22
+
23
+ parser.add_argument("--data-path", help="Path to the data csv file")
24
+ parser.add_argument("--output-dir", default=None, help="Output directory")
25
+ parser.add_argument("--provider", choices=["azure", "openai", "watsonx", "rits"])
26
+ parser.add_argument("--eval-model-name", help="Name of the model used by CLEAR for evaluating and analyzing outputs")
27
+ parser.add_argument("--gen-model-name", help="Name of the generator model whose responses are evaluated (e.g. gpt-3.5-turbo)",
28
+ default=None)
29
+
30
+ parser.add_argument("--config-path", default=None, help="Optional: path to the config file")
31
+ parser.add_argument("--perform-generation", type=str2bool, default=True, help="Whether to perform generations or"
32
+ "use existing generations")
33
+ parser.add_argument("--is-reference-based", type=str2bool, default=False,
34
+ help="Whether to use use references for the evaluations (if true, references must be stored in the 'reference' column of the input.")
35
+ parser.add_argument("--resume-enabled", type=str2bool, default=True,
36
+ help="Whether to use use intermediate results found in the output dir")
37
+ parser.add_argument("--run-name", default=None,
38
+ help="Unique identifier for the run")
39
+ parser.add_argument("--evaluation-criteria", type=parse_dict, help="Json of a dictionary of evaluation criteria for"
40
+ "the judge. Example: --evaluation-criteria '{\"correction\": \"Response is factually correct\"}'")
41
+ parser.add_argument("--max-examples-to-analyze", type=int, help="Analyze only the specified number of examples")
42
+ parser.add_argument("--input-columns", nargs='+', help="List of column names to present in the ui")
43
+
44
+ args = parser.parse_args()
45
+
46
+ # Only keep explicitly passed args (ignore None)
47
+ overrides = {
48
+ k: v for k, v in vars(args).items()
49
+ if v is not None
50
+ }
51
+ return overrides
@@ -0,0 +1,41 @@
1
+ import argparse
2
+ import json
3
+ import os
4
+ import sys
5
+ from pathlib import Path
6
+ import streamlit.web.cli as stcli
7
+ from clear_eval.analysis_runner import run_clear_eval_analysis, run_clear_eval_generation, run_clear_eval_aggregation
8
+ from clear_eval.args import parse_args
9
+
10
+
11
+ def main():
12
+ overrides = parse_args()
13
+ run_clear_eval_analysis(**overrides)
14
+
15
+ def run_generation_cli():
16
+ overrides = parse_args()
17
+ run_clear_eval_generation(**overrides)
18
+
19
+ def run_evaluation_cli():
20
+ overrides = parse_args()
21
+ overrides["perform_generation"] = False
22
+ run_clear_eval_analysis(**overrides)
23
+
24
+ def run_aggregation_cli():
25
+ overrides = parse_args()
26
+ run_clear_eval_aggregation(**overrides)
27
+
28
+ def run_dashboard_cli():
29
+ parser = argparse.ArgumentParser(description="Run the dashboard.")
30
+ parser.add_argument("--port", type=int, help="Optional port to run the dashboard on.")
31
+ args = parser.parse_args()
32
+
33
+ streamlit_app = Path(__file__).parent / "load_ui.py"
34
+ sys.argv = ["streamlit", "run", str(streamlit_app)]
35
+ if args.port:
36
+ sys.argv += ["--server.port", str(args.port)]
37
+
38
+ stcli.main()
39
+
40
+ if __name__ == "__main__":
41
+ main()
@@ -0,0 +1,3 @@
1
+ from clear_eval.dashboard.show_analysis_dashboard import show_dashboard
2
+
3
+ show_dashboard()
@@ -0,0 +1,10 @@
1
+ import logging
2
+
3
+ def setup_logging(level=logging.INFO):
4
+ if not logging.getLogger().hasHandlers():
5
+ logging.basicConfig(
6
+ format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
7
+ level=logging.INFO,
8
+ )
9
+ for noisy_lib in ["requests", "urllib3", "openai", "ibm_watsonx_ai", "httpx"]:
10
+ logging.getLogger(noisy_lib).setLevel(logging.WARNING)
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: clear_eval
3
+ Version: 1.0.0
4
+ Summary: A python API sdk facilitating Error Analysis via LLM-as-a-Judge
5
+ Author-email: Lilach Eden <lilache@il.ibm.com>, Asaf Yehudai <asaf.yehudai@ibm.com>
6
+ License: Apache-2.0
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: python-dotenv
13
+ Requires-Dist: langchain
14
+ Requires-Dist: langgraph
15
+ Requires-Dist: langchain_openai
16
+ Requires-Dist: langchain_ibm
17
+ Requires-Dist: ibm_watsonx_ai>=1.2.8
18
+ Requires-Dist: openai
19
+ Requires-Dist: pyyaml
20
+ Requires-Dist: pandas
21
+ Requires-Dist: tqdm
22
+ Requires-Dist: pyyaml
23
+ Requires-Dist: streamlit
24
+ Requires-Dist: matplotlib
25
+ Requires-Dist: seaborn
26
+ Requires-Dist: langchain_community
27
+ Requires-Dist: numpy
28
+ Requires-Dist: argparse
29
+ Dynamic: license-file
30
+
31
+ # CLEAR: Error Analysis via LLM-as-a-Judge Made Easy
32
+
33
+ **CLEAR (Comprehensive LLM Error Analysis and Reporting)** is an interactive, open-source package for **LLM-based error analysis**. It helps surface meaningful, recurring issues in model outputs by combining automated evaluation with powerful visualization tools.
34
+
35
+ The workflow consists of two main phases:
36
+
37
+ 1. **Analysis**
38
+ Generates textual feedback for each instance; Identifies system-level error categories from these critiques and quantifies their frequencies.
39
+
40
+ 2. **Interactive Dashboard**
41
+ An intuitive dashboard provides a comprehensive view of model behavior. Users can:
42
+ - Explore aggregate visualizations of identified issues
43
+ - Apply dynamic filters to focus on specific error types or score ranges
44
+ - Drill down into individual examples that illustrate specific failure patterns
45
+
46
+ CLEAR makes it easier to diagnose model shortcomings and prioritize targeted improvements.
47
+
48
+ You can run CLEAR as a full pipeline, or reuse specific stages (generation, evaluation, or just UI).
49
+
50
+
51
+
52
+ ## 🚀 Quickstart
53
+
54
+ Requires Python 3.10+ and the necessary credentials for a supported provider.
55
+
56
+ 1. ### **Clone the repo and set up a virtual environment:**
57
+
58
+ ```bash
59
+ git clone https://github.com/IBM/CLEAR.git
60
+ cd CLEAR
61
+ python3 -m venv .venv
62
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
63
+ pip install -e .
64
+ ```
65
+
66
+ 2. ### Set provider type and credentials
67
+ CLEAR requires a supported LLM provider and credentials to run analysis. [See supported providers ↓](#supported-providers-and-credentials)
68
+ > ⚠️ Using a private proxy or openai deployment? You must configure your model names explicitly (see below). Otherwise, default model names will be used automatically for supported providers.
69
+
70
+ 3. ### **Run on sample data:**
71
+
72
+ The sample dataset is a small subset of the **GSM8K math problems**.
73
+ For running on the sample data and default configuration, you simpy have to set your provider and run
74
+ ```bash
75
+ run-clear-eval-analysis --provider=openai # or rits, watsonx
76
+ ```
77
+
78
+ This will:
79
+ - Run the full CLEAR pipeline
80
+ - Save results under: `results/gsm8k/sample_output/`
81
+
82
+ 4. ### **View results in the interactive dashboard:**
83
+
84
+ ```bash
85
+ run-clear-eval-dashboard
86
+ ```
87
+
88
+ Or set the port with
89
+ ```bash
90
+ run-clear-eval-dashboard --port <port>
91
+ ```
92
+ Then:
93
+ - Upload the generated ZIP file from `results/gsm8k/sample_output/`
94
+ - Explore issues, scores, filters, and drill into examples
95
+
96
+ 5. ### **To explore the dashboard without running any analysis:**
97
+ Run the dashboard:
98
+ ```bash
99
+ run-clear-eval-dashboard
100
+ ```
101
+
102
+ Then you can load the pre-generated sample output zip from [here](results/input_for_ui), without running any analysis.
103
+
104
+
105
+ ---
106
+
107
+
108
+ ## 📂 Analyzing your own data
109
+
110
+ ### 📄 Input Data Format
111
+
112
+ CLEAR takes a **CSV file** as input, with each row representing a single instance to be evaluated.
113
+
114
+ #### Required Columns
115
+
116
+ | Column | Used When | Description |
117
+ |----------------|-------------------------------------|-------------------------------------------------------------------|
118
+ | `id` | Always | Unique identifier for the instance |
119
+ | `model_input` | Always | Prompt provided to the generation model |
120
+ | `response` | Using pre-generated responses | Pre-generated model response (ignored if generation is enabled) |
121
+ | `ground_truth` | Performing reference based analysis | Ground-truth answer for evaluation (optional) |
122
+ | _others_ | `--input_columns` is used | Additional input columns to show in dashboard (e.g. `question`) |
123
+
124
+ ---
125
+
126
+ ### 🚀 Running the analysis
127
+
128
+ CLEAR can be run via the CLI or Python API.
129
+
130
+ #### Option 1: CLI commands
131
+
132
+ Each stage has its own entry point:
133
+
134
+ ```bash
135
+ run-clear-eval-analysis --config_path path/to/config.yaml # run full pypeline
136
+ run-clear-eval-generation --config_path path/to/config.yaml # run generation only
137
+ run-clear-eval-evaluation --config_path path/to/config.yaml # Assume generation responses are given, run evaluation
138
+ ```
139
+
140
+ - If `--config_path` is specified, **all parameters are taken from the config** unless explicitly overridden
141
+ - CLI flags passed directly override corresponding config values
142
+
143
+ #### Option 2: Python API
144
+
145
+ ```python
146
+ from clear_eval.analysis_runner import run_clear_eval_analysis, run_clear_eval_generation, run_clear_eval_evaluation
147
+
148
+ run_clear_eval_analysis(
149
+ config_path="configs/sample_run_config.yaml"
150
+ )
151
+ ```
152
+
153
+ You may also pass overrides instead of using a config file:
154
+
155
+ ```python
156
+ from clear_eval.analysis_runner import run_clear_eval_analysis
157
+
158
+ run_clear_eval_analysis(
159
+ run_name="my_data",
160
+ provider="openai",
161
+ data_path="my_data.csv",
162
+ gen_model_name="gpt-3.5-turbo",
163
+ eval_model_name="gpt-4",
164
+ output_dir="results/gsm8k/",
165
+ perform_generation=False,
166
+ input_columns=["question"]
167
+ )
168
+ ```
169
+ ### 📊 Launching the Dashboard
170
+
171
+ ```bash
172
+ run-clear-eval-dashboard
173
+ ```
174
+
175
+ Upload the ZIP file generated in your `--output-dir` when prompted.
176
+
177
+ ### 🎛 Supported CLI Arguments
178
+
179
+ Arguments can be provided via:
180
+ - A YAML config file (`--config_path`)
181
+ - CLI flags
182
+ - Python function parameters (when using the API)
183
+
184
+ > ⚠️ **Boolean arguments** (`perform_generation`, `is_reference_based`, `resume_enabled`)
185
+ > These must be set explicitly to `true` or `false` in YAML, CLI, or Python.
186
+ > On the CLI, use `--flag True` or `--flag False` (case-insensitive).
187
+
188
+ > ⚠️ **Naming Convention**
189
+ > Parameter names use `snake_case` in YAML and Python, but use `--kebab-case` in CLI.
190
+ > For example:
191
+ > - YAML: `perform_generation: true`
192
+ > - Python: `perform_generation=True`
193
+ > - CLI: `--perform-generation True`
194
+
195
+ | Argument | Description | Default |
196
+ |----------------------|--------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
197
+ | `--config_path` | Path to a YAML config file (all values loaded unless overridden by CLI args) | |
198
+ | `--run_name` | Unique run name (used in result file names) | |
199
+ | `--data_path` | Path to input CSV file | |
200
+ | `--output_dir` | Output directory to write results | |
201
+ | `--provider` | Model provider: `openai`, `watsonx`, `rits` | |
202
+ | `--eval_model_name` | Name of judge model (e.g. `gpt-4o`) | |
203
+ | `--gen_model_name` | Name of the generator model to evaluate. If not running generations - the generator name to display. | |
204
+ | `--perform_generation` | Whether to generate responses or use existing `response` column | True |
205
+ | `--is_reference_based` | Use reference-based evaluation (requires `ground_truth` column in input) | False |
206
+ | `--resume_enabled` | Whether to reuse intermediate outputs from previous runs stored in output_dir | True |
207
+ | `--evaluation_criteria` | Custom criteria dictionary for scoring individual records: `{"criteria_name1":"criteria_desc1", ...}`supported for yaml config and python. | None |
208
+ | `--input_columns` | Comma-separated list of additional input fields (other than `model_input`) to appear in the results and dashboard (e.g. `question`) | None |
209
+
210
+ ---
211
+
212
+ ## 🔑Supported providers and credentials
213
+
214
+ Depending on your selected `--provider`:
215
+
216
+ | Provider | Required Environment Variables |
217
+ |------------|---------------------------------------------------------------------|
218
+ | `openai` | `OPENAI_API_KEY`, [`OPENAI_API_BASE` if using proxy ] | |
219
+ | `watsonx` | `WATSONX_APIKEY`, `WATSONX_URL`, `WATSONX_SPACE_ID` or `PROJECT_ID` |
220
+ | `rits` | `RITS_API_KEY` |
221
+
222
+ ---
223
+
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/clear_eval/__init__.py
5
+ src/clear_eval/analysis_runner.py
6
+ src/clear_eval/args.py
7
+ src/clear_eval/cli.py
8
+ src/clear_eval/load_ui.py
9
+ src/clear_eval/logging_config.py
10
+ src/clear_eval.egg-info/PKG-INFO
11
+ src/clear_eval.egg-info/SOURCES.txt
12
+ src/clear_eval.egg-info/dependency_links.txt
13
+ src/clear_eval.egg-info/entry_points.txt
14
+ src/clear_eval.egg-info/requires.txt
15
+ src/clear_eval.egg-info/top_level.txt
@@ -0,0 +1,7 @@
1
+ [console_scripts]
2
+ run-analysis = clear_eval.cli:main
3
+ run-clear-eval-aggregation = clear_eval.cli:run_aggregation_cli
4
+ run-clear-eval-analysis = clear_eval.cli:main
5
+ run-clear-eval-dashboard = clear_eval.cli:run_dashboard_cli
6
+ run-clear-eval-evaluation = clear_eval.cli:run_evaluation_cli
7
+ run-clear-eval-generation = clear_eval.cli:run_generation_cli
@@ -0,0 +1,17 @@
1
+ python-dotenv
2
+ langchain
3
+ langgraph
4
+ langchain_openai
5
+ langchain_ibm
6
+ ibm_watsonx_ai>=1.2.8
7
+ openai
8
+ pyyaml
9
+ pandas
10
+ tqdm
11
+ pyyaml
12
+ streamlit
13
+ matplotlib
14
+ seaborn
15
+ langchain_community
16
+ numpy
17
+ argparse
@@ -0,0 +1 @@
1
+ clear_eval