leafant 0.2.0a1__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.
Files changed (102) hide show
  1. leafant-0.2.0a1/MANIFEST.in +8 -0
  2. leafant-0.2.0a1/PKG-INFO +57 -0
  3. leafant-0.2.0a1/README.md +153 -0
  4. leafant-0.2.0a1/assets/long-context-cache.png +0 -0
  5. leafant-0.2.0a1/assets/long-context.png +0 -0
  6. leafant-0.2.0a1/assets/s1bench-tasks.png +0 -0
  7. leafant-0.2.0a1/assets/s1bench.png +0 -0
  8. leafant-0.2.0a1/assets/workflow-benchmarks.png +0 -0
  9. leafant-0.2.0a1/assets/workflow-pilot-coverage.png +0 -0
  10. leafant-0.2.0a1/colab/config.yaml +51 -0
  11. leafant-0.2.0a1/docs/BENCHMARKS.md +53 -0
  12. leafant-0.2.0a1/docs/CI_ROUTING.md +26 -0
  13. leafant-0.2.0a1/docs/DEVELOPMENT.md +16 -0
  14. leafant-0.2.0a1/docs/FLASH_ARCHITECTURE.md +138 -0
  15. leafant-0.2.0a1/docs/PACKAGE.md +22 -0
  16. leafant-0.2.0a1/docs/RELEASING.md +40 -0
  17. leafant-0.2.0a1/docs/TYPED_API.md +96 -0
  18. leafant-0.2.0a1/docs/WORKFLOW_SERVICE.md +43 -0
  19. leafant-0.2.0a1/docs/benchmark-evidence.json +336 -0
  20. leafant-0.2.0a1/docs/flash_mixer_cpu_evidence.json +69 -0
  21. leafant-0.2.0a1/docs/model_size_estimate.json +18 -0
  22. leafant-0.2.0a1/docs/public_dataset_scoring_evidence.json +44 -0
  23. leafant-0.2.0a1/examples/ci-exit-status.json +21 -0
  24. leafant-0.2.0a1/examples/decision.json +16 -0
  25. leafant-0.2.0a1/leafant/__init__.py +43 -0
  26. leafant-0.2.0a1/leafant/agent.py +381 -0
  27. leafant-0.2.0a1/leafant/backbone.py +83 -0
  28. leafant-0.2.0a1/leafant/benchmarks.py +291 -0
  29. leafant-0.2.0a1/leafant/box_reader.py +154 -0
  30. leafant-0.2.0a1/leafant/calibrate.py +287 -0
  31. leafant-0.2.0a1/leafant/checkpoint.py +101 -0
  32. leafant-0.2.0a1/leafant/ci_routing.py +131 -0
  33. leafant-0.2.0a1/leafant/civil_toxicity.py +76 -0
  34. leafant-0.2.0a1/leafant/cli.py +140 -0
  35. leafant-0.2.0a1/leafant/compare_gliner.py +63 -0
  36. leafant-0.2.0a1/leafant/compare_jev.py +95 -0
  37. leafant-0.2.0a1/leafant/compare_laya.py +128 -0
  38. leafant-0.2.0a1/leafant/competition.py +274 -0
  39. leafant-0.2.0a1/leafant/data.py +443 -0
  40. leafant-0.2.0a1/leafant/datasets.py +326 -0
  41. leafant-0.2.0a1/leafant/evals.py +375 -0
  42. leafant-0.2.0a1/leafant/evidence.py +51 -0
  43. leafant-0.2.0a1/leafant/extract.py +174 -0
  44. leafant-0.2.0a1/leafant/fact_checklist.py +108 -0
  45. leafant-0.2.0a1/leafant/format.py +241 -0
  46. leafant-0.2.0a1/leafant/image_decisions.py +97 -0
  47. leafant-0.2.0a1/leafant/inference_cache.py +123 -0
  48. leafant-0.2.0a1/leafant/intent_scorer.py +57 -0
  49. leafant-0.2.0a1/leafant/joint_reader.py +37 -0
  50. leafant-0.2.0a1/leafant/long_reader.py +367 -0
  51. leafant-0.2.0a1/leafant/losses.py +92 -0
  52. leafant-0.2.0a1/leafant/model.py +241 -0
  53. leafant-0.2.0a1/leafant/multitask.py +437 -0
  54. leafant-0.2.0a1/leafant/onnx_export.py +74 -0
  55. leafant-0.2.0a1/leafant/question_schema.py +142 -0
  56. leafant-0.2.0a1/leafant/reader_limits.py +36 -0
  57. leafant-0.2.0a1/leafant/scoped_evidence.py +39 -0
  58. leafant-0.2.0a1/leafant/serve.py +332 -0
  59. leafant-0.2.0a1/leafant/set_mixer.py +86 -0
  60. leafant-0.2.0a1/leafant/tokenizer.py +113 -0
  61. leafant-0.2.0a1/leafant/train.py +115 -0
  62. leafant-0.2.0a1/leafant/util.py +28 -0
  63. leafant-0.2.0a1/leafant/warm_start.py +172 -0
  64. leafant-0.2.0a1/leafant/workflow_specialist.py +303 -0
  65. leafant-0.2.0a1/leafant/workflows.py +51 -0
  66. leafant-0.2.0a1/leafant.egg-info/PKG-INFO +57 -0
  67. leafant-0.2.0a1/leafant.egg-info/SOURCES.txt +100 -0
  68. leafant-0.2.0a1/leafant.egg-info/dependency_links.txt +1 -0
  69. leafant-0.2.0a1/leafant.egg-info/entry_points.txt +3 -0
  70. leafant-0.2.0a1/leafant.egg-info/requires.txt +32 -0
  71. leafant-0.2.0a1/leafant.egg-info/top_level.txt +1 -0
  72. leafant-0.2.0a1/prompts/decision_policy.md +28 -0
  73. leafant-0.2.0a1/pyproject.toml +28 -0
  74. leafant-0.2.0a1/scripts/audit_saved_decisions.py +160 -0
  75. leafant-0.2.0a1/scripts/benchmark_inference.py +189 -0
  76. leafant-0.2.0a1/scripts/build_custom_decisions.py +217 -0
  77. leafant-0.2.0a1/scripts/check_serving_checkpoint.py +240 -0
  78. leafant-0.2.0a1/scripts/evaluate_laya_budget.py +141 -0
  79. leafant-0.2.0a1/scripts/freeze_independent_panel.py +120 -0
  80. leafant-0.2.0a1/scripts/github_ci_input.py +97 -0
  81. leafant-0.2.0a1/scripts/package_checkpoint.py +202 -0
  82. leafant-0.2.0a1/scripts/shadow_ci_route.py +89 -0
  83. leafant-0.2.0a1/scripts/train_cloud.py +298 -0
  84. leafant-0.2.0a1/setup.cfg +4 -0
  85. leafant-0.2.0a1/tests/test_budget_evaluation_save.py +97 -0
  86. leafant-0.2.0a1/tests/test_checkpoint_export.py +33 -0
  87. leafant-0.2.0a1/tests/test_ci_routing.py +239 -0
  88. leafant-0.2.0a1/tests/test_clinc_dataset.py +22 -0
  89. leafant-0.2.0a1/tests/test_core_regressions.py +604 -0
  90. leafant-0.2.0a1/tests/test_current_laya_evaluation.py +69 -0
  91. leafant-0.2.0a1/tests/test_fact_checklist.py +30 -0
  92. leafant-0.2.0a1/tests/test_flash_architecture.py +133 -0
  93. leafant-0.2.0a1/tests/test_independent_panel.py +68 -0
  94. leafant-0.2.0a1/tests/test_inference_cache.py +134 -0
  95. leafant-0.2.0a1/tests/test_jev_adapter.py +44 -0
  96. leafant-0.2.0a1/tests/test_joint_reader.py +112 -0
  97. leafant-0.2.0a1/tests/test_native_amp.py +55 -0
  98. leafant-0.2.0a1/tests/test_profile_precision.py +29 -0
  99. leafant-0.2.0a1/tests/test_saved_decision_audit.py +129 -0
  100. leafant-0.2.0a1/tests/test_serving_checkpoint_probe.py +67 -0
  101. leafant-0.2.0a1/tests/test_serving_limits.py +441 -0
  102. leafant-0.2.0a1/tests/test_warm_start_data.py +227 -0
@@ -0,0 +1,8 @@
1
+ graft assets
2
+ graft docs
3
+ graft examples
4
+ graft prompts
5
+ graft scripts
6
+ include colab/config.yaml
7
+ global-exclude *.py[cod]
8
+ prune .pytest_cache
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: leafant
3
+ Version: 0.2.0a1
4
+ Summary: Leaf Ant Flash by PlutoAI - lightweight typed decisions with adaptive option-set attention
5
+ Project-URL: Publisher, https://plutosi.one
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: numpy>=1.26
9
+ Requires-Dist: torch>=2.6
10
+ Requires-Dist: transformers<5,>=4.57
11
+ Requires-Dist: huggingface-hub>=0.34
12
+ Requires-Dist: safetensors
13
+ Requires-Dist: sentencepiece
14
+ Provides-Extra: hf
15
+ Requires-Dist: transformers<5,>=4.48; extra == "hf"
16
+ Requires-Dist: safetensors; extra == "hf"
17
+ Requires-Dist: sentencepiece; extra == "hf"
18
+ Provides-Extra: vision
19
+ Requires-Dist: transformers<5,>=4.57; extra == "vision"
20
+ Requires-Dist: safetensors; extra == "vision"
21
+ Requires-Dist: Pillow>=10; extra == "vision"
22
+ Requires-Dist: torchvision; extra == "vision"
23
+ Provides-Extra: cloud
24
+ Requires-Dist: transformers<5,>=4.48; extra == "cloud"
25
+ Requires-Dist: safetensors; extra == "cloud"
26
+ Requires-Dist: sentencepiece; extra == "cloud"
27
+ Requires-Dist: datasets<5,>=4; extra == "cloud"
28
+ Requires-Dist: pyyaml; extra == "cloud"
29
+ Requires-Dist: pytest; extra == "cloud"
30
+ Provides-Extra: serve
31
+ Requires-Dist: fastapi>=0.110; extra == "serve"
32
+ Requires-Dist: uvicorn>=0.27; extra == "serve"
33
+ Provides-Extra: evals
34
+ Requires-Dist: scikit-learn; extra == "evals"
35
+
36
+ # Leaf Ant Flash
37
+
38
+ Leaf Ant returns typed decisions for agents and software workflows. Pass a log, message, or JSON record and ask a Choice, Boolean, or Score question. The result includes the available outcomes and their probabilities.
39
+
40
+ ```python
41
+ from leafant import load_reader
42
+
43
+ reader = load_reader()
44
+ result = reader.predict(
45
+ "Unit tests passed. The payment integration check failed.",
46
+ {"release": {"type": "choice", "instructions": "Should the release proceed?",
47
+ "criteria": {"proceed": "All required checks passed",
48
+ "review": "A required check failed or has no result"}}},
49
+ )
50
+ print(result["answers"]["release"])
51
+ ```
52
+
53
+ The default text reader downloads pinned weights on first use. It selects CUDA when available and otherwise uses CPU. Use the separate CPU workflow bundle for lower-memory inference on its four registered schemas.
54
+
55
+ Install the HTTP extra to run `leafant-serve`. The Python API and HTTP server are an engineering preview.
56
+
57
+ [Documentation and benchmarks](https://github.com/yessthisiskhaleel/leaf-ant-flash) · [PlutoAI](https://plutosi.one)
@@ -0,0 +1,153 @@
1
+ # Leaf Ant Flash
2
+
3
+ **A System 1 decision model for coding agents and software workflows.** Send a log, message, or structured record and ask a Choice, Boolean, or Score question. Leaf Ant returns probabilities and a decision your code can use for routing, triage, or review.
4
+
5
+ Built by **PlutoAI**. [Install](#installation) · [Python quickstart](#quickstart) · [HTTP server](#self-host-the-http-server) · [CPU pilot](#self-host-the-workflow-pilot) · [Benchmarks](#benchmarks) · [Website](https://plutosi.one)
6
+
7
+ ## Installation
8
+
9
+ Use Python 3.10 or later. Install from the repository while the PyPI distribution is pending. The commands assume you have a checkout.
10
+
11
+ **macOS or Linux**
12
+
13
+ ```sh
14
+ python3 -m venv .venv
15
+ source .venv/bin/activate
16
+ python -m pip install .
17
+ ```
18
+
19
+ **Windows PowerShell**
20
+
21
+ ```powershell
22
+ py -3.12 -m venv .venv
23
+ .\.venv\Scripts\python.exe -m pip install .
24
+ .\.venv\Scripts\python.exe -c "import leafant; print(leafant.__version__)"
25
+ ```
26
+
27
+ The base install includes the Python reader. Use `python -m pip install ".[serve]"` in the same environment to add the HTTP server. Choose a compatible PyTorch build if you use a GPU. [PyTorch install selector](https://pytorch.org/get-started/locally/)
28
+
29
+ ## Quickstart
30
+
31
+ Ask a question over a structured release record. The first call to `load_reader()` downloads the default model and selects a device.
32
+
33
+ ```python
34
+ import json
35
+ from pathlib import Path
36
+
37
+ from leafant import load_reader
38
+
39
+ reader = load_reader()
40
+ request = json.loads(Path("examples/decision.json").read_text(encoding="utf-8"))
41
+ result = reader.predict(request["state"], request["questions"])
42
+ answer = result["answers"]["release_check"]
43
+ print(answer["decision"])
44
+ print(answer["probabilities"])
45
+ ```
46
+
47
+ Run the example from the repository root. Model files stay in the Hugging Face cache. The general reader needs enough memory for its weights and inputs. The separate CPU bundle is the smaller download for the registered workflows. [Example input](examples/decision.json) · [Reader and device options](docs/TYPED_API.md#reader-and-device)
48
+
49
+ ## Self-host the HTTP server
50
+
51
+ From the repository root, install the HTTP extra and set a local API key. The server binds to `127.0.0.1:8000` by default. The endpoint is available when `GET /health` reports `ready: true`.
52
+
53
+ ```sh
54
+ python -m pip install ".[serve]"
55
+ export LEAFANT_API_KEY="choose-a-local-key"
56
+ leafant-serve
57
+ ```
58
+
59
+ In another terminal, set the same API key and ask whether a failed check should send the release to review.
60
+
61
+ ```sh
62
+ curl -sS http://127.0.0.1:8000/v1/systemone \
63
+ -H "Authorization: Bearer $LEAFANT_API_KEY" \
64
+ -H "Content-Type: application/json" \
65
+ --data-binary @examples/decision.json
66
+ ```
67
+
68
+ Read `answers.release_check.decision` for the suggested action and `answers.release_check.probabilities` for the scores of both options. [Example request](examples/decision.json) · [PowerShell, device options, and API details](docs/TYPED_API.md)
69
+
70
+ For a server used by other machines, configure authentication and TLS at your ingress. Keep the server’s loopback default for local use. `--max-queued` caps the queue, and `--queue-timeout-ms` controls how long a request can wait for the inference worker. Busy requests return HTTP 429. [Server options and errors](docs/TYPED_API.md)
71
+
72
+ Existing System One clients can reuse the `/v1/systemone` path and the basic typed request. Compare response usage fields and decline handling before changing an existing client’s base URL. [Compatibility notes](docs/TYPED_API.md#moving-a-system-one-client)
73
+
74
+ ## What a decision looks like
75
+
76
+ An agent inspecting a failed build can ask who should investigate, whether a required check failed, and how urgent the failure is. The workflow retains control over the next action.
77
+
78
+ | Question type | Example | Response |
79
+ | --- | --- | --- |
80
+ | Choice | Who should investigate this failure? | A named option and a probability for every option |
81
+ | Boolean (`noul`) | Did a required check fail? | The probability of yes and a Boolean decision |
82
+ | Score | How urgent is this case? | A distribution over ordered levels and a rounded expected score |
83
+
84
+ Supply the same state once for several questions. A caller can set a confidence floor and send declined answers to review. [CI routing with source references](docs/CI_ROUTING.md)
85
+
86
+ ### Handle a declined decision
87
+
88
+ The answer’s `decision` is `None` in Python when it falls below the confidence floor. The probabilities are still available for logging. Keep the model’s suggestion separate from the workflow action.
89
+
90
+ ```python
91
+ result = reader.predict(request["state"], request["questions"], min_confidence=0.8)
92
+ decision = result["answers"]["release_check"]["decision"]
93
+ next_step = decision if decision is not None else "review"
94
+ ```
95
+
96
+ On HTTP, a confidence decline returns 422 with the answers in `detail.answers`. Context overflow and invalid input also return 422, with a different error body.
97
+
98
+ | Response | How to handle it |
99
+ | --- | --- |
100
+ | 200 | Read the typed decision for each question. |
101
+ | 401 | Use the server’s bearer key. |
102
+ | 422 with `model declined a decision` | Review the declined question and retain the available answers for inspection. |
103
+ | 422 with `max_tokens_exceeded` | Reduce the state or the total question input. |
104
+ | 429 | Retry with backoff or send the case to review. |
105
+
106
+ Try a CI fixture from the repository root. With only an exit code as evidence, it returns `human_review` and the reason `exit_status_only`. The fixture runs without loading a model.
107
+
108
+ ```sh
109
+ python scripts/shadow_ci_route.py examples/ci-exit-status.json
110
+ ```
111
+
112
+ ## Choose a reader
113
+
114
+ | Reader | Use it for | Status |
115
+ | --- | --- | --- |
116
+ | **CPU workflow specialist** | Registered questions for agent traces, customer service, invoices, and security incidents | Self-hostable, human-reviewed pilot |
117
+ | **General text reader** | General text and JSON questions, including long logs and documents | Experimental. Up to 32,000 tokens for state plus one question and 64,000 per request |
118
+ | **Optional visual reader** | Typed questions about a referenced PNG or JPEG | Experimental and requires separate model files |
119
+
120
+ The general text reader answered 286 of 350 English and 273 of 350 German MASSIVE intent questions correctly. Those measurements cover two locales on one task. [Multilingual evidence](docs/BENCHMARKS.md#multilingual-text)
121
+
122
+ The optional image reader answers typed questions about a referenced image. A separate detector returns the location of a described object. A CPU checklist can score whether a summary contains each fact supplied by the caller. [Image reader](leafant/image_decisions.py) · [Box detector](leafant/box_reader.py) · [Summary checklist](leafant/fact_checklist.py)
123
+
124
+ ## Self-host the workflow pilot
125
+
126
+ The separately distributed **CPU workflow service bundle** includes the fitted weights, supported schemas, dependency pins, and a sample request. Run it locally to shadow one decision per request while your current workflow handles the actual case. The source checkout includes the API implementation. [CPU service setup](docs/WORKFLOW_SERVICE.md)
127
+
128
+ After installing the bundle’s pinned requirements, start it in the extracted directory.
129
+
130
+ ```sh
131
+ python -m leafant.serve --workflow-specialist workflow-specialist.zip --min-confidence 0.75 --max-queued 8 --queue-timeout-ms 1000
132
+ ```
133
+
134
+ The bundle’s `schemas.json` defines the four accepted state shapes and their exact questions. Use the included example to verify service startup. For a support pilot, submit incoming tickets, capture independent human labels, and report both the share Leaf Ant answered and mistakes among those answers. [Pilot setup and evaluation](docs/WORKFLOW_SERVICE.md#review-a-real-workflow)
135
+
136
+ ## Benchmarks
137
+
138
+ The experimental text reader scored **72.01%** across 13 S1Bench tasks, ahead of Laya Vega at **46.81%** and behind archived Jev 1.13 at **76.10%**. The right panel compares Leaf Ant and Vega at the same number of answers within each task. [Full benchmark guide](docs/BENCHMARKS.md#s1bench)
139
+
140
+ For the CPU pilot, confidence determines how often Leaf Ant answers. It answered **342 of 2,000 archived workflow questions** at the selected floor and got **6 of those answers wrong**. Live qualification still requires representative, independently reviewed cases. [Accuracy by workflow](docs/BENCHMARKS.md#typed-workflows) · [Pilot threshold curve](docs/BENCHMARKS.md#pilot-accuracy-and-coverage) · [Long-context accuracy and latency](docs/BENCHMARKS.md#long-context)
141
+
142
+ ![Accuracy for Leaf Ant, archived Jev, and Laya across four typed workflows.](assets/workflow-benchmarks.png)
143
+
144
+ ## Project documentation
145
+
146
+ | I want to | Guide |
147
+ | --- | --- |
148
+ | Call the API from an app | [Typed requests, example, and response fields](docs/TYPED_API.md) |
149
+ | Route CI failures with traceable evidence | [CI routing in shadow mode](docs/CI_ROUTING.md) |
150
+ | Self-host the fitted CPU reader | [Workflow service and schemas](docs/WORKFLOW_SERVICE.md) |
151
+ | Inspect the data behind the charts | [Benchmarks and run fingerprints](docs/BENCHMARKS.md) |
152
+ | Understand how the readers differ | [Architecture](docs/FLASH_ARCHITECTURE.md) · [Reader and model dependencies](docs/TYPED_API.md#reader-and-device) |
153
+ | Test, build, and distribute the package | [Development](docs/DEVELOPMENT.md) · [Releasing](docs/RELEASING.md) |
Binary file
Binary file
Binary file
@@ -0,0 +1,51 @@
1
+ run:
2
+ name: leafant-flash-training-v1
3
+ seed: 42
4
+ model:
5
+ model_name: leaf-ant-flash
6
+ architecture_version: flash/1
7
+ publisher: PlutoAI
8
+ publisher_url: https://plutosi.one
9
+ publisher_urls: [https://plutosi.one]
10
+ backbone: intfloat/multilingual-e5-small
11
+ d_model: 384
12
+ n_heads: 6
13
+ set_layers: 1
14
+ set_mixer: adaptive_latent
15
+ set_inducing_points: 16
16
+ set_exact_threshold: 256
17
+ set_latent_train_probability: 0.25
18
+ question_conditioned_abstention: true
19
+ separate_question_encoding: true
20
+ max_question_len: 128
21
+ encoder_cache_bytes: 67108864
22
+ training:
23
+ epochs: 3
24
+ batch_size: 2
25
+ grad_accum: 16
26
+ lr: 0.0003
27
+ hf_lr: 0.00002
28
+ amp: auto
29
+ gradient_checkpointing: true
30
+ max_batch_options: 192
31
+ checkpoint_every_steps: 25
32
+ validation_every_steps: 200
33
+ max_seconds: 14400
34
+ warmup_steps: 50
35
+ val_fraction: 0.08
36
+ calib_frac: 0.08
37
+ calib_max: 1200
38
+ val_max_per_task: 100
39
+ sampling: proportional
40
+ task_weights: {}
41
+ rps_w: 0.1
42
+ brier_w: 0.25
43
+ abstain_w: 0.5
44
+ data:
45
+ datasets: [ag_news, banking77, clinc150, emotion, sst5, boolq, typed_decisions, xnli, massive, massive_scenario]
46
+ languages: all
47
+ per_task_train: 2000
48
+ per_language_train: 300
49
+ max_state_len: 256
50
+ max_opt_len: 48
51
+ synthetic_rows: 1000
@@ -0,0 +1,53 @@
1
+ # Leaf Ant Flash benchmarks
2
+
3
+ Leaf Ant has two measured configurations. The native 4B reader answers general text and JSON questions. The CPU specialist answers registered questions across four workflows. The charts identify the reader and test used for each measurement.
4
+
5
+ ## S1Bench
6
+
7
+ The 4B reader answered 2,791 of 3,880 public questions correctly. The headline **72.01%** is the average accuracy across 13 tasks, with equal weight per task. Jev 1.13’s **76.10%** comes from its published per-task results. Laya Vega’s **46.81%** comes from a replay on the same questions. [S1Bench dataset loader](https://github.com/InterfazeAI/lev/blob/79e1661aeb42dadebc144753a4f37117510952ee/packages/lev/src/lev/data/s1bench.py) · [Jev archive](https://github.com/InterfazeAI/lev/blob/79e1661aeb42dadebc144753a4f37117510952ee/docs/charts/logs/jev-s1bench-2026-09-24.txt)
8
+
9
+ ![S1Bench accuracy for Leaf Ant 4B, Jev 1.13, and Laya Vega, plus Leaf Ant and Vega error rates on 1,941 answers per model.](../assets/s1bench.png)
10
+
11
+ For the error comparison, Vega’s routing policy chose to answer 1,941 questions. Leaf Ant selected its highest-confidence questions within each task, matching the number Vega answered there. Leaf Ant made **385 errors** and Vega made **929**. Each model chose its own questions within that budget.
12
+
13
+ ![All 13 S1Bench tasks, with three model bars for each task.](../assets/s1bench-tasks.png)
14
+
15
+ Leaf Ant scored higher than Vega on 11 of 13 tasks. Vega led on Civil Comments and SummEval relevance. Jev led Leaf Ant on 10 of 13 tasks.
16
+
17
+ ### Multilingual text
18
+
19
+ The 4B reader answered **286/350 English** and **273/350 German** MASSIVE intent questions correctly. These are two locale splits of the same intent classification task. [MASSIVE dataset](https://huggingface.co/datasets/AmazonScience/massive)
20
+
21
+ ## Typed workflows
22
+
23
+ The CPU specialist, archived Jev 1.13, and the archived Laya typed specialist each answered the same 2,000 questions. This chart scores every answer. For ordinal questions, the benchmark compares the most probable level to the reference label.
24
+
25
+ ![Accuracy by workflow. Overall, Leaf Ant CPU scored 73.90%, archived Jev scored 73.80%, and archived Laya typed scored 76.55%.](../assets/workflow-benchmarks.png)
26
+
27
+ The Leaf Ant–Jev difference was **+0.10 percentage points**, with a paired 95% interval of **−2.45 to +2.60 points**. Laya’s typed specialist led overall. Leaf Ant led both on invoice processing and trailed both on customer service and security incidents. [Typed-decisions dataset](https://huggingface.co/datasets/LocalLLaMA/typed-decisions)
28
+
29
+ ### Pilot accuracy and coverage
30
+
31
+ Coverage is the share of questions Leaf Ant answers. The curve shows what happens as the threshold changes. At the highlighted **0.75** confidence floor, it answered **342 of 2,000** questions and made **6 errors** among those answers. The pilot scores the rounded decision it actually returns for ordinal questions.
32
+
33
+ ![At the pilot threshold, Leaf Ant answered 17.1% of workflow questions and got 98.25% of those answers right.](../assets/workflow-pilot-coverage.png)
34
+
35
+ This threshold is qualified for human review on the registered schemas. Automated production decisions need an error and coverage estimate from the intended live workflow.
36
+
37
+ ## Long context
38
+
39
+ The native 4B reader accepts **32,000 tokens** for shared state plus any one question and **64,000 tokens per request**, with the shared state counted once. The test below uses synthetic coding and company decisions. Input sizes and answer counts differ by fixture. Latency is measured for the full loopback HTTP request on one NVIDIA T4.
40
+
41
+ ![4B long-context result table. The reader got 18 of 36 long development cases right and 3 of 5 answers in the full 64,000-token request.](../assets/long-context.png)
42
+
43
+ The 4B reader answered both versions correctly in **3 of 18** development pairs where a decisive fact changed. That is the relevant test for an agent deciding whether a recent event changes the next action.
44
+
45
+ ### Speed after editing a long log
46
+
47
+ The next experiment measures the 1.5B workflow-attention reader on the same NVIDIA T4 GPU class. The worker rereads the log with exact-state caching or reuses the unchanged text. At 31,000 tokens, the edited log took **16.20 s** with a reread and **0.60 s** with reuse. Both modes returned the old status after the edit.
48
+
49
+ ![Latency after a log edit, comparing a full reread and reuse of unchanged text at 8,192 and 31,000 tokens.](../assets/long-context-cache.png)
50
+
51
+ ## Benchmark records
52
+
53
+ The published figures summarize the recorded runs. The source repository carries aggregate evidence with run fingerprints. Traces, weights, and datasets are distributed separately. [Aggregate benchmark record](benchmark-evidence.json) · [Laya documentation](https://github.com/NandhaKishorM/laya/blob/main/BENCHMARKS.md) · [Jev model documentation](https://docs.typesafe.ai/models)
@@ -0,0 +1,26 @@
1
+ # CI routing in shadow mode
2
+
3
+ Use Leaf Ant to suggest who should investigate a failed CI job while your existing process continues to assign incidents. The three suggested routes are `component_maintainer`, `build_infrastructure`, and `human_review`.
4
+
5
+ ## Replay a failure
6
+
7
+ From the repository root, run the example with Python 3.10 or newer. It reads a fixture containing a single exit status. The client's evidence check returns `human_review` with reason `exit_status_only` and retains the input's source reference.
8
+
9
+ ```bash
10
+ python scripts/shadow_ci_route.py examples/ci-exit-status.json
11
+ ```
12
+
13
+ For a public GitHub Actions job, collect the failure annotations. Use a completed failed or timed-out job and its job ID. Run the second command with the [Leaf Ant server](../README.md#self-host-the-http-server) running and the same `LEAFANT_API_KEY` in the client's environment.
14
+
15
+ ```bash
16
+ python scripts/github_ci_input.py python/cpython 141864770234 --failure-annotations > ci-input.json
17
+ python scripts/shadow_ci_route.py ci-input.json
18
+ ```
19
+
20
+ ## What the client checks
21
+
22
+ The input has a `target` and a list of evidence `packets`. The target names the repository, full commit SHA, and run ID. Include job ID and attempt when they are available. A packet has the same execution identity, a source URL, the excerpt, and a SHA-256 digest of its UTF-8 bytes. The connector obtains those fields from the CI provider.
23
+
24
+ The client checks the execution identity and excerpt digest before asking the model. An ambiguous or missing packet goes to review. A declined model answer, timeout, or malformed response also goes to review. The client returns a suggestion for the caller to log or show to a reviewer.
25
+
26
+ For a pilot, record the suggestion, your existing route, and the eventual human-confirmed owner. Compare wrong assignments at the same share of automatically routed incidents. Group reruns of the same incident together. [Routing code](../leafant/ci_routing.py) · [Shadow client](../scripts/shadow_ci_route.py) · [Tests](../tests/test_ci_routing.py)
@@ -0,0 +1,16 @@
1
+ # Development
2
+
3
+ From the repository root, install the package and test dependencies. The checks below run on CPU and use small local fixtures.
4
+
5
+ ```bash
6
+ python -m pip install -e ".[cloud,serve]" httpx
7
+ python -m pytest -q
8
+ ```
9
+
10
+ The training entry point can show its configuration and compute plan before requesting a GPU.
11
+
12
+ ```bash
13
+ python scripts/train_cloud.py --plan-only
14
+ ```
15
+
16
+ The archived benchmark data, fitted pilot artifact, and pretrained weights are managed separately from source control. Keep new benchmark work reproducible by recording the model revision, input identity, evaluation rule, hardware, and whether model or threshold selection used the evaluation examples. [Architecture guide](FLASH_ARCHITECTURE.md)
@@ -0,0 +1,138 @@
1
+ # Leaf Ant Flash by PlutoAI
2
+
3
+ Publisher: [plutosi.one](https://plutosi.one).
4
+ Python package: leafant 0.2.0a1. Model identifier: leaf-ant-flash.
5
+ Architecture revision: flash/1. Status: architecture preview requiring cloud
6
+ training and benchmark validation.
7
+
8
+ ## Architecture
9
+
10
+ ```mermaid
11
+ flowchart LR
12
+ S[Text or JSON state] --> E[Shared multilingual encoder]
13
+ Q[Question instructions] --> E
14
+ O[Independent option sequences] --> E
15
+ E --> C[Question-conditioned option-to-state attention]
16
+ C --> M[Adaptive option-set mixer]
17
+ M --> D[Choice / Boolean / ordinal probabilities]
18
+ E --> A[Question-conditioned error head]
19
+ D --> A
20
+ D --> G[Calibration and decision gates]
21
+ A --> G
22
+ G --> R[Typed answers or declined decisions]
23
+ ```
24
+
25
+ The candidate uses multilingual-e5-small as a shared encoder. State tokens,
26
+ question instructions, and each option are encoded independently. Repeated option
27
+ and question encodings can be reused by a byte-bounded inference cache. Each new
28
+ state is encoded again, and all state-dependent decisions are recomputed.
29
+
30
+ Option tokens attend to state representations whose key/value projections are
31
+ shared across options. Question representations condition both option scoring
32
+ and the error head. The latter can distinguish decision questions on the same
33
+ state rather than seeing only one state vector and probability statistics.
34
+
35
+ For up to 256 options, the mixer uses full set attention. Larger questions exchange
36
+ information through 16 learned summaries. This inducing-point approach uses
37
+ O(K * R) attention pairs per layer for K options and R summaries, instead of
38
+ O(K squared). Independent option encoding and option-to-state attention still
39
+ cost work proportional to K; this architecture does not make high-K requests free.
40
+ The current choice API accepts at most 512 options per question.
41
+
42
+ During training, small questions use the summary branch with probability 0.25.
43
+ This lets both branches receive updates even when available real schemas have
44
+ fewer than 257 options. Inference uses the fixed threshold consistently on every
45
+ host; the branch does not change with device or batch composition. Interrupted
46
+ resume checkpoints already retain the Torch RNG state controlling training routes.
47
+
48
+ The branch is selected per question. A two-option question continues to use full
49
+ attention when it shares a batch with a 150-option question. Padded options are
50
+ masked and cannot affect the summaries. No positional embeddings are attached
51
+ to option slots, so choice probabilities are permutation equivariant in inference
52
+ within floating-point tolerance. Ordinal criteria have a meaningful fixed order.
53
+
54
+ The summary mixer is inspired by [Set Transformer](https://arxiv.org/abs/1810.00825).
55
+ It is a deliberate capacity/computation tradeoff: compression can lose useful
56
+ candidate interactions. Cloud ablations against set_mixer: transformer are needed
57
+ to determine whether it improves the accuracy/latency tradeoff on real tasks.
58
+
59
+ CPU profiling of a 384-dimensional head with random weights, one question and two
60
+ CPU threads found full attention faster at 77/150 options and summary attention
61
+ about 1.27x faster at 512. The default threshold of 256 avoids the measured
62
+ medium-set regression. These are head-only FP32 measurements, not trained-model
63
+ accuracy or GPU benchmarks. See flash_mixer_cpu_evidence.json.
64
+
65
+ ## Runtime and model size
66
+
67
+ | Purpose | Dependencies |
68
+ |---|---|
69
+ | Core library | Python 3.10+, torch 2.6+, numpy 1.26+ |
70
+ | Flash encoder inference | transformers >=4.48,<5; safetensors; sentencepiece |
71
+ | HTTP endpoint | fastapi >=0.110; uvicorn >=0.27 |
72
+ | Cloud training | Inference dependencies; datasets >=4,<5; pyyaml; pytest |
73
+
74
+ From the extracted package directory:
75
+
76
+ ```bash
77
+ python -m pip install -e ".[hf]"
78
+ python -m pip install -e ".[hf,serve]"
79
+ python -m leafant.serve --checkpoint results/cloud-run/checkpoint --device cpu
80
+ ```
81
+
82
+ Select CUDA for inference on a supported GPU. The training configuration
83
+ targets a single 16 GB GPU and uses mixed precision and gradient checkpointing.
84
+ Memory use and training throughput depend on the device and input lengths.
85
+ CPU inference is supported, but Flash CPU latency has not been measured with a
86
+ trained checkpoint. Initial downloads are needed; new saved HF checkpoint folders
87
+ include encoder configuration and tokenizer files for offline loading.
88
+
89
+ The Flash configuration has 123,749,475 parameters, including 117,653,760 in the
90
+ encoder and 6,095,715 in the decision architecture. FP32 weights alone are
91
+ 0.495 GB (0.461 GiB). FP32 weights plus tokenizer files are expected to occupy roughly 0.5 GB. Mixed
92
+ precision training leaves the saved master weights in FP32. Retaining model.pt,
93
+ best.ckpt and last.ckpt is approximately 2.5 GB, excluding dataset/HF caches.
94
+ The Python/PyTorch environment and inference activations require additional
95
+ disk/RAM/VRAM. See model_size_estimate.json for the parameter calculation.
96
+
97
+ ## Decision policy
98
+
99
+ Leaf Ant Flash does not generate text or consume a special system-message role.
100
+ [The decision policy template](../prompts/decision_policy.md) is supplied for
101
+ question instructions and training-data annotation. The default pipeline does
102
+ not prepend it automatically. Any adopted policy must appear consistently in
103
+ training and inference within the question token budget.
104
+
105
+ Declining a decision is enforced by calibrated gates, not by prompt wording.
106
+ The error head predicts incorrect decisions. Explicit evidence insufficiency,
107
+ instruction hierarchy and prompt-injection robustness require labeled examples
108
+ and dedicated held-out evaluation; they are not established by the template.
109
+
110
+ ## Validation and release requirements
111
+
112
+ Local checks cover permutation equivariance at K=2,32,33,77,150,256,257,512, padding
113
+ isolation, mixed-size batch independence, all three primitives, question-conditioned
114
+ error features, cache parity and checkpoint round trips. They use random tiny
115
+ models and perform no optimizer steps or local training. The optional cloud test
116
+ checks FP16 updates through both mixer branches and reloads a trained checkpoint.
117
+ An opt-in interrupted FP16 resume check includes Flash's stochastic branch routing.
118
+
119
+ The multilingual splits and validation samples retain task/language strata.
120
+ Selection macro-averages languages within a task, then tasks, and logs individual
121
+ language accuracies and sample counts. Small sample point estimates are noisy.
122
+ MASSIVE sampling preserves the full source-split label vocabulary.
123
+ The typed-decisions scorer retains teacher distributions and continuous gold
124
+ scores and reports distribution-mode accuracy, KL, soft Brier, TV and ten-bin ECE.
125
+ Its formulas match the public scorer on 245 live-source decisions; missing
126
+ responses are counted against accuracy and prevent complete distribution-quality
127
+ results. See public_dataset_scoring_evidence.json for the numerical parity check.
128
+ Teacher agreement alone does not establish correctness on real applications.
129
+
130
+ Before calling this a competitive release, train Flash on the cloud, compare the
131
+ same frozen cases against Laya's relevant checkpoints and an accessible Jev
132
+ endpoint, measure CPU/GPU cold and warm inference, and confirm on untouched cases
133
+ and repeated seeds. Browser task success needs separate Karpo runtime evaluation
134
+ with the same browser environment and System 2 model. Flash currently accepts
135
+ text/JSON and has no screenshot encoder.
136
+
137
+ Neither the new mixer nor branding establishes superiority. No trained Flash
138
+ checkpoint or all-benchmark victory is available in this workspace yet.
@@ -0,0 +1,22 @@
1
+ # Leaf Ant Flash
2
+
3
+ Leaf Ant returns typed decisions for agents and software workflows. Pass a log, message, or JSON record and ask a Choice, Boolean, or Score question. The result includes the available outcomes and their probabilities.
4
+
5
+ ```python
6
+ from leafant import load_reader
7
+
8
+ reader = load_reader()
9
+ result = reader.predict(
10
+ "Unit tests passed. The payment integration check failed.",
11
+ {"release": {"type": "choice", "instructions": "Should the release proceed?",
12
+ "criteria": {"proceed": "All required checks passed",
13
+ "review": "A required check failed or has no result"}}},
14
+ )
15
+ print(result["answers"]["release"])
16
+ ```
17
+
18
+ The default text reader downloads pinned weights on first use. It selects CUDA when available and otherwise uses CPU. Use the separate CPU workflow bundle for lower-memory inference on its four registered schemas.
19
+
20
+ Install the HTTP extra to run `leafant-serve`. The Python API and HTTP server are an engineering preview.
21
+
22
+ [Documentation and benchmarks](https://github.com/yessthisiskhaleel/leaf-ant-flash) · [PlutoAI](https://plutosi.one)
@@ -0,0 +1,40 @@
1
+ # Release Leaf Ant
2
+
3
+ The distribution is named `leafant`. The install command for an indexed release is `python -m pip install leafant`. Use `python -m pip install "leafant[serve]"` for the HTTP server. For a preview version, use `--pre` or pin the version. The current quickstart installs from a source checkout while the PyPI release is pending.
4
+
5
+ ## Build and check the distribution
6
+
7
+ From the repository root, run this in a clean Python environment.
8
+
9
+ ```sh
10
+ python -m pip install build twine
11
+ python -m build
12
+ python -m twine check --strict dist/*
13
+ ```
14
+
15
+ Install the wheel in a second environment without the checkout on its Python path. Run `python -c "from leafant import load_reader; print(load_reader.__name__)"` and `leafant-serve --help`. Confirm the package versions and tagged source agree. The Python and HTTP quickstarts download the same pinned text reader. Run a first-download decision and a restart from the cached weights on the target host.
16
+
17
+ ## Publish to PyPI
18
+
19
+ The [Package workflow](../.github/workflows/package.yml) builds and checks the wheel and source distribution. To enable publication, connect the PyPI project to the following Trusted Publisher.
20
+
21
+ | Field | Value |
22
+ | --- | --- |
23
+ | Owner | `yessthisiskhaleel` |
24
+ | Repository | `leaf-ant-flash` |
25
+ | Workflow | `package.yml` |
26
+ | Environment | `pypi` |
27
+
28
+ Run **Package** from `main` with **Publish the checked artifacts to PyPI** selected when the release is ready. The workflow builds and smoke-tests the same artifact it uploads. From a fresh environment run the indexed install and confirm that it resolves the intended version.
29
+
30
+ ## Distribute the fitted CPU artifact
31
+
32
+ The Python package includes the reader and server code. Upload `workflow-specialist.zip`, `schemas.json`, `request.json`, and the model card to the Hugging Face model repository. Using its repository ID, verify first use with `WorkflowSpecialist.from_pretrained(...)` and a repeat load from the cache. The standalone `leaf-ant-workflow-service.zip` bundles the same weights with a minimal runtime and can be attached for offline self-hosting. [CPU setup](WORKFLOW_SERVICE.md)
33
+
34
+ Record the license for the source and the terms for any redistributed fitted weights before describing either as open source. The native reader pulls its backbone from the upstream model publisher. [Upstream readers](TYPED_API.md#reader-and-device)
35
+
36
+ ## Claims to verify on the release
37
+
38
+ - **Self-hosting** uses the CPU bundle’s qualified operating point or the documented text reader.
39
+ - **Jev client compatibility** needs a client-level test of usage fields, accepted answers, and error responses. [Protocol differences](TYPED_API.md#moving-a-system-one-client)
40
+ - **Production performance** requires independently reviewed live traffic from the intended workflow. The archived benchmark measures a defined test set. [Benchmark scope](BENCHMARKS.md)