maxffarrell commited on
Commit
aa2af66
·
verified ·
1 Parent(s): 2144616

Publish experimental ARK 0.6B Q8 GGUF with provenance and validation

Browse files
.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
+ ark-asr-0.6b-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
CONVERTER-LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The transcribe.cpp authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
README.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Edge0/ARK-ASR-0.6B
4
+ pipeline_tag: automatic-speech-recognition
5
+ language:
6
+ - zh
7
+ - en
8
+ - de
9
+ - ja
10
+ - fr
11
+ - ko
12
+ - es
13
+ - pl
14
+ - it
15
+ - ro
16
+ - hu
17
+ - cs
18
+ - nl
19
+ - fi
20
+ - hr
21
+ - sk
22
+ - sl
23
+ - et
24
+ - lt
25
+ tags:
26
+ - gguf
27
+ - arkasr
28
+ - transcribe.cpp
29
+ ---
30
+
31
+ # ARK-ASR-0.6B GGUF candidate
32
+
33
+ Community Q8 conversion of [Edge0/ARK-ASR-0.6B](https://huggingface.co/Edge0/ARK-ASR-0.6B),
34
+ prepared for a draft Hex integration. No retraining. Not affiliated with the
35
+ original authors, and not a canonical handy-computer artifact.
36
+
37
+ **Requires an ARK-enabled runtime.** Stock llama.cpp, whisper.cpp and released
38
+ transcribe-cpp 0.2.4 cannot load it. Use the candidate runtime at
39
+ [maxffarrell/transcribe.cpp](https://github.com/maxffarrell/transcribe.cpp/tree/19f301609c06126e5071d1de5acdd95c714eec05),
40
+ revision `19f301609c06126e5071d1de5acdd95c714eec05`.
41
+ [Upstream draft PR](https://github.com/handy-computer/transcribe.cpp/pull/191).
42
+
43
+ ## File
44
+
45
+ `ark-asr-0.6b-Q8_0.gguf`: 1,372,881,664 bytes.
46
+ SHA-256: `ceca6bacd9cab3b52892de6703562aeeb62dc8a4b14aab0b020706637dd127dc`.
47
+
48
+ The 0.6B name describes the decoder; the full model also contains the audio
49
+ encoder and adapter. Q8 linear weights, F16 tied embedding/output matrix and
50
+ convolutions, F32 norms/biases/frontend tensors.
51
+
52
+ ## Run
53
+
54
+ ```sh
55
+ git clone https://github.com/maxffarrell/transcribe.cpp
56
+ cd transcribe.cpp
57
+ git checkout 19f301609c06126e5071d1de5acdd95c714eec05
58
+ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DTRANSCRIBE_BUILD_EXAMPLES=ON
59
+ cmake --build build --target transcribe-cli -j 8
60
+ hf download maxffarrell/ARK-ASR-0.6B-GGUF ark-asr-0.6b-Q8_0.gguf --local-dir models/ark
61
+ build/bin/transcribe-cli --backend metal -m models/ark/ark-asr-0.6b-Q8_0.gguf audio.wav
62
+ ```
63
+
64
+ Use `--backend cpu` for CPU inference. Input frontend: mono 16 kHz.
65
+ Long recordings use overlapping windows of at most 30 seconds. Language is
66
+ inferred from audio; forced-language steering, translation, streaming and
67
+ timestamps are not supported by this candidate.
68
+
69
+ ## Validation and limitations
70
+
71
+ Six public short samples from transcribe.cpp (JFK, Mandarin, Japanese, Korean,
72
+ noise and silence) produced exactly matching text in the original PyTorch
73
+ checkpoint, F16 GGUF and this Q8 GGUF. The Q8 JFK transcript also matched on
74
+ CPU and Metal. A 197-second public English speech clip completed through the
75
+ runtime's overlapping-window path on Metal. The existing 45 runtime CTests
76
+ passed. See `validation.json` for the compared text.
77
+
78
+ Reference agreement is not a ground-truth WER measurement. The original model
79
+ and both GGUF precisions emitted Japanese text for the Korean sample and
80
+ `嗯。` for noise and silence. Automatic language detection and hallucination
81
+ on nonspeech remain material limitations. The publisher's 19-language list
82
+ is coverage metadata, not validation of all languages. Long-audio completion
83
+ does not establish parity against an unchunked reference. Full tensor parity,
84
+ WER evaluation and upstream port acceptance remain incomplete. Treat this as
85
+ an experimental model, not an accuracy or speed recommendation.
86
+
87
+ ## Reproduce
88
+
89
+ Source: `Edge0/ARK-ASR-0.6B@45776b56d58cdfb2e2eb632f7e110f38684633e0`.
90
+ Original `model.safetensors` SHA-256:
91
+ `57a86ce1c2f2c2d6ebb7ad9642c9e951a5109625122b48c9180126a28787673d`.
92
+
93
+ ```sh
94
+ uv run convert-arkasr-to-gguf.py --input Edge0/ARK-ASR-0.6B \
95
+ --revision 45776b56d58cdfb2e2eb632f7e110f38684633e0 \
96
+ --variant ark-asr-0.6b --outtype q8_0 --output ark-asr-0.6b-Q8_0.gguf
97
+ ```
98
+
99
+ The included converter reuses harshav's work from
100
+ [ARK-ASR-3B-GGUF](https://huggingface.co/harshav/ARK-ASR-3B-GGUF), with variant,
101
+ revision and capability metadata adapted for 0.6B. Its source archive is pinned
102
+ in `conversion.json`. Converter/runtime license: MIT (`CONVERTER-LICENSE`);
103
+ weights: Apache-2.0 (`LICENSE`). Original architecture, training and evaluation:
104
+ [AutoArk/open-audio-opd](https://github.com/AutoArk/open-audio-opd).
105
+
106
+ This community conversion and its draft integration were prepared with Codex
107
+ at the contributor's request.
ark-asr-0.6b-Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ceca6bacd9cab3b52892de6703562aeeb62dc8a4b14aab0b020706637dd127dc
3
+ size 1372881664
conversion.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source_repository": "Edge0/ARK-ASR-0.6B",
3
+ "source_revision": "45776b56d58cdfb2e2eb632f7e110f38684633e0",
4
+ "source_sha256": "57a86ce1c2f2c2d6ebb7ad9642c9e951a5109625122b48c9180126a28787673d",
5
+ "output_file": "ark-asr-0.6b-Q8_0.gguf",
6
+ "output_bytes": 1372881664,
7
+ "output_sha256": "ceca6bacd9cab3b52892de6703562aeeb62dc8a4b14aab0b020706637dd127dc",
8
+ "converter_revision": "19f301609c06126e5071d1de5acdd95c714eec05",
9
+ "reused_runtime_source": "https://huggingface.co/harshav/ARK-ASR-3B-GGUF/resolve/main/transcribe.cpp-arkasr-b838a2b.tar.gz",
10
+ "reused_source_sha256": "776c2a7a690dc21dc629aa79d03003a0a9f9a463f1e0a4f3a4cefc6ee59dbe97",
11
+ "versions": {
12
+ "torch": "2.14.1",
13
+ "numpy": "2.5.3",
14
+ "gguf": "0.19.0",
15
+ "safetensors": "0.8.0",
16
+ "transformers": "4.57.6",
17
+ "huggingface-hub": "0.36.2"
18
+ },
19
+ "command": "uv run convert-arkasr-to-gguf.py --input Edge0/ARK-ASR-0.6B --revision 45776b56d58cdfb2e2eb632f7e110f38684633e0 --variant ark-asr-0.6b --outtype q8_0 --output ark-asr-0.6b-Q8_0.gguf"
20
+ }
convert-arkasr-to-gguf.py ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # /// script
3
+ # requires-python = ">=3.12,<3.15"
4
+ # dependencies = [
5
+ # "gguf",
6
+ # "huggingface-hub",
7
+ # "numpy",
8
+ # "safetensors",
9
+ # "torch",
10
+ # "transformers",
11
+ # ]
12
+ # ///
13
+ """Convert ARK-ASR 0.6B or 3B to GGUF format for transcribe.cpp.
14
+
15
+ Architecture (see PLAN.md §ARK):
16
+ * Audio encoder: Whisper-large-v3 (128 mel, d_model 1280, 32 layers, 20 heads)
17
+ with *partial interleaved RoPE* (rot_dim 32 of head_dim 64, theta 10000,
18
+ Q+K only); k_proj has no bias; the encoder's own final LayerNorm is dropped
19
+ (nn.Identity).
20
+ * Adapter: LayerNorm(1280) -> merge 4 consecutive frames (->5120) ->
21
+ Linear 5120->4096 -> GELU -> Linear 4096->2048.
22
+ * Decoder: stock Qwen2.5-3B (2048 hid, 36 L, GQA 16/2, SwiGLU, RMSNorm,
23
+ rope_theta 1e6, vocab 151936, tied embeddings).
24
+
25
+ Audio placeholder token <|audio|> (151663) embeddings are replaced by the first
26
+ N = ((mel_frames+1)//2)//4 adapter frames.
27
+
28
+ Streams tensors one-at-a-time via safe_open (BF16->F16). ~9 GB peak RAM.
29
+
30
+ Usage:
31
+ uv run --python 3.12 scripts/convert-arkasr-to-gguf.py --input AutoArk-AI/ARK-ASR-3B \
32
+ --output arkasr-3b-f16.gguf --outtype f16
33
+ """
34
+
35
+ import argparse
36
+ import json
37
+ import sys
38
+ from pathlib import Path
39
+
40
+ import numpy as np
41
+ import torch
42
+
43
+ try:
44
+ from gguf import GGUFWriter, GGMLQuantizationType
45
+ except ImportError:
46
+ print("Error: gguf package not found. Install with: pip install gguf")
47
+ sys.exit(1)
48
+
49
+ try:
50
+ from safetensors import safe_open
51
+ except ImportError:
52
+ print("Error: safetensors package not found. Install with: pip install safetensors")
53
+ sys.exit(1)
54
+
55
+ try:
56
+ from huggingface_hub import snapshot_download
57
+ except ImportError:
58
+ snapshot_download = None
59
+
60
+
61
+ def load_model_dir(model_id: str, revision: str | None = None) -> Path:
62
+ p = Path(model_id)
63
+ if p.is_dir():
64
+ return p
65
+ if snapshot_download is None:
66
+ print("Error: huggingface_hub not installed and --input is not a local dir")
67
+ sys.exit(1)
68
+ print(f"Downloading model from HuggingFace: {model_id}")
69
+ return Path(snapshot_download(
70
+ model_id, revision=revision,
71
+ allow_patterns=["*.safetensors", "*.json", "merges.txt", "*.jinja"],
72
+ ))
73
+
74
+
75
+ def map_tensor_name(name: str):
76
+ """Map an HF tensor name to a GGUF name, or None to skip it."""
77
+ # --- decoder (Qwen2.5-3B) ---
78
+ if name == "model.embed_tokens.weight":
79
+ return "dec.embed.weight"
80
+ if name == "model.norm.weight":
81
+ return "dec.norm.weight"
82
+ if name == "lm_head.weight":
83
+ return None # tied to dec.embed.weight; reused at runtime
84
+ if name.startswith("model.layers."):
85
+ rest = name[len("model.layers."):]
86
+ idx, _, sub = rest.partition(".")
87
+ m = {
88
+ "self_attn.q_proj.weight": "attn.q.weight",
89
+ "self_attn.q_proj.bias": "attn.q.bias",
90
+ "self_attn.k_proj.weight": "attn.k.weight",
91
+ "self_attn.k_proj.bias": "attn.k.bias",
92
+ "self_attn.v_proj.weight": "attn.v.weight",
93
+ "self_attn.v_proj.bias": "attn.v.bias",
94
+ "self_attn.o_proj.weight": "attn.o.weight",
95
+ "input_layernorm.weight": "attn_norm.weight",
96
+ "post_attention_layernorm.weight": "ffn_norm.weight",
97
+ "mlp.gate_proj.weight": "ffn.gate.weight",
98
+ "mlp.up_proj.weight": "ffn.up.weight",
99
+ "mlp.down_proj.weight": "ffn.down.weight",
100
+ }.get(sub)
101
+ return f"dec.blk.{idx}.{m}" if m else None
102
+
103
+ # --- adapter ---
104
+ if name == "audio_encoder.layer_norm.weight":
105
+ return "adapter.ln.weight"
106
+ if name == "audio_encoder.layer_norm.bias":
107
+ return "adapter.ln.bias"
108
+ if name == "audio_encoder.adapting.0.weight":
109
+ return "adapter.fc1.weight"
110
+ if name == "audio_encoder.adapting.0.bias":
111
+ return "adapter.fc1.bias"
112
+ if name == "audio_encoder.adapting.2.weight":
113
+ return "adapter.fc2.weight"
114
+ if name == "audio_encoder.adapting.2.bias":
115
+ return "adapter.fc2.bias"
116
+
117
+ # --- whisper encoder ---
118
+ if name.startswith("audio_encoder.whisper."):
119
+ rest = name[len("audio_encoder.whisper."):]
120
+ if rest == "conv1.weight":
121
+ return "enc.conv1.weight"
122
+ if rest == "conv1.bias":
123
+ return "enc.conv1.bias"
124
+ if rest == "conv2.weight":
125
+ return "enc.conv2.weight"
126
+ if rest == "conv2.bias":
127
+ return "enc.conv2.bias"
128
+ if rest == "embed_positions.weight":
129
+ return None # unused (use_rope=True)
130
+ if rest in ("layer_norm.weight", "layer_norm.bias"):
131
+ return None # encoder final LN replaced by nn.Identity
132
+ if rest.startswith("layers."):
133
+ r2 = rest[len("layers."):]
134
+ idx, _, sub = r2.partition(".")
135
+ m = {
136
+ "self_attn.q_proj.weight": "attn.q.weight",
137
+ "self_attn.q_proj.bias": "attn.q.bias",
138
+ "self_attn.k_proj.weight": "attn.k.weight", # no bias
139
+ "self_attn.v_proj.weight": "attn.v.weight",
140
+ "self_attn.v_proj.bias": "attn.v.bias",
141
+ "self_attn.out_proj.weight": "attn.o.weight",
142
+ "self_attn.out_proj.bias": "attn.o.bias",
143
+ "self_attn_layer_norm.weight": "attn_ln.weight",
144
+ "self_attn_layer_norm.bias": "attn_ln.bias",
145
+ "fc1.weight": "fc1.weight",
146
+ "fc1.bias": "fc1.bias",
147
+ "fc2.weight": "fc2.weight",
148
+ "fc2.bias": "fc2.bias",
149
+ "final_layer_norm.weight": "ffn_ln.weight",
150
+ "final_layer_norm.bias": "ffn_ln.bias",
151
+ }.get(sub)
152
+ return f"enc.blk.{idx}.{m}" if m else None
153
+ return None
154
+ return None
155
+
156
+
157
+ def build_mel_and_window(n_fft: int, n_mels: int, sr: int):
158
+ """Whisper feature-extractor mel filterbank (n_freqs, n_mels) + hann window.
159
+
160
+ Mirrors transformers.WhisperFeatureExtractor: slaney mel scale + slaney
161
+ norm, 0..sr/2 Hz, and torch.hann_window(periodic=True)."""
162
+ from transformers.audio_utils import mel_filter_bank
163
+ n_freqs = 1 + n_fft // 2
164
+ fb = mel_filter_bank(
165
+ num_frequency_bins=n_freqs,
166
+ num_mel_filters=n_mels,
167
+ min_frequency=0.0,
168
+ max_frequency=float(sr) / 2.0,
169
+ sampling_rate=sr,
170
+ norm="slaney",
171
+ mel_scale="slaney",
172
+ ) # (n_freqs, n_mels) float32
173
+ fb = np.ascontiguousarray(fb, dtype=np.float32)
174
+ # periodic hann window of length n_fft
175
+ win = np.hanning(n_fft + 1)[:-1].astype(np.float32)
176
+ return fb, win
177
+
178
+
179
+ def main():
180
+ ap = argparse.ArgumentParser(description="Convert ARK-ASR-3B to GGUF")
181
+ ap.add_argument("--input", required=True, help="HF model ID or local dir")
182
+ ap.add_argument("--output", required=True, help="Output GGUF path")
183
+ ap.add_argument("--outtype", default="f16", choices=["f16", "f32", "q8_0"],
184
+ help="dtype for 2D weights (default f16). q8_0 quantizes 2D "
185
+ "decoder/encoder/adapter weights; keeps the tied embedding, "
186
+ "conv kernels (F16) and norms/filterbank (F32).")
187
+ ap.add_argument("--variant", required=True, choices=["ark-asr-0.6b", "ark-asr-3b"])
188
+ ap.add_argument("--revision", help="Pinned Hugging Face source revision")
189
+ args = ap.parse_args()
190
+
191
+ mdir = load_model_dir(args.input, args.revision)
192
+ with open(mdir / "config.json", encoding="utf-8") as f:
193
+ cfg = json.load(f)
194
+ wc = cfg["whisper_config"]
195
+ expected_hidden = {"ark-asr-0.6b": 896, "ark-asr-3b": 2048}[args.variant]
196
+ if cfg["model_type"] != "arkasr" or cfg["hidden_size"] != expected_hidden:
197
+ raise ValueError("Checkpoint does not match the selected ARK variant")
198
+ if not cfg.get("tie_word_embeddings") or not cfg.get("use_rope"):
199
+ raise ValueError("ARK runtime requires tied embeddings and RoPE")
200
+
201
+ w = GGUFWriter(args.output, "arkasr")
202
+ w.add_name(args.variant.upper())
203
+ w.add_string("stt.variant", args.variant)
204
+ w.add_bool("stt.capability.lang_detect", True)
205
+ w.add_array("general.languages", ["zh", "en", "de", "ja", "fr", "ko", "es", "pl", "it", "ro", "hu", "cs", "nl", "fi", "hr", "sk", "sl", "et", "lt"] if args.variant == "ark-asr-0.6b" else ["zh", "en", "de", "ja", "fr", "ko", "es"])
206
+ w.add_description("ARK-ASR (Whisper-RoPE encoder + Qwen2 decoder)")
207
+
208
+ # ---- decoder (Qwen2.5-3B) hparams ----
209
+ hid = int(cfg["hidden_size"])
210
+ n_heads = int(cfg["num_attention_heads"])
211
+ w.add_uint32("arkasr.llm.hidden_size", hid)
212
+ w.add_uint32("arkasr.llm.num_layers", int(cfg["num_hidden_layers"]))
213
+ w.add_uint32("arkasr.llm.num_heads", n_heads)
214
+ w.add_uint32("arkasr.llm.num_kv_heads", int(cfg["num_key_value_heads"]))
215
+ w.add_uint32("arkasr.llm.head_dim", hid // n_heads)
216
+ w.add_uint32("arkasr.llm.intermediate_size", int(cfg["intermediate_size"]))
217
+ w.add_uint32("arkasr.llm.vocab_size", int(cfg["vocab_size"]))
218
+ w.add_uint32("arkasr.llm.max_position_embeddings", int(cfg.get("max_position_embeddings", 32768)))
219
+ w.add_float32("arkasr.llm.rope_theta", float(cfg.get("rope_theta", 1000000.0)))
220
+ w.add_float32("arkasr.llm.rms_norm_eps", float(cfg.get("rms_norm_eps", 1e-6)))
221
+
222
+ # ---- whisper encoder hparams ----
223
+ d_model = int(wc["d_model"])
224
+ e_heads = int(wc["encoder_attention_heads"])
225
+ e_head_dim = d_model // e_heads
226
+ w.add_uint32("arkasr.whisper.d_model", d_model)
227
+ w.add_uint32("arkasr.whisper.num_layers", int(wc["encoder_layers"]))
228
+ w.add_uint32("arkasr.whisper.num_heads", e_heads)
229
+ w.add_uint32("arkasr.whisper.head_dim", e_head_dim)
230
+ w.add_uint32("arkasr.whisper.ffn_dim", int(wc["encoder_ffn_dim"]))
231
+ w.add_uint32("arkasr.whisper.num_mel_bins", int(wc["num_mel_bins"]))
232
+ w.add_uint32("arkasr.whisper.max_source_positions", int(wc["max_source_positions"]))
233
+ # RotaryEmbedding(dim = head_dim // 2), base 10000 (rope_ratio 1)
234
+ w.add_uint32("arkasr.whisper.rot_dim", e_head_dim // 2)
235
+ w.add_float32("arkasr.whisper.rope_theta", 10000.0)
236
+ w.add_float32("arkasr.whisper.ln_eps", 1e-5)
237
+
238
+ # ---- adapter / audio / tokenizer hparams ----
239
+ w.add_uint32("arkasr.adapter.merge_factor", int(cfg.get("merge_factor", 4)))
240
+ w.add_uint32("arkasr.audio_token_id", int(cfg["audio_token_id"]))
241
+ w.add_uint32("arkasr.bos_token_id", int(cfg.get("bos_token_id", 151643)))
242
+ w.add_uint32("arkasr.eos_token_id", int(cfg.get("eos_token_id", 151645)))
243
+ w.add_uint32("arkasr.pad_token_id", int(cfg.get("pad_token_id", 151643)))
244
+ w.add_uint32("arkasr.n_fft", 400)
245
+ w.add_uint32("arkasr.hop_length", 160)
246
+ w.add_uint32("arkasr.sample_rate", 16000)
247
+
248
+ # ---- mel filterbank + window ----
249
+ fb, win = build_mel_and_window(400, int(wc["num_mel_bins"]), 16000)
250
+ w.add_tensor("enc.mel_filters", fb, raw_dtype=GGMLQuantizationType.F32)
251
+ w.add_tensor("enc.mel_window", win, raw_dtype=GGMLQuantizationType.F32)
252
+
253
+ # ---- tokenizer: GPT-2 byte-level BPE (vocab + merges + specials) ----
254
+ vocab_size = int(cfg["vocab_size"])
255
+ tokens = [f"[PAD{i}]" for i in range(vocab_size)]
256
+ vj = mdir / "vocab.json"
257
+ if vj.exists():
258
+ with open(vj, encoding="utf-8") as f:
259
+ vmap = json.load(f)
260
+ for tok, idx in vmap.items():
261
+ if 0 <= idx < vocab_size:
262
+ tokens[idx] = tok
263
+ aj = mdir / "added_tokens.json"
264
+ if aj.exists():
265
+ with open(aj, encoding="utf-8") as f:
266
+ for tok, idx in json.load(f).items():
267
+ if 0 <= idx < vocab_size:
268
+ tokens[idx] = tok
269
+ w.add_tokenizer_model("gpt2")
270
+ w.add_token_list(tokens)
271
+ mt = mdir / "merges.txt"
272
+ if mt.exists():
273
+ merges = []
274
+ with open(mt, encoding="utf-8") as f:
275
+ for line in f:
276
+ line = line.rstrip("\n")
277
+ if line and not line.startswith("#"):
278
+ merges.append(line)
279
+ if merges:
280
+ w.add_token_merges(merges)
281
+ else:
282
+ print("WARNING: merges.txt missing — decode-only is fine, encode falls back to per-byte")
283
+
284
+ # ---- stream tensors ----
285
+ index_path = mdir / "model.safetensors.index.json"
286
+ if index_path.exists():
287
+ with open(index_path, encoding="utf-8") as f:
288
+ weight_map = json.load(f)["weight_map"]
289
+ else:
290
+ # single-file checkpoint
291
+ only = next(mdir.glob("*.safetensors"))
292
+ weight_map = {}
293
+ with safe_open(str(only), framework="pt") as h:
294
+ for k in h.keys():
295
+ weight_map[k] = only.name
296
+
297
+ handles = {}
298
+ def get_handle(fname):
299
+ if fname not in handles:
300
+ handles[fname] = safe_open(str(mdir / fname), framework="pt")
301
+ return handles[fname]
302
+
303
+ # q8_0: keep these at F16/F32 (sampling-critical / conv / filterbank).
304
+ def keep_unquantized(name):
305
+ return (name == "dec.embed.weight" or name.endswith("conv1.weight") or name.endswith("conv2.weight"))
306
+
307
+ try:
308
+ from gguf import quants as _gguf_quants
309
+ except ImportError:
310
+ _gguf_quants = None
311
+
312
+ n_written = 0
313
+ n_quant = 0
314
+ for hf_name in sorted(weight_map.keys()):
315
+ gguf_name = map_tensor_name(hf_name)
316
+ if gguf_name is None:
317
+ continue
318
+ t = get_handle(weight_map[hf_name]).get_tensor(hf_name)
319
+ if t.ndim <= 1:
320
+ data = np.ascontiguousarray(t.to(torch.float32).numpy())
321
+ w.add_tensor(gguf_name, data, raw_dtype=GGMLQuantizationType.F32)
322
+ elif args.outtype == "q8_0" and t.ndim == 2 and not keep_unquantized(gguf_name) \
323
+ and (t.shape[-1] % 32 == 0) and _gguf_quants is not None:
324
+ arr = np.ascontiguousarray(t.to(torch.float32).numpy())
325
+ qd = _gguf_quants.quantize(arr, GGMLQuantizationType.Q8_0)
326
+ w.add_tensor(gguf_name, qd, raw_dtype=GGMLQuantizationType.Q8_0)
327
+ n_quant += 1
328
+ else:
329
+ dt = torch.float32 if args.outtype == "f32" else torch.float16
330
+ qt = GGMLQuantizationType.F32 if args.outtype == "f32" else GGMLQuantizationType.F16
331
+ data = np.ascontiguousarray(t.to(dt).numpy())
332
+ w.add_tensor(gguf_name, data, raw_dtype=qt)
333
+ n_written += 1
334
+ if n_written % 50 == 0:
335
+ print(f" ... {n_written} tensors ({n_quant} q8_0)")
336
+
337
+ print(f"Writing GGUF ({n_written} tensors) -> {args.output}")
338
+ w.write_header_to_file()
339
+ w.write_kv_data_to_file()
340
+ w.write_tensors_to_file()
341
+ w.close()
342
+ print("Done.")
343
+
344
+
345
+ if __name__ == "__main__":
346
+ main()
validation.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "runtime_revision": "19f301609c06126e5071d1de5acdd95c714eec05",
3
+ "samples_source": "handy-computer/transcribe.cpp@48559bbd9a44320f1b581606f712ce1dd0e2309f",
4
+ "short_cases": [
5
+ {
6
+ "sample": "jfk.wav",
7
+ "pytorch": "And so, my fellow Americans, ask not what your country can do for you; ask what you can do for your country.",
8
+ "f16": "And so, my fellow Americans, ask not what your country can do for you; ask what you can do for your country.",
9
+ "q8_0": "And so, my fellow Americans, ask not what your country can do for you; ask what you can do for your country.",
10
+ "exact": true
11
+ },
12
+ {
13
+ "sample": "zh-short.wav",
14
+ "pytorch": "\u65e5\u672c\u539f\u5b50\u80fd\u673a\u6784\u8868\u793a\uff0c\u6838\u7535\u7ad9\u68c0\u6d4b\u51fa\u4e86\u653e\u5c04\u6027\u7269\u8d28\u201c\u7130\u201d\u6838\u70b9\u3002",
15
+ "f16": "\u65e5\u672c\u539f\u5b50\u80fd\u673a\u6784\u8868\u793a\uff0c\u6838\u7535\u7ad9\u68c0\u6d4b\u51fa\u4e86\u653e\u5c04\u6027\u7269\u8d28\u201c\u7130\u201d\u6838\u70b9\u3002",
16
+ "q8_0": "\u65e5\u672c\u539f\u5b50\u80fd\u673a\u6784\u8868\u793a\uff0c\u6838\u7535\u7ad9\u68c0\u6d4b\u51fa\u4e86\u653e\u5c04\u6027\u7269\u8d28\u201c\u7130\u201d\u6838\u70b9\u3002",
17
+ "exact": true
18
+ },
19
+ {
20
+ "sample": "ja-short.wav",
21
+ "pytorch": "\u3057\u304b\u3057\u3001\u901a\u4fe1\u7d4c\u8def\u304c\u9045\u3044\u305f\u3081\u3001\u897f\u6d0b\u306e\u30b9\u30bf\u30a4\u30eb\u306f25\u5e74\u304b\u308930\u5e74\u9045\u308c\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002",
22
+ "f16": "\u3057\u304b\u3057\u3001\u901a\u4fe1\u7d4c\u8def\u304c\u9045\u3044\u305f\u3081\u3001\u897f\u6d0b\u306e\u30b9\u30bf\u30a4\u30eb\u306f25\u5e74\u304b\u308930\u5e74\u9045\u308c\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002",
23
+ "q8_0": "\u3057\u304b\u3057\u3001\u901a\u4fe1\u7d4c\u8def\u304c\u9045\u3044\u305f\u3081\u3001\u897f\u6d0b\u306e\u30b9\u30bf\u30a4\u30eb\u306f25\u5e74\u304b\u308930\u5e74\u9045\u308c\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002",
24
+ "exact": true
25
+ },
26
+ {
27
+ "sample": "ko-short.wav",
28
+ "pytorch": "\u7121\u7406\u306f\u3001\u4e00\u5339\u304b\u3089\u4e09\u5339\u306e\u540c\u65cf\u6210\u4eba\u30b9\u30b3\u30c3\u30af\u3068\u3001\u3080\u3084\u4e09\u5341\u5339\u306b\u3044\u308b\u306e\u30a2\u30f3\u30b3\u30c3\u30af\u3068\u4e09\u5339\u3067\u69cb\u6210\u3055\u308c\u307e\u3059\u3002",
29
+ "f16": "\u7121\u7406\u306f\u3001\u4e00\u5339\u304b\u3089\u4e09\u5339\u306e\u540c\u65cf\u6210\u4eba\u30b9\u30b3\u30c3\u30af\u3068\u3001\u3080\u3084\u4e09\u5341\u5339\u306b\u3044\u308b\u306e\u30a2\u30f3\u30b3\u30c3\u30af\u3068\u4e09\u5339\u3067\u69cb\u6210\u3055\u308c\u307e\u3059\u3002",
30
+ "q8_0": "\u7121\u7406\u306f\u3001\u4e00\u5339\u304b\u3089\u4e09\u5339\u306e\u540c\u65cf\u6210\u4eba\u30b9\u30b3\u30c3\u30af\u3068\u3001\u3080\u3084\u4e09\u5341\u5339\u306b\u3044\u308b\u306e\u30a2\u30f3\u30b3\u30c3\u30af\u3068\u4e09\u5339\u3067\u69cb\u6210\u3055\u308c\u307e\u3059\u3002",
31
+ "exact": true
32
+ },
33
+ {
34
+ "sample": "noise.wav",
35
+ "pytorch": "\u55ef\u3002",
36
+ "f16": "\u55ef\u3002",
37
+ "q8_0": "\u55ef\u3002",
38
+ "exact": true
39
+ },
40
+ {
41
+ "sample": "jobs-silence.wav",
42
+ "pytorch": "\u55ef\u3002",
43
+ "f16": "\u55ef\u3002",
44
+ "q8_0": "\u55ef\u3002",
45
+ "exact": true
46
+ }
47
+ ],
48
+ "cpu_metal_jfk_exact": true,
49
+ "long_audio": {
50
+ "sample": "love-loss.wav",
51
+ "duration_seconds": 197.15,
52
+ "completion": "ok",
53
+ "reference_parity_checked": false
54
+ },
55
+ "is_ground_truth_wer": false
56
+ }