sieve-probe 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.
- sieve_probe-0.1.0/CHANGELOG.md +8 -0
- sieve_probe-0.1.0/LICENSE +21 -0
- sieve_probe-0.1.0/MANIFEST.in +10 -0
- sieve_probe-0.1.0/PKG-INFO +150 -0
- sieve_probe-0.1.0/README.ja.md +121 -0
- sieve_probe-0.1.0/README.md +130 -0
- sieve_probe-0.1.0/conftest.py +11 -0
- sieve_probe-0.1.0/docs/normalization.ja.md +50 -0
- sieve_probe-0.1.0/docs/normalization.md +54 -0
- sieve_probe-0.1.0/pyproject.toml +36 -0
- sieve_probe-0.1.0/setup.cfg +4 -0
- sieve_probe-0.1.0/sieve_probe/__init__.py +5 -0
- sieve_probe-0.1.0/sieve_probe/__main__.py +8 -0
- sieve_probe-0.1.0/sieve_probe/cli.py +212 -0
- sieve_probe-0.1.0/sieve_probe/data/public-1.json +53 -0
- sieve_probe-0.1.0/sieve_probe/engine.py +179 -0
- sieve_probe-0.1.0/sieve_probe/fixedmath.py +69 -0
- sieve_probe-0.1.0/sieve_probe/inputs.py +224 -0
- sieve_probe-0.1.0/sieve_probe/normalize.py +31 -0
- sieve_probe-0.1.0/sieve_probe/publicdata.py +14 -0
- sieve_probe-0.1.0/sieve_probe.egg-info/PKG-INFO +150 -0
- sieve_probe-0.1.0/sieve_probe.egg-info/SOURCES.txt +35 -0
- sieve_probe-0.1.0/sieve_probe.egg-info/dependency_links.txt +1 -0
- sieve_probe-0.1.0/sieve_probe.egg-info/entry_points.txt +2 -0
- sieve_probe-0.1.0/sieve_probe.egg-info/top_level.txt +1 -0
- sieve_probe-0.1.0/tests/public_text_baseline.json +1 -0
- sieve_probe-0.1.0/tests/test_cli.py +370 -0
- sieve_probe-0.1.0/tests/test_engine.py +251 -0
- sieve_probe-0.1.0/tests/test_inputs.py +256 -0
- sieve_probe-0.1.0/tests/test_normalize.py +68 -0
- sieve_probe-0.1.0/tests/test_public_text.py +417 -0
- sieve_probe-0.1.0/tests/test_scaling.py +83 -0
- sieve_probe-0.1.0/tests/test_structure.py +490 -0
- sieve_probe-0.1.0/tools/check_public_text.py +299 -0
- sieve_probe-0.1.0/tools/check_release_assets.py +125 -0
- sieve_probe-0.1.0/tools/check_release_version.py +78 -0
- sieve_probe-0.1.0/tools/extract_changelog.py +56 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## [0.1.0] - 2026-12-01
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- The `battery` command prints the bundled public battery `public-1`: twelve one-word prompts, as text or JSON, so answers can be collected with the user's own means.
|
|
6
|
+
- The `validate` command checks an observation or battery file and reports every format problem as one closed reason word.
|
|
7
|
+
- The `compare` command measures the Jensen-Shannon distance (base 2, no square root) between a recording and each reference on the shared cells, the parity-split noise of every input, the ranks and the closed status words, with the allowance rule and the exit codes.
|
|
8
|
+
- Exact fraction arithmetic with a fixed-point logarithm: identical inputs give byte-identical outputs on every operating system, rounded to six decimals once before the output; the JSON output carries the input hashes and never an answer string.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kai IWASAKI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
include LICENSE
|
|
2
|
+
include CHANGELOG.md
|
|
3
|
+
include conftest.py
|
|
4
|
+
include README.md
|
|
5
|
+
include README.ja.md
|
|
6
|
+
recursive-include tools *.py
|
|
7
|
+
recursive-include tests *.py *.json
|
|
8
|
+
recursive-include docs *.md
|
|
9
|
+
recursive-include sieve_probe *.py *.json
|
|
10
|
+
global-exclude __pycache__ *.py[cod]
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sieve-probe
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Measure how close a distribution of one-word answers stays to declared reference distributions, with exact numbers and closed words
|
|
5
|
+
Author: Kai IWASAKI
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/neguseatama/sieve-probe
|
|
8
|
+
Project-URL: Repository, https://github.com/neguseatama/sieve-probe.git
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# Sieve Probe v0.1.0
|
|
22
|
+
|
|
23
|
+
Measure how close a distribution of one-word answers stays to the reference
|
|
24
|
+
distributions you declare. The output is a set of reproducible numbers and
|
|
25
|
+
closed words, computed on recordings you collected yourself. The tool
|
|
26
|
+
collects nothing: no network access, no keys, no dependencies beyond the
|
|
27
|
+
standard library. Python 3.10 or later.
|
|
28
|
+
|
|
29
|
+
The subject of this tool is the distribution of answers. It does not
|
|
30
|
+
identify models, vendors or versions; the reading of the numbers is yours.
|
|
31
|
+
|
|
32
|
+
## The five steps
|
|
33
|
+
|
|
34
|
+
1. Print the bundled public battery: `sieve-probe battery` (twelve one-word
|
|
35
|
+
prompts, battery `public-1`).
|
|
36
|
+
2. Collect one answer per sample with your own means. The tool never
|
|
37
|
+
collects anything.
|
|
38
|
+
3. Record the answers as an observation file (JSON, the shape is below).
|
|
39
|
+
Record the reference recordings in the same shape.
|
|
40
|
+
4. Compare: `sieve-probe compare OBS --reference NAME=FILE --declare NAME`.
|
|
41
|
+
5. Read the distances, the noise values, the ranks and the status words.
|
|
42
|
+
The exit code carries the same meaning.
|
|
43
|
+
|
|
44
|
+
## Commands
|
|
45
|
+
|
|
46
|
+
- `sieve-probe battery [--format text|json]` — print the bundled battery,
|
|
47
|
+
so answers can be collected against it. The battery is a starting point,
|
|
48
|
+
not a claimed-best set; new questions arrive with a version bump.
|
|
49
|
+
- `sieve-probe validate FILE` — check an observation or battery file; a
|
|
50
|
+
format problem is reported as exactly one closed reason word.
|
|
51
|
+
- `sieve-probe compare OBS --reference NAME=FILE [--reference ...]
|
|
52
|
+
--declare NAME [--min-samples N] [--min-cells N] [--format text|json]` —
|
|
53
|
+
the comparison on the shared cells.
|
|
54
|
+
- `sieve-probe --version`.
|
|
55
|
+
|
|
56
|
+
## The distance and the noise
|
|
57
|
+
|
|
58
|
+
- The distance is the Jensen-Shannon divergence (base 2, values from 0 to
|
|
59
|
+
1, no square root), computed per cell and averaged over the shared cells.
|
|
60
|
+
- The shared cells are the cells present in the observation and in every
|
|
61
|
+
reference whose total number of samples reaches `--min-samples` (default
|
|
62
|
+
20). Fewer than `--min-cells` (default 8) shared cells gives the status
|
|
63
|
+
`too_few_samples` and exit code 2.
|
|
64
|
+
- The noise of one recording splits every cell into even-index and
|
|
65
|
+
odd-index samples, measures the distance between the two halves, and
|
|
66
|
+
averages it over the shared cells (`s_obs` for the observation, `s_ref`
|
|
67
|
+
for a reference).
|
|
68
|
+
- The allowance: the distance to the declared reference is compared with
|
|
69
|
+
`s_obs + s_ref`. Within it, the status is `within_noise_allowance`;
|
|
70
|
+
above it, `beyond_noise_allowance`. The thresholds are fixed by design
|
|
71
|
+
and every number is printed, so the reading stays yours.
|
|
72
|
+
- The nearest reference is the one with the smallest distance; distances
|
|
73
|
+
within 0.000000001 of each other share a rank. The declared reference
|
|
74
|
+
inside that nearest group gives the status `nearest_is_declared`,
|
|
75
|
+
otherwise `nearest_is_other`.
|
|
76
|
+
|
|
77
|
+
## Exit codes
|
|
78
|
+
|
|
79
|
+
- `0` — the observation sits within the allowance and the declared
|
|
80
|
+
reference is nearest.
|
|
81
|
+
- `1` — any other observation result (`beyond_noise_allowance` or
|
|
82
|
+
`nearest_is_other`).
|
|
83
|
+
- `2` — a usage error, a format error, or `too_few_samples`.
|
|
84
|
+
|
|
85
|
+
## Closed words
|
|
86
|
+
|
|
87
|
+
Status words: `within_noise_allowance`, `beyond_noise_allowance`,
|
|
88
|
+
`nearest_is_declared`, `nearest_is_other`, `too_few_samples`.
|
|
89
|
+
|
|
90
|
+
Reason words (a format problem is reported as exactly one of these):
|
|
91
|
+
`unreadable_file`, `not_json`, `not_object`, `probe_version_mismatch`,
|
|
92
|
+
`unknown_top_key`, `missing_top_key`, `meta_not_object`, `unknown_meta_key`,
|
|
93
|
+
`meta_value_not_string`, `samples_not_list`, `sample_entry_not_object`,
|
|
94
|
+
`unknown_sample_key`, `cell_not_string`, `answer_not_string`,
|
|
95
|
+
`sample_not_integer`, `sample_sequence_gap`, `sample_sequence_duplicate`,
|
|
96
|
+
`cells_not_list`, `cell_entry_not_object`, `unknown_cell_key`,
|
|
97
|
+
`cell_id_not_string`, `prompt_not_string`, `duplicate_cell_id`.
|
|
98
|
+
|
|
99
|
+
Usage words: `missing_reference`, `duplicate_reference_name`,
|
|
100
|
+
`invalid_reference_spec`, `declared_not_in_references`, `invalid_threshold`.
|
|
101
|
+
|
|
102
|
+
## The shape of an observation file
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"probe_obs_version": 1,
|
|
107
|
+
"meta": {"label": "my-endpoint", "collected_on": "2026-11-29",
|
|
108
|
+
"setting": "temperature 1.0"},
|
|
109
|
+
"samples": [
|
|
110
|
+
{"cell": "p01", "sample": 0, "answer": "seven"},
|
|
111
|
+
{"cell": "p01", "sample": 1, "answer": "Seven."}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- The three `meta` keys are optional strings; no other `meta` key is
|
|
117
|
+
accepted.
|
|
118
|
+
- `sample` numbers run from 0 upward within a cell, without gaps or
|
|
119
|
+
duplicates.
|
|
120
|
+
- `answer` is a string. Answers are normalized before counting: Unicode
|
|
121
|
+
NFKC, lower case, then the closed sets of whitespace and punctuation are
|
|
122
|
+
stripped at both ends only. The rules and the examples are in
|
|
123
|
+
[docs/normalization.md](docs/normalization.md). An answer that normalizes
|
|
124
|
+
to nothing counts as one single empty value.
|
|
125
|
+
|
|
126
|
+
## The JSON output of compare
|
|
127
|
+
|
|
128
|
+
`"probe_version": 1`, the inputs with their base file names and `sha256`,
|
|
129
|
+
the number of shared cells, `s_obs`, per reference the `distance`, `s_ref`
|
|
130
|
+
and `rank`, the distance of every shared cell, and the status words. The
|
|
131
|
+
numbers carry six decimals. Answer strings are never part of any output.
|
|
132
|
+
|
|
133
|
+
## Determinism
|
|
134
|
+
|
|
135
|
+
The engine computes with exact fractions and a fixed-point logarithm; no
|
|
136
|
+
floating point is involved in a distance. Identical inputs give
|
|
137
|
+
byte-identical outputs on every operating system. Rounding to six decimals
|
|
138
|
+
happens once, right before the output (round half up).
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
python3 -m unittest discover -s tests
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT License. See [LICENSE](https://github.com/neguseatama/sieve-probe/blob/main/LICENSE).
|
|
149
|
+
|
|
150
|
+
Copyright (c) 2026 Kai IWASAKI
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Sieve Probe v0.1.0
|
|
2
|
+
|
|
3
|
+
1 語回答の分布が、宣言した参照の分布にどれだけ近いかを測ります。出力は、
|
|
4
|
+
自分で集めた記録の上で計算される、再現できる数と閉じた語の集まりです。
|
|
5
|
+
この道具は何も収集しません。ネットワークへの接続も鍵もなく、依存は
|
|
6
|
+
標準ライブラリだけです。Python 3.10 以上。
|
|
7
|
+
|
|
8
|
+
この道具の主語は回答の分布です。モデルや提供元や版を特定することはせず、
|
|
9
|
+
数の読み方を使う人の側に残します。
|
|
10
|
+
|
|
11
|
+
## 5 段階の使い方
|
|
12
|
+
|
|
13
|
+
1. 同梱の公開の問題集を出します: `sieve-probe battery`(12 問の 1 語回答の
|
|
14
|
+
問い、問題集 `public-1`)。
|
|
15
|
+
2. 自分の手段で、標本ごとに回答を 1 つ集めます。道具は収集しません。
|
|
16
|
+
3. 回答を観測ファイル(JSON、形は下記)に記録します。参照の記録も
|
|
17
|
+
同じ形で記録します。
|
|
18
|
+
4. 比べます: `sieve-probe compare OBS --reference NAME=FILE --declare NAME`。
|
|
19
|
+
5. 距離、ばらつき、順位、状態の語を読みます。終了符号が同じ意味を
|
|
20
|
+
持ちます。
|
|
21
|
+
|
|
22
|
+
## コマンド
|
|
23
|
+
|
|
24
|
+
- `sieve-probe battery [--format text|json]` — 同梱の問題集を出します。
|
|
25
|
+
回答を集める際の文面になります。問題集は出発点で、最適とは主張しません。
|
|
26
|
+
問いの追加は、版を上げて行います。
|
|
27
|
+
- `sieve-probe validate FILE` — 観測ファイルか問題集ファイルを検査します。
|
|
28
|
+
形式の誤りは、閉じた理由の語をちょうど 1 つで示します。
|
|
29
|
+
- `sieve-probe compare OBS --reference NAME=FILE [--reference ...]
|
|
30
|
+
--declare NAME [--min-samples N] [--min-cells N] [--format text|json]` —
|
|
31
|
+
共通セルの上での比較です。
|
|
32
|
+
- `sieve-probe --version`。
|
|
33
|
+
|
|
34
|
+
## 距離とばらつき
|
|
35
|
+
|
|
36
|
+
- 距離は Jensen–Shannon ダイバージェンス(底 2、値は 0 から 1、平方根は
|
|
37
|
+
取らない)です。セルごとに計算し、共通セルで平均します。
|
|
38
|
+
- 共通セルは、観測とすべての参照にあり、標本数の合計が `--min-samples`
|
|
39
|
+
(既定 20)に届くセルです。共通セルが `--min-cells`(既定 8)に満たない
|
|
40
|
+
ときは、状態 `too_few_samples` と終了符号 2 になります。
|
|
41
|
+
- ばらつきは、記録 1 件の各セルを `sample` の偶数と奇数に分け、2 つの半分
|
|
42
|
+
の距離を共通セルで平均したものです(観測は `s_obs`、参照は `s_ref`)。
|
|
43
|
+
- 許容: 宣言した参照との距離を `s_obs + s_ref` と比べます。以下なら状態は
|
|
44
|
+
`within_noise_allowance`、上なら `beyond_noise_allowance` です。閾値は
|
|
45
|
+
設計上の固定で、数はすべて出力されるので、読み方は使う人の側に
|
|
46
|
+
残ります。
|
|
47
|
+
- 最も近い参照は距離が最小のものです。差が 0.000000001 未満の距離は
|
|
48
|
+
同じ順位になります。宣言した参照がその最も近い集まりに含まれるとき
|
|
49
|
+
状態は `nearest_is_declared`、含まれないとき `nearest_is_other` です。
|
|
50
|
+
|
|
51
|
+
## 終了符号
|
|
52
|
+
|
|
53
|
+
- `0` — 観測が許容の中にあり、宣言した参照が最も近い。
|
|
54
|
+
- `1` — それ以外の観測の結果(`beyond_noise_allowance` か
|
|
55
|
+
`nearest_is_other`)。
|
|
56
|
+
- `2` — 使い方の誤り、形式の誤り、`too_few_samples`。
|
|
57
|
+
|
|
58
|
+
## 閉じた語
|
|
59
|
+
|
|
60
|
+
状態の語: `within_noise_allowance`・`beyond_noise_allowance`・
|
|
61
|
+
`nearest_is_declared`・`nearest_is_other`・`too_few_samples`。
|
|
62
|
+
|
|
63
|
+
理由の語(形式の誤りは、この中のちょうど 1 つで示されます):
|
|
64
|
+
`unreadable_file`・`not_json`・`not_object`・`probe_version_mismatch`・
|
|
65
|
+
`unknown_top_key`・`missing_top_key`・`meta_not_object`・
|
|
66
|
+
`unknown_meta_key`・`meta_value_not_string`・`samples_not_list`・
|
|
67
|
+
`sample_entry_not_object`・`unknown_sample_key`・`cell_not_string`・
|
|
68
|
+
`answer_not_string`・`sample_not_integer`・`sample_sequence_gap`・
|
|
69
|
+
`sample_sequence_duplicate`・`cells_not_list`・`cell_entry_not_object`・
|
|
70
|
+
`unknown_cell_key`・`cell_id_not_string`・`prompt_not_string`・
|
|
71
|
+
`duplicate_cell_id`。
|
|
72
|
+
|
|
73
|
+
使い方の語: `missing_reference`・`duplicate_reference_name`・
|
|
74
|
+
`invalid_reference_spec`・`declared_not_in_references`・`invalid_threshold`。
|
|
75
|
+
|
|
76
|
+
## 観測ファイルの形
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"probe_obs_version": 1,
|
|
81
|
+
"meta": {"label": "my-endpoint", "collected_on": "2026-11-29",
|
|
82
|
+
"setting": "temperature 1.0"},
|
|
83
|
+
"samples": [
|
|
84
|
+
{"cell": "p01", "sample": 0, "answer": "seven"},
|
|
85
|
+
{"cell": "p01", "sample": 1, "answer": "Seven."}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- `meta` の 3 つの鍵は任意の文字列で、どれも省けます。それ以外の `meta`
|
|
91
|
+
の鍵は受け付けません。
|
|
92
|
+
- `sample` の番号は、セルの中で 0 から始まり、欠けも重複もありません。
|
|
93
|
+
- `answer` は文字列です。回答は数える前に正規化されます: Unicode NFKC、
|
|
94
|
+
小文字化、その後で空白と句読点の閉じた集合を前後だけ取り除く。規則と
|
|
95
|
+
例は [docs/normalization.ja.md](docs/normalization.ja.md) にあります。
|
|
96
|
+
正規化して空になる回答は、1 つの空の値として数えられます。
|
|
97
|
+
|
|
98
|
+
## compare の JSON 出力
|
|
99
|
+
|
|
100
|
+
`"probe_version": 1`、入力ごとの基本ファイル名と `sha256`、共通セルの数、
|
|
101
|
+
`s_obs`、参照ごとの `distance` と `s_ref` と `rank`、セルごとの距離、
|
|
102
|
+
状態の語。数は小数 6 桁です。回答の文字列は、どの出力にも現れません。
|
|
103
|
+
|
|
104
|
+
## 決定論
|
|
105
|
+
|
|
106
|
+
エンジンは正確な分数と固定小数点の対数で計算します。距離の計算に
|
|
107
|
+
浮動小数は入りません。同じ入力は、どの OS でもバイト単位で同じ出力に
|
|
108
|
+
なります。小数 6 桁への丸めは、出力の直前に 1 か所だけです
|
|
109
|
+
(0.5 は切り上げ)。
|
|
110
|
+
|
|
111
|
+
## 開発
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
python3 -m unittest discover -s tests
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## ライセンス
|
|
118
|
+
|
|
119
|
+
MIT License。[LICENSE](https://github.com/neguseatama/sieve-probe/blob/main/LICENSE) を参照してください。
|
|
120
|
+
|
|
121
|
+
Copyright (c) 2026 Kai IWASAKI
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Sieve Probe v0.1.0
|
|
2
|
+
|
|
3
|
+
Measure how close a distribution of one-word answers stays to the reference
|
|
4
|
+
distributions you declare. The output is a set of reproducible numbers and
|
|
5
|
+
closed words, computed on recordings you collected yourself. The tool
|
|
6
|
+
collects nothing: no network access, no keys, no dependencies beyond the
|
|
7
|
+
standard library. Python 3.10 or later.
|
|
8
|
+
|
|
9
|
+
The subject of this tool is the distribution of answers. It does not
|
|
10
|
+
identify models, vendors or versions; the reading of the numbers is yours.
|
|
11
|
+
|
|
12
|
+
## The five steps
|
|
13
|
+
|
|
14
|
+
1. Print the bundled public battery: `sieve-probe battery` (twelve one-word
|
|
15
|
+
prompts, battery `public-1`).
|
|
16
|
+
2. Collect one answer per sample with your own means. The tool never
|
|
17
|
+
collects anything.
|
|
18
|
+
3. Record the answers as an observation file (JSON, the shape is below).
|
|
19
|
+
Record the reference recordings in the same shape.
|
|
20
|
+
4. Compare: `sieve-probe compare OBS --reference NAME=FILE --declare NAME`.
|
|
21
|
+
5. Read the distances, the noise values, the ranks and the status words.
|
|
22
|
+
The exit code carries the same meaning.
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
- `sieve-probe battery [--format text|json]` — print the bundled battery,
|
|
27
|
+
so answers can be collected against it. The battery is a starting point,
|
|
28
|
+
not a claimed-best set; new questions arrive with a version bump.
|
|
29
|
+
- `sieve-probe validate FILE` — check an observation or battery file; a
|
|
30
|
+
format problem is reported as exactly one closed reason word.
|
|
31
|
+
- `sieve-probe compare OBS --reference NAME=FILE [--reference ...]
|
|
32
|
+
--declare NAME [--min-samples N] [--min-cells N] [--format text|json]` —
|
|
33
|
+
the comparison on the shared cells.
|
|
34
|
+
- `sieve-probe --version`.
|
|
35
|
+
|
|
36
|
+
## The distance and the noise
|
|
37
|
+
|
|
38
|
+
- The distance is the Jensen-Shannon divergence (base 2, values from 0 to
|
|
39
|
+
1, no square root), computed per cell and averaged over the shared cells.
|
|
40
|
+
- The shared cells are the cells present in the observation and in every
|
|
41
|
+
reference whose total number of samples reaches `--min-samples` (default
|
|
42
|
+
20). Fewer than `--min-cells` (default 8) shared cells gives the status
|
|
43
|
+
`too_few_samples` and exit code 2.
|
|
44
|
+
- The noise of one recording splits every cell into even-index and
|
|
45
|
+
odd-index samples, measures the distance between the two halves, and
|
|
46
|
+
averages it over the shared cells (`s_obs` for the observation, `s_ref`
|
|
47
|
+
for a reference).
|
|
48
|
+
- The allowance: the distance to the declared reference is compared with
|
|
49
|
+
`s_obs + s_ref`. Within it, the status is `within_noise_allowance`;
|
|
50
|
+
above it, `beyond_noise_allowance`. The thresholds are fixed by design
|
|
51
|
+
and every number is printed, so the reading stays yours.
|
|
52
|
+
- The nearest reference is the one with the smallest distance; distances
|
|
53
|
+
within 0.000000001 of each other share a rank. The declared reference
|
|
54
|
+
inside that nearest group gives the status `nearest_is_declared`,
|
|
55
|
+
otherwise `nearest_is_other`.
|
|
56
|
+
|
|
57
|
+
## Exit codes
|
|
58
|
+
|
|
59
|
+
- `0` — the observation sits within the allowance and the declared
|
|
60
|
+
reference is nearest.
|
|
61
|
+
- `1` — any other observation result (`beyond_noise_allowance` or
|
|
62
|
+
`nearest_is_other`).
|
|
63
|
+
- `2` — a usage error, a format error, or `too_few_samples`.
|
|
64
|
+
|
|
65
|
+
## Closed words
|
|
66
|
+
|
|
67
|
+
Status words: `within_noise_allowance`, `beyond_noise_allowance`,
|
|
68
|
+
`nearest_is_declared`, `nearest_is_other`, `too_few_samples`.
|
|
69
|
+
|
|
70
|
+
Reason words (a format problem is reported as exactly one of these):
|
|
71
|
+
`unreadable_file`, `not_json`, `not_object`, `probe_version_mismatch`,
|
|
72
|
+
`unknown_top_key`, `missing_top_key`, `meta_not_object`, `unknown_meta_key`,
|
|
73
|
+
`meta_value_not_string`, `samples_not_list`, `sample_entry_not_object`,
|
|
74
|
+
`unknown_sample_key`, `cell_not_string`, `answer_not_string`,
|
|
75
|
+
`sample_not_integer`, `sample_sequence_gap`, `sample_sequence_duplicate`,
|
|
76
|
+
`cells_not_list`, `cell_entry_not_object`, `unknown_cell_key`,
|
|
77
|
+
`cell_id_not_string`, `prompt_not_string`, `duplicate_cell_id`.
|
|
78
|
+
|
|
79
|
+
Usage words: `missing_reference`, `duplicate_reference_name`,
|
|
80
|
+
`invalid_reference_spec`, `declared_not_in_references`, `invalid_threshold`.
|
|
81
|
+
|
|
82
|
+
## The shape of an observation file
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"probe_obs_version": 1,
|
|
87
|
+
"meta": {"label": "my-endpoint", "collected_on": "2026-11-29",
|
|
88
|
+
"setting": "temperature 1.0"},
|
|
89
|
+
"samples": [
|
|
90
|
+
{"cell": "p01", "sample": 0, "answer": "seven"},
|
|
91
|
+
{"cell": "p01", "sample": 1, "answer": "Seven."}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
- The three `meta` keys are optional strings; no other `meta` key is
|
|
97
|
+
accepted.
|
|
98
|
+
- `sample` numbers run from 0 upward within a cell, without gaps or
|
|
99
|
+
duplicates.
|
|
100
|
+
- `answer` is a string. Answers are normalized before counting: Unicode
|
|
101
|
+
NFKC, lower case, then the closed sets of whitespace and punctuation are
|
|
102
|
+
stripped at both ends only. The rules and the examples are in
|
|
103
|
+
[docs/normalization.md](docs/normalization.md). An answer that normalizes
|
|
104
|
+
to nothing counts as one single empty value.
|
|
105
|
+
|
|
106
|
+
## The JSON output of compare
|
|
107
|
+
|
|
108
|
+
`"probe_version": 1`, the inputs with their base file names and `sha256`,
|
|
109
|
+
the number of shared cells, `s_obs`, per reference the `distance`, `s_ref`
|
|
110
|
+
and `rank`, the distance of every shared cell, and the status words. The
|
|
111
|
+
numbers carry six decimals. Answer strings are never part of any output.
|
|
112
|
+
|
|
113
|
+
## Determinism
|
|
114
|
+
|
|
115
|
+
The engine computes with exact fractions and a fixed-point logarithm; no
|
|
116
|
+
floating point is involved in a distance. Identical inputs give
|
|
117
|
+
byte-identical outputs on every operating system. Rounding to six decimals
|
|
118
|
+
happens once, right before the output (round half up).
|
|
119
|
+
|
|
120
|
+
## Development
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
python3 -m unittest discover -s tests
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT License. See [LICENSE](https://github.com/neguseatama/sieve-probe/blob/main/LICENSE).
|
|
129
|
+
|
|
130
|
+
Copyright (c) 2026 Kai IWASAKI
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""pytest configuration: make the module at the repository root importable.
|
|
2
|
+
|
|
3
|
+
The repository root is put first on sys.path so that an installed copy and a
|
|
4
|
+
bare pytest run use the same import path (the package is a single module
|
|
5
|
+
that depends only on the standard library).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# 正規化の規則
|
|
2
|
+
|
|
3
|
+
回答は、正規化した値の下で数えられます。規則は閉じています。次の 4 段階
|
|
4
|
+
がすべてで、この順序以外の処理は行いません。実装は
|
|
5
|
+
`sieve_probe/normalize.py` にあります。
|
|
6
|
+
|
|
7
|
+
## 規則
|
|
8
|
+
|
|
9
|
+
1. **Unicode NFKC。** 全角の英字と全角の句読点は ASCII の形になります
|
|
10
|
+
(seven → seven、! → !)。NFKC が保持する記号はそのまま残ります。
|
|
11
|
+
2. **小文字化。** SEVEN → seven。
|
|
12
|
+
3. **前後を取り除く。** 空白と句読点を、先頭と末尾だけ、順序や混在を
|
|
13
|
+
問わず取り除きます。空白の閉じた集合: 半角空白、タブ、改行、垂直タブ、
|
|
14
|
+
フォームフィード、復帰。句読点の閉じた集合: `.` `,` `;` `:` `!` `?`
|
|
15
|
+
`"` `'` `` ` `` `(` `)`、曲がった引用符 “ ” ‘ ’、CJK の括弧
|
|
16
|
+
「 」 『 』、読点と句点 、 。、中黒 ・、省略記号 …、ダッシュ ― – — -。
|
|
17
|
+
4. **1 つの空の値。** 正規化して空になる回答は、1 つの値(空の値)として
|
|
18
|
+
数えられます。出力には現れず、1 つの件数にまとまるだけです。
|
|
19
|
+
|
|
20
|
+
内側の句読点はその場所に残ります。触れるのは両端だけです。それ以外の
|
|
21
|
+
処理はありません: 分かち書きも語幹の処理も類義語のまとめもしません。
|
|
22
|
+
|
|
23
|
+
## 例
|
|
24
|
+
|
|
25
|
+
| 元の回答 | 正規化した値 | 働く規則 |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `Seven.` | `seven` | 末尾のピリオド |
|
|
28
|
+
| `SEVEN` | `seven` | 小文字化 |
|
|
29
|
+
| ` seven`(タブ付き) | `seven` | 前後の空白 |
|
|
30
|
+
| `seven` | `seven` | NFKC |
|
|
31
|
+
| `Seven.` | `seven` | NFKC と末尾のピリオド |
|
|
32
|
+
| `"seven?"` | `seven` | 引用符と疑問符 |
|
|
33
|
+
| `'seven'` | `seven` | 引用符 |
|
|
34
|
+
| `seven,` | `seven` | 末尾のコンマ |
|
|
35
|
+
| `(seven)` | `seven` | 全角の括弧は NFKC で ASCII になる |
|
|
36
|
+
| `「seven」` | `seven` | CJK の括弧 |
|
|
37
|
+
| `、seven。` | `seven` | 読点と句点 |
|
|
38
|
+
| `seven-` | `seven` | 末尾のハイフン |
|
|
39
|
+
| `seven・` | `seven` | 末尾の中黒 |
|
|
40
|
+
| `seven…` | `seven` | 末尾の省略記号 |
|
|
41
|
+
| `“seven”` | `seven` | 曲がった引用符 |
|
|
42
|
+
| `7` | `7` | 数字はそのまま |
|
|
43
|
+
| `Seven's` | `seven's` | 内側のアポストロフィは残る |
|
|
44
|
+
| `seven-fold` | `seven-fold` | 内側のハイフンは残る |
|
|
45
|
+
| `St. James` | `st. james` | 内側のピリオドは残る |
|
|
46
|
+
| `seven・seven` | `seven・seven` | 内側の中黒は残る |
|
|
47
|
+
| (空になる元の回答) | 空の値 | `""`、`" "`、`".。!?"`、`"( )"` |
|
|
48
|
+
|
|
49
|
+
空の値は 1 つの値です。`""` も `" "` も `".。"` も、同じ 1 つの
|
|
50
|
+
件数にまとまります。
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# The normalization rules
|
|
2
|
+
|
|
3
|
+
Every answer is counted under its normalized value. The rules are closed:
|
|
4
|
+
they are exactly the four steps below, in this order, with no other
|
|
5
|
+
clean-up. The implementation lives in `sieve_probe/normalize.py`.
|
|
6
|
+
|
|
7
|
+
## The rules
|
|
8
|
+
|
|
9
|
+
1. **Unicode NFKC.** Fullwidth letters and fullwidth punctuation become
|
|
10
|
+
their ASCII forms (seven becomes seven, ! becomes !). Marks that
|
|
11
|
+
NFKC keeps stay as they are.
|
|
12
|
+
2. **Lower case.** SEVEN becomes seven.
|
|
13
|
+
3. **Strip both ends.** Whitespace and punctuation are removed from the
|
|
14
|
+
beginning and the end only, in any order and any mixture. The closed
|
|
15
|
+
whitespace set: space, tab, line feed, vertical tab, form feed, carriage
|
|
16
|
+
return. The closed punctuation set: `.` `,` `;` `:` `!` `?` `"` `'`
|
|
17
|
+
`` ` `` `(` `)`, the curly quotes “ ” ‘ ’, the CJK brackets 「 」 『 』,
|
|
18
|
+
the ideographic comma and period 、 。, the middle dot ・, the ellipsis
|
|
19
|
+
…, and the dashes ― – — -.
|
|
20
|
+
4. **The one empty value.** An answer whose normalized value is empty
|
|
21
|
+
counts as one single value (the empty value). It is never printed;
|
|
22
|
+
it only merges into one count.
|
|
23
|
+
|
|
24
|
+
Inner punctuation stays where it is: only the two ends are touched.
|
|
25
|
+
Nothing else is removed: no word splitting, no stemming, no synonyms.
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
| Raw answer | Normalized value | Rule at work |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `Seven.` | `seven` | trailing period |
|
|
32
|
+
| `SEVEN` | `seven` | lower case |
|
|
33
|
+
| ` seven` (with a tab) | `seven` | surrounding whitespace |
|
|
34
|
+
| `seven` | `seven` | NFKC |
|
|
35
|
+
| `Seven.` | `seven` | NFKC and the trailing period |
|
|
36
|
+
| `"seven?"` | `seven` | quotes and a question mark |
|
|
37
|
+
| `'seven'` | `seven` | straight quotes |
|
|
38
|
+
| `seven,` | `seven` | trailing comma |
|
|
39
|
+
| `(seven)` | `seven` | fullwidth parentheses become ASCII in NFKC |
|
|
40
|
+
| `「seven」` | `seven` | CJK brackets |
|
|
41
|
+
| `、seven。` | `seven` | ideographic comma and period |
|
|
42
|
+
| `seven-` | `seven` | trailing hyphen |
|
|
43
|
+
| `seven・` | `seven` | trailing middle dot |
|
|
44
|
+
| `seven…` | `seven` | trailing ellipsis |
|
|
45
|
+
| `“seven”` | `seven` | curly quotes |
|
|
46
|
+
| `7` | `7` | digits stay as they are |
|
|
47
|
+
| `Seven's` | `seven's` | the inner apostrophe stays |
|
|
48
|
+
| `seven-fold` | `seven-fold` | the inner hyphen stays |
|
|
49
|
+
| `St. James` | `st. james` | the inner period stays |
|
|
50
|
+
| `seven・seven` | `seven・seven` | the inner middle dot stays |
|
|
51
|
+
| (empty raw answers) | the empty value | `""`, `" "`, `".。!?"`, `"( )"` |
|
|
52
|
+
|
|
53
|
+
The empty value is one single value: the answers `""` and `" "` and
|
|
54
|
+
`".。"` all land in the same count.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sieve-probe"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Measure how close a distribution of one-word answers stays to declared reference distributions, with exact numbers and closed words"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "Kai IWASAKI" }]
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
dependencies = []
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/neguseatama/sieve-probe"
|
|
27
|
+
Repository = "https://github.com/neguseatama/sieve-probe.git"
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
sieve-probe = "sieve_probe.cli:main"
|
|
31
|
+
|
|
32
|
+
[tool.setuptools]
|
|
33
|
+
packages = ["sieve_probe"]
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.package-data]
|
|
36
|
+
sieve_probe = ["data/*.json"]
|