febilly commited on
Commit
7d80957
·
verified ·
1 Parent(s): 8efaf80

Initial release: Q4_K_M imatrix build of StreamRevise

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ 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
+ Hy-MT2-1.8B-StreamRevise-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
37
+ Hy-MT2-1.8B-StreamRevise.imatrix.gguf filter=lfs diff=lfs merge=lfs -text
Hy-MT2-1.8B-StreamRevise-Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eaf0fecb53a50f533377f975ad507294fd504eb94619f2f19119a5e81fdb06b0
3
+ size 1069288736
Hy-MT2-1.8B-StreamRevise.imatrix.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8829921f1bf1789280090368132fe0a348da8c2a6d67c012da222a5283eb17a9
3
+ size 2393696
README.md ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - tencent/Hy-MT2-1.8B
5
+ - febilly/Hy-MT2-1.8B-StreamRevise-LoRA
6
+ base_model_relation: quantized
7
+ pipeline_tag: translation
8
+ tags:
9
+ - translation
10
+ - streaming-translation
11
+ - simultaneous-translation
12
+ - subtitles
13
+ - speech-translation
14
+ - gguf
15
+ - llama.cpp
16
+ - quantized
17
+ language:
18
+ - zh
19
+ - en
20
+ - ja
21
+ ---
22
+
23
+ # Hy-MT2-1.8B-StreamRevise — GGUF
24
+
25
+ 4-bit llama.cpp build of **StreamRevise**, a translation model for **live subtitles**. Every time the ASR
26
+ hypothesis updates, you pass the model its own previous translation of the sentence in progress; it decides
27
+ whether to keep that text and extend it, or rewrite part of it because the meaning changed. Subtitles grow
28
+ smoothly instead of flickering.
29
+
30
+ **1.07 GB on disk, and about 1.4 GB resident at `n_ctx 2048`.** Small enough to ship with a desktop app.
31
+ See [Footprint](#footprint) for how that scales.
32
+
33
+ Adapter, full prompt spec, training details:
34
+ [**Hy-MT2-1.8B-StreamRevise-LoRA**](https://huggingface.co/febilly/Hy-MT2-1.8B-StreamRevise-LoRA) ·
35
+ Base model: [`tencent/Hy-MT2-1.8B`](https://huggingface.co/tencent/Hy-MT2-1.8B)
36
+
37
+ > **中文简介**:实时字幕翻译模型的 4-bit 本地部署版。语音边说边识别,源文一直在变——每次更新时把模型上一版
38
+ > 译文一起喂回去,它自己决定保留已显示的部分继续接,还是因为意思变了而改写,让字幕平滑增长不闪烁。
39
+ > 1.07 GB,纯 CPU 可跑(约 2.1 GB 内存),有显卡则单次请求 <0.1 秒。
40
+
41
+ ---
42
+
43
+ ## Files
44
+
45
+ | file | size | what it is |
46
+ |---|---|---|
47
+ | `Hy-MT2-1.8B-StreamRevise-Q4_K_M.gguf` | 1.07 GB | **the model.** Q4_K_M with imatrix calibration, token embeddings at `Q4_K` |
48
+ | `Hy-MT2-1.8B-StreamRevise.imatrix.gguf` | 2.3 MB | importance matrix, only needed if you want to re-quantize at another bit width |
49
+
50
+ Only one quantization is published. The alternatives were measured and the differences sit inside the noise
51
+ floor, so the smallest one shipped:
52
+
53
+ | variant | size | verdict |
54
+ |---|---|---|
55
+ | **Q4_K_M, embeddings `Q4_K`** | **1.07 GB** | published here |
56
+ | Q4_K_M, embeddings `Q8_0` | 1.19 GB | +0.5pp exact match — noise |
57
+ | Q4_K_M, embeddings `F16` | 1.42 GB | no measurable gain |
58
+ | Q4_K_M, defaults | 1.92 GB | `llama-quantize` promotes embeddings to F32. No quality gain, 470 MB wasted |
59
+
60
+ Embeddings are tied to `lm_head` in this architecture, which is why their bit width gets its own column.
61
+ imatrix calibration used real streaming-translation prompts, which is what makes 4-bit embeddings safe here.
62
+
63
+ ---
64
+
65
+ ## Run it
66
+
67
+ ```bash
68
+ llama-server -m Hy-MT2-1.8B-StreamRevise-Q4_K_M.gguf -c 4096 --port 8080 -ngl 99 --no-webui
69
+ ```
70
+
71
+ Drop `-ngl 99` (or set `0`) on CPU-only machines. Then POST to `/completion`:
72
+
73
+ ```json
74
+ {
75
+ "prompt": "<|hy_begin▁of▁sentence|><|hy_User|>{PROMPT}<|hy_Assistant|>",
76
+ "n_predict": 256,
77
+ "temperature": 0,
78
+ "cache_prompt": true
79
+ }
80
+ ```
81
+
82
+ Three things to get right:
83
+
84
+ 1. **`temperature: 0`** — greedy, not the base model's `0.7`. Consecutive updates hand the model nearly the
85
+ same prompt and you want nearly the same output back; sampling introduces changes that have nothing to do
86
+ with the source changing, and those land on screen as flicker. All numbers below are greedy.
87
+ 2. **`cache_prompt: true`** — updates within one utterance share a long prefix. KV reuse is what makes
88
+ per-update latency negligible.
89
+ 3. **`{PROMPT}` must use the StreamRevise layout**, not a plain translation instruction.
90
+
91
+ ### A warning you can ignore
92
+
93
+ llama.cpp prints this on load:
94
+
95
+ ```
96
+ load: special_eos_id is not in special_eog_ids - the tokenizer config may be incorrect
97
+ load: special_eom_id is not in special_eog_ids - the tokenizer config may be incorrect
98
+ ```
99
+
100
+ It is harmless here. Hy-MT2 declares a single-value `eos_token_id`, and this build carries an explicit
101
+ `tokenizer.ggml.eom_token_id = 120020` that llama.cpp does not fold into its `special_eog_ids` set — hence
102
+ the complaint. Generation still terminates correctly: expect `stop_type: eos` and a `predicted_n` far below
103
+ your `n_predict`. If instead the model never stops, you are running a GGUF converted without the
104
+ end-of-message fix — see below.
105
+
106
+ ---
107
+
108
+ ## Prompt format
109
+
110
+ Full spec and a copy-paste renderer are in the
111
+ [LoRA repo](https://huggingface.co/febilly/Hy-MT2-1.8B-StreamRevise-LoRA#prompt-format). Short version.
112
+
113
+ First chunk of a new sentence, nothing to revise yet:
114
+
115
+ ```text
116
+ Translate the following text into {TARGET_LANGUAGE}. Note that you should only output the translated result without any additional explanation:
117
+
118
+ {CURRENT_SOURCE}
119
+ ```
120
+
121
+ Every update after that:
122
+
123
+ ```text
124
+ [Background Information]
125
+ Recent source utterances:
126
+ {UP_TO_10_PREVIOUS_SOURCE_SENTENCES}
127
+
128
+ Previous version of the current source:
129
+ {PREVIOUS_SOURCE}
130
+
131
+ Previous translation of the current source:
132
+ {PREVIOUS_TRANSLATION}
133
+
134
+ When the source meaning has not changed, preserve the still-correct prefix of the previous translation whenever possible. When content is added or corrected, accuracy and completeness take priority.
135
+
136
+ Please translate the following text into {TARGET_LANGUAGE}, taking the provided background information into consideration.
137
+
138
+ [Source Text]
139
+ {CURRENT_SOURCE}
140
+ ```
141
+
142
+ Background blocks are each optional, joined by a blank line, always in that order. `{TARGET_LANGUAGE}` is a
143
+ full English language name. `Recent source utterances` carries **source text only**, never the translations.
144
+
145
+ The model keeps no state between requests — the caller owns the revision chain and sends it in full every
146
+ time. That means you can retry, reorder, or drop requests freely.
147
+
148
+ ---
149
+
150
+ ## Speed
151
+
152
+ | | short prompt (33 tok) | long prompt (137 tok) |
153
+ |---|---|---|
154
+ | GPU (A40, CUDA, `-ngl 99`) | **0.06 s**, 256 tok/s decode | **0.06 s**, 337 tok/s decode |
155
+ | CPU (56-thread server) | 0.53 s, 17 tok/s decode | 1.16 s, 17 tok/s decode |
156
+
157
+ Rough expectations elsewhere: 8-core desktop CPU ~10–20 tok/s; Apple Silicon (Metal) ~30–60+ tok/s; any
158
+ discrete GPU with ≥2 GB VRAM (CUDA or Vulkan) ~50–300 tok/s.
159
+
160
+ For live subtitles: under 100 ms per update on a GPU, 0.5–1.2 s on CPU alone — usable, if not instant.
161
+
162
+ ## Footprint
163
+
164
+ Weights are ~1.02 GiB once loaded. The KV cache is the only part that scales with your settings: this is a
165
+ 32-layer model with 4 KV heads at head_dim 128, so **64 KiB per token** at f16.
166
+
167
+ | `n_ctx` | KV cache | ballpark resident |
168
+ |---|---|---|
169
+ | 1024 | 64 MiB | ~1.3 GB |
170
+ | **2048** | **128 MiB** | **~1.4 GB** |
171
+ | 4096 | 256 MiB | ~1.5 GB |
172
+ | 8192 | 512 MiB | ~1.8 GB |
173
+
174
+ Measured: raising `-c` from 2048 to 4096 costs exactly 135 MB. `--parallel` costs nothing extra — `-c` is the
175
+ total KV budget, divided among slots, not multiplied by them.
176
+
177
+ Two things push the number above these estimates, and neither is the model's doing: the CUDA context and
178
+ allocator pool (often 300–500 MB, and `nvidia-smi` reports it against your process), and compute buffers
179
+ sized by `-b`/`-ub`. If you are counting VRAM on a small card, lower `-c` first — that is the part you
180
+ control.
181
+
182
+ ## What 4-bit costs
183
+
184
+ 843 trajectories / 2,438 states, same prompts and greedy decoding on both sides.
185
+
186
+ | | bf16 | this build |
187
+ |---|---|---|
188
+ | state exact match | 0.287 | 0.282 |
189
+ | mean state similarity | 0.814 | 0.801 |
190
+ | final exact match | 0.199 | 0.211 |
191
+ | characters erased per append | 2.56 | 2.32 |
192
+ | prefix preserved (append transition) | 0.798 | 0.824 |
193
+ | prefix preserved (final transition) | 0.917 | 0.925 |
194
+ | empty-output rate | 0.000 | 0.000 |
195
+
196
+ About 1.3pp of similarity and half a point of exact match. The stability rows come out level or slightly
197
+ ahead, which is within noise. Full table in the
198
+ [LoRA repo](https://huggingface.co/febilly/Hy-MT2-1.8B-StreamRevise-LoRA#numbers).
199
+
200
+ ---
201
+
202
+ ## If you convert Hy-MT2 yourself
203
+
204
+ llama.cpp's HunYuan converter doesn't write an `eog`/`eom` token when the source model has a **single-valued**
205
+ `eos_token_id` — and Hy-MT2 does. Without a fix, generation never stops and you get endless repetition.
206
+
207
+ **This build already has the fix applied**; its metadata carries `tokenizer.ggml.eom_token_id = 120020`. If
208
+ you're converting from scratch, append this to `_fix_special_tokens()` in `conversion/hunyuan.py`:
209
+
210
+ ```python
211
+ eos = self.hparams.get("eos_token_id")
212
+ if eos is not None:
213
+ ids = eos if isinstance(eos, list) else [eos]
214
+ self.gguf_writer.add_eom_token_id(int(ids[0]))
215
+ ```
216
+
217
+ Converted and quantized with llama.cpp `b10442`.
218
+
219
+ ---
220
+
221
+ ## Limitations
222
+
223
+ - **Stability is a tendency, not a guarantee.** Nothing enforces prefix preservation; worst case a single
224
+ update rewrites the whole line. If your UI can't tolerate that, only display the prefix that has held
225
+ steady for N updates.
226
+ - **Prompt format matters a lot** — off-format prompts lose quality and stability.
227
+ - **Language coverage is uneven**: zh/en/ja are what it was trained on and measured on. Other directions
228
+ fall back to base-model behaviour, untested.
229
+ - **Greedy decoding assumed.**
230
+ - Metric definitions are project-internal; don't compare them against numbers from simultaneous-MT papers.
231
+
232
+ ## License
233
+
234
+ Apache 2.0, same as the base model [`tencent/Hy-MT2-1.8B`](https://huggingface.co/tencent/Hy-MT2-1.8B).