valtron-core 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.
- valtron_core-0.1.0/LICENSE +201 -0
- valtron_core-0.1.0/PKG-INFO +248 -0
- valtron_core-0.1.0/README.md +202 -0
- valtron_core-0.1.0/pyproject.toml +88 -0
- valtron_core-0.1.0/src/valtron_core/__init__.py +3 -0
- valtron_core-0.1.0/src/valtron_core/__main__.py +16 -0
- valtron_core-0.1.0/src/valtron_core/attachments.py +32 -0
- valtron_core-0.1.0/src/valtron_core/bert_evaluator.py +227 -0
- valtron_core-0.1.0/src/valtron_core/bert_trainer.py +332 -0
- valtron_core-0.1.0/src/valtron_core/client.py +276 -0
- valtron_core-0.1.0/src/valtron_core/config.py +109 -0
- valtron_core-0.1.0/src/valtron_core/cost_utils.py +95 -0
- valtron_core-0.1.0/src/valtron_core/decompose.py +906 -0
- valtron_core-0.1.0/src/valtron_core/evaluation/__init__.py +0 -0
- valtron_core-0.1.0/src/valtron_core/evaluation/comparison_functions.py +607 -0
- valtron_core-0.1.0/src/valtron_core/evaluation/json_eval.py +557 -0
- valtron_core-0.1.0/src/valtron_core/evaluator.py +573 -0
- valtron_core-0.1.0/src/valtron_core/few_shot_training_data_generator.py +976 -0
- valtron_core-0.1.0/src/valtron_core/loader.py +382 -0
- valtron_core-0.1.0/src/valtron_core/models.py +331 -0
- valtron_core-0.1.0/src/valtron_core/optimized_evaluator.py +261 -0
- valtron_core-0.1.0/src/valtron_core/prompt_optimizer.py +474 -0
- valtron_core-0.1.0/src/valtron_core/recipes/README.md +122 -0
- valtron_core-0.1.0/src/valtron_core/recipes/__init__.py +25 -0
- valtron_core-0.1.0/src/valtron_core/recipes/base.py +223 -0
- valtron_core-0.1.0/src/valtron_core/recipes/config.py +146 -0
- valtron_core-0.1.0/src/valtron_core/recipes/model_eval.py +1118 -0
- valtron_core-0.1.0/src/valtron_core/report.py +1218 -0
- valtron_core-0.1.0/src/valtron_core/runner.py +1001 -0
- valtron_core-0.1.0/src/valtron_core/templates/common.css +36 -0
- valtron_core-0.1.0/src/valtron_core/templates/config_wizard.html +1191 -0
- valtron_core-0.1.0/src/valtron_core/templates/detailed_analysis.jinja2.html +1189 -0
- valtron_core-0.1.0/src/valtron_core/templates/evaluation_report.jinja2.html +3143 -0
- valtron_core-0.1.0/src/valtron_core/templates/pdf_report.jinja2.html +555 -0
- valtron_core-0.1.0/src/valtron_core/transformer_classifier.py +297 -0
- valtron_core-0.1.0/src/valtron_core/transformer_wrapper.py +86 -0
- valtron_core-0.1.0/src/valtron_core/utilities/__init__.py +1 -0
- valtron_core-0.1.0/src/valtron_core/utilities/aggregate_reports.py +359 -0
- valtron_core-0.1.0/src/valtron_core/utilities/cli_introspect.py +233 -0
- valtron_core-0.1.0/src/valtron_core/utilities/code_introspection.py +1076 -0
- valtron_core-0.1.0/src/valtron_core/utilities/config_wizard.py +255 -0
- valtron_core-0.1.0/src/valtron_core/utilities/field_config_generator.py +92 -0
- valtron_core-0.1.0/src/valtron_core/utilities/train_transformer.py +231 -0
|
@@ -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,248 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: valtron-core
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LLM call optimization across various providers (online and local models)
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: InferLink
|
|
8
|
+
Author-email: valtron@inferlink.com
|
|
9
|
+
Requires-Python: >=3.12,<4.0
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Dist: accelerate (>=1.12.0,<2.0.0)
|
|
18
|
+
Requires-Dist: datasets (>=2.14.0,<3.0.0)
|
|
19
|
+
Requires-Dist: flask (>=3.0.0,<4.0.0)
|
|
20
|
+
Requires-Dist: flask-cors (>=4.0.0,<5.0.0)
|
|
21
|
+
Requires-Dist: google-cloud-aiplatform (>=1.129.0,<2.0.0)
|
|
22
|
+
Requires-Dist: google-generativeai (>=0.8.5,<0.9.0)
|
|
23
|
+
Requires-Dist: jinja2 (>=3.1.0,<4.0.0)
|
|
24
|
+
Requires-Dist: litellm (>=1.0.0,<2.0.0)
|
|
25
|
+
Requires-Dist: matplotlib (>=3.8.0,<4.0.0)
|
|
26
|
+
Requires-Dist: nltk (>=3.9.2,<4.0.0)
|
|
27
|
+
Requires-Dist: plotly (>=5.18.0,<6.0.0)
|
|
28
|
+
Requires-Dist: pydantic (>=2.0,<3.0)
|
|
29
|
+
Requires-Dist: pydantic-settings (>=2.0,<3.0)
|
|
30
|
+
Requires-Dist: pydyf (>=0.11.0,<0.12.0)
|
|
31
|
+
Requires-Dist: pylatex (>=1.4.2,<2.0.0)
|
|
32
|
+
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
|
|
33
|
+
Requires-Dist: rapidfuzz (>=3.14.3,<4.0.0)
|
|
34
|
+
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
35
|
+
Requires-Dist: rich (>=13.0.0,<14.0.0)
|
|
36
|
+
Requires-Dist: scikit-learn (>=1.3.0,<2.0.0)
|
|
37
|
+
Requires-Dist: structlog (>=24.0.0,<25.0.0)
|
|
38
|
+
Requires-Dist: torch (>=2.1.0,<3.0.0)
|
|
39
|
+
Requires-Dist: transformers (>=4.35.0,<5.0.0)
|
|
40
|
+
Requires-Dist: typer (>=0.12.0,<0.13.0)
|
|
41
|
+
Requires-Dist: weasyprint (>=62.0,<63.0)
|
|
42
|
+
Project-URL: Documentation, https://valtron.ai/docs/
|
|
43
|
+
Project-URL: Homepage, https://github.com/inferlinkdev/valtron-core/
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
<div align="center">
|
|
47
|
+
|
|
48
|
+
# Valtron Core
|
|
49
|
+
|
|
50
|
+
[Documentation](https://valtron.ai/docs) · [Quick Start](#quick-start) · [Examples](#examples) · [Contributing](#contributing)
|
|
51
|
+
|
|
52
|
+
A Python framework for evaluating and optimizing LLM calls across any provider.
|
|
53
|
+
|
|
54
|
+
Proudly built and backed by [InferLink](https://inferlink.com).
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
Valtron lets you run the same task across multiple LLMs simultaneously, then compare them on accuracy, cost, and speed. Define a prompt, a labeled dataset, and the models you want to test — Valtron evaluates each one, scores the results, and produces an interactive HTML/PDF report with an AI recommendation.
|
|
61
|
+
|
|
62
|
+
## Features
|
|
63
|
+
|
|
64
|
+
- **Multi-model comparison** — run GPT-4o, Claude, Gemini, Llama, and any LiteLLM-compatible model side-by-side on the same dataset
|
|
65
|
+
- **Detailed evaluation** — label classification (string match) and structured extraction (nested JSON with field-level precision/recall/F1)
|
|
66
|
+
- **Prompt optimization** — seven built-in strategies (few-shot generation, chain-of-thought, decomposition, hallucination filtering, and more) applied per model
|
|
67
|
+
- **Cost and latency tracking** — per-document and aggregate cost, response time, and accuracy metrics
|
|
68
|
+
- **HTML and PDF reports** — interactive charts, per-document breakdowns, and an AI-generated recommendation
|
|
69
|
+
- **Transformer training** — train a local DistilBERT classifier from your evaluation data for zero-cost inference
|
|
70
|
+
- **Self-hosted model support** — Ollama, vLLM, LM Studio, and more for free, private inference
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
### Prerequisites
|
|
75
|
+
|
|
76
|
+
- Python 3.12+
|
|
77
|
+
- [Poetry](https://python-poetry.org/) for dependency management
|
|
78
|
+
- Docker (optional)
|
|
79
|
+
|
|
80
|
+
### Install
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
poetry install
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Copy `.env.example` to `.env` and add at least one provider key:
|
|
87
|
+
|
|
88
|
+
```env
|
|
89
|
+
OPENAI_API_KEY=sk-...
|
|
90
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
91
|
+
GOOGLE_API_KEY=...
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Run an evaluation
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from valtron_core.recipes import ModelEval
|
|
98
|
+
|
|
99
|
+
data = [
|
|
100
|
+
{"id": "1", "content": "Fast shipping, exactly what I ordered.", "label": "positive"},
|
|
101
|
+
{"id": "2", "content": "Wrong item sent. Refund process was painful.", "label": "negative"},
|
|
102
|
+
{"id": "3", "content": "Average experience, nothing special.", "label": "neutral"},
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
config = {
|
|
106
|
+
"models": [
|
|
107
|
+
{"name": "gpt-4o-mini"},
|
|
108
|
+
{"name": "claude-haiku-4-5-20251001"},
|
|
109
|
+
],
|
|
110
|
+
"prompt": "Classify the sentiment of the following review as positive, negative, or neutral.\n\nReview: {document}\n\nSentiment:",
|
|
111
|
+
"output_dir": "./results",
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
experiment = ModelEval(config=config, data=data)
|
|
115
|
+
report_path = experiment.run()
|
|
116
|
+
print(f"Report: {report_path}")
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Open `./results/evaluation_report.html` to see accuracy, cost, latency, and a recommendation.
|
|
120
|
+
|
|
121
|
+
## Configuration
|
|
122
|
+
|
|
123
|
+
The config accepts a dict, a JSON file path, or a typed `ModelEvalConfig` object. Key fields:
|
|
124
|
+
|
|
125
|
+
| Field | Required | Description |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| `models` | Yes | Models to evaluate; each has a `name` and optional `prompt_manipulation` list |
|
|
128
|
+
| `prompt` | Yes | Prompt template containing `{document}` |
|
|
129
|
+
| `output_dir` | No | Where to write results (can also be passed to `run()`) |
|
|
130
|
+
| `few_shot` | No | Settings for few-shot example generation |
|
|
131
|
+
| `output_formats` | No | `["html"]` by default; add `"pdf"` for a PDF report |
|
|
132
|
+
|
|
133
|
+
**Prompt manipulation options** (set per model via `"prompt_manipulation": [...]`):
|
|
134
|
+
|
|
135
|
+
- `"explanation"` — add chain-of-thought reasoning before the answer
|
|
136
|
+
- `"few_shot"` — inject generated few-shot examples into the prompt
|
|
137
|
+
- `"decompose"` — split the prompt into sequential sub-calls *(structured extraction only)*
|
|
138
|
+
- `"hallucination_filter"` — drop extracted values not grounded in the source text *(structured extraction only)*
|
|
139
|
+
- `"multi_pass"` — call the model twice and merge results *(structured extraction only)*
|
|
140
|
+
|
|
141
|
+
See [Config Format](https://valtron.ai/docs/config-format) for the full reference, including field-level metrics, structured extraction, and few-shot settings.
|
|
142
|
+
|
|
143
|
+
**Prefer a guided setup?** The Configuration Wizard is a browser-based UI that builds your config file step by step:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
poetry run python -m valtron_core.utilities.config_wizard
|
|
147
|
+
# or with Docker
|
|
148
|
+
docker compose run --rm -p 5000:5000 server poetry run python -m valtron_core.utilities.config_wizard
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Open `http://localhost:5000` in your browser.
|
|
152
|
+
|
|
153
|
+
## Examples
|
|
154
|
+
|
|
155
|
+
| Script | What it demonstrates |
|
|
156
|
+
|---|---|
|
|
157
|
+
| `examples/sentiment_classification.py` | Label classification across two models |
|
|
158
|
+
| `examples/affiliation_extraction.py` | Structured extraction with field-level metrics |
|
|
159
|
+
| `examples/transformer_comparison.py` | Train a local transformer and compare against cloud LLMs |
|
|
160
|
+
| `examples/multimodal_molecules.py` | Multimodal classification with image attachments |
|
|
161
|
+
| `examples/incremental_evaluation.py` | Load a prior run and add new models without re-evaluating |
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Run any example
|
|
165
|
+
poetry run python examples/sentiment_classification.py
|
|
166
|
+
|
|
167
|
+
# With Docker
|
|
168
|
+
docker compose run --rm server poetry run python examples/sentiment_classification.py
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
See [Examples](https://valtron.ai/docs/examples/) for detailed walkthroughs.
|
|
172
|
+
|
|
173
|
+
## Docker
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Build the image (first run is slow; installs system dependencies including LaTeX)
|
|
177
|
+
docker compose build server
|
|
178
|
+
|
|
179
|
+
# Run an example
|
|
180
|
+
docker compose run --rm server poetry run python examples/sentiment_classification.py
|
|
181
|
+
|
|
182
|
+
# Interactive shell
|
|
183
|
+
docker compose run --rm --service-ports server bash
|
|
184
|
+
|
|
185
|
+
# Run the test suite
|
|
186
|
+
docker compose run --rm pipeline-test
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
> **Using Ollama with Docker?** Set `OLLAMA_API_BASE=http://host.docker.internal:11434` in `.env` so the container can reach Ollama running on your host.
|
|
190
|
+
|
|
191
|
+
## Development
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Install dependencies
|
|
195
|
+
poetry install
|
|
196
|
+
|
|
197
|
+
# Run tests
|
|
198
|
+
poetry run pytest
|
|
199
|
+
|
|
200
|
+
# Run with coverage
|
|
201
|
+
poetry run pytest --cov=src/valtron_core --cov-report=html
|
|
202
|
+
|
|
203
|
+
# Format and lint
|
|
204
|
+
poetry run black src/ tests/
|
|
205
|
+
poetry run ruff check src/ tests/
|
|
206
|
+
poetry run mypy src/
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The test suite covers the evaluation pipeline, report generation, prompt optimizers, few-shot generation, transformer training, and the `ModelEval` recipe. The Docker Compose `pipeline-test` service runs the full suite with coverage and JUnit XML output.
|
|
210
|
+
|
|
211
|
+
## Architecture
|
|
212
|
+
|
|
213
|
+
Valtron is built on [LiteLLM](https://github.com/BerriAI/litellm), which provides a unified interface to 100+ LLM providers. On top of that, Valtron adds the evaluation pipeline, prompt optimization strategies, report generation, and transformer training:
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
Input data (documents + expected labels)
|
|
217
|
+
↓
|
|
218
|
+
Config (models, prompt, optimizations)
|
|
219
|
+
↓
|
|
220
|
+
ModelEval.run()
|
|
221
|
+
├── Generate few-shot examples (optional)
|
|
222
|
+
├── Prepare per-model prompts (apply manipulations)
|
|
223
|
+
├── Evaluate all models concurrently
|
|
224
|
+
├── Compute metrics (accuracy, cost, time, field scores)
|
|
225
|
+
└── Generate report (HTML + optional PDF)
|
|
226
|
+
↓
|
|
227
|
+
evaluation_report.html · models/*.json · metadata.json
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Full documentation lives in [docs/valtron/](https://valtron.ai/docs/intro). To run the docs site locally:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
cd docs/valtron && docker compose up
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Then open `http://localhost:3000`.
|
|
237
|
+
|
|
238
|
+
## Contributing
|
|
239
|
+
|
|
240
|
+
1. Fork the repository
|
|
241
|
+
2. Create a feature branch
|
|
242
|
+
3. Make your changes and run the test suite
|
|
243
|
+
4. Submit a pull request
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
TBD
|
|
248
|
+
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Valtron Core
|
|
4
|
+
|
|
5
|
+
[Documentation](https://valtron.ai/docs) · [Quick Start](#quick-start) · [Examples](#examples) · [Contributing](#contributing)
|
|
6
|
+
|
|
7
|
+
A Python framework for evaluating and optimizing LLM calls across any provider.
|
|
8
|
+
|
|
9
|
+
Proudly built and backed by [InferLink](https://inferlink.com).
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
Valtron lets you run the same task across multiple LLMs simultaneously, then compare them on accuracy, cost, and speed. Define a prompt, a labeled dataset, and the models you want to test — Valtron evaluates each one, scores the results, and produces an interactive HTML/PDF report with an AI recommendation.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Multi-model comparison** — run GPT-4o, Claude, Gemini, Llama, and any LiteLLM-compatible model side-by-side on the same dataset
|
|
20
|
+
- **Detailed evaluation** — label classification (string match) and structured extraction (nested JSON with field-level precision/recall/F1)
|
|
21
|
+
- **Prompt optimization** — seven built-in strategies (few-shot generation, chain-of-thought, decomposition, hallucination filtering, and more) applied per model
|
|
22
|
+
- **Cost and latency tracking** — per-document and aggregate cost, response time, and accuracy metrics
|
|
23
|
+
- **HTML and PDF reports** — interactive charts, per-document breakdowns, and an AI-generated recommendation
|
|
24
|
+
- **Transformer training** — train a local DistilBERT classifier from your evaluation data for zero-cost inference
|
|
25
|
+
- **Self-hosted model support** — Ollama, vLLM, LM Studio, and more for free, private inference
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### Prerequisites
|
|
30
|
+
|
|
31
|
+
- Python 3.12+
|
|
32
|
+
- [Poetry](https://python-poetry.org/) for dependency management
|
|
33
|
+
- Docker (optional)
|
|
34
|
+
|
|
35
|
+
### Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
poetry install
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Copy `.env.example` to `.env` and add at least one provider key:
|
|
42
|
+
|
|
43
|
+
```env
|
|
44
|
+
OPENAI_API_KEY=sk-...
|
|
45
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
46
|
+
GOOGLE_API_KEY=...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Run an evaluation
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from valtron_core.recipes import ModelEval
|
|
53
|
+
|
|
54
|
+
data = [
|
|
55
|
+
{"id": "1", "content": "Fast shipping, exactly what I ordered.", "label": "positive"},
|
|
56
|
+
{"id": "2", "content": "Wrong item sent. Refund process was painful.", "label": "negative"},
|
|
57
|
+
{"id": "3", "content": "Average experience, nothing special.", "label": "neutral"},
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
config = {
|
|
61
|
+
"models": [
|
|
62
|
+
{"name": "gpt-4o-mini"},
|
|
63
|
+
{"name": "claude-haiku-4-5-20251001"},
|
|
64
|
+
],
|
|
65
|
+
"prompt": "Classify the sentiment of the following review as positive, negative, or neutral.\n\nReview: {document}\n\nSentiment:",
|
|
66
|
+
"output_dir": "./results",
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
experiment = ModelEval(config=config, data=data)
|
|
70
|
+
report_path = experiment.run()
|
|
71
|
+
print(f"Report: {report_path}")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Open `./results/evaluation_report.html` to see accuracy, cost, latency, and a recommendation.
|
|
75
|
+
|
|
76
|
+
## Configuration
|
|
77
|
+
|
|
78
|
+
The config accepts a dict, a JSON file path, or a typed `ModelEvalConfig` object. Key fields:
|
|
79
|
+
|
|
80
|
+
| Field | Required | Description |
|
|
81
|
+
|---|---|---|
|
|
82
|
+
| `models` | Yes | Models to evaluate; each has a `name` and optional `prompt_manipulation` list |
|
|
83
|
+
| `prompt` | Yes | Prompt template containing `{document}` |
|
|
84
|
+
| `output_dir` | No | Where to write results (can also be passed to `run()`) |
|
|
85
|
+
| `few_shot` | No | Settings for few-shot example generation |
|
|
86
|
+
| `output_formats` | No | `["html"]` by default; add `"pdf"` for a PDF report |
|
|
87
|
+
|
|
88
|
+
**Prompt manipulation options** (set per model via `"prompt_manipulation": [...]`):
|
|
89
|
+
|
|
90
|
+
- `"explanation"` — add chain-of-thought reasoning before the answer
|
|
91
|
+
- `"few_shot"` — inject generated few-shot examples into the prompt
|
|
92
|
+
- `"decompose"` — split the prompt into sequential sub-calls *(structured extraction only)*
|
|
93
|
+
- `"hallucination_filter"` — drop extracted values not grounded in the source text *(structured extraction only)*
|
|
94
|
+
- `"multi_pass"` — call the model twice and merge results *(structured extraction only)*
|
|
95
|
+
|
|
96
|
+
See [Config Format](https://valtron.ai/docs/config-format) for the full reference, including field-level metrics, structured extraction, and few-shot settings.
|
|
97
|
+
|
|
98
|
+
**Prefer a guided setup?** The Configuration Wizard is a browser-based UI that builds your config file step by step:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
poetry run python -m valtron_core.utilities.config_wizard
|
|
102
|
+
# or with Docker
|
|
103
|
+
docker compose run --rm -p 5000:5000 server poetry run python -m valtron_core.utilities.config_wizard
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Open `http://localhost:5000` in your browser.
|
|
107
|
+
|
|
108
|
+
## Examples
|
|
109
|
+
|
|
110
|
+
| Script | What it demonstrates |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `examples/sentiment_classification.py` | Label classification across two models |
|
|
113
|
+
| `examples/affiliation_extraction.py` | Structured extraction with field-level metrics |
|
|
114
|
+
| `examples/transformer_comparison.py` | Train a local transformer and compare against cloud LLMs |
|
|
115
|
+
| `examples/multimodal_molecules.py` | Multimodal classification with image attachments |
|
|
116
|
+
| `examples/incremental_evaluation.py` | Load a prior run and add new models without re-evaluating |
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Run any example
|
|
120
|
+
poetry run python examples/sentiment_classification.py
|
|
121
|
+
|
|
122
|
+
# With Docker
|
|
123
|
+
docker compose run --rm server poetry run python examples/sentiment_classification.py
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
See [Examples](https://valtron.ai/docs/examples/) for detailed walkthroughs.
|
|
127
|
+
|
|
128
|
+
## Docker
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Build the image (first run is slow; installs system dependencies including LaTeX)
|
|
132
|
+
docker compose build server
|
|
133
|
+
|
|
134
|
+
# Run an example
|
|
135
|
+
docker compose run --rm server poetry run python examples/sentiment_classification.py
|
|
136
|
+
|
|
137
|
+
# Interactive shell
|
|
138
|
+
docker compose run --rm --service-ports server bash
|
|
139
|
+
|
|
140
|
+
# Run the test suite
|
|
141
|
+
docker compose run --rm pipeline-test
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
> **Using Ollama with Docker?** Set `OLLAMA_API_BASE=http://host.docker.internal:11434` in `.env` so the container can reach Ollama running on your host.
|
|
145
|
+
|
|
146
|
+
## Development
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Install dependencies
|
|
150
|
+
poetry install
|
|
151
|
+
|
|
152
|
+
# Run tests
|
|
153
|
+
poetry run pytest
|
|
154
|
+
|
|
155
|
+
# Run with coverage
|
|
156
|
+
poetry run pytest --cov=src/valtron_core --cov-report=html
|
|
157
|
+
|
|
158
|
+
# Format and lint
|
|
159
|
+
poetry run black src/ tests/
|
|
160
|
+
poetry run ruff check src/ tests/
|
|
161
|
+
poetry run mypy src/
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The test suite covers the evaluation pipeline, report generation, prompt optimizers, few-shot generation, transformer training, and the `ModelEval` recipe. The Docker Compose `pipeline-test` service runs the full suite with coverage and JUnit XML output.
|
|
165
|
+
|
|
166
|
+
## Architecture
|
|
167
|
+
|
|
168
|
+
Valtron is built on [LiteLLM](https://github.com/BerriAI/litellm), which provides a unified interface to 100+ LLM providers. On top of that, Valtron adds the evaluation pipeline, prompt optimization strategies, report generation, and transformer training:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
Input data (documents + expected labels)
|
|
172
|
+
↓
|
|
173
|
+
Config (models, prompt, optimizations)
|
|
174
|
+
↓
|
|
175
|
+
ModelEval.run()
|
|
176
|
+
├── Generate few-shot examples (optional)
|
|
177
|
+
├── Prepare per-model prompts (apply manipulations)
|
|
178
|
+
├── Evaluate all models concurrently
|
|
179
|
+
├── Compute metrics (accuracy, cost, time, field scores)
|
|
180
|
+
└── Generate report (HTML + optional PDF)
|
|
181
|
+
↓
|
|
182
|
+
evaluation_report.html · models/*.json · metadata.json
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Full documentation lives in [docs/valtron/](https://valtron.ai/docs/intro). To run the docs site locally:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
cd docs/valtron && docker compose up
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Then open `http://localhost:3000`.
|
|
192
|
+
|
|
193
|
+
## Contributing
|
|
194
|
+
|
|
195
|
+
1. Fork the repository
|
|
196
|
+
2. Create a feature branch
|
|
197
|
+
3. Make your changes and run the test suite
|
|
198
|
+
4. Submit a pull request
|
|
199
|
+
|
|
200
|
+
## License
|
|
201
|
+
|
|
202
|
+
TBD
|