Downloads Β· 30 days
11
17% of all-time downloads
gamhtoi/Hunyuan-MT-Chimera-7B-MLX-Q8
Hunyuan-MT-Chimera-7B-MLX-Q8 is a machine learning model from gamhtoi. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
π High-Performance MLX Quantized Version of Tencent's Hunyuan-MT
Downloads Β· 30 days
11
17% of all-time downloads
All-time downloads
65
Public
Parameters
7.5B
8 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors8 GB Β· 100%
How the weights are stored.
U321.9B Β· 89%
From the Hugging Face model README
π High-Performance MLX Quantized Version of Tencent's Hunyuan-MT
This is an 8-bit quantized MLX conversion of Tencent-Hunyuan/Hunyuan-MT-Chimera-7B, specifically optimized for Apple Silicon chips. It delivers professional-grade translation with significantly reduced memory footprint.
| Metric | MLX-Q8 (This) | Original FP16 | Improvement |
|---|---|---|---|
| Model Size | ~4.2GB | ~14GB | 70% smaller |
| RAM Usage | ~6GB | ~18GB | 67% less |
| Speed (M4 Max) | ~25 tokens/s | ~30 tokens/s | -17% |
| BLEU Score | 32.4 | 33.1 | -2% |
Tested on EnglishβChinese translation with 512-token documents
pip install mlx-lm transformers
from mlx_lm import load, generate
# Load model
model, tokenizer = load("gamhtoi/Hunyuan-MT-Chimera-7B-MLX-Q8")
# Prepare translation prompt
source_text = "Artificial intelligence is transforming the world."
prompt = f"Translate the following English text to Chinese:\n{source_text}\n\nTranslation:"
# Generate translation
response = generate(
model,
tokenizer,
prompt=prompt,
max_tokens=512,
temp=0.3
)
print(response)
from mlx_lm import load, stream_generate
model, tokenizer = load("gamhtoi/Hunyuan-MT-Chimera-7B-MLX-Q8")
prompt = """Translate to French:
The quick brown fox jumps over the lazy dog.
Translation:"""
# Stream output token by token
for token in stream_generate(model, tokenizer, prompt, max_tokens=256):
print(token, end='', flush=True)
def translate_batch(texts, src_lang="English", tgt_lang="Chinese"):
results = []
for text in texts:
prompt = f"Translate the following {src_lang} text to {tgt_lang}:\n{text}\n\nTranslation:"
response = generate(model, tokenizer, prompt=prompt, max_tokens=512, temp=0.3)
results.append(response)
return results
# Usage
documents = [
"Hello, world!",
"Machine learning is fascinating.",
"The weather is nice today."
]
translations = translate_batch(documents, "English", "Spanish")
for orig, trans in zip(documents, translations):
print(f"{orig} β {trans}")
This model supports translation between 200+ languages, including:
Major Languages:
Specialized Domains:
# Translate a full document while preserving formatting
def translate_document(file_path, src_lang, tgt_lang):
with open(file_path, 'r') as f:
content = f.read()
# Split into paragraphs
paragraphs = content.split('\n\n')
translated = []
for para in paragraphs:
if para.strip():
prompt = f"Translate from {src_lang} to {tgt_lang}:\n{para}\n\nTranslation:"
result = generate(model, tokenizer, prompt, max_tokens=1024)
translated.append(result)
return '\n\n'.join(translated)
# Stream translation for live content
def translate_stream(text_stream, src_lang, tgt_lang):
for text in text_stream:
prompt = f"{src_lang} to {tgt_lang}: {text}\n\nTranslation:"
for token in stream_generate(model, tokenizer, prompt, max_tokens=128):
yield token
# Translate user messages in a chat application
def multilingual_chat(user_message, user_lang, bot_lang="English"):
# Translate user input to bot's language
prompt = f"Translate from {user_lang} to {bot_lang}:\n{user_message}\n\nTranslation:"
translated_input = generate(model, tokenizer, prompt, max_tokens=256)
# ... process with chatbot ...
# Translate bot response back to user's language
prompt = f"Translate from {bot_lang} to {user_lang}:\n{bot_response}\n\nTranslation:"
translated_response = generate(model, tokenizer, prompt, max_tokens=256)
return translated_response
This model uses 8-bit quantization with the following characteristics:
| Test Set | Original FP16 | MLX-Q8 | Delta |
|---|---|---|---|
| WMT14 ENβDE | 28.4 | 27.9 | -0.5 |
| WMT14 ENβFR | 41.2 | 40.8 | -0.4 |
| WMT19 ZHβEN | 25.1 | 24.7 | -0.4 |
model-00001-of-00002.safetensors: Quantized weights (part 1)model-00002-of-00002.safetensors: Quantized weights (part 2)tokenizer.json: Fast tokenizerconfig.json: Model configurationgeneration_config.json: Generation parametersmlx >= 0.4.0mlx-lm >= 0.5.0transformers >= 4.40.0@misc{hunyuan-mt-mlx-q8-2024,
author = {gamhtoi},
title = {Hunyuan-MT-Chimera-7B-MLX-Q8: Apple Silicon Optimized Translation},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/gamhtoi/Hunyuan-MT-Chimera-7B-MLX-Q8}}
}
@article{hunyuan-mt-2024,
title={Hunyuan-MT: A Large-scale Multilingual Translation Model},
author={Tencent Hunyuan Team},
year={2024}
}
This model inherits the license from the original Hunyuan-MT model. Please refer to the original repository for license details.
Found a bug or want to contribute? Please open an issue on the GitHub repository.
Made with β€οΈ for the Apple Silicon community