yoriai 0.16.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.
- yoriai-0.16.0/LICENSE +202 -0
- yoriai-0.16.0/PKG-INFO +64 -0
- yoriai-0.16.0/README.md +41 -0
- yoriai-0.16.0/pyproject.toml +39 -0
- yoriai-0.16.0/setup.cfg +4 -0
- yoriai-0.16.0/src/yoriai/__init__.py +156 -0
- yoriai-0.16.0/src/yoriai/__main__.py +104 -0
- yoriai-0.16.0/src/yoriai/_repo/LICENSE +202 -0
- yoriai-0.16.0/src/yoriai/_repo/LOG.md +132 -0
- yoriai-0.16.0/src/yoriai/_repo/SPEC.md +244 -0
- yoriai-0.16.0/src/yoriai/_repo/VENDORED.json +56 -0
- yoriai-0.16.0/src/yoriai/_repo/WITNESS.md +207 -0
- yoriai-0.16.0/src/yoriai/_repo/log/key.json +7 -0
- yoriai-0.16.0/src/yoriai/_repo/python/afterai_core.py +421 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_compare.py +669 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_core.py +357 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_forecast.py +376 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_index.py +513 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_log.py +977 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_measure.py +487 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_report.py +224 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_verify.py +271 -0
- yoriai-0.16.0/src/yoriai/_repo/python/yoriai_witness.py +562 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/README.md +32 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/SHA256SUMS +26 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/afterai_core.py +421 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/badge.svg +1 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/ballots/A1.r1.json +34 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/ballots/A2.r1.json +34 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/ballots/A3.r1.json +34 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/ballots/A4.r1.json +34 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/definition.json +40 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/keys.json +13 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/prompts.txt +21 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/raw/A1.r1.json +46 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/raw/A2.r1.json +45 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/raw/A3.r1.json +43 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/raw/A4.r1.json +49 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/report.html +30 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/result.json +165 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/roster.json +82 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/votes.csv +13 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/witness/A1.r1.a1.ad4e95.json +16 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/witness/A2.r1.a1.7fef35.json +16 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/witness/A3.r1.a1.a8b8cc.json +16 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/witness/A4.r1.a1.bae16a.json +16 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/witness/attestors.json +31 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/yoriai_core.py +357 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/yoriai_report.py +224 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/yoriai_verify.py +235 -0
- yoriai-0.16.0/src/yoriai/_repo/records/witnessed-council-20261204/publish/yoriai_witness.py +501 -0
- yoriai-0.16.0/src/yoriai/_repo/vectors/check_log_python.py +102 -0
- yoriai-0.16.0/src/yoriai/_repo/vectors/check_python.py +31 -0
- yoriai-0.16.0/src/yoriai/_repo/vectors/check_witness_python.py +55 -0
- yoriai-0.16.0/src/yoriai/_repo/vectors/log-v1.json +5430 -0
- yoriai-0.16.0/src/yoriai/_repo/vectors/measure-v2.json +14670 -0
- yoriai-0.16.0/src/yoriai/_repo/vectors/witness-v1.json +4153 -0
- yoriai-0.16.0/src/yoriai/_repo/witness/attestors.json +31 -0
- yoriai-0.16.0/src/yoriai.egg-info/PKG-INFO +64 -0
- yoriai-0.16.0/src/yoriai.egg-info/SOURCES.txt +61 -0
- yoriai-0.16.0/src/yoriai.egg-info/dependency_links.txt +1 -0
- yoriai-0.16.0/src/yoriai.egg-info/entry_points.txt +2 -0
- yoriai-0.16.0/src/yoriai.egg-info/top_level.txt +1 -0
yoriai-0.16.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
yoriai-0.16.0/PKG-INFO
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: yoriai
|
|
3
|
+
Version: 0.16.0
|
|
4
|
+
Summary: How many independent judgements does a panel of AI judges hold? The YORIAI reference implementation, its conformance vectors, and checkers for its signed records.
|
|
5
|
+
Author: Yakumo Co., Ltd.
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://yoriai-ai.com
|
|
8
|
+
Project-URL: Source, https://github.com/ogasurfproject-jpg/yoriai
|
|
9
|
+
Project-URL: Specification, https://github.com/ogasurfproject-jpg/yoriai/blob/main/SPEC.md
|
|
10
|
+
Project-URL: Issues, https://github.com/ogasurfproject-jpg/yoriai/issues
|
|
11
|
+
Keywords: llm-as-a-judge,evaluation,ai-judges,effective-voters,inter-rater-reliability,transparency-log,conformance
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Software Development :: Testing
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# yoriai
|
|
25
|
+
|
|
26
|
+
When several AI judges agree, is that several opinions or one? `yoriai` measures how many independent judgements a panel of AI judges holds (yoriai-measure-v2), offline, with the same digits in every language.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
pip install yoriai
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import yoriai
|
|
34
|
+
|
|
35
|
+
answer = yoriai.measure({"votes": {
|
|
36
|
+
"judge-a": {"q1": "supported", "q2": "contradicted", "q3": "supported"},
|
|
37
|
+
"judge-b": {"q1": "supported", "q2": "contradicted", "q3": "not_supported"},
|
|
38
|
+
"judge-c": {"q1": "supported", "q2": "supported", "q3": "supported"},
|
|
39
|
+
}})
|
|
40
|
+
print(answer["effective_voters"], answer["reading"])
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
With the right answers (`"gold"`), the answer also gives each judge's accuracy, the majority's, the error correlation between judges, Kish's effective number of judges, and the questions every judge got wrong together. With how people answered the same questions (`"reference"`), it says how many independent people the judges are worth. [SPEC.md](https://github.com/ogasurfproject-jpg/yoriai/blob/main/SPEC.md) fixes every number.
|
|
44
|
+
|
|
45
|
+
From the command line, with one judgement per row (`voter,question,label`):
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
yoriai measure judgements.csv --gold gold.csv
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Nothing leaves your machine unless you ask
|
|
52
|
+
|
|
53
|
+
`yoriai.measure(...)` runs the reference implementation in the package. `yoriai.measure(..., receipt=True)` and `yoriai measure ... --receipt` send the input to https://yoriai-ai.com, which measures it with the same code, records salted hashes of the input and the answer in a public append-only log (yoriai-log-v1, a Merkle tree like Certificate Transparency, its heads timestamped in Bitcoin), and returns a signed receipt. The package then checks the receipt itself: the signature against the log key it pins, the inclusion proof, the input and answer the receipt commits to, and the answer computed again. Anyone holding the receipt can check it later with `yoriai verify-receipt`.
|
|
54
|
+
|
|
55
|
+
## Check the package, not us
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
yoriai provenance # the commit the files come from; every SHA-256 checked
|
|
59
|
+
yoriai selftest # the repository's own conformance checkers: 111 measurement, 424 log and 72 witness vectors
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The files under `yoriai/_repo` are the repository's own, byte for byte: the reference implementation, the conformance vectors and their checkers, the pinned log key and attestor addresses, and the three specifications. The package adds only `yoriai/__init__.py` and `yoriai/__main__.py`.
|
|
63
|
+
|
|
64
|
+
Standard library only, Python 3.9 or later. Apache-2.0. By YORIAI (Yakumo Co., Ltd.). The JavaScript twin is `npm install yoriai`.
|
yoriai-0.16.0/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# yoriai
|
|
2
|
+
|
|
3
|
+
When several AI judges agree, is that several opinions or one? `yoriai` measures how many independent judgements a panel of AI judges holds (yoriai-measure-v2), offline, with the same digits in every language.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
pip install yoriai
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
import yoriai
|
|
11
|
+
|
|
12
|
+
answer = yoriai.measure({"votes": {
|
|
13
|
+
"judge-a": {"q1": "supported", "q2": "contradicted", "q3": "supported"},
|
|
14
|
+
"judge-b": {"q1": "supported", "q2": "contradicted", "q3": "not_supported"},
|
|
15
|
+
"judge-c": {"q1": "supported", "q2": "supported", "q3": "supported"},
|
|
16
|
+
}})
|
|
17
|
+
print(answer["effective_voters"], answer["reading"])
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
With the right answers (`"gold"`), the answer also gives each judge's accuracy, the majority's, the error correlation between judges, Kish's effective number of judges, and the questions every judge got wrong together. With how people answered the same questions (`"reference"`), it says how many independent people the judges are worth. [SPEC.md](https://github.com/ogasurfproject-jpg/yoriai/blob/main/SPEC.md) fixes every number.
|
|
21
|
+
|
|
22
|
+
From the command line, with one judgement per row (`voter,question,label`):
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
yoriai measure judgements.csv --gold gold.csv
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Nothing leaves your machine unless you ask
|
|
29
|
+
|
|
30
|
+
`yoriai.measure(...)` runs the reference implementation in the package. `yoriai.measure(..., receipt=True)` and `yoriai measure ... --receipt` send the input to https://yoriai-ai.com, which measures it with the same code, records salted hashes of the input and the answer in a public append-only log (yoriai-log-v1, a Merkle tree like Certificate Transparency, its heads timestamped in Bitcoin), and returns a signed receipt. The package then checks the receipt itself: the signature against the log key it pins, the inclusion proof, the input and answer the receipt commits to, and the answer computed again. Anyone holding the receipt can check it later with `yoriai verify-receipt`.
|
|
31
|
+
|
|
32
|
+
## Check the package, not us
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
yoriai provenance # the commit the files come from; every SHA-256 checked
|
|
36
|
+
yoriai selftest # the repository's own conformance checkers: 111 measurement, 424 log and 72 witness vectors
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The files under `yoriai/_repo` are the repository's own, byte for byte: the reference implementation, the conformance vectors and their checkers, the pinned log key and attestor addresses, and the three specifications. The package adds only `yoriai/__init__.py` and `yoriai/__main__.py`.
|
|
40
|
+
|
|
41
|
+
Standard library only, Python 3.9 or later. Apache-2.0. By YORIAI (Yakumo Co., Ltd.). The JavaScript twin is `npm install yoriai`.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "yoriai"
|
|
7
|
+
version = "0.16.0"
|
|
8
|
+
description = "How many independent judgements does a panel of AI judges hold? The YORIAI reference implementation, its conformance vectors, and checkers for its signed records."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
authors = [{ name = "Yakumo Co., Ltd." }]
|
|
14
|
+
keywords = ["llm-as-a-judge", "evaluation", "ai-judges", "effective-voters", "inter-rater-reliability", "transparency-log", "conformance"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
22
|
+
"Topic :: Software Development :: Testing",
|
|
23
|
+
]
|
|
24
|
+
dependencies = []
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://yoriai-ai.com"
|
|
28
|
+
Source = "https://github.com/ogasurfproject-jpg/yoriai"
|
|
29
|
+
Specification = "https://github.com/ogasurfproject-jpg/yoriai/blob/main/SPEC.md"
|
|
30
|
+
Issues = "https://github.com/ogasurfproject-jpg/yoriai/issues"
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
yoriai = "yoriai.__main__:main"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.packages.find]
|
|
36
|
+
where = ["src"]
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.package-data]
|
|
39
|
+
yoriai = ["_repo/**/*"]
|
yoriai-0.16.0/setup.cfg
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""YORIAI: how many independent judgements a panel of AI judges holds.
|
|
2
|
+
|
|
3
|
+
import yoriai
|
|
4
|
+
answer = yoriai.measure({"votes": {"judge-a": {"q1": "yes", "q2": "no"},
|
|
5
|
+
"judge-b": {"q1": "yes", "q2": "yes"}}})
|
|
6
|
+
answer["effective_voters"]
|
|
7
|
+
|
|
8
|
+
measure() is offline: it runs the reference implementation of yoriai-measure-v2 that ships in this package and
|
|
9
|
+
sends nothing anywhere. measure(..., receipt=True) asks https://yoriai-ai.com to measure the same input and record
|
|
10
|
+
it in the public measurement log (yoriai-log-v1), then checks the signed receipt here, including that the answer is
|
|
11
|
+
what this package computes; the input leaves your machine only in that case.
|
|
12
|
+
|
|
13
|
+
The files under yoriai/_repo are the repository's own (https://github.com/ogasurfproject-jpg/yoriai), byte for
|
|
14
|
+
byte, at the commit _repo/VENDORED.json names; `python -m yoriai provenance` checks every SHA-256, and
|
|
15
|
+
`python -m yoriai selftest` runs the repository's conformance checkers on them. Standard library only.
|
|
16
|
+
"""
|
|
17
|
+
import csv
|
|
18
|
+
import hashlib
|
|
19
|
+
import importlib
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import subprocess
|
|
23
|
+
import sys
|
|
24
|
+
import urllib.error
|
|
25
|
+
import urllib.request
|
|
26
|
+
|
|
27
|
+
__version__ = "0.16.0"
|
|
28
|
+
SPEC = "yoriai-measure-v2"
|
|
29
|
+
BASE = "https://yoriai-ai.com"
|
|
30
|
+
__all__ = ["measure", "verify_receipt", "verify_witness", "votes_from_rows", "read_rows", "selftest", "provenance",
|
|
31
|
+
"REPO", "SPEC", "BASE", "__version__"]
|
|
32
|
+
|
|
33
|
+
_HERE = os.path.dirname(os.path.abspath(__file__))
|
|
34
|
+
# Installed: the vendored copy beside this file. From a checkout of the repository: the repository itself.
|
|
35
|
+
REPO = os.path.join(_HERE, "_repo")
|
|
36
|
+
if not os.path.isdir(REPO):
|
|
37
|
+
REPO = os.path.normpath(os.path.join(_HERE, "..", "..", "..", ".."))
|
|
38
|
+
_PY = os.path.join(REPO, "python")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _ref(name):
|
|
42
|
+
"""A reference module of _repo/python, loaded the way the repository's own scripts load it."""
|
|
43
|
+
if _PY not in sys.path:
|
|
44
|
+
sys.path.insert(0, _PY)
|
|
45
|
+
return importlib.import_module(name)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def measure(args, receipt=False, base=BASE, timeout=120):
|
|
49
|
+
"""The answer of yoriai-measure-v2 for args (the JSON the service takes: votes, and optionally options,
|
|
50
|
+
abstain_labels, seed, gold, reference, witnesses). An answer with an "error" key is a refusal.
|
|
51
|
+
|
|
52
|
+
receipt=True: the same input goes to base/measure, the answer comes back with a signed receipt from the
|
|
53
|
+
public log, and the receipt is checked here (signature, leaf, inclusion in the signed head, the input and
|
|
54
|
+
answer it commits to, and the answer computed again). Raises RuntimeError when any check fails."""
|
|
55
|
+
if not receipt:
|
|
56
|
+
return _ref("yoriai_measure").measure(args)
|
|
57
|
+
body = dict(args)
|
|
58
|
+
body["receipt"] = True
|
|
59
|
+
answer = _post(base.rstrip("/") + "/measure", body, timeout)
|
|
60
|
+
if "error" in answer:
|
|
61
|
+
return answer
|
|
62
|
+
rec = answer.get("receipt")
|
|
63
|
+
if not isinstance(rec, dict):
|
|
64
|
+
raise RuntimeError("the service answered without a receipt")
|
|
65
|
+
failed = [c for c in verify_receipt(rec, request=body, answer=answer) if not c["ok"]]
|
|
66
|
+
if failed:
|
|
67
|
+
raise RuntimeError("the receipt does not check: " + "; ".join("%s (%s)" % (c["check"], c["why"]) for c in failed))
|
|
68
|
+
return answer
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def verify_receipt(receipt, request=None, answer=None, key=None):
|
|
72
|
+
"""Checks a receipt of the public log on its own, against the log key pinned in this package (or key). With the
|
|
73
|
+
request and the answer it also checks that they are the ones the receipt commits to, and computes the answer
|
|
74
|
+
again. Returns a list of {"check", "ok", "why"}, in the order of the reference checkers."""
|
|
75
|
+
yl = _ref("yoriai_log")
|
|
76
|
+
key = key or yl._pinned_key()
|
|
77
|
+
rows = yl.check_receipt(receipt, key=key, request=request, answer=answer)
|
|
78
|
+
return [{"check": n, "ok": ok, "why": why} for n, ok, why in rows]
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def verify_witness(record, expect=None, attestors=None):
|
|
82
|
+
"""Checks a witnessed model call (yoriai-witness-v1): the attestor's signature over the provider's own reply,
|
|
83
|
+
against the attestor addresses pinned in this package. expect: {"provider", "model", "system", "user"} to insist
|
|
84
|
+
on. Returns the reference checker's result: {"checks": [(name, ok, why)], "reply": ..., "after_block": ...}."""
|
|
85
|
+
yw = _ref("yoriai_witness")
|
|
86
|
+
if attestors is None:
|
|
87
|
+
attestors = yw.load_attestors(yw.ATTESTORS_FILE)
|
|
88
|
+
return yw.check_witness(record, attestors, expect)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def read_rows(path):
|
|
92
|
+
"""Rows of a CSV file (with a header) or a JSON Lines file, as dictionaries."""
|
|
93
|
+
with open(path, encoding="utf-8-sig", newline="") as f:
|
|
94
|
+
if path.lower().endswith((".jsonl", ".ndjson")):
|
|
95
|
+
return [json.loads(line) for line in f if line.strip()]
|
|
96
|
+
return list(csv.DictReader(f))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def votes_from_rows(rows, voter="voter", question="question", label="label"):
|
|
100
|
+
"""The votes object from long-format rows, one per judgement: {voter: {question: label}}. A row with an empty
|
|
101
|
+
label is no answer. The same voter answering the same question twice is an error."""
|
|
102
|
+
votes = {}
|
|
103
|
+
for k, r in enumerate(rows):
|
|
104
|
+
try:
|
|
105
|
+
v, q, lb = r[voter], r[question], r[label]
|
|
106
|
+
except KeyError as e:
|
|
107
|
+
raise ValueError("row %d has no column %s (columns: %s)" % (k + 1, e, ", ".join(map(str, r))))
|
|
108
|
+
if lb is None or str(lb) == "":
|
|
109
|
+
continue
|
|
110
|
+
v, q = str(v), str(q)
|
|
111
|
+
if q in votes.get(v, {}):
|
|
112
|
+
raise ValueError("voter %r answered question %r twice" % (v, q))
|
|
113
|
+
votes.setdefault(v, {})[q] = str(lb)
|
|
114
|
+
return votes
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def selftest():
|
|
118
|
+
"""Runs the repository's own conformance checkers (vectors/check_python.py) on the files of this package.
|
|
119
|
+
Returns (passed, output)."""
|
|
120
|
+
p = subprocess.run([sys.executable, os.path.join(REPO, "vectors", "check_python.py")], capture_output=True,
|
|
121
|
+
text=True, stdin=subprocess.DEVNULL)
|
|
122
|
+
out = (p.stdout + p.stderr).strip()
|
|
123
|
+
return p.returncode == 0 and out.splitlines()[-1:] == ["VECTORS_PASS"], out
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def provenance():
|
|
127
|
+
"""The commit the vendored files come from and, for each, whether its bytes still have the SHA-256 recorded
|
|
128
|
+
when the package was built. Returns {"commit", "files", "mismatched", "missing"}."""
|
|
129
|
+
path = os.path.join(REPO, "VENDORED.json")
|
|
130
|
+
if not os.path.exists(path):
|
|
131
|
+
return {"commit": None, "files": 0, "mismatched": [], "missing": [], "note": "running from a checkout"}
|
|
132
|
+
doc = json.load(open(path, encoding="utf-8"))
|
|
133
|
+
bad, missing = [], []
|
|
134
|
+
for rel, want in sorted(doc["files"].items()):
|
|
135
|
+
p = os.path.join(REPO, *rel.split("/"))
|
|
136
|
+
if not os.path.exists(p):
|
|
137
|
+
missing.append(rel)
|
|
138
|
+
elif hashlib.sha256(open(p, "rb").read()).hexdigest() != want:
|
|
139
|
+
bad.append(rel)
|
|
140
|
+
return {"commit": doc["commit"], "repository": doc["repository"], "files": len(doc["files"]),
|
|
141
|
+
"mismatched": bad, "missing": missing}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _post(url, body, timeout):
|
|
145
|
+
data = json.dumps(body, ensure_ascii=False).encode("utf-8")
|
|
146
|
+
req = urllib.request.Request(url, data=data, method="POST", headers={
|
|
147
|
+
"content-type": "application/json", "accept": "application/json", "user-agent": "yoriai-python/" + __version__})
|
|
148
|
+
try:
|
|
149
|
+
with urllib.request.urlopen(req, timeout=timeout) as r:
|
|
150
|
+
return json.loads(r.read().decode("utf-8"))
|
|
151
|
+
except urllib.error.HTTPError as e:
|
|
152
|
+
text = e.read().decode("utf-8", "replace")
|
|
153
|
+
try:
|
|
154
|
+
return json.loads(text)
|
|
155
|
+
except ValueError:
|
|
156
|
+
raise RuntimeError("HTTP %d from %s: %s" % (e.code, url, text[:300]))
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""yoriai: how many independent judgements a panel of AI judges holds (yoriai-measure-v2).
|
|
2
|
+
|
|
3
|
+
yoriai measure INPUT.json the answer, offline (INPUT is the JSON the service takes)
|
|
4
|
+
yoriai measure VOTES.csv [--gold GOLD.csv] long format, one judgement per row: voter,question,label
|
|
5
|
+
(GOLD: question,label); JSON Lines works the same way
|
|
6
|
+
yoriai measure ... --receipt measure at https://yoriai-ai.com, record it in the public log,
|
|
7
|
+
and check the signed receipt here (the input is sent)
|
|
8
|
+
yoriai measure ... --out ANSWER.json also write the answer to a file
|
|
9
|
+
yoriai verify-receipt ANSWER.json [--request REQUEST.json]
|
|
10
|
+
check a receipt of the public log (the repository's own checker)
|
|
11
|
+
yoriai verify-witness RECORD.json [--request REQUEST.json] [--live]
|
|
12
|
+
check a witnessed model call (yoriai-witness-v1)
|
|
13
|
+
yoriai selftest the repository's conformance checkers, on this package's files
|
|
14
|
+
yoriai provenance the commit the files come from, and every SHA-256 checked
|
|
15
|
+
yoriai version
|
|
16
|
+
|
|
17
|
+
Exit status: 0 when the command succeeded, 1 when a check failed or the input was refused, 2 on a usage error.
|
|
18
|
+
"""
|
|
19
|
+
import json
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
import yoriai
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _opts(argv, flags=()):
|
|
26
|
+
pos, opts, i = [], {}, 0
|
|
27
|
+
while i < len(argv):
|
|
28
|
+
a = argv[i]
|
|
29
|
+
if a in flags:
|
|
30
|
+
opts[a] = True
|
|
31
|
+
i += 1
|
|
32
|
+
elif a.startswith("--"):
|
|
33
|
+
if i + 1 >= len(argv):
|
|
34
|
+
raise SystemExit("yoriai: %s needs a value" % a)
|
|
35
|
+
opts[a] = argv[i + 1]
|
|
36
|
+
i += 2
|
|
37
|
+
else:
|
|
38
|
+
pos.append(a)
|
|
39
|
+
i += 1
|
|
40
|
+
return pos, opts
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _input(path, opts):
|
|
44
|
+
if path.lower().endswith(".json"):
|
|
45
|
+
with open(path, encoding="utf-8") as f:
|
|
46
|
+
args = json.load(f)
|
|
47
|
+
else:
|
|
48
|
+
args = {"votes": yoriai.votes_from_rows(yoriai.read_rows(path), opts.get("--voter", "voter"),
|
|
49
|
+
opts.get("--question", "question"), opts.get("--label", "label"))}
|
|
50
|
+
if "--gold" in opts:
|
|
51
|
+
rows = yoriai.read_rows(opts["--gold"])
|
|
52
|
+
args["gold"] = {str(r[opts.get("--question", "question")]): str(r[opts.get("--label", "label")])
|
|
53
|
+
for r in rows if str(r.get(opts.get("--label", "label")) or "") != ""}
|
|
54
|
+
return args
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def cmd_measure(argv):
|
|
58
|
+
pos, opts = _opts(argv, flags=("--receipt",))
|
|
59
|
+
if len(pos) != 1:
|
|
60
|
+
print(__doc__.strip())
|
|
61
|
+
return 2
|
|
62
|
+
answer = yoriai.measure(_input(pos[0], opts), receipt=bool(opts.get("--receipt")), base=opts.get("--base", yoriai.BASE))
|
|
63
|
+
text = json.dumps(answer, ensure_ascii=False, indent=2)
|
|
64
|
+
if "--out" in opts:
|
|
65
|
+
with open(opts["--out"], "w", encoding="utf-8") as f:
|
|
66
|
+
f.write(text + "\n")
|
|
67
|
+
print(text)
|
|
68
|
+
return 1 if "error" in answer else 0
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def main(argv=None):
|
|
72
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
73
|
+
cmd, rest = (argv[0], argv[1:]) if argv else ("", [])
|
|
74
|
+
try:
|
|
75
|
+
if cmd == "measure":
|
|
76
|
+
return cmd_measure(rest)
|
|
77
|
+
if cmd == "verify-receipt" and rest:
|
|
78
|
+
return yoriai._ref("yoriai_log").cmd_verify(rest)
|
|
79
|
+
if cmd == "verify-witness" and rest:
|
|
80
|
+
return yoriai._ref("yoriai_witness").main(["check"] + rest)
|
|
81
|
+
if cmd == "selftest":
|
|
82
|
+
ok, out = yoriai.selftest()
|
|
83
|
+
print(out)
|
|
84
|
+
return 0 if ok else 1
|
|
85
|
+
if cmd == "provenance":
|
|
86
|
+
p = yoriai.provenance()
|
|
87
|
+
print(json.dumps(p, indent=2))
|
|
88
|
+
if p["commit"] is None:
|
|
89
|
+
return 0
|
|
90
|
+
ok = not p["mismatched"] and not p["missing"]
|
|
91
|
+
print("PROVENANCE_OK %d files, %s at %s" % (p["files"], p["repository"], p["commit"]) if ok else "PROVENANCE_FAILED")
|
|
92
|
+
return 0 if ok else 1
|
|
93
|
+
if cmd == "version":
|
|
94
|
+
print("yoriai %s (%s)" % (yoriai.__version__, yoriai.SPEC))
|
|
95
|
+
return 0
|
|
96
|
+
except (ValueError, OSError, RuntimeError) as e:
|
|
97
|
+
print("yoriai: %s" % e, file=sys.stderr)
|
|
98
|
+
return 1
|
|
99
|
+
print(__doc__.strip())
|
|
100
|
+
return 2
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
sys.exit(main())
|