Cem13 commited on
Commit
8ae71a4
·
verified ·
1 Parent(s): 6e4cd91

Expand usage, use cases, performance details, and runnable examples

Browse files
NOTICE CHANGED
@@ -1,4 +1,4 @@
1
  Kodama Core: locally adapted decision model.
2
  Pretrained ModernBERT: Answer.AI, LightOn, and collaborators. Apache-2.0 per the included upstream model card.
3
  Changes: typed-decision and escalation heads, local fine-tuning, calibration.
4
- Original Kodama additions and runtime: no separate public license selected for this private release.
 
1
  Kodama Core: locally adapted decision model.
2
  Pretrained ModernBERT: Answer.AI, LightOn, and collaborators. Apache-2.0 per the included upstream model card.
3
  Changes: typed-decision and escalation heads, local fine-tuning, calibration.
4
+ Original Kodama additions and runtime: no separate public license selected for this release.
README.md CHANGED
@@ -18,30 +18,145 @@ Fast text/JSON decision model with a ModernBERT-large backbone and a trained typ
18
 
19
  All models return structured `Choice`, `Score`, and `Noul` decisions. They score answer options directly; they do not generate conversational responses. These are custom `jevlike` checkpoints, loaded with the bundled runtime below. Generic Transformers `pipeline()` / `AutoModel` loading is not the supported entry point.
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ## Install and download
22
 
23
- Use Python 3.10+ (tested with Python 3.12, PyTorch 2.10 and Transformers 5.2.0).
24
- Authenticate with `hf auth login` if the repository is private. The `huggingface_hub`
25
- client also reads an existing `HF_TOKEN`; never put a token in source code.
 
26
 
27
  ```bash
28
- pip install huggingface_hub
 
29
  hf download Cem13/kodama-core --local-dir kodama-core
30
- pip install "./kodama-core/runtime[model,ingest]" "transformers==5.2.0"
31
  ```
32
 
 
 
 
 
 
 
 
33
  ```python
34
- from jevlike import SystemOne, Choice, Noul
 
 
35
  model = SystemOne.load("kodama-core", device="cuda", long_state="chunk")
36
- print(model.predict("The invoice is overdue.", {
37
- "overdue": Noul("The invoice is overdue."),
38
- "route": Choice("Which team should handle this?", ["billing", "technical"]),
39
- }))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  ```
41
 
42
- The checkpoint uses a 2,048-token context. `long_state="chunk"` processes longer
43
- inputs in overlapping windows and combines their answer distributions. The
44
- bundled tokenizer and all decision weights are local; no backbone download is needed.
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  ## Local evaluation
47
 
@@ -58,6 +173,38 @@ Median short-text latency: **26.5 ms** for one question and **104.8 ms** for ten
58
  questions (20 timed calls per workload). Batch throughput: **94.6 decisions/s**.
59
  These are local exploratory measurements, not service guarantees.
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  ## Training and limitations
62
 
63
  The base encoders were pretrained by their upstream authors. Kodama adds local
@@ -70,16 +217,20 @@ correctness; use suitable validation before relying on decisions.
70
 
71
  ## Attribution and licensing
72
 
73
- The pretrained base components identify their license as Apache-2.0. Upstream cards, source revisions, and the Apache license text are preserved in `third_party/` and `NOTICE`. No separate public license has been selected for the original Kodama additions and runtime in this private release; the upstream license statements should not be read as a new license grant for those additions.
74
 
75
  Base sources:
76
 
77
  - [answerdotai/ModernBERT-large](https://huggingface.co/answerdotai/ModernBERT-large/tree/45bb4654a4d5aaff24dd11d4781fa46d39bf8c13)
78
 
79
- ## Kodama family
80
 
81
- - [Kodama Core](https://huggingface.co/Cem13/kodama-core)
82
- - [Kodama Sense](https://huggingface.co/Cem13/kodama-sense)
83
- - [Kodama Vision](https://huggingface.co/Cem13/kodama-vision)
 
84
 
85
- `release_manifest.json` records the exact bytes, hashes, and pinned base revisions. `runtime/` contains the installable inference source.
 
 
 
 
18
 
19
  All models return structured `Choice`, `Score`, and `Noul` decisions. They score answer options directly; they do not generate conversational responses. These are custom `jevlike` checkpoints, loaded with the bundled runtime below. Generic Transformers `pipeline()` / `AutoModel` loading is not the supported entry point.
20
 
21
+ ## Which Kodama model should I use?
22
+
23
+ | Model | Inputs | Typical reason to choose it |
24
+ |---|---|---|
25
+ | [Kodama Core](https://huggingface.co/Cem13/kodama-core) | Text; JSON serialized as text | Fast routing, classification, and small decisions inside an application |
26
+ | [Kodama Vision](https://huggingface.co/Cem13/kodama-vision) | One image plus optional text | Experimental object, vehicle, or document-type classification |
27
+ | [Kodama Sense](https://huggingface.co/Cem13/kodama-sense) | Text, images, PDFs, charts, audio, video, and mixed media | Decisions that require visual or audio evidence |
28
+
29
+ These models choose from the answers you supply. They are not conversational chatbots,
30
+ open-ended report writers, transcription services, or general document extraction systems.
31
+ The use cases below are applications to evaluate on your own examples; the benchmark
32
+ results do not establish reliable performance on every such application.
33
+
34
+ ## Practical use cases
35
+
36
+ | Application | Example question | Decision returned |
37
+ |---|---|---|
38
+ | Support-ticket routing | “Which team should handle this request?” | Billing, technical support, sales, or other |
39
+ | Queue prioritization | “How urgent is this ticket?” | An ordered urgency level and its probabilities |
40
+ | Agent workflow checks | “Does the supplied log show that the task completed?” | A probability for the statement |
41
+ | News or document triage | “Which topic best describes this text?” | One label from a supplied taxonomy |
42
+ | Structured business records | “Which follow-up action fits this order record?” | A typed classification after JSON serialization |
43
+
44
+ Core is the first model to try when the evidence is already text and latency matters.
45
+ Its 45.95% result on the broad typed-decisions test means task-specific validation is
46
+ still necessary before automatically acting on these decisions. It does not read raw
47
+ images, PDF pages, audio, or video; provide extracted text or choose Sense for those inputs.
48
+
49
  ## Install and download
50
 
51
+ Tested environment: Python 3.12, PyTorch 2.10, Transformers 5.2.0, Linux, and an NVIDIA
52
+ RTX 4050 Laptop GPU with 6 GB VRAM. Python 3.10+ is supported by the package. Install a
53
+ CUDA-enabled PyTorch build appropriate for your system when using the GPU examples.
54
+ Approximate model download size: **1.66 GB**, excluding Python/CUDA dependencies and caches.
55
 
56
  ```bash
57
+ python -m pip install huggingface_hub
58
+ # For a private repository, authenticate once with: hf auth login
59
  hf download Cem13/kodama-core --local-dir kodama-core
60
+ python -m pip install "./kodama-core/runtime[model,ingest]" "transformers==5.2.0"
61
  ```
62
 
63
+ Run the examples from the directory containing `kodama-core`. After the download and
64
+ dependency installation, prediction runs locally; no API key or paid inference service
65
+ is needed for prediction. Private downloads require access to the repository. An existing
66
+ `HF_TOKEN` can authenticate the Hub client without adding a token to source code.
67
+
68
+ ## Python: route a ticket and score urgency
69
+
70
  ```python
71
+ import json
72
+ from jevlike import SystemOne, Choice, Score, Noul
73
+
74
  model = SystemOne.load("kodama-core", device="cuda", long_state="chunk")
75
+ questions = {
76
+ "team": Choice("Which team should handle this request?", {
77
+ "billing": "payments, invoices, refunds",
78
+ "technical": "bugs, errors, broken software",
79
+ "other": "another kind of request",
80
+ }),
81
+ "urgency": Score("How urgent is this request?", ["low", "normal", "urgent"]),
82
+ "refund": Noul("The customer explicitly requests a refund."),
83
+ }
84
+ state = json.dumps({"message": "I was charged twice. Please refund the duplicate payment."})
85
+ result = model.predict(state, questions)
86
+ print(result["answers"])
87
+ ```
88
+
89
+ The direct Core Python API takes a **string** state. Serialize a dictionary with
90
+ `json.dumps`, as above. The HTTP API below accepts JSON objects directly.
91
+ A runnable version is included at `examples/quickstart.py`:
92
+
93
+ ```bash
94
+ python kodama-core/examples/quickstart.py
95
+ ```
96
+
97
+ ### Multiple records and long text
98
+
99
+ ```python
100
+ results = model.predict_batch([
101
+ ("Please refund this duplicate charge.", questions),
102
+ ("The application crashes every time I log in.", questions),
103
+ ])
104
+ ```
105
+
106
+ Each result matches the corresponding input item. Questions across records are batched
107
+ within a token budget. Batch-result `latency_ms` covers the whole batch call, not an
108
+ independent per-record measurement. The checkpoint uses a 2,048-token context, including
109
+ the question and option text. `long_state="chunk"` reads overlapping windows; the default
110
+ `"truncate"` mode truncates long states. Chunk pooling does not reproduce a single
111
+ unlimited-context read, and escalation/calibration should be revalidated for long inputs.
112
+
113
+ For CPU execution, load with `device="cpu"`; CPU speed has not been benchmarked here.
114
+ The GPU benchmark used float32 model weights with BF16 autocast.
115
+
116
+ ## Understanding the answers
117
+
118
+ Every response contains `model`, `latency_ms`, and `answers`, keyed by your question names.
119
+
120
+ | Question type | How to define it | Main output |
121
+ |---|---|---|
122
+ | `Choice` | 2–255 distinct labels, optionally with descriptions | `choice` and a label-to-probability dictionary |
123
+ | `Score` | 2–10 ordered descriptions, lowest first | Zero-based `level`, its `label`, a probability list, and expected `score` scaled to 0–10 |
124
+ | `Noul` | A statement to test; no answer options | `noul`, the probability that the statement is true |
125
+
126
+ `confidence` is the largest answer probability. For `Noul`, a confident **false** answer
127
+ can have `noul=0.02` and `confidence=0.98`; use `noul` when deciding whether the statement
128
+ is true. `escalate` and `escalate_prob` help flag uncertain answers for another step in
129
+ your application. Neither confidence nor escalation is a guarantee of correctness.
130
+
131
+ Use specific instructions and descriptive, distinct options. Probabilities are conditional
132
+ on the supplied options; adding an `other` option can be useful when your label set does
133
+ not cover every input, but the model's use of that option still needs validation.
134
+
135
+ Core and Vision apply saved temperature calibration by default. Their `escalate_prob`
136
+ comes from a separately trained escalation head with saved calibration; default escalation
137
+ is above 0.5. Set `calibrated=False` on prediction calls to inspect uncalibrated outputs.
138
+ Their answer dictionaries do not include Sense's per-answer `calibrated` flag.
139
+
140
+ ## Serve a local HTTP API
141
+
142
+ ```bash
143
+ python -m pip install "./kodama-core/runtime[server]"
144
  ```
145
 
146
+ ```bash
147
+ python -m jevlike.server --checkpoint kodama-core --port 8077
148
+ ```
149
+
150
+ From another terminal:
151
+
152
+ ```bash
153
+ curl http://127.0.0.1:8077/v1/systemone \
154
+ -H 'Content-Type: application/json' \
155
+ -d '{"state":{"message":"Please refund the duplicate charge."},"questions":{"team":{"type":"choice","instructions":"Which team?","criteria":["billing","technical","other"]}}}'
156
+ ```
157
+
158
+ The server binds to localhost by default. `GET /health` reports readiness. Model loading
159
+ happens once at startup. This repository does not supply an active hosted inference endpoint.
160
 
161
  ## Local evaluation
162
 
 
173
  questions (20 timed calls per workload). Batch throughput: **94.6 decisions/s**.
174
  These are local exploratory measurements, not service guarantees.
175
 
176
+ ## Timing details and interpretation
177
+
178
+ | Text workload | Median | p95 |
179
+ |---|---:|---:|
180
+ | short 1q | 26.5 ms | 29.0 ms |
181
+ | short 5q | 60.1 ms | 65.5 ms |
182
+ | short 10q | 104.8 ms | 119.2 ms |
183
+ | short 50q | 682.2 ms | 754.4 ms |
184
+ | long 1q | 123.9 ms | 131.8 ms |
185
+ | long 5q | 685.8 ms | 728.8 ms |
186
+ | long 10q | 1321.1 ms | 1337.0 ms |
187
+
188
+ Twenty timed calls per workload, three warmups, four CPU threads, and CUDA synchronization.
189
+ Short evidence strings contain approximately 80–120 ModernBERT tokens. Long timing strings
190
+ are the same shared strings across backends, derived from 1,500 ModernBERT tokens. Batch
191
+ throughput used 16 states × three questions and three repetitions. Peak PyTorch allocation
192
+ in the comparison run was 2.80 GiB (allocator reservation 2.90 GiB); this is not a universal
193
+ minimum VRAM requirement. The desktop shared the GPU, and clocks were not locked.
194
+
195
+ On the same earlier benchmark, standard Laya measured 30.8 ms for one short-text question
196
+ and 118.5 ms for ten, compared with Core's 26.5/104.8 ms. Accuracy was task-dependent:
197
+ Core scored 58.0% versus Laya's 66.0% on other held-out tasks. Laya's specialized checkpoint
198
+ scored 74.25% on typed decisions versus Core's 45.95%; that checkpoint was trained for the
199
+ task family. The results do not establish that Core universally outperforms Laya.
200
+
201
+ The 2,496 accuracy decisions use identical normalized states/questions across models.
202
+ No calibration was refitted on that test set. Small news/finance groups have substantial
203
+ sampling uncertainty. These local normalized tasks are not a reproduction of publisher
204
+ headline benchmark scores. See [evaluation/comparison.json](evaluation/comparison.json)
205
+ for the recorded protocol, model accuracies, and Core's timing samples.
206
+ [Run metadata](evaluation/run_metadata.json) records the hardware, precision, and memory measurements.
207
+
208
  ## Training and limitations
209
 
210
  The base encoders were pretrained by their upstream authors. Kodama adds local
 
217
 
218
  ## Attribution and licensing
219
 
220
+ The pretrained base components identify their license as Apache-2.0. Upstream cards, source revisions, and the Apache license text are preserved in `third_party/` and `NOTICE`. No separate public license has been selected for the original Kodama additions and runtime in this release; the upstream license statements should not be read as a new license grant for those additions.
221
 
222
  Base sources:
223
 
224
  - [answerdotai/ModernBERT-large](https://huggingface.co/answerdotai/ModernBERT-large/tree/45bb4654a4d5aaff24dd11d4781fa46d39bf8c13)
225
 
226
+ ## Troubleshooting and reproducibility
227
 
228
+ - **401/403 while downloading:** authenticate with an account allowed to read the repository.
229
+ - **Model configuration / AutoModel error:** use the bundled `jevlike` runtime and the custom loader shown above.
230
+ - **Import or tokenizer mismatch:** use the documented Transformers version and install the runtime extras for this model.
231
+ - **Different answers near a tie:** numerical precision and batch shapes can affect probabilities; measure your own task before changing inference settings.
232
 
233
+ `release_manifest.json` records file hashes and pinned base revisions. The runtime is
234
+ bundled under `runtime/`; `examples/quickstart.py` provides a complete local example.
235
+ The pretrained foundations were not trained from scratch by Kodama. Earlier evaluation
236
+ artifacts use `jevlike` for Core, `omni` for Sense, and `prototype` for Vision.
evaluation/run_metadata.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "jevlike",
3
+ "created_utc": "2026-09-30T15:25:31.394308+00:00",
4
+ "load_seconds": 26.41778670099984,
5
+ "metadata": {
6
+ "checkpoint": "checkpoints/jevlike-large-nf",
7
+ "context": 2048,
8
+ "precision": "float32 weights, bfloat16 autocast",
9
+ "long_state": "chunk",
10
+ "parameters": 412898308,
11
+ "loaded_allocated_gib": 1.5381693840026855
12
+ },
13
+ "torch": "2.10.0+cu128",
14
+ "transformers": "5.2.0",
15
+ "gpu": "NVIDIA GeForce RTX 4050 Laptop GPU",
16
+ "gpu_before": "NVIDIA GeForce RTX 4050 Laptop GPU, 59, 8.60 W, 885 MHz, 1126 MiB, 18 %",
17
+ "threads": 4,
18
+ "manifest_sha256": "77c421d0c50c76eb89016a4d77b4fde198d58c0bb0ca0d8413af171fdc183d24",
19
+ "accuracy": {
20
+ "completed": 2496,
21
+ "requested": 2496,
22
+ "errors": [],
23
+ "seconds": 86.19311960999994
24
+ },
25
+ "peak_allocated_gib": 2.7976670265197754,
26
+ "peak_reserved_gib": 2.90234375,
27
+ "peak_cpu_rss_gib": 4.338947296142578,
28
+ "gpu_after": "NVIDIA GeForce RTX 4050 Laptop GPU, 68, 54.81 W, 2295 MHz, 4115 MiB, 100 %",
29
+ "cpu_fallbacks": 0,
30
+ "total_seconds": 183.62152970700004,
31
+ "complete": true
32
+ }
examples/quickstart.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Run from any directory after installing the downloaded model's runtime."""
2
+ import argparse
3
+ import json
4
+ from pathlib import Path
5
+
6
+ from jevlike import SystemOne, Choice, Score, Noul
7
+
8
+
9
+ def main():
10
+ parser = argparse.ArgumentParser(description=__doc__)
11
+ parser.add_argument('--model-dir', type=Path, default=Path(__file__).resolve().parents[1])
12
+ parser.add_argument('--device', default='cuda', choices=['cuda', 'cpu'])
13
+ args = parser.parse_args()
14
+ model = SystemOne.load(str(args.model_dir), device=args.device, long_state='chunk')
15
+ questions = {
16
+ 'team': Choice('Which team should handle this request?', {
17
+ 'billing': 'payments, invoices, refunds',
18
+ 'technical': 'bugs, errors, broken software',
19
+ 'other': 'another kind of request',
20
+ }),
21
+ 'urgency': Score('How urgent is this request?', ['low', 'normal', 'urgent']),
22
+ 'refund': Noul('The customer explicitly requests a refund.'),
23
+ }
24
+ state = json.dumps({'message': 'I was charged twice. Please refund the duplicate payment.'})
25
+ result = model.predict(state, questions)
26
+ print(json.dumps(result, indent=2, allow_nan=False))
27
+
28
+
29
+ if __name__ == '__main__':
30
+ main()
release_manifest.json CHANGED
@@ -10,14 +10,14 @@
10
  },
11
  "files": {
12
  "NOTICE": {
13
- "bytes": 335,
14
- "sha256": "e409c9dcdf16aff55eb7d45bd1beb164be92d277151b07ed119cafedb52946ca",
15
- "git_blob_sha1": "f59de758d69de48884cfd7fb6a73430dce4c3317"
16
  },
17
  "README.md": {
18
- "bytes": 3704,
19
- "sha256": "f37d45e61b903c6d8225c830d6ed072978c4fad4eb6b7036ed5cd962ee49a0c2",
20
- "git_blob_sha1": "bf0090332696a26709da0f8d72a26ec5e208d32b"
21
  },
22
  "calibration.json": {
23
  "bytes": 2506,
@@ -233,6 +233,17 @@
233
  "bytes": 782,
234
  "sha256": "c18a3ff75a88c0a25b3bdda8def1344609814efbd8578edd715f47c8ca18207c",
235
  "git_blob_sha1": "bfe45ebc64441c76f6dbc0a5b0b415d0457f9a15"
 
 
 
 
 
 
 
 
 
 
236
  }
237
- }
 
238
  }
 
10
  },
11
  "files": {
12
  "NOTICE": {
13
+ "bytes": 327,
14
+ "sha256": "7fddd61735b6bd4ad139ab0c75c5a5272862b8d7e5db627803cffdf6b8192be2",
15
+ "git_blob_sha1": "e5bc217b2051bf19924e1be786257a157e80a9cd"
16
  },
17
  "README.md": {
18
+ "bytes": 12099,
19
+ "sha256": "0d775eb4df23c3b1974cd81333358cf896c270dbd2281c3f7a5c95dc0eaeba39",
20
+ "git_blob_sha1": "f28e16ac42cb1b0808b5fb8cc0ac64e5d29b8c86"
21
  },
22
  "calibration.json": {
23
  "bytes": 2506,
 
233
  "bytes": 782,
234
  "sha256": "c18a3ff75a88c0a25b3bdda8def1344609814efbd8578edd715f47c8ca18207c",
235
  "git_blob_sha1": "bfe45ebc64441c76f6dbc0a5b0b415d0457f9a15"
236
+ },
237
+ "examples/quickstart.py": {
238
+ "bytes": 1204,
239
+ "sha256": "6b21f55c5f7941ecb66e906e8efc23e6e892190cdfad7cd8a84755a822cd2c32",
240
+ "git_blob_sha1": "2c294e879361d5a419168c8355fe7ac408ff8bb2"
241
+ },
242
+ "evaluation/run_metadata.json": {
243
+ "bytes": 1074,
244
+ "sha256": "34a1077ebf74bf9996d676cfa28f71678cdde09a71b02a0b0057cb9b29a975c3",
245
+ "git_blob_sha1": "7558e9b69cb23ec2015029cab7d1703442183d2a"
246
  }
247
+ },
248
+ "documentation_updated_utc": "2026-10-01T07:52:44.255662+00:00"
249
  }