Files

180 lines
8.1 KiB
Markdown

# Hy-MT3 model and adapter
Status: Draft v1.0, researched 2026-11-26. Model cards and conversions change; re-check tags, sizes and licences before T2.7 and before any release. Everything here is guidance for adapters, Settings hints and the evaluation. **Never hard-code this list as "available" in the app**; discover installed models at runtime.
Sources: [Hy-MT3-7B-GGUF](https://huggingface.co/tencent/Hy-MT3-7B-GGUF), [Hy-MT3-1.8B-GGUF](https://huggingface.co/tencent/Hy-MT3-1.8B-GGUF), [Hy-MT3 GitHub](https://github.com/Tencent-Hunyuan/Hy-MT3), [Hy-MT3 report](https://arxiv.org/pdf/2611.27673).
## 1. Family and tags
| Model | Role | Tag | Size | Notes |
|---|---|---|---|---|
| Hy-MT3-7B | **Default (provisional)** | `hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M` | 5.15 GB download; about 6.5 GB resident with 8K context | 7.5B parameters, `hunyuan-dense`, Q4_K_M |
| Hy-MT3-1.8B | **Fast preset** | `hf.co/tencent/Hy-MT3-1.8B-GGUF:Q4_K_M` | 1.35 GB download | 2B-class, Q4_K_M; **VERIFY** on your Ollama |
| Hy-MT3-30B-A3B | Quality, not a preset | `hf.co/tencent/Hy-MT3-30B-A3B-GGUF:*` | far above 16 GB | MoE, 3B active; hidden unless installed |
- Licence: **Apache-2.0** per the Hugging Face model cards. `/api/show` reports `license: null` for the GGUF, so show the model-card licence in Settings, not the Ollama field.
- 102 supported languages. See `docs/LANGUAGES.md` for the exact model names.
- The model has **no default system prompt**. Do not send one.
- `/api/show` capabilities: `["completion"]`. No vision, no thinking. Do not send `images` or `think`.
- Chat template (verified): `{{ if .System }}<|startoftext|>{{ .System }}<|extra_4|>{{ end }}{{ if .Prompt }}<|startoftext|>{{ .Prompt }}<|extra_0|>{{ end }}{{ .Response }}<|eos|>`.
- Model card max context: **8192**. GGUF metadata reports `context_length = 262144`; that is the base model metadata, not the documented translation context. Set `num_ctx: 8192`.
## 2. Sampling
Publisher recommendation for 1.8B and 7B:
```json
{
"temperature": 0.7,
"top_p": 0.6,
"top_k": 20,
"repetition_penalty": 1.05,
"max_tokens": 4096
}
```
In Ollama:
| Ollama option | Value |
|---|---|
| `temperature` | 0.7 |
| `top_p` | 0.6 |
| `top_k` | 20 |
| `repeat_penalty` | 1.05 |
| `num_predict` | 4096 |
| `num_ctx` | 8192 |
`/api/show` reports only stop tokens, no sampling defaults, so the adapter must set these explicitly. The M7 evaluation compares temperature 0.7 with 0.2; a translation app may prefer lower variance, but the publisher default is the starting point.
## 3. The canonical default prompt
This is the only default in v1. It is byte-exact: keep the bold markers, the period after the target language, the colon and the blank line.
```text
Translate the following text into {target_lang}. Note that you should **only output the translated result without any additional explanation**:
{source_text}
```
- `{target_lang}` is the exact full English name from the model card (`German`, `Chinese`, `Traditional Chinese`, `Portuguese`, `Norwegian Nynorsk`, `Cyrillic Kazakh`, …).
- No source-language field, no system message, no timestamp, no app name.
- The prefix depends only on `{target_lang}`; append `{source_text}` last. This preserves Ollama's prompt-prefix cache.
- The owner's reference run reported **177/178 prompt tokens cached**; our run reported 178 prompt tokens, 246 output tokens, 44.6 tok/s, 6.52 s total on an M5 Pro 48 GB.
## 4. Other documented templates
These are the only allowed alternatives (ADR-012). v1 defaults to the template above for everything; the others are fallbacks selected by content class or validation.
### Terminology (future glossary)
```text
*Reference the following translations:*
{source_term} translates to {target_term}
{source_term} translates to {target_term}
Translate the following text into {target_lang}. Note that you must **ONLY output the translated result without any additional explanation**:
{source_text}
```
### Style (future style presets)
```text
Please translate the following text into {target_lang}. Note that the translation style must strictly conform to [**{target_style}**]:
{source_text}
```
### Personalization
```text
[Source Text]
{source_text}
[Translation Tasks]
1. **{user_preference}**
2. **{user_preference}**
3. ...
4. Translate the [Source Text] into {target_lang}.
```
### Delimiters (placeholder-heavy text)
```text
Please accurately translate the following text into {target_lang}. You must **retain the exact same number of delimiters in the translation. Strictly do not omit, escape, or translate these symbols, and pay close attention to their placement**.
{source_text}
```
### Structured Data 1 (Markdown, JSON, HTML)
```text
### Task
Translate the user-facing text within the following {format_type} data into {target_lang}.
### Strict Rules
1. **Structure Preservation:** You MUST preserve the original {format_type} data structure, nesting, hierarchy, and indentation exactly as they are.
2. **Selective Translation:** Translate ONLY the visible, user-facing text content/values.
3. **Strict Non-Translation:** NEVER translate or alter code tags, keys, properties, object names, or variable placeholders. Leave them exactly in their original English/code form.
### Source Data
{source_text}
```
### Structured Data 2 (background information)
```text
[Background Information]
{background_text}
Please translate the following text into {target_lang}, taking the provided background information into consideration.
[Source Text]
{source_text}
```
## 5. Content policy for v1
| Source content | Prompt |
|---|---|
| Plain prose, light Markdown, ordinary URLs | **Default** |
| JSON, HTML, Markdown tables, complex nesting | **Structured Data 1** with `format_type` (`JSON`, `HTML`, `Markdown`) |
| Many placeholders/delimiters, or a protected token was lost | **Delimiters** (one retry only) |
| User glossary (future) | **Terminology** |
| User style (future) | **Style** |
The default prompt already preserved a URL, an e-mail, `{{limit}}`, a code span and a JSON object in our checks. Validation is still mandatory; do not assume.
## 6. Known limitations
- **Literal compounds.** Technical English sometimes becomes a literal German compound ("thinking tokens" → "Denktokens", "non-thinking mode" → "nicht-denkenden Modus"). A style or terminology prompt may help; do not rewrite silently.
- **Preamble risk.** The model usually follows "only output the translation", but can add an explanation on unusual input. Detect and flag; never strip automatically.
- **Long input.** The card's context is 8192. Chunk before the limit; do not rely on the GGUF metadata's larger base context.
- **Numbers and units.** Locale formatting may change (`1.5` → `1,5`). Validate semantic numeric presence, not the exact string.
- **Code and keys.** The default template handles simple JSON well; use Structured Data 1 for real code or nested data. Never translate identifiers silently.
- **Same-language input.** A German→German request may return the text unchanged or "improved"; detect and warn.
- **No glossary in v1.** Terminology consistency across a document is not guaranteed.
## 7. Compatibility spike results (T2.7)
Fill in from the spike. One row per tag and direction.
| Tag | Digest (first 12) | Ollama | Direction | Works | Notes (quality, preamble, tokens, speed) |
|---|---|---|---|---|---|
| hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M | | 0.40.18 | en→de | ☐ | |
| hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M | | 0.40.18 | de→en | ☐ | |
| hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M | | 0.40.18 | markdown | ☐ | |
| hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M | | 0.40.18 | json | ☐ | |
| hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M | | 0.40.18 | placeholders | ☐ | |
| hf.co/tencent/Hy-MT3-1.8B-GGUF:Q4_K_M | | | en→de | ☐ | |
| hf.co/tencent/Hy-MT3-1.8B-GGUF:Q4_K_M | | | de→en | ☐ | |
## 8. Adding a model
1. Capture fixtures (`make fixtures`) for the new tag.
2. Extend `HyMT3Adapter` only if the model family is still Hy-MT3; a different family needs its own adapter and documented prompts.
3. Bump the adapter `version`.
4. Add it to this document with sources and licence status.
5. Run `/evaluate` on the corpus before offering it as a preset.