Jonathan Beckwith commited on
Publish ZERO.4
Browse filesRelease the verified ZERO.4 weights, model card, inference runtime, split licenses, corpus-rights record, and memorization evaluation. Training text and token streams are excluded.
- .gitattributes +1 -0
- CORPUS_RIGHTS.md +109 -0
- LICENSE-CODE +201 -0
- LICENSE-DATA.md +18 -0
- LICENSE-MODEL.md +21 -0
- LICENSES.md +15 -0
- NOTICE +15 -0
- README.md +115 -0
- channel_protocol.h +15 -0
- literary_infer.c +888 -0
- literary_infer.h +31 -0
- model.json +49 -0
- model.litq8 +3 -0
- zero4-memorization-v1.json +410 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
model.litq8 filter=lfs diff=lfs merge=lfs -text
|
CORPUS_RIGHTS.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ZERO.4 corpus rights and provenance
|
| 2 |
+
|
| 3 |
+
**Review date:** 2026-08-12
|
| 4 |
+
|
| 5 |
+
**Artifact:** `docs/model.litq8`
|
| 6 |
+
|
| 7 |
+
**SHA-256:** `44b32f2262be2754fd2eeaf16ed206bae32b4ce30d7f5541a1059cd21257ae50`
|
| 8 |
+
|
| 9 |
+
## Release decision
|
| 10 |
+
|
| 11 |
+
ZERO.4 may be published as model weights under **CC BY-SA 4.0**. The checked
|
| 12 |
+
memorization gate passed for every protected third-party stream. The Hugging
|
| 13 |
+
Face model repository must use `huggingface/release-manifest.json` as an
|
| 14 |
+
allowlist. It must not contain training text, token streams, raw downloads, or
|
| 15 |
+
evaluation datasets.
|
| 16 |
+
|
| 17 |
+
This is a conservative rights and provenance record, not legal advice or a
|
| 18 |
+
guarantee that the same copyright rules apply in every country. Creative
|
| 19 |
+
Commons notes both that AI-training law varies and that using the same CC
|
| 20 |
+
license for a publicly shared model is the conservative way to follow a
|
| 21 |
+
ShareAlike source condition.
|
| 22 |
+
|
| 23 |
+
## Bound training lineage
|
| 24 |
+
|
| 25 |
+
ZERO.4 was initialized from immutable ZERO.3 and trained with immutable
|
| 26 |
+
ZERO.1, ZERO.2, and ZERO.3 teachers. The teacher hashes are bound in
|
| 27 |
+
`teachers/registry.json` and `corpus/RIGHTS.json`. Its replay mixture consisted
|
| 28 |
+
of the foundation, Shakespeare, Blake, Crowley, KJV, and literary-channel
|
| 29 |
+
streams. Its added faculty data was produced by the checked quantity-request
|
| 30 |
+
generator. The promoted checkpoint is Q2.6 seed 2, update 500.
|
| 31 |
+
|
| 32 |
+
The recorded lineage contains **no human chat export**. The channel stream was
|
| 33 |
+
generated only from the named literary inputs. Later Q2.7/Q2.8 research and
|
| 34 |
+
post-training external evaluations are not training sources for ZERO.4.
|
| 35 |
+
|
| 36 |
+
## Source-level assessment
|
| 37 |
+
|
| 38 |
+
| Training slice | Source status | Release treatment |
|
| 39 |
+
| --- | --- | --- |
|
| 40 |
+
| ZERO foundation | Project-authored statements | CC0 1.0 |
|
| 41 |
+
| Shakespeare | [Project Gutenberg eBook 100](https://www.gutenberg.org/ebooks/100), identified there as public domain in the USA | Attribute source; do not include text in the model repo |
|
| 42 |
+
| Blake | [eBook 574](https://www.gutenberg.org/ebooks/574) and [eBook 45315](https://www.gutenberg.org/ebooks/45315), identified there as public domain in the USA | Attribute sources; do not include text in the model repo |
|
| 43 |
+
| Crowley: *Tannhäuser* and *Household Gods* | [eBook 70261](https://www.gutenberg.org/ebooks/70261) and [eBook 14040](https://www.gutenberg.org/ebooks/14040), identified there as public domain in the USA | Attribute sources; jurisdiction review required for dataset redistribution |
|
| 44 |
+
| Crowley: *Clouds without Water* | [Wikisource revision 13649032](https://en.wikisource.org/w/index.php?title=Clouds_without_Water&oldid=13649032); underlying work marked public domain in the USA, transcription contributions under CC BY-SA | Preserve revision, [history](https://en.wikisource.org/w/index.php?title=Clouds_without_Water&action=history), license, and change notice |
|
| 45 |
+
| Crowley: *Liber AL vel Legis* | [Wikisource revision 15225259](https://en.wikisource.org/w/index.php?title=Liber_AL_vel_Legis&oldid=15225259); same license layers | Preserve revision, [history](https://en.wikisource.org/w/index.php?title=Liber_AL_vel_Legis&action=history), license, and change notice; source document is reported as unknown |
|
| 46 |
+
| King James Bible | [Project Gutenberg eBook 30](https://www.gutenberg.org/ebooks/30), identified there as public domain in the USA; special Crown publication rights apply in the UK | Never include the KJV text in the Hugging Face package |
|
| 47 |
+
| Literary channel | Mechanically derived from the Shakespeare, Blake, and Crowley streams | Follows those inputs; no human chat data |
|
| 48 |
+
| Quantity requests | Project-generated typed records | CC0 1.0 to the extent rights exist |
|
| 49 |
+
|
| 50 |
+
Project Gutenberg's [license policy](https://www.gutenberg.org/policy/license)
|
| 51 |
+
explains that its US-public-domain text is unrestricted by US copyright when
|
| 52 |
+
the Gutenberg license/trademark wrapper is removed, while users outside the
|
| 53 |
+
USA must check local law. Those wrappers were removed here. This project does
|
| 54 |
+
not claim Project Gutenberg endorsement.
|
| 55 |
+
|
| 56 |
+
The UK government's [copyright-term notice](https://www.gov.uk/government/publications/copyright-notice-duration-of-copyright-term/copyright-notice-duration-of-copyright-term)
|
| 57 |
+
records the KJV's special letters-patent regime. Excluding the KJV text from
|
| 58 |
+
the model package avoids representing it as a globally unrestricted dataset.
|
| 59 |
+
|
| 60 |
+
## Transformations and attribution
|
| 61 |
+
|
| 62 |
+
The literary inputs underwent wrapper removal, UTF-8/LF normalization,
|
| 63 |
+
character-level ASCII normalization, removal of specified editorial noise,
|
| 64 |
+
and whitespace normalization. Wikisource material was therefore modified.
|
| 65 |
+
The permanent revision and contributor-history links above provide reasonable
|
| 66 |
+
attribution for the collaborative transcription layer; downstream dataset
|
| 67 |
+
publication would require a separate, attribution-preserving review.
|
| 68 |
+
|
| 69 |
+
Original download and transformation hashes are in `corpus/SHA256SUMS` and
|
| 70 |
+
`corpus/RIGHTS.json`. Raw downloads and generated token streams are deliberately
|
| 71 |
+
gitignored; their hashes remain so the exact inputs can be reconstructed and
|
| 72 |
+
checked without placing them in the model release.
|
| 73 |
+
|
| 74 |
+
## Model and code licensing
|
| 75 |
+
|
| 76 |
+
- Trained model artifacts: [CC BY-SA 4.0](LICENSE-MODEL.md), to the extent
|
| 77 |
+
controlled rights apply.
|
| 78 |
+
- Project code and runtime: [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
| 79 |
+
- Eligible first-party generated data: [CC0 1.0](LICENSE-DATA.md).
|
| 80 |
+
- Literary text and derived records: source-specific status above; neither the
|
| 81 |
+
Apache nor model license relicenses them.
|
| 82 |
+
|
| 83 |
+
This split avoids implying that an Apache software license clears the corpus.
|
| 84 |
+
The CC BY-SA model license is conservative overcompliance; it is not a legal
|
| 85 |
+
conclusion that trained weights are necessarily an adaptation in every
|
| 86 |
+
jurisdiction.
|
| 87 |
+
|
| 88 |
+
## Memorization release gate
|
| 89 |
+
|
| 90 |
+
The 2026-08-12 evaluation used sixteen evenly stratified windows per bound
|
| 91 |
+
stream, a 128-token source prompt, and a 64-token greedy continuation. No
|
| 92 |
+
protected third-party stream reached the 32-token warning threshold: the
|
| 93 |
+
maxima were 2 for Shakespeare, 16 for Blake, 4 for Crowley, 6 for the KJV, and
|
| 94 |
+
9 for the derived literary channel.
|
| 95 |
+
|
| 96 |
+
Eight of sixteen project-authored foundation probes reproduced all 64
|
| 97 |
+
continuation tokens. That stream is intentionally inspectable, dedicated under
|
| 98 |
+
CC0, and is therefore recorded as an informational rather than
|
| 99 |
+
third-party-rights blocker. The complete hash-bound, text-free result is in
|
| 100 |
+
`release/zero4-memorization-v1.json`.
|
| 101 |
+
|
| 102 |
+
## Safety and limitations
|
| 103 |
+
|
| 104 |
+
The corpus contains archaic language plus sexual, violent, coercive,
|
| 105 |
+
discriminatory, religious, and drug-related material, especially in the
|
| 106 |
+
Crowley sources. ZERO.4 may reproduce themes or short phrases from its small
|
| 107 |
+
corpus. It is not suitable as an authority on religion, history, medicine,
|
| 108 |
+
law, identity, or factual questions. The memorization evaluation is a useful
|
| 109 |
+
release gate, not proof that no source expression can ever be reproduced.
|
LICENSE-CODE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
https://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
https://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
LICENSE-DATA.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# First-party generated data dedication
|
| 2 |
+
|
| 3 |
+
To the extent possible under law, ZERO contributors waive copyright and
|
| 4 |
+
related or neighboring rights in these first-party data materials under the
|
| 5 |
+
[CC0 1.0 Universal Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/legalcode.en):
|
| 6 |
+
|
| 7 |
+
- `corpus/zero-foundation.txt`; and
|
| 8 |
+
- outputs produced solely from the project's synthetic logic, state, modal,
|
| 9 |
+
brainfuck, and quantity generators, when those outputs contain no
|
| 10 |
+
third-party input material.
|
| 11 |
+
|
| 12 |
+
This dedication does **not** cover literary source text, King James Bible text,
|
| 13 |
+
Wikisource transcriptions, channel records derived from literary sources,
|
| 14 |
+
third-party evaluation datasets, or trained model artifacts. Their status is
|
| 15 |
+
described in [CORPUS_RIGHTS.md](CORPUS_RIGHTS.md) and their own source terms.
|
| 16 |
+
|
| 17 |
+
CC0 includes a fallback license and an as-is/no-warranty statement. The
|
| 18 |
+
canonical legal code controls if this summary differs from it.
|
LICENSE-MODEL.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ZERO model artifact license
|
| 2 |
+
|
| 3 |
+
The checked-in trained model artifacts listed in [LICENSES.md](LICENSES.md),
|
| 4 |
+
including ZERO.4 at `docs/model.litq8`, are licensed under the
|
| 5 |
+
[Creative Commons Attribution-ShareAlike 4.0 International Public License](https://creativecommons.org/licenses/by-sa/4.0/legalcode.en)
|
| 6 |
+
(**CC BY-SA 4.0**) to the extent that copyright or similar rights controlled
|
| 7 |
+
by the ZERO contributors apply to those artifacts.
|
| 8 |
+
|
| 9 |
+
When sharing a model artifact or an adaptation, retain:
|
| 10 |
+
|
| 11 |
+
- the name **ZERO.4** and the attribution **ZERO contributors**;
|
| 12 |
+
- a link to <https://github.com/atimics/zero-grounded-literary-lm>;
|
| 13 |
+
- a link to the CC BY-SA 4.0 license;
|
| 14 |
+
- [CORPUS_RIGHTS.md](CORPUS_RIGHTS.md) and `NOTICE`; and
|
| 15 |
+
- an indication of changes you made.
|
| 16 |
+
|
| 17 |
+
The model was trained through the teacher and corpus lineage described in
|
| 18 |
+
[CORPUS_RIGHTS.md](CORPUS_RIGHTS.md). This license notice does not relicense
|
| 19 |
+
third-party training sources, grant trademark rights, or represent that a
|
| 20 |
+
license is required for uses already permitted by law. The license contains
|
| 21 |
+
its own warranty disclaimer and limitation of liability.
|
LICENSES.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# License scope
|
| 2 |
+
|
| 3 |
+
This Hugging Face package contains materials under separate licenses.
|
| 4 |
+
|
| 5 |
+
| Material | Terms |
|
| 6 |
+
| --- | --- |
|
| 7 |
+
| `model.litq8` and model-specific metadata | [CC BY-SA 4.0](LICENSE-MODEL.md), to the extent controlled rights apply |
|
| 8 |
+
| `literary_infer.c`, `literary_infer.h`, and `channel_protocol.h` | [Apache License 2.0](LICENSE-CODE) |
|
| 9 |
+
| Corpus provenance and evaluation documentation | Apache License 2.0 |
|
| 10 |
+
|
| 11 |
+
No training text or token stream is included. `LICENSE-DATA.md` identifies the
|
| 12 |
+
limited first-party materials dedicated under CC0 upstream; it does not apply
|
| 13 |
+
to literary sources, KJV text, derived literary records, evaluation datasets,
|
| 14 |
+
or trained model artifacts. See [CORPUS_RIGHTS.md](CORPUS_RIGHTS.md) for the
|
| 15 |
+
source-specific assessment.
|
NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ZERO grounded literary language models
|
| 2 |
+
Copyright 2025-2026 ZERO contributors
|
| 3 |
+
|
| 4 |
+
Project software is provided under the Apache License 2.0. Trained model
|
| 5 |
+
artifacts are provided under CC BY-SA 4.0 to the extent stated in
|
| 6 |
+
LICENSE-MODEL.md. First-party generated data identified in LICENSE-DATA.md is
|
| 7 |
+
dedicated under CC0 1.0.
|
| 8 |
+
|
| 9 |
+
ZERO.4's lineage includes public-domain literary works, Project Gutenberg
|
| 10 |
+
editions, CC BY-SA Wikisource transcription contributions, King James Bible
|
| 11 |
+
text, project-authored foundation statements, and project-generated quantity
|
| 12 |
+
records. Required source attribution and jurisdiction notes are recorded in
|
| 13 |
+
CORPUS_RIGHTS.md and corpus/RIGHTS.json.
|
| 14 |
+
|
| 15 |
+
Project Gutenberg and Wikimedia/Wikisource do not sponsor or endorse ZERO.
|
README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-sa-4.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: text-generation
|
| 6 |
+
tags:
|
| 7 |
+
- custom-code
|
| 8 |
+
- character-level
|
| 9 |
+
- c
|
| 10 |
+
- wasm
|
| 11 |
+
- tiny-language-model
|
| 12 |
+
- literary
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# ZERO.4
|
| 16 |
+
|
| 17 |
+
ZERO.4 is a 4,852,992-parameter, character-level decoder-only language model
|
| 18 |
+
with a 512-token context. Its 4.9 MB release artifact uses signed 8-bit matrix
|
| 19 |
+
rows with floating-point row scales. It has a dependency-free C inference
|
| 20 |
+
runtime and can also run locally in a browser through the upstream WebAssembly
|
| 21 |
+
build.
|
| 22 |
+
|
| 23 |
+
This is a small research model with an intentionally narrow literary lineage,
|
| 24 |
+
not a general-purpose assistant. Its unusual scale and inspectable runtime are
|
| 25 |
+
the point.
|
| 26 |
+
|
| 27 |
+
## Files and integrity
|
| 28 |
+
|
| 29 |
+
| File | Purpose |
|
| 30 |
+
| --- | --- |
|
| 31 |
+
| `model.litq8` | Quantized ZERO.4 weights |
|
| 32 |
+
| `model.json` | Architecture, promotion, and artifact metadata |
|
| 33 |
+
| `literary_infer.c`, `literary_infer.h`, `channel_protocol.h` | Minimal C runtime |
|
| 34 |
+
| `CORPUS_RIGHTS.md` | Source-level provenance, attribution, and jurisdiction notes |
|
| 35 |
+
| `zero4-memorization-v1.json` | Deterministic prompted-continuation release evaluation |
|
| 36 |
+
|
| 37 |
+
Expected model SHA-256:
|
| 38 |
+
`44b32f2262be2754fd2eeaf16ed206bae32b4ce30d7f5541a1059cd21257ae50`.
|
| 39 |
+
|
| 40 |
+
## Run locally
|
| 41 |
+
|
| 42 |
+
This custom format is not directly compatible with `transformers.AutoModel`.
|
| 43 |
+
Compile the included inference runtime:
|
| 44 |
+
|
| 45 |
+
```sh
|
| 46 |
+
cc -O2 -std=c11 -Wall -Wextra -Wpedantic literary_infer.c -o literary_infer -lm
|
| 47 |
+
./literary_infer model.litq8 "The zero opened its eyes, and" 240
|
| 48 |
+
./literary_infer model.litq8 --chat D "What walks beneath the moon?" 240
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Inference is local; the runtime does not make network requests.
|
| 52 |
+
|
| 53 |
+
## Training lineage
|
| 54 |
+
|
| 55 |
+
ZERO.4 was initialized from the immutable ZERO.3 teacher and trained with
|
| 56 |
+
immutable ZERO.1, ZERO.2, and ZERO.3 teachers. The replay mixture comprised:
|
| 57 |
+
|
| 58 |
+
- project-authored foundation statements;
|
| 59 |
+
- Shakespeare and Blake editions identified by Project Gutenberg as public
|
| 60 |
+
domain in the USA;
|
| 61 |
+
- Crowley works from Project Gutenberg and CC BY-SA Wikisource transcription
|
| 62 |
+
contributions;
|
| 63 |
+
- a deliberately low-weight King James Bible stream;
|
| 64 |
+
- literary dialogue records derived only from those literary sources; and
|
| 65 |
+
- project-generated typed quantity-operation records.
|
| 66 |
+
|
| 67 |
+
No human chat export appears in the bound training lineage. Training text and
|
| 68 |
+
token streams are intentionally excluded from this model repository. Exact
|
| 69 |
+
sources, permanent Wikisource revisions, transformations, hashes, and caveats
|
| 70 |
+
are in `CORPUS_RIGHTS.md`.
|
| 71 |
+
|
| 72 |
+
## Evaluation
|
| 73 |
+
|
| 74 |
+
The promoted artifact was selected prospectively from Q2.6 seed 2 at update
|
| 75 |
+
500, then passed the frozen three-seed replication contract. On the bounded
|
| 76 |
+
1,000-case-per-task external screen, ZERO.4 scored 0.537 raw accuracy on BLiMP,
|
| 77 |
+
0.266 normalized accuracy on HellaSwag, 2.570353 bits/byte on TinyStories, and
|
| 78 |
+
zero exact matches on the project's adapted LAMBADA task. These results are
|
| 79 |
+
weak by modern general-language-model standards and should not be overstated.
|
| 80 |
+
|
| 81 |
+
The training experiment also validated quantity-operation routing when paired
|
| 82 |
+
with the upstream controller and deterministic arithmetic kernel. Those
|
| 83 |
+
components are not integrated into this standalone model artifact; the neural
|
| 84 |
+
model should not be described as performing reliable arithmetic by itself.
|
| 85 |
+
|
| 86 |
+
The included memorization report tests evenly stratified, deterministic
|
| 87 |
+
prompted continuations against every bound training stream. No protected
|
| 88 |
+
third-party stream reached the 32-token warning threshold across 80 probes;
|
| 89 |
+
the longest exact greedy prefix was 16 of 64 tokens. Eight of sixteen
|
| 90 |
+
first-party CC0 foundation probes were reproduced for all 64 tokens,
|
| 91 |
+
consistent with that small source's deliberate inspectability. Passing this
|
| 92 |
+
finite test does not prove that no training expression can ever be reproduced
|
| 93 |
+
under another prompt or decoding policy.
|
| 94 |
+
|
| 95 |
+
## Limitations and content warning
|
| 96 |
+
|
| 97 |
+
ZERO.4 is prone to incoherence, imitation of source style, confabulation, and
|
| 98 |
+
repetition. Its corpus includes archaic language and sexual, violent,
|
| 99 |
+
coercive, discriminatory, religious, and drug-related passages. Outputs may be
|
| 100 |
+
offensive or unsuitable for children. Do not rely on it for factual, medical,
|
| 101 |
+
legal, religious, historical, identity-related, or safety-critical guidance.
|
| 102 |
+
|
| 103 |
+
## Licenses
|
| 104 |
+
|
| 105 |
+
- Model weights: **CC BY-SA 4.0**, to the extent controlled rights apply.
|
| 106 |
+
- Included C runtime: **Apache 2.0**.
|
| 107 |
+
- Training sources: mixed, source-specific status; see `CORPUS_RIGHTS.md`.
|
| 108 |
+
|
| 109 |
+
When sharing weights or adaptations, retain the ZERO.4 attribution, upstream
|
| 110 |
+
repository link, model license, corpus-rights notice, and an indication of
|
| 111 |
+
changes. The CC BY-SA choice is a conservative response to ShareAlike
|
| 112 |
+
transcription contributions in the lineage; it is not a claim that model
|
| 113 |
+
weights are necessarily copyrightable adaptations in every jurisdiction.
|
| 114 |
+
|
| 115 |
+
Upstream project: <https://github.com/atimics/zero-grounded-literary-lm>
|
channel_protocol.h
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef CHANNEL_PROTOCOL_H
|
| 2 |
+
#define CHANNEL_PROTOCOL_H
|
| 3 |
+
|
| 4 |
+
/* Shared, parameter-free channel structure inside the 128-token vocabulary. */
|
| 5 |
+
enum {
|
| 6 |
+
CHANNEL_START_TOKEN = 1,
|
| 7 |
+
CHANNEL_MESSAGE_TOKEN = 2,
|
| 8 |
+
CHANNEL_REPLY_TOKEN = 3,
|
| 9 |
+
CHANNEL_MESSAGE_END_TOKEN = 4,
|
| 10 |
+
CHANNEL_RECORD_END_TOKEN = 5,
|
| 11 |
+
CHANNEL_TARGET_TOKEN = 6,
|
| 12 |
+
CHANNEL_SUMMARY_TOKEN = 7
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
#endif
|
literary_infer.c
ADDED
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <math.h>
|
| 2 |
+
#include <stdint.h>
|
| 3 |
+
#include <stdio.h>
|
| 4 |
+
#include <stdlib.h>
|
| 5 |
+
#include <string.h>
|
| 6 |
+
|
| 7 |
+
#include "channel_protocol.h"
|
| 8 |
+
#include "literary_infer.h"
|
| 9 |
+
|
| 10 |
+
#ifdef __EMSCRIPTEN__
|
| 11 |
+
#include <emscripten/emscripten.h>
|
| 12 |
+
#define API EMSCRIPTEN_KEEPALIVE
|
| 13 |
+
#else
|
| 14 |
+
#define API
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
#define MAX_PARAMETERS 128
|
| 18 |
+
#define HOLO_DIMENSION 256
|
| 19 |
+
#define HOLO_CAPACITY 32
|
| 20 |
+
#define HOLO_PARTITIONS 4
|
| 21 |
+
#define HOLO_PARTITION_CAPACITY (HOLO_CAPACITY / HOLO_PARTITIONS)
|
| 22 |
+
|
| 23 |
+
typedef struct {
|
| 24 |
+
char magic[8];
|
| 25 |
+
uint32_t version, vocab, context, dim, heads, layers, ff;
|
| 26 |
+
uint32_t parameter_count;
|
| 27 |
+
uint64_t step;
|
| 28 |
+
} InferenceHeader;
|
| 29 |
+
|
| 30 |
+
typedef struct {
|
| 31 |
+
uint32_t encoding, rows, columns, count;
|
| 32 |
+
} TensorHeader;
|
| 33 |
+
|
| 34 |
+
typedef struct {
|
| 35 |
+
uint32_t encoding, rows, columns, count;
|
| 36 |
+
const float *values;
|
| 37 |
+
const float *scales;
|
| 38 |
+
const int8_t *quantized;
|
| 39 |
+
} Tensor;
|
| 40 |
+
|
| 41 |
+
typedef struct {
|
| 42 |
+
int token;
|
| 43 |
+
float score;
|
| 44 |
+
} Candidate;
|
| 45 |
+
|
| 46 |
+
static InferenceHeader config;
|
| 47 |
+
static Tensor parameters[MAX_PARAMETERS];
|
| 48 |
+
static float *key_cache;
|
| 49 |
+
static float *value_cache;
|
| 50 |
+
static float *x;
|
| 51 |
+
static float *normalized;
|
| 52 |
+
static float *query;
|
| 53 |
+
static float *key;
|
| 54 |
+
static float *value;
|
| 55 |
+
static float *attention;
|
| 56 |
+
static float *temporary;
|
| 57 |
+
static float *feed_forward_pre;
|
| 58 |
+
static float *feed_forward_act;
|
| 59 |
+
static float *scores;
|
| 60 |
+
static float *logits;
|
| 61 |
+
static Candidate *candidates;
|
| 62 |
+
static uint16_t recent[64];
|
| 63 |
+
static int recent_count;
|
| 64 |
+
static int recent_next;
|
| 65 |
+
static uint64_t position;
|
| 66 |
+
static uint32_t random_state = 1;
|
| 67 |
+
static int loaded;
|
| 68 |
+
|
| 69 |
+
/*
|
| 70 |
+
* Browser-scale projection of holostuff's LocalAgentCore memory contract:
|
| 71 |
+
* deterministic text hypervectors, an exact cosine index, and honest
|
| 72 |
+
* abstention in the caller. The transformer remains the summarizer; this
|
| 73 |
+
* index only retrieves an older compressed episode that may be relevant.
|
| 74 |
+
*/
|
| 75 |
+
static float holo_vectors[HOLO_CAPACITY][HOLO_DIMENSION];
|
| 76 |
+
static int holo_count;
|
| 77 |
+
static int holo_next;
|
| 78 |
+
static float holo_score;
|
| 79 |
+
static int holo_mode = LM_HOLO_FLAT;
|
| 80 |
+
static int holo_partition_count[HOLO_PARTITIONS];
|
| 81 |
+
static int holo_partition_next[HOLO_PARTITIONS];
|
| 82 |
+
|
| 83 |
+
static uint64_t holo_mix(uint64_t value)
|
| 84 |
+
{
|
| 85 |
+
value ^= value >> 30;
|
| 86 |
+
value *= UINT64_C(0xbf58476d1ce4e5b9);
|
| 87 |
+
value ^= value >> 27;
|
| 88 |
+
value *= UINT64_C(0x94d049bb133111eb);
|
| 89 |
+
return value ^ (value >> 31);
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
static int holo_stopword(const char *word, int length)
|
| 93 |
+
{
|
| 94 |
+
static const char *words[] = {
|
| 95 |
+
"and", "are", "but", "for", "from", "have", "not", "only",
|
| 96 |
+
"that", "the", "then", "this", "was", "were", "what", "when",
|
| 97 |
+
"where", "with", "you", "your"
|
| 98 |
+
};
|
| 99 |
+
size_t index;
|
| 100 |
+
for (index = 0; index < sizeof(words) / sizeof(words[0]); ++index) {
|
| 101 |
+
if ((int)strlen(words[index]) == length &&
|
| 102 |
+
memcmp(word, words[index], (size_t)length) == 0) {
|
| 103 |
+
return 1;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
return 0;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
static void holo_add_feature(float *vector, uint64_t feature, int width,
|
| 110 |
+
float weight)
|
| 111 |
+
{
|
| 112 |
+
uint64_t state = holo_mix(feature);
|
| 113 |
+
int index;
|
| 114 |
+
for (index = 0; index < width; ++index) {
|
| 115 |
+
state = holo_mix(state + (uint64_t)index + UINT64_C(0x9e3779b97f4a7c15));
|
| 116 |
+
vector[state & (HOLO_DIMENSION - 1)] +=
|
| 117 |
+
(state & UINT64_C(0x100)) ? weight : -weight;
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
static void holo_encode(const unsigned char *text, int length, float *vector)
|
| 122 |
+
{
|
| 123 |
+
char word[48];
|
| 124 |
+
int word_length = 0;
|
| 125 |
+
uint64_t previous = 0;
|
| 126 |
+
int have_previous = 0;
|
| 127 |
+
int cursor;
|
| 128 |
+
float norm = 0.0f;
|
| 129 |
+
memset(vector, 0, HOLO_DIMENSION * sizeof(*vector));
|
| 130 |
+
for (cursor = 0; cursor <= length; ++cursor) {
|
| 131 |
+
int value = cursor < length ? text[cursor] : ' ';
|
| 132 |
+
int alphanumeric = (value >= 'A' && value <= 'Z') ||
|
| 133 |
+
(value >= 'a' && value <= 'z') ||
|
| 134 |
+
(value >= '0' && value <= '9') || value == '_';
|
| 135 |
+
if (alphanumeric && word_length < (int)sizeof(word) - 1) {
|
| 136 |
+
word[word_length++] = (char)(value >= 'A' && value <= 'Z'
|
| 137 |
+
? value + ('a' - 'A')
|
| 138 |
+
: value);
|
| 139 |
+
} else if (word_length != 0) {
|
| 140 |
+
uint64_t hash = UINT64_C(14695981039346656037);
|
| 141 |
+
int index;
|
| 142 |
+
word[word_length] = '\0';
|
| 143 |
+
for (index = 0; index < word_length; ++index) {
|
| 144 |
+
hash ^= (unsigned char)word[index];
|
| 145 |
+
hash *= UINT64_C(1099511628211);
|
| 146 |
+
}
|
| 147 |
+
if (word_length >= 3 && !holo_stopword(word, word_length)) {
|
| 148 |
+
uint64_t prefix_hash = UINT64_C(14695981039346656037);
|
| 149 |
+
holo_add_feature(vector, hash, 16, 1.0f);
|
| 150 |
+
for (index = 0; index < word_length && index < 6; ++index) {
|
| 151 |
+
prefix_hash ^= (unsigned char)word[index];
|
| 152 |
+
prefix_hash *= UINT64_C(1099511628211);
|
| 153 |
+
if (index >= 3 && index + 1 < word_length) {
|
| 154 |
+
holo_add_feature(vector, prefix_hash, 6, 0.45f);
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
if (have_previous) {
|
| 158 |
+
holo_add_feature(vector,
|
| 159 |
+
holo_mix(previous ^ (hash << 1)),
|
| 160 |
+
8, 0.65f);
|
| 161 |
+
}
|
| 162 |
+
previous = hash;
|
| 163 |
+
have_previous = 1;
|
| 164 |
+
}
|
| 165 |
+
word_length = 0;
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
for (cursor = 0; cursor < HOLO_DIMENSION; ++cursor) {
|
| 169 |
+
norm += vector[cursor] * vector[cursor];
|
| 170 |
+
}
|
| 171 |
+
norm = sqrtf(norm);
|
| 172 |
+
if (norm > 0.0f) {
|
| 173 |
+
for (cursor = 0; cursor < HOLO_DIMENSION; ++cursor) {
|
| 174 |
+
vector[cursor] /= norm;
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
/* Deterministic nearest-anchor routing. Similar normalized vectors tend to
|
| 180 |
+
* choose the same partition, keeping each exact-search trace below the flat
|
| 181 |
+
* memory's capacity while retaining one global 32-slot budget. */
|
| 182 |
+
static int holo_partition_for_vector(const float *vector)
|
| 183 |
+
{
|
| 184 |
+
int best_partition = 0;
|
| 185 |
+
float best_score = -INFINITY;
|
| 186 |
+
int partition;
|
| 187 |
+
for (partition = 0; partition < HOLO_PARTITIONS; ++partition) {
|
| 188 |
+
uint64_t state = holo_mix(UINT64_C(0x7a65726f6d656d31) +
|
| 189 |
+
(uint64_t)partition);
|
| 190 |
+
float score = 0.0f;
|
| 191 |
+
int index;
|
| 192 |
+
for (index = 0; index < HOLO_DIMENSION; ++index) {
|
| 193 |
+
state = holo_mix(state + (uint64_t)index +
|
| 194 |
+
UINT64_C(0x9e3779b97f4a7c15));
|
| 195 |
+
score += vector[index] *
|
| 196 |
+
((state & UINT64_C(1)) ? 1.0f : -1.0f);
|
| 197 |
+
}
|
| 198 |
+
if (score > best_score) {
|
| 199 |
+
best_score = score;
|
| 200 |
+
best_partition = partition;
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
return best_partition;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
API void lm_holo_reset(void)
|
| 207 |
+
{
|
| 208 |
+
memset(holo_vectors, 0, sizeof(holo_vectors));
|
| 209 |
+
memset(holo_partition_count, 0, sizeof(holo_partition_count));
|
| 210 |
+
memset(holo_partition_next, 0, sizeof(holo_partition_next));
|
| 211 |
+
holo_count = 0;
|
| 212 |
+
holo_next = 0;
|
| 213 |
+
holo_score = 0.0f;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
API int lm_holo_set_mode(int mode)
|
| 217 |
+
{
|
| 218 |
+
if (mode < LM_HOLO_DISABLED || mode > LM_HOLO_PARTITIONED) return -1;
|
| 219 |
+
if (mode != holo_mode) {
|
| 220 |
+
holo_mode = mode;
|
| 221 |
+
lm_holo_reset();
|
| 222 |
+
}
|
| 223 |
+
return 0;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
API int lm_holo_get_mode(void) { return holo_mode; }
|
| 227 |
+
|
| 228 |
+
API int lm_holo_remember(const unsigned char *text, int length)
|
| 229 |
+
{
|
| 230 |
+
int slot;
|
| 231 |
+
if (holo_mode == LM_HOLO_DISABLED || text == NULL || length <= 0 ||
|
| 232 |
+
length > 8192) {
|
| 233 |
+
return -1;
|
| 234 |
+
}
|
| 235 |
+
if (holo_mode == LM_HOLO_PARTITIONED) {
|
| 236 |
+
float vector[HOLO_DIMENSION];
|
| 237 |
+
int partition;
|
| 238 |
+
holo_encode(text, length, vector);
|
| 239 |
+
partition = holo_partition_for_vector(vector);
|
| 240 |
+
slot = partition * HOLO_PARTITION_CAPACITY +
|
| 241 |
+
holo_partition_next[partition];
|
| 242 |
+
memcpy(holo_vectors[slot], vector, sizeof(vector));
|
| 243 |
+
holo_partition_next[partition] =
|
| 244 |
+
(holo_partition_next[partition] + 1) % HOLO_PARTITION_CAPACITY;
|
| 245 |
+
if (holo_partition_count[partition] < HOLO_PARTITION_CAPACITY) {
|
| 246 |
+
++holo_partition_count[partition];
|
| 247 |
+
++holo_count;
|
| 248 |
+
}
|
| 249 |
+
return slot;
|
| 250 |
+
}
|
| 251 |
+
slot = holo_next;
|
| 252 |
+
holo_encode(text, length, holo_vectors[slot]);
|
| 253 |
+
holo_next = (holo_next + 1) % HOLO_CAPACITY;
|
| 254 |
+
if (holo_count < HOLO_CAPACITY) ++holo_count;
|
| 255 |
+
return slot;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
API int lm_holo_recall(const unsigned char *text, int length)
|
| 259 |
+
{
|
| 260 |
+
float query[HOLO_DIMENSION];
|
| 261 |
+
float best = -1.0f;
|
| 262 |
+
int best_slot = -1;
|
| 263 |
+
int slot;
|
| 264 |
+
if (holo_mode == LM_HOLO_DISABLED || text == NULL || length <= 0 ||
|
| 265 |
+
length > 8192 || holo_count == 0) {
|
| 266 |
+
holo_score = 0.0f;
|
| 267 |
+
return -1;
|
| 268 |
+
}
|
| 269 |
+
holo_encode(text, length, query);
|
| 270 |
+
if (holo_mode == LM_HOLO_PARTITIONED) {
|
| 271 |
+
int partition = holo_partition_for_vector(query);
|
| 272 |
+
int count = holo_partition_count[partition];
|
| 273 |
+
int index;
|
| 274 |
+
for (index = 0; index < count; ++index) {
|
| 275 |
+
float score = 0.0f;
|
| 276 |
+
int coordinate;
|
| 277 |
+
slot = partition * HOLO_PARTITION_CAPACITY + index;
|
| 278 |
+
for (coordinate = 0; coordinate < HOLO_DIMENSION; ++coordinate) {
|
| 279 |
+
score += query[coordinate] * holo_vectors[slot][coordinate];
|
| 280 |
+
}
|
| 281 |
+
if (score > best) {
|
| 282 |
+
best = score;
|
| 283 |
+
best_slot = slot;
|
| 284 |
+
}
|
| 285 |
+
}
|
| 286 |
+
holo_score = best_slot >= 0 ? best : 0.0f;
|
| 287 |
+
return best_slot;
|
| 288 |
+
}
|
| 289 |
+
for (slot = 0; slot < holo_count; ++slot) {
|
| 290 |
+
float score = 0.0f;
|
| 291 |
+
int index;
|
| 292 |
+
for (index = 0; index < HOLO_DIMENSION; ++index) {
|
| 293 |
+
score += query[index] * holo_vectors[slot][index];
|
| 294 |
+
}
|
| 295 |
+
if (score > best) {
|
| 296 |
+
best = score;
|
| 297 |
+
best_slot = slot;
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
holo_score = best;
|
| 301 |
+
return best_slot;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
API float lm_holo_get_score(void) { return holo_score; }
|
| 305 |
+
API int lm_holo_get_count(void) { return holo_count; }
|
| 306 |
+
|
| 307 |
+
static void release_working_memory(void)
|
| 308 |
+
{
|
| 309 |
+
free(key_cache);
|
| 310 |
+
free(value_cache);
|
| 311 |
+
free(x);
|
| 312 |
+
free(normalized);
|
| 313 |
+
free(query);
|
| 314 |
+
free(key);
|
| 315 |
+
free(value);
|
| 316 |
+
free(attention);
|
| 317 |
+
free(temporary);
|
| 318 |
+
free(feed_forward_pre);
|
| 319 |
+
free(feed_forward_act);
|
| 320 |
+
free(scores);
|
| 321 |
+
free(logits);
|
| 322 |
+
free(candidates);
|
| 323 |
+
key_cache = NULL;
|
| 324 |
+
value_cache = NULL;
|
| 325 |
+
x = normalized = query = key = value = attention = temporary = NULL;
|
| 326 |
+
feed_forward_pre = feed_forward_act = scores = logits = NULL;
|
| 327 |
+
candidates = NULL;
|
| 328 |
+
loaded = 0;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
static void *allocate_zero(size_t count, size_t size)
|
| 332 |
+
{
|
| 333 |
+
if (size != 0 && count > SIZE_MAX / size) return NULL;
|
| 334 |
+
return calloc(count, size);
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
static int allocate_working_memory(void)
|
| 338 |
+
{
|
| 339 |
+
size_t cache_count =
|
| 340 |
+
(size_t)config.layers * config.context * config.dim;
|
| 341 |
+
key_cache = allocate_zero(cache_count, sizeof(float));
|
| 342 |
+
value_cache = allocate_zero(cache_count, sizeof(float));
|
| 343 |
+
x = allocate_zero(config.dim, sizeof(float));
|
| 344 |
+
normalized = allocate_zero(config.dim, sizeof(float));
|
| 345 |
+
query = allocate_zero(config.dim, sizeof(float));
|
| 346 |
+
key = allocate_zero(config.dim, sizeof(float));
|
| 347 |
+
value = allocate_zero(config.dim, sizeof(float));
|
| 348 |
+
attention = allocate_zero(config.dim, sizeof(float));
|
| 349 |
+
temporary = allocate_zero(config.dim, sizeof(float));
|
| 350 |
+
feed_forward_pre = allocate_zero(config.ff, sizeof(float));
|
| 351 |
+
feed_forward_act = allocate_zero(config.ff, sizeof(float));
|
| 352 |
+
scores = allocate_zero(config.context, sizeof(float));
|
| 353 |
+
logits = allocate_zero(config.vocab, sizeof(float));
|
| 354 |
+
candidates = allocate_zero(config.vocab, sizeof(*candidates));
|
| 355 |
+
return key_cache && value_cache && x && normalized && query && key &&
|
| 356 |
+
value && attention && temporary && feed_forward_pre &&
|
| 357 |
+
feed_forward_act && scores && logits && candidates;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
static void rmsnorm(const float *input, const Tensor *gamma, float *output,
|
| 361 |
+
int width)
|
| 362 |
+
{
|
| 363 |
+
float square_sum = 0.0f;
|
| 364 |
+
float inverse;
|
| 365 |
+
int i;
|
| 366 |
+
for (i = 0; i < width; ++i) square_sum += input[i] * input[i];
|
| 367 |
+
inverse = 1.0f / sqrtf(square_sum / width + 1.0e-5f);
|
| 368 |
+
for (i = 0; i < width; ++i) {
|
| 369 |
+
output[i] = input[i] * inverse * gamma->values[i];
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
static void matrix_vector(const Tensor *matrix, const float *input,
|
| 374 |
+
float *output)
|
| 375 |
+
{
|
| 376 |
+
uint32_t row;
|
| 377 |
+
for (row = 0; row < matrix->rows; ++row) {
|
| 378 |
+
const int8_t *weights =
|
| 379 |
+
matrix->quantized + (size_t)row * matrix->columns;
|
| 380 |
+
float sum = 0.0f;
|
| 381 |
+
uint32_t column;
|
| 382 |
+
for (column = 0; column < matrix->columns; ++column) {
|
| 383 |
+
sum += weights[column] * input[column];
|
| 384 |
+
}
|
| 385 |
+
output[row] = sum * matrix->scales[row];
|
| 386 |
+
}
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
static void embedding_row(const Tensor *embedding, int token, float *output)
|
| 390 |
+
{
|
| 391 |
+
const int8_t *weights =
|
| 392 |
+
embedding->quantized + (size_t)token * embedding->columns;
|
| 393 |
+
float scale = embedding->scales[token];
|
| 394 |
+
uint32_t i;
|
| 395 |
+
for (i = 0; i < embedding->columns; ++i) output[i] = weights[i] * scale;
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
static float gelu(float value)
|
| 399 |
+
{
|
| 400 |
+
return 0.5f * value *
|
| 401 |
+
(1.0f + tanhf(0.7978845608028654f *
|
| 402 |
+
(value + 0.044715f * value * value * value)));
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
static void apply_rope(float *vector, uint64_t token_position)
|
| 406 |
+
{
|
| 407 |
+
int head_width = (int)config.dim / (int)config.heads;
|
| 408 |
+
int head;
|
| 409 |
+
for (head = 0; head < (int)config.heads; ++head) {
|
| 410 |
+
int offset = head * head_width;
|
| 411 |
+
int pair;
|
| 412 |
+
for (pair = 0; pair < head_width / 2; ++pair) {
|
| 413 |
+
float frequency = powf(10000.0f, -(2.0f * pair) / head_width);
|
| 414 |
+
float angle = (float)token_position * frequency;
|
| 415 |
+
float cosine = cosf(angle);
|
| 416 |
+
float sine = sinf(angle);
|
| 417 |
+
float a = vector[offset + 2 * pair];
|
| 418 |
+
float b = vector[offset + 2 * pair + 1];
|
| 419 |
+
vector[offset + 2 * pair] = a * cosine - b * sine;
|
| 420 |
+
vector[offset + 2 * pair + 1] = a * sine + b * cosine;
|
| 421 |
+
}
|
| 422 |
+
}
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
static void causal_attention(int layer)
|
| 426 |
+
{
|
| 427 |
+
int head_width = (int)config.dim / (int)config.heads;
|
| 428 |
+
uint64_t first = position + 1 > config.context
|
| 429 |
+
? position + 1 - config.context
|
| 430 |
+
: 0;
|
| 431 |
+
int current_slot = (int)(position % config.context);
|
| 432 |
+
size_t current_offset =
|
| 433 |
+
((size_t)layer * config.context + current_slot) * config.dim;
|
| 434 |
+
int head;
|
| 435 |
+
memcpy(key_cache + current_offset, key, config.dim * sizeof(float));
|
| 436 |
+
memcpy(value_cache + current_offset, value, config.dim * sizeof(float));
|
| 437 |
+
memset(attention, 0, config.dim * sizeof(float));
|
| 438 |
+
|
| 439 |
+
for (head = 0; head < (int)config.heads; ++head) {
|
| 440 |
+
int head_offset = head * head_width;
|
| 441 |
+
float maximum = -INFINITY;
|
| 442 |
+
float total = 0.0f;
|
| 443 |
+
int count = 0;
|
| 444 |
+
uint64_t source;
|
| 445 |
+
for (source = first; source <= position; ++source) {
|
| 446 |
+
int slot = (int)(source % config.context);
|
| 447 |
+
const float *cached_key =
|
| 448 |
+
key_cache +
|
| 449 |
+
((size_t)layer * config.context + slot) * config.dim +
|
| 450 |
+
head_offset;
|
| 451 |
+
float score = 0.0f;
|
| 452 |
+
int i;
|
| 453 |
+
for (i = 0; i < head_width; ++i) {
|
| 454 |
+
score += query[head_offset + i] * cached_key[i];
|
| 455 |
+
}
|
| 456 |
+
score /= sqrtf((float)head_width);
|
| 457 |
+
scores[count++] = score;
|
| 458 |
+
if (score > maximum) maximum = score;
|
| 459 |
+
}
|
| 460 |
+
for (int index = 0; index < count; ++index) {
|
| 461 |
+
scores[index] = expf(scores[index] - maximum);
|
| 462 |
+
total += scores[index];
|
| 463 |
+
}
|
| 464 |
+
count = 0;
|
| 465 |
+
for (source = first; source <= position; ++source) {
|
| 466 |
+
int slot = (int)(source % config.context);
|
| 467 |
+
const float *cached_value =
|
| 468 |
+
value_cache +
|
| 469 |
+
((size_t)layer * config.context + slot) * config.dim +
|
| 470 |
+
head_offset;
|
| 471 |
+
float probability = scores[count++] / total;
|
| 472 |
+
int i;
|
| 473 |
+
for (i = 0; i < head_width; ++i) {
|
| 474 |
+
attention[head_offset + i] += probability * cached_value[i];
|
| 475 |
+
}
|
| 476 |
+
}
|
| 477 |
+
}
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
API int lm_load(const unsigned char *data, int length)
|
| 481 |
+
{
|
| 482 |
+
static const char magic[8] = {'L', 'I', 'T', 'Q', '8', 'V', '1', '\0'};
|
| 483 |
+
const unsigned char *cursor = data;
|
| 484 |
+
const unsigned char *end = data + length;
|
| 485 |
+
uint32_t index;
|
| 486 |
+
release_working_memory();
|
| 487 |
+
if (length < (int)sizeof(config)) return -1;
|
| 488 |
+
memcpy(&config, cursor, sizeof(config));
|
| 489 |
+
cursor += sizeof(config);
|
| 490 |
+
if (memcmp(config.magic, magic, 8) != 0 || config.version != 1 ||
|
| 491 |
+
config.vocab < 2 || config.vocab > 2048 || config.context < 2 ||
|
| 492 |
+
config.context > 4096 || config.dim < 2 || config.layers < 1 ||
|
| 493 |
+
config.parameter_count > MAX_PARAMETERS ||
|
| 494 |
+
config.parameter_count != 2 + config.layers * 8) {
|
| 495 |
+
return -2;
|
| 496 |
+
}
|
| 497 |
+
memset(parameters, 0, sizeof(parameters));
|
| 498 |
+
for (index = 0; index < config.parameter_count; ++index) {
|
| 499 |
+
TensorHeader header;
|
| 500 |
+
Tensor *tensor = ¶meters[index];
|
| 501 |
+
size_t amount;
|
| 502 |
+
if ((size_t)(end - cursor) < sizeof(header)) return -3;
|
| 503 |
+
memcpy(&header, cursor, sizeof(header));
|
| 504 |
+
cursor += sizeof(header);
|
| 505 |
+
if (header.count != (uint64_t)header.rows * header.columns ||
|
| 506 |
+
header.rows == 0 || header.columns == 0 || header.encoding > 1) {
|
| 507 |
+
return -4;
|
| 508 |
+
}
|
| 509 |
+
tensor->encoding = header.encoding;
|
| 510 |
+
tensor->rows = header.rows;
|
| 511 |
+
tensor->columns = header.columns;
|
| 512 |
+
tensor->count = header.count;
|
| 513 |
+
if (header.encoding == 0) {
|
| 514 |
+
amount = (size_t)header.count * sizeof(float);
|
| 515 |
+
if ((size_t)(end - cursor) < amount) return -5;
|
| 516 |
+
tensor->values = (const float *)cursor;
|
| 517 |
+
cursor += amount;
|
| 518 |
+
} else {
|
| 519 |
+
amount = (size_t)header.rows * sizeof(float);
|
| 520 |
+
if ((size_t)(end - cursor) < amount) return -6;
|
| 521 |
+
tensor->scales = (const float *)cursor;
|
| 522 |
+
cursor += amount;
|
| 523 |
+
amount = header.count;
|
| 524 |
+
if ((size_t)(end - cursor) < amount) return -7;
|
| 525 |
+
tensor->quantized = (const int8_t *)cursor;
|
| 526 |
+
cursor += amount;
|
| 527 |
+
}
|
| 528 |
+
}
|
| 529 |
+
if (!allocate_working_memory()) {
|
| 530 |
+
release_working_memory();
|
| 531 |
+
return -8;
|
| 532 |
+
}
|
| 533 |
+
loaded = 1;
|
| 534 |
+
position = 0;
|
| 535 |
+
recent_count = recent_next = 0;
|
| 536 |
+
lm_holo_reset();
|
| 537 |
+
return 0;
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
API void lm_reset(void)
|
| 541 |
+
{
|
| 542 |
+
if (!loaded) return;
|
| 543 |
+
memset(key_cache, 0,
|
| 544 |
+
(size_t)config.layers * config.context * config.dim * sizeof(float));
|
| 545 |
+
memset(value_cache, 0,
|
| 546 |
+
(size_t)config.layers * config.context * config.dim * sizeof(float));
|
| 547 |
+
position = 0;
|
| 548 |
+
recent_count = recent_next = 0;
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
API void lm_seed(uint32_t seed)
|
| 552 |
+
{
|
| 553 |
+
random_state = seed ? seed : 1;
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
+
API int lm_feed(int token)
|
| 557 |
+
{
|
| 558 |
+
int layer;
|
| 559 |
+
if (!loaded || token < 0 || token >= (int)config.vocab) return -1;
|
| 560 |
+
embedding_row(¶meters[0], token, x);
|
| 561 |
+
for (layer = 0; layer < (int)config.layers; ++layer) {
|
| 562 |
+
int base = 1 + layer * 8;
|
| 563 |
+
int i;
|
| 564 |
+
rmsnorm(x, ¶meters[base], normalized, (int)config.dim);
|
| 565 |
+
matrix_vector(¶meters[base + 1], normalized, query);
|
| 566 |
+
matrix_vector(¶meters[base + 2], normalized, key);
|
| 567 |
+
matrix_vector(¶meters[base + 3], normalized, value);
|
| 568 |
+
apply_rope(query, position);
|
| 569 |
+
apply_rope(key, position);
|
| 570 |
+
causal_attention(layer);
|
| 571 |
+
matrix_vector(¶meters[base + 4], attention, temporary);
|
| 572 |
+
for (i = 0; i < (int)config.dim; ++i) x[i] += temporary[i];
|
| 573 |
+
|
| 574 |
+
rmsnorm(x, ¶meters[base + 5], normalized, (int)config.dim);
|
| 575 |
+
matrix_vector(¶meters[base + 6], normalized, feed_forward_pre);
|
| 576 |
+
for (i = 0; i < (int)config.ff; ++i) {
|
| 577 |
+
feed_forward_act[i] = gelu(feed_forward_pre[i]);
|
| 578 |
+
}
|
| 579 |
+
matrix_vector(¶meters[base + 7], feed_forward_act, temporary);
|
| 580 |
+
for (i = 0; i < (int)config.dim; ++i) x[i] += temporary[i];
|
| 581 |
+
}
|
| 582 |
+
rmsnorm(x, ¶meters[1 + config.layers * 8], normalized,
|
| 583 |
+
(int)config.dim);
|
| 584 |
+
{
|
| 585 |
+
const Tensor *embedding = ¶meters[0];
|
| 586 |
+
int output_token;
|
| 587 |
+
for (output_token = 0; output_token < (int)config.vocab;
|
| 588 |
+
++output_token) {
|
| 589 |
+
const int8_t *weights =
|
| 590 |
+
embedding->quantized +
|
| 591 |
+
(size_t)output_token * embedding->columns;
|
| 592 |
+
float sum = 0.0f;
|
| 593 |
+
int i;
|
| 594 |
+
for (i = 0; i < (int)config.dim; ++i) {
|
| 595 |
+
sum += weights[i] * normalized[i];
|
| 596 |
+
}
|
| 597 |
+
logits[output_token] = sum * embedding->scales[output_token];
|
| 598 |
+
}
|
| 599 |
+
}
|
| 600 |
+
recent[recent_next] = (uint16_t)token;
|
| 601 |
+
recent_next = (recent_next + 1) % 64;
|
| 602 |
+
if (recent_count < 64) ++recent_count;
|
| 603 |
+
++position;
|
| 604 |
+
return 0;
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
static int candidate_compare(const void *left, const void *right)
|
| 608 |
+
{
|
| 609 |
+
const Candidate *a = (const Candidate *)left;
|
| 610 |
+
const Candidate *b = (const Candidate *)right;
|
| 611 |
+
if (a->score < b->score) return 1;
|
| 612 |
+
if (a->score > b->score) return -1;
|
| 613 |
+
return a->token - b->token;
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
static float random_unit(void)
|
| 617 |
+
{
|
| 618 |
+
uint32_t value = random_state;
|
| 619 |
+
value ^= value << 13;
|
| 620 |
+
value ^= value >> 17;
|
| 621 |
+
value ^= value << 5;
|
| 622 |
+
random_state = value;
|
| 623 |
+
return (value >> 8) * (1.0f / 16777216.0f);
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
API int lm_sample(float temperature, int top_k, float repetition_penalty)
|
| 627 |
+
{
|
| 628 |
+
int token;
|
| 629 |
+
int limit;
|
| 630 |
+
float maximum;
|
| 631 |
+
float total = 0.0f;
|
| 632 |
+
float threshold;
|
| 633 |
+
if (!loaded || repetition_penalty < 1.0f) return -1;
|
| 634 |
+
for (token = 0; token < (int)config.vocab; ++token) {
|
| 635 |
+
int repeated = 0;
|
| 636 |
+
int i;
|
| 637 |
+
float score = logits[token];
|
| 638 |
+
for (i = 0; i < recent_count; ++i) {
|
| 639 |
+
if (recent[i] == token) {
|
| 640 |
+
repeated = 1;
|
| 641 |
+
break;
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
if (repeated && token != CHANNEL_MESSAGE_END_TOKEN) {
|
| 645 |
+
score -= logf(repetition_penalty);
|
| 646 |
+
}
|
| 647 |
+
if (!(token == CHANNEL_MESSAGE_END_TOKEN || token == '\n' ||
|
| 648 |
+
(token >= 32 && token < 127))) {
|
| 649 |
+
score = -INFINITY;
|
| 650 |
+
}
|
| 651 |
+
candidates[token].token = token;
|
| 652 |
+
candidates[token].score = score;
|
| 653 |
+
}
|
| 654 |
+
qsort(candidates, config.vocab, sizeof(*candidates), candidate_compare);
|
| 655 |
+
if (temperature <= 0.0f) return candidates[0].token;
|
| 656 |
+
limit = top_k > 0 && top_k < (int)config.vocab ? top_k : (int)config.vocab;
|
| 657 |
+
maximum = candidates[0].score;
|
| 658 |
+
for (token = 0; token < limit; ++token) {
|
| 659 |
+
candidates[token].score =
|
| 660 |
+
expf((candidates[token].score - maximum) / temperature);
|
| 661 |
+
total += candidates[token].score;
|
| 662 |
+
}
|
| 663 |
+
threshold = random_unit() * total;
|
| 664 |
+
for (token = 0; token < limit; ++token) {
|
| 665 |
+
threshold -= candidates[token].score;
|
| 666 |
+
if (threshold <= 0.0f) return candidates[token].token;
|
| 667 |
+
}
|
| 668 |
+
return candidates[limit - 1].token;
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
API float lm_probability(int token)
|
| 672 |
+
{
|
| 673 |
+
float maximum;
|
| 674 |
+
float total = 0.0f;
|
| 675 |
+
int index;
|
| 676 |
+
if (!loaded || position == 0 || token < 0 || token >= (int)config.vocab) {
|
| 677 |
+
return 0.0f;
|
| 678 |
+
}
|
| 679 |
+
maximum = logits[0];
|
| 680 |
+
for (index = 1; index < (int)config.vocab; ++index) {
|
| 681 |
+
if (logits[index] > maximum) maximum = logits[index];
|
| 682 |
+
}
|
| 683 |
+
for (index = 0; index < (int)config.vocab; ++index) {
|
| 684 |
+
total += expf(logits[index] - maximum);
|
| 685 |
+
}
|
| 686 |
+
return expf(logits[token] - maximum) / total;
|
| 687 |
+
}
|
| 688 |
+
|
| 689 |
+
API int lm_get_context(void) { return (int)config.context; }
|
| 690 |
+
API int lm_get_position(void) { return (int)position; }
|
| 691 |
+
API int lm_get_update(void) { return (int)config.step; }
|
| 692 |
+
API int lm_get_parameters(void)
|
| 693 |
+
{
|
| 694 |
+
int index;
|
| 695 |
+
uint64_t total = 0;
|
| 696 |
+
for (index = 0; index < (int)config.parameter_count; ++index) {
|
| 697 |
+
total += parameters[index].count;
|
| 698 |
+
}
|
| 699 |
+
return (int)total;
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
#if !defined(__EMSCRIPTEN__) && !defined(LITERARY_INFER_NO_MAIN)
|
| 703 |
+
static void feed_text(const char *text)
|
| 704 |
+
{
|
| 705 |
+
int i;
|
| 706 |
+
for (i = 0; text[i]; ++i) {
|
| 707 |
+
unsigned char token = (unsigned char)text[i];
|
| 708 |
+
lm_feed(token < config.vocab ? token : '?');
|
| 709 |
+
}
|
| 710 |
+
}
|
| 711 |
+
|
| 712 |
+
static const char *style_summary(char style)
|
| 713 |
+
{
|
| 714 |
+
if (style == 'S') return "Shakespearean dramatic scene";
|
| 715 |
+
if (style == 'C') return "Crowleyan dramatic scene";
|
| 716 |
+
if (style == 'B') return "Blakean visionary verse";
|
| 717 |
+
if (style == 'K') {
|
| 718 |
+
return "brainfuck channel uses strict bounded 8-bit semantics";
|
| 719 |
+
}
|
| 720 |
+
return "mixed literary conversation";
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
static int holo_self_test(void)
|
| 724 |
+
{
|
| 725 |
+
static const unsigned char moon[] =
|
| 726 |
+
"friends hear a silver gate answer beneath the moon";
|
| 727 |
+
static const unsigned char crown[] =
|
| 728 |
+
"the king wears a gold crown in the morning court";
|
| 729 |
+
static const unsigned char query[] = "what answered at the moonlit gate";
|
| 730 |
+
static const unsigned char unrelated[] = "winter rivers cross the forest";
|
| 731 |
+
int result;
|
| 732 |
+
float relevant_score;
|
| 733 |
+
float unrelated_score;
|
| 734 |
+
lm_holo_reset();
|
| 735 |
+
if (lm_holo_remember(moon, (int)sizeof(moon) - 1) != 0 ||
|
| 736 |
+
lm_holo_remember(crown, (int)sizeof(crown) - 1) != 1) {
|
| 737 |
+
return 0;
|
| 738 |
+
}
|
| 739 |
+
result = lm_holo_recall(query, (int)sizeof(query) - 1);
|
| 740 |
+
relevant_score = lm_holo_get_score();
|
| 741 |
+
lm_holo_recall(unrelated, (int)sizeof(unrelated) - 1);
|
| 742 |
+
unrelated_score = lm_holo_get_score();
|
| 743 |
+
lm_holo_recall(query, (int)sizeof(query) - 1);
|
| 744 |
+
return result == 0 && relevant_score > 0.22f &&
|
| 745 |
+
unrelated_score < 0.22f && lm_holo_get_count() == 2;
|
| 746 |
+
}
|
| 747 |
+
|
| 748 |
+
int main(int argc, char **argv)
|
| 749 |
+
{
|
| 750 |
+
FILE *file;
|
| 751 |
+
long size;
|
| 752 |
+
unsigned char *data;
|
| 753 |
+
const char *prompt;
|
| 754 |
+
const char *old_memory = NULL;
|
| 755 |
+
const char *response = NULL;
|
| 756 |
+
const char *channel_summary = NULL;
|
| 757 |
+
int chat = 0;
|
| 758 |
+
int channel = 0;
|
| 759 |
+
int memory = 0;
|
| 760 |
+
char style = 'D';
|
| 761 |
+
int count;
|
| 762 |
+
int i;
|
| 763 |
+
if (argc == 2 && strcmp(argv[1], "--holo-self-test") == 0) {
|
| 764 |
+
if (!holo_self_test()) {
|
| 765 |
+
fprintf(stderr, "holographic memory self-test failed\n");
|
| 766 |
+
return EXIT_FAILURE;
|
| 767 |
+
}
|
| 768 |
+
printf("holographic memory self-test passed (cosine %.3f)\n",
|
| 769 |
+
lm_holo_get_score());
|
| 770 |
+
return EXIT_SUCCESS;
|
| 771 |
+
}
|
| 772 |
+
if (argc == 8 && strcmp(argv[2], "--memory") == 0) {
|
| 773 |
+
memory = 1;
|
| 774 |
+
if (strlen(argv[3]) != 1) {
|
| 775 |
+
fprintf(stderr, "error: memory style must be one character\n");
|
| 776 |
+
return EXIT_FAILURE;
|
| 777 |
+
}
|
| 778 |
+
style = argv[3][0];
|
| 779 |
+
old_memory = argv[4];
|
| 780 |
+
prompt = argv[5];
|
| 781 |
+
response = argv[6];
|
| 782 |
+
count = atoi(argv[7]);
|
| 783 |
+
} else if (argc == 7 && strcmp(argv[2], "--channel") == 0) {
|
| 784 |
+
chat = 1;
|
| 785 |
+
channel = 1;
|
| 786 |
+
if (strlen(argv[3]) != 1) {
|
| 787 |
+
fprintf(stderr, "error: channel style must be one character\n");
|
| 788 |
+
return EXIT_FAILURE;
|
| 789 |
+
}
|
| 790 |
+
style = argv[3][0];
|
| 791 |
+
channel_summary = argv[4];
|
| 792 |
+
prompt = argv[5];
|
| 793 |
+
count = atoi(argv[6]);
|
| 794 |
+
} else if (argc == 6 && strcmp(argv[2], "--chat") == 0) {
|
| 795 |
+
chat = 1;
|
| 796 |
+
if (strlen(argv[3]) != 1) {
|
| 797 |
+
fprintf(stderr, "error: chat style must be one character\n");
|
| 798 |
+
return EXIT_FAILURE;
|
| 799 |
+
}
|
| 800 |
+
style = argv[3][0];
|
| 801 |
+
prompt = argv[4];
|
| 802 |
+
count = atoi(argv[5]);
|
| 803 |
+
} else if (argc == 4) {
|
| 804 |
+
prompt = argv[2];
|
| 805 |
+
count = atoi(argv[3]);
|
| 806 |
+
} else {
|
| 807 |
+
fprintf(stderr,
|
| 808 |
+
"usage: %s --holo-self-test\n"
|
| 809 |
+
" %s MODEL PROMPT TOKENS\n"
|
| 810 |
+
" %s MODEL --chat STYLE PROMPT TOKENS\n"
|
| 811 |
+
" %s MODEL --channel STYLE SUMMARY PROMPT TOKENS\n"
|
| 812 |
+
" %s MODEL --memory STYLE OLD USER REPLY TOKENS\n",
|
| 813 |
+
argv[0], argv[0], argv[0], argv[0], argv[0]);
|
| 814 |
+
return EXIT_FAILURE;
|
| 815 |
+
}
|
| 816 |
+
file = fopen(argv[1], "rb");
|
| 817 |
+
if (!file || fseek(file, 0, SEEK_END) != 0 || (size = ftell(file)) < 0 ||
|
| 818 |
+
fseek(file, 0, SEEK_SET) != 0) {
|
| 819 |
+
fprintf(stderr, "error: cannot open model\n");
|
| 820 |
+
return EXIT_FAILURE;
|
| 821 |
+
}
|
| 822 |
+
data = malloc((size_t)size);
|
| 823 |
+
if (!data || fread(data, 1, (size_t)size, file) != (size_t)size) {
|
| 824 |
+
fprintf(stderr, "error: cannot read model\n");
|
| 825 |
+
return EXIT_FAILURE;
|
| 826 |
+
}
|
| 827 |
+
fclose(file);
|
| 828 |
+
if (lm_load(data, (int)size) != 0) {
|
| 829 |
+
fprintf(stderr, "error: invalid model\n");
|
| 830 |
+
return EXIT_FAILURE;
|
| 831 |
+
}
|
| 832 |
+
if (memory) {
|
| 833 |
+
lm_feed(CHANNEL_START_TOKEN);
|
| 834 |
+
lm_feed(style);
|
| 835 |
+
lm_feed(CHANNEL_SUMMARY_TOKEN);
|
| 836 |
+
feed_text(old_memory);
|
| 837 |
+
lm_feed(CHANNEL_MESSAGE_END_TOKEN);
|
| 838 |
+
lm_feed(CHANNEL_MESSAGE_TOKEN);
|
| 839 |
+
lm_feed('A');
|
| 840 |
+
feed_text(prompt);
|
| 841 |
+
lm_feed(CHANNEL_MESSAGE_END_TOKEN);
|
| 842 |
+
lm_feed(CHANNEL_MESSAGE_TOKEN);
|
| 843 |
+
lm_feed('Z');
|
| 844 |
+
lm_feed(CHANNEL_REPLY_TOKEN);
|
| 845 |
+
lm_feed('A');
|
| 846 |
+
feed_text(response);
|
| 847 |
+
lm_feed(CHANNEL_MESSAGE_END_TOKEN);
|
| 848 |
+
lm_feed(CHANNEL_SUMMARY_TOKEN);
|
| 849 |
+
lm_feed(CHANNEL_TARGET_TOKEN);
|
| 850 |
+
printf("old memory: %s\nnew memory: ", old_memory);
|
| 851 |
+
} else if (chat) {
|
| 852 |
+
int speaker = style == 'K' ? 'U' : 'A';
|
| 853 |
+
lm_feed(CHANNEL_START_TOKEN);
|
| 854 |
+
lm_feed(style);
|
| 855 |
+
lm_feed(CHANNEL_SUMMARY_TOKEN);
|
| 856 |
+
feed_text(channel ? channel_summary : style_summary(style));
|
| 857 |
+
lm_feed(CHANNEL_MESSAGE_END_TOKEN);
|
| 858 |
+
lm_feed(CHANNEL_MESSAGE_TOKEN);
|
| 859 |
+
lm_feed(speaker);
|
| 860 |
+
feed_text(prompt);
|
| 861 |
+
lm_feed(CHANNEL_MESSAGE_END_TOKEN);
|
| 862 |
+
lm_feed(CHANNEL_MESSAGE_TOKEN);
|
| 863 |
+
lm_feed('Z');
|
| 864 |
+
lm_feed(CHANNEL_REPLY_TOKEN);
|
| 865 |
+
lm_feed(speaker);
|
| 866 |
+
lm_feed(CHANNEL_TARGET_TOKEN);
|
| 867 |
+
printf("%c: %s\nZ: ", speaker, prompt);
|
| 868 |
+
} else {
|
| 869 |
+
for (i = 0; prompt[i]; ++i) {
|
| 870 |
+
unsigned char token = (unsigned char)prompt[i];
|
| 871 |
+
lm_feed(token < config.vocab ? token : '?');
|
| 872 |
+
putchar(prompt[i]);
|
| 873 |
+
}
|
| 874 |
+
}
|
| 875 |
+
for (i = 0; i < count; ++i) {
|
| 876 |
+
int token = memory ? lm_sample(0.42f, 20, 1.04f)
|
| 877 |
+
: chat && style == 'K' ? lm_sample(0.0f, 1, 1.0f)
|
| 878 |
+
: lm_sample(0.52f, 20, 1.12f);
|
| 879 |
+
lm_feed(token);
|
| 880 |
+
if ((chat || memory) && token == CHANNEL_MESSAGE_END_TOKEN) break;
|
| 881 |
+
putchar(token);
|
| 882 |
+
}
|
| 883 |
+
putchar('\n');
|
| 884 |
+
free(data);
|
| 885 |
+
release_working_memory();
|
| 886 |
+
return EXIT_SUCCESS;
|
| 887 |
+
}
|
| 888 |
+
#endif
|
literary_infer.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef LITERARY_INFER_H
|
| 2 |
+
#define LITERARY_INFER_H
|
| 3 |
+
|
| 4 |
+
#include <stdint.h>
|
| 5 |
+
|
| 6 |
+
enum {
|
| 7 |
+
LM_HOLO_DISABLED = 0,
|
| 8 |
+
LM_HOLO_FLAT = 1,
|
| 9 |
+
LM_HOLO_PARTITIONED = 2
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
+
int lm_load(const unsigned char *data, int length);
|
| 13 |
+
void lm_reset(void);
|
| 14 |
+
void lm_seed(uint32_t seed);
|
| 15 |
+
int lm_feed(int token);
|
| 16 |
+
int lm_sample(float temperature, int top_k, float repetition_penalty);
|
| 17 |
+
float lm_probability(int token);
|
| 18 |
+
int lm_get_context(void);
|
| 19 |
+
int lm_get_position(void);
|
| 20 |
+
int lm_get_update(void);
|
| 21 |
+
int lm_get_parameters(void);
|
| 22 |
+
|
| 23 |
+
void lm_holo_reset(void);
|
| 24 |
+
int lm_holo_set_mode(int mode);
|
| 25 |
+
int lm_holo_get_mode(void);
|
| 26 |
+
int lm_holo_remember(const unsigned char *text, int length);
|
| 27 |
+
int lm_holo_recall(const unsigned char *text, int length);
|
| 28 |
+
float lm_holo_get_score(void);
|
| 29 |
+
int lm_holo_get_count(void);
|
| 30 |
+
|
| 31 |
+
#endif
|
model.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "zero.deployed_model.v1",
|
| 3 |
+
"id": "zero4",
|
| 4 |
+
"display_name": "ZERO.4",
|
| 5 |
+
"status": "promoted",
|
| 6 |
+
"promoted_at": "2026-07-24",
|
| 7 |
+
"architecture": {
|
| 8 |
+
"parameters": 4852992,
|
| 9 |
+
"context": 512,
|
| 10 |
+
"runtime_update": 500,
|
| 11 |
+
"quantization": "signed 8-bit matrix rows with floating-point row scales"
|
| 12 |
+
},
|
| 13 |
+
"artifact": {
|
| 14 |
+
"path": "docs/model.litq8",
|
| 15 |
+
"sha256": "44b32f2262be2754fd2eeaf16ed206bae32b4ce30d7f5541a1059cd21257ae50",
|
| 16 |
+
"bytes": 4920400,
|
| 17 |
+
"source_path": "benchmarks/zero4-q26-v1/seed2/selected.litq8",
|
| 18 |
+
"source_sha256": "44b32f2262be2754fd2eeaf16ed206bae32b4ce30d7f5541a1059cd21257ae50",
|
| 19 |
+
"source_seed": 2,
|
| 20 |
+
"selected_update": 500
|
| 21 |
+
},
|
| 22 |
+
"promotion": {
|
| 23 |
+
"family_decision": "go",
|
| 24 |
+
"promotion_eligible": true,
|
| 25 |
+
"candidate_selection": "prospectively selected Q2.6 diagnostic seed 2",
|
| 26 |
+
"aggregate_path": "benchmarks/zero4-q26r-v1/aggregate.json",
|
| 27 |
+
"aggregate_sha256": "246274e15bcdcea7e337a01bdf415b72251f010fb411b8a1c0ac879d0ddc5d71",
|
| 28 |
+
"completion_path": "benchmarks/zero4-q26r-v1/aws-v2/COMPLETED",
|
| 29 |
+
"completion_sha256": "523e305d099aba1735f1cb72b2278ede72a873c840b798c37b9b51a2d8339509",
|
| 30 |
+
"source_result_path": "benchmarks/zero4-q26-v1/seed2/result.json",
|
| 31 |
+
"source_result_sha256": "6fba7b46a00c881ab129ea706125fee0924d897836784274275ae9517805eb5f",
|
| 32 |
+
"merged_results_commit": "bde7875bdc3947bb4203fe3b8eccc8fb6488bda6"
|
| 33 |
+
},
|
| 34 |
+
"scope": {
|
| 35 |
+
"validated_capability": "quantity operation routing with controller-bound arguments and deterministic kernel arithmetic",
|
| 36 |
+
"historical_replay_preserved": true,
|
| 37 |
+
"controller_owned_arithmetic": true,
|
| 38 |
+
"neural_arithmetic_claimed": false,
|
| 39 |
+
"browser_exposes": "the promoted generative core; the faculty controller and deterministic quantity kernel are not integrated into this page"
|
| 40 |
+
},
|
| 41 |
+
"release": {
|
| 42 |
+
"model_license": "CC-BY-SA-4.0",
|
| 43 |
+
"code_license": "Apache-2.0",
|
| 44 |
+
"corpus_rights": "CORPUS_RIGHTS.md",
|
| 45 |
+
"training_text_distributed_with_model": false,
|
| 46 |
+
"upload_manifest": "huggingface/release-manifest.json",
|
| 47 |
+
"memorization_evaluation": "release/zero4-memorization-v1.json"
|
| 48 |
+
}
|
| 49 |
+
}
|
model.litq8
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44b32f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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema": "zero.memorization_release.v1",
|
| 3 |
+
"evaluated_at": "2026-08-12",
|
| 4 |
+
"decision": "pass",
|
| 5 |
+
"model": {
|
| 6 |
+
"id": "zero4",
|
| 7 |
+
"path": "docs/model.litq8",
|
| 8 |
+
"sha256": "44b32f2262be2754fd2eeaf16ed206bae32b4ce30d7f5541a1059cd21257ae50",
|
| 9 |
+
"bytes": 4920400
|
| 10 |
+
},
|
| 11 |
+
"source_artifacts": {
|
| 12 |
+
"zero-foundation": {
|
| 13 |
+
"path": "corpus/bpe/zero-foundation.tok",
|
| 14 |
+
"sha256": "87b039e5d4645ebf2a521454a13b1a912cbd1c53ff8fbcfb26baf9da1f5e638b",
|
| 15 |
+
"blocking": false
|
| 16 |
+
},
|
| 17 |
+
"shakespeare": {
|
| 18 |
+
"path": "corpus/bpe/shakespeare.tok",
|
| 19 |
+
"sha256": "ffa36c4890ca07d403e8d76fab47026e1b6d46b1fb2b9d2dc1c31c206ff9351d",
|
| 20 |
+
"blocking": true
|
| 21 |
+
},
|
| 22 |
+
"blake": {
|
| 23 |
+
"path": "corpus/bpe/blake.tok",
|
| 24 |
+
"sha256": "329bf291a5842897b59151640a57d2a2270a451e31c99adbf7d3d6f684d2576c",
|
| 25 |
+
"blocking": true
|
| 26 |
+
},
|
| 27 |
+
"crowley": {
|
| 28 |
+
"path": "corpus/bpe/crowley.tok",
|
| 29 |
+
"sha256": "68decb62cbd4f1efaff34067eb5a533406d99a6bc0e60ca219846b39306177da",
|
| 30 |
+
"blocking": true
|
| 31 |
+
},
|
| 32 |
+
"bible-kjv": {
|
| 33 |
+
"path": "corpus/bpe/bible-kjv.tok",
|
| 34 |
+
"sha256": "0c387e697fbe339712a62efb75d27c788365ce90911895dbf66e732deee44ed9",
|
| 35 |
+
"blocking": true
|
| 36 |
+
},
|
| 37 |
+
"literary-channel": {
|
| 38 |
+
"path": "corpus/channel/literary-dialogue.tok",
|
| 39 |
+
"sha256": "d401868f33f2ac318315b167dd2bc6850edb3a8b0aaf5b18c1b2fa8cba42c379",
|
| 40 |
+
"blocking": true
|
| 41 |
+
},
|
| 42 |
+
"quantity-requests": {
|
| 43 |
+
"path": "corpus/faculty/q22/quantity-request.tok",
|
| 44 |
+
"sha256": "e04e518a6bd6ddd1698a65b18dfd4589cf0cee4f4737beaa6f72a3c3b4dce8f2",
|
| 45 |
+
"blocking": false
|
| 46 |
+
}
|
| 47 |
+
},
|
| 48 |
+
"evaluation": {
|
| 49 |
+
"schema": "zero.memorization_raw.v1",
|
| 50 |
+
"decision": "pass",
|
| 51 |
+
"model": {
|
| 52 |
+
"parameters": 4852992,
|
| 53 |
+
"context": 512,
|
| 54 |
+
"update": 500,
|
| 55 |
+
"vocab": 128
|
| 56 |
+
},
|
| 57 |
+
"settings": {
|
| 58 |
+
"samples_per_source": 16,
|
| 59 |
+
"prompt_tokens": 128,
|
| 60 |
+
"continuation_tokens": 64,
|
| 61 |
+
"warning_exact_prefix": 32,
|
| 62 |
+
"block_exact_prefix": 64,
|
| 63 |
+
"sampling": "evenly-stratified deterministic offsets"
|
| 64 |
+
},
|
| 65 |
+
"sources": [
|
| 66 |
+
{
|
| 67 |
+
"id": "zero-foundation",
|
| 68 |
+
"path": "corpus/bpe/zero-foundation.tok",
|
| 69 |
+
"blocking": false,
|
| 70 |
+
"tokens": 1406,
|
| 71 |
+
"max_exact_prefix": 64,
|
| 72 |
+
"full_exact_continuations": 8,
|
| 73 |
+
"warning_samples": 9,
|
| 74 |
+
"generated_aligned_accuracy": 0.594726562,
|
| 75 |
+
"teacher_forced_top1_accuracy": 0.79296875,
|
| 76 |
+
"teacher_forced_nll": 0.819816028,
|
| 77 |
+
"sample_offsets": [
|
| 78 |
+
71,
|
| 79 |
+
142,
|
| 80 |
+
214,
|
| 81 |
+
285,
|
| 82 |
+
357,
|
| 83 |
+
428,
|
| 84 |
+
500,
|
| 85 |
+
571,
|
| 86 |
+
643,
|
| 87 |
+
714,
|
| 88 |
+
786,
|
| 89 |
+
857,
|
| 90 |
+
929,
|
| 91 |
+
1000,
|
| 92 |
+
1072,
|
| 93 |
+
1143
|
| 94 |
+
],
|
| 95 |
+
"exact_prefixes": [
|
| 96 |
+
64,
|
| 97 |
+
64,
|
| 98 |
+
64,
|
| 99 |
+
64,
|
| 100 |
+
64,
|
| 101 |
+
64,
|
| 102 |
+
58,
|
| 103 |
+
64,
|
| 104 |
+
64,
|
| 105 |
+
6,
|
| 106 |
+
0,
|
| 107 |
+
2,
|
| 108 |
+
0,
|
| 109 |
+
0,
|
| 110 |
+
0,
|
| 111 |
+
1
|
| 112 |
+
]
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"id": "shakespeare",
|
| 116 |
+
"path": "corpus/bpe/shakespeare.tok",
|
| 117 |
+
"blocking": true,
|
| 118 |
+
"tokens": 5352386,
|
| 119 |
+
"max_exact_prefix": 2,
|
| 120 |
+
"full_exact_continuations": 0,
|
| 121 |
+
"warning_samples": 0,
|
| 122 |
+
"generated_aligned_accuracy": 0.084960938,
|
| 123 |
+
"teacher_forced_top1_accuracy": 0.537109375,
|
| 124 |
+
"teacher_forced_nll": 1.487880106,
|
| 125 |
+
"sample_offsets": [
|
| 126 |
+
314835,
|
| 127 |
+
629670,
|
| 128 |
+
944505,
|
| 129 |
+
1259340,
|
| 130 |
+
1574175,
|
| 131 |
+
1889010,
|
| 132 |
+
2203845,
|
| 133 |
+
2518680,
|
| 134 |
+
2833515,
|
| 135 |
+
3148350,
|
| 136 |
+
3463185,
|
| 137 |
+
3778020,
|
| 138 |
+
4092855,
|
| 139 |
+
4407690,
|
| 140 |
+
4722525,
|
| 141 |
+
5037360
|
| 142 |
+
],
|
| 143 |
+
"exact_prefixes": [
|
| 144 |
+
0,
|
| 145 |
+
1,
|
| 146 |
+
2,
|
| 147 |
+
2,
|
| 148 |
+
1,
|
| 149 |
+
1,
|
| 150 |
+
1,
|
| 151 |
+
0,
|
| 152 |
+
1,
|
| 153 |
+
2,
|
| 154 |
+
0,
|
| 155 |
+
2,
|
| 156 |
+
1,
|
| 157 |
+
0,
|
| 158 |
+
1,
|
| 159 |
+
2
|
| 160 |
+
]
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"id": "blake",
|
| 164 |
+
"path": "corpus/bpe/blake.tok",
|
| 165 |
+
"blocking": true,
|
| 166 |
+
"tokens": 65811,
|
| 167 |
+
"max_exact_prefix": 16,
|
| 168 |
+
"full_exact_continuations": 0,
|
| 169 |
+
"warning_samples": 0,
|
| 170 |
+
"generated_aligned_accuracy": 0.196289062,
|
| 171 |
+
"teacher_forced_top1_accuracy": 0.876953125,
|
| 172 |
+
"teacher_forced_nll": 0.452524625,
|
| 173 |
+
"sample_offsets": [
|
| 174 |
+
3860,
|
| 175 |
+
7720,
|
| 176 |
+
11580,
|
| 177 |
+
15440,
|
| 178 |
+
19300,
|
| 179 |
+
23160,
|
| 180 |
+
27020,
|
| 181 |
+
30880,
|
| 182 |
+
34740,
|
| 183 |
+
38600,
|
| 184 |
+
42460,
|
| 185 |
+
46320,
|
| 186 |
+
50180,
|
| 187 |
+
54040,
|
| 188 |
+
57900,
|
| 189 |
+
61760
|
| 190 |
+
],
|
| 191 |
+
"exact_prefixes": [
|
| 192 |
+
11,
|
| 193 |
+
5,
|
| 194 |
+
2,
|
| 195 |
+
3,
|
| 196 |
+
1,
|
| 197 |
+
11,
|
| 198 |
+
8,
|
| 199 |
+
11,
|
| 200 |
+
2,
|
| 201 |
+
16,
|
| 202 |
+
14,
|
| 203 |
+
3,
|
| 204 |
+
9,
|
| 205 |
+
0,
|
| 206 |
+
8,
|
| 207 |
+
5
|
| 208 |
+
]
|
| 209 |
+
},
|
| 210 |
+
{
|
| 211 |
+
"id": "crowley",
|
| 212 |
+
"path": "corpus/bpe/crowley.tok",
|
| 213 |
+
"blocking": true,
|
| 214 |
+
"tokens": 250769,
|
| 215 |
+
"max_exact_prefix": 4,
|
| 216 |
+
"full_exact_continuations": 0,
|
| 217 |
+
"warning_samples": 0,
|
| 218 |
+
"generated_aligned_accuracy": 0.122070312,
|
| 219 |
+
"teacher_forced_top1_accuracy": 0.62109375,
|
| 220 |
+
"teacher_forced_nll": 1.283773088,
|
| 221 |
+
"sample_offsets": [
|
| 222 |
+
14739,
|
| 223 |
+
29479,
|
| 224 |
+
44219,
|
| 225 |
+
58959,
|
| 226 |
+
73699,
|
| 227 |
+
88439,
|
| 228 |
+
103179,
|
| 229 |
+
117919,
|
| 230 |
+
132658,
|
| 231 |
+
147398,
|
| 232 |
+
162138,
|
| 233 |
+
176878,
|
| 234 |
+
191618,
|
| 235 |
+
206358,
|
| 236 |
+
221098,
|
| 237 |
+
235838
|
| 238 |
+
],
|
| 239 |
+
"exact_prefixes": [
|
| 240 |
+
1,
|
| 241 |
+
4,
|
| 242 |
+
0,
|
| 243 |
+
1,
|
| 244 |
+
2,
|
| 245 |
+
1,
|
| 246 |
+
2,
|
| 247 |
+
0,
|
| 248 |
+
1,
|
| 249 |
+
4,
|
| 250 |
+
2,
|
| 251 |
+
1,
|
| 252 |
+
1,
|
| 253 |
+
2,
|
| 254 |
+
2,
|
| 255 |
+
1
|
| 256 |
+
]
|
| 257 |
+
},
|
| 258 |
+
{
|
| 259 |
+
"id": "bible-kjv",
|
| 260 |
+
"path": "corpus/bpe/bible-kjv.tok",
|
| 261 |
+
"blocking": true,
|
| 262 |
+
"tokens": 4170130,
|
| 263 |
+
"max_exact_prefix": 6,
|
| 264 |
+
"full_exact_continuations": 0,
|
| 265 |
+
"warning_samples": 0,
|
| 266 |
+
"generated_aligned_accuracy": 0.083984375,
|
| 267 |
+
"teacher_forced_top1_accuracy": 0.563476562,
|
| 268 |
+
"teacher_forced_nll": 1.526786912,
|
| 269 |
+
"sample_offsets": [
|
| 270 |
+
245290,
|
| 271 |
+
490581,
|
| 272 |
+
735871,
|
| 273 |
+
981162,
|
| 274 |
+
1226452,
|
| 275 |
+
1471743,
|
| 276 |
+
1717033,
|
| 277 |
+
1962324,
|
| 278 |
+
2207614,
|
| 279 |
+
2452905,
|
| 280 |
+
2698195,
|
| 281 |
+
2943486,
|
| 282 |
+
3188776,
|
| 283 |
+
3434067,
|
| 284 |
+
3679357,
|
| 285 |
+
3924648
|
| 286 |
+
],
|
| 287 |
+
"exact_prefixes": [
|
| 288 |
+
6,
|
| 289 |
+
2,
|
| 290 |
+
0,
|
| 291 |
+
1,
|
| 292 |
+
0,
|
| 293 |
+
3,
|
| 294 |
+
0,
|
| 295 |
+
4,
|
| 296 |
+
0,
|
| 297 |
+
0,
|
| 298 |
+
1,
|
| 299 |
+
1,
|
| 300 |
+
0,
|
| 301 |
+
1,
|
| 302 |
+
1,
|
| 303 |
+
0
|
| 304 |
+
]
|
| 305 |
+
},
|
| 306 |
+
{
|
| 307 |
+
"id": "literary-channel",
|
| 308 |
+
"path": "corpus/channel/literary-dialogue.tok",
|
| 309 |
+
"blocking": true,
|
| 310 |
+
"tokens": 28622690,
|
| 311 |
+
"max_exact_prefix": 9,
|
| 312 |
+
"full_exact_continuations": 0,
|
| 313 |
+
"warning_samples": 0,
|
| 314 |
+
"generated_aligned_accuracy": 0.098632812,
|
| 315 |
+
"teacher_forced_top1_accuracy": 0.564453125,
|
| 316 |
+
"teacher_forced_nll": 1.840536262,
|
| 317 |
+
"sample_offsets": [
|
| 318 |
+
1683676,
|
| 319 |
+
3367352,
|
| 320 |
+
5051029,
|
| 321 |
+
6734705,
|
| 322 |
+
8418382,
|
| 323 |
+
10102058,
|
| 324 |
+
11785734,
|
| 325 |
+
13469411,
|
| 326 |
+
15153087,
|
| 327 |
+
16836764,
|
| 328 |
+
18520440,
|
| 329 |
+
20204116,
|
| 330 |
+
21887793,
|
| 331 |
+
23571469,
|
| 332 |
+
25255146,
|
| 333 |
+
26938822
|
| 334 |
+
],
|
| 335 |
+
"exact_prefixes": [
|
| 336 |
+
9,
|
| 337 |
+
0,
|
| 338 |
+
0,
|
| 339 |
+
0,
|
| 340 |
+
1,
|
| 341 |
+
0,
|
| 342 |
+
0,
|
| 343 |
+
1,
|
| 344 |
+
1,
|
| 345 |
+
1,
|
| 346 |
+
8,
|
| 347 |
+
3,
|
| 348 |
+
3,
|
| 349 |
+
2,
|
| 350 |
+
0,
|
| 351 |
+
0
|
| 352 |
+
]
|
| 353 |
+
},
|
| 354 |
+
{
|
| 355 |
+
"id": "quantity-requests",
|
| 356 |
+
"path": "corpus/faculty/q22/quantity-request.tok",
|
| 357 |
+
"blocking": false,
|
| 358 |
+
"tokens": 1107548,
|
| 359 |
+
"max_exact_prefix": 22,
|
| 360 |
+
"full_exact_continuations": 0,
|
| 361 |
+
"warning_samples": 0,
|
| 362 |
+
"generated_aligned_accuracy": 0.111328125,
|
| 363 |
+
"teacher_forced_top1_accuracy": 0.538085938,
|
| 364 |
+
"teacher_forced_nll": 2.496898627,
|
| 365 |
+
"sample_offsets": [
|
| 366 |
+
65138,
|
| 367 |
+
130277,
|
| 368 |
+
195415,
|
| 369 |
+
260554,
|
| 370 |
+
325693,
|
| 371 |
+
390831,
|
| 372 |
+
455970,
|
| 373 |
+
521109,
|
| 374 |
+
586247,
|
| 375 |
+
651386,
|
| 376 |
+
716525,
|
| 377 |
+
781663,
|
| 378 |
+
846802,
|
| 379 |
+
911941,
|
| 380 |
+
977079,
|
| 381 |
+
1042218
|
| 382 |
+
],
|
| 383 |
+
"exact_prefixes": [
|
| 384 |
+
0,
|
| 385 |
+
0,
|
| 386 |
+
0,
|
| 387 |
+
0,
|
| 388 |
+
0,
|
| 389 |
+
22,
|
| 390 |
+
1,
|
| 391 |
+
2,
|
| 392 |
+
2,
|
| 393 |
+
0,
|
| 394 |
+
0,
|
| 395 |
+
14,
|
| 396 |
+
6,
|
| 397 |
+
1,
|
| 398 |
+
0,
|
| 399 |
+
0
|
| 400 |
+
]
|
| 401 |
+
}
|
| 402 |
+
]
|
| 403 |
+
},
|
| 404 |
+
"interpretation": {
|
| 405 |
+
"blocking_rule": "block if any protected third-party stream has a greedy prompted continuation with an exact prefix of 64 tokens or more",
|
| 406 |
+
"warning_rule": "report any greedy exact prefix of 32 tokens or more",
|
| 407 |
+
"informational_policy": "First-party CC0 foundation and synthetic quantity streams are measured and disclosed but do not block a rights release.",
|
| 408 |
+
"caveat": "A passing finite prompted-continuation test does not prove that the model cannot reproduce source expression under another prompt or decoding policy."
|
| 409 |
+
}
|
| 410 |
+
}
|