Views
No views yet
pip install hf-hub-ctranslate2>=1.0.0 ctranslate2>=3.13.0ct2-transformers-converter --model Helsinki-NLP/opus-mt-en-fr --output_dir /home/michael/tmp-ct2fast-opus-mt-en-fr --force --copy_files README.md generation_config.json tokenizer_config.json vocab.json source.spm .gitattributes target.spm --quantization float16compute_type=int8_float16 for device="cuda"compute_type=int8 for device="cpu"1from hf_hub_ctranslate2 import TranslatorCT2fromHfHub, GeneratorCT2fromHfHub
2from transformers import AutoTokenizer
3
4model_name = "michaelfeil/ct2fast-opus-mt-en-fr"
5# use either TranslatorCT2fromHfHub or GeneratorCT2fromHfHub here, depending on model.
6model = TranslatorCT2fromHfHub(
7 # load in int8 on CUDA
8 model_name_or_path=model_name,
9 device="cuda",
10 compute_type="int8_float16",
11 tokenizer=AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-fr")
12)
13outputs = model.generate(
14 text=["How do you call a fast Flan-ingo?", "User: How are you doing?"],
15)
16print(outputs)| testset | BLEU | chr-F |
|---|---|---|
| newsdiscussdev2015-enfr.en.fr | 33.8 | 0.602 |
| newsdiscusstest2015-enfr.en.fr | 40.0 | 0.643 |
| newssyscomb2009.en.fr | 29.8 | 0.584 |
| news-test2008.en.fr | 27.5 | 0.554 |
| newstest2009.en.fr | 29.4 | 0.577 |
| newstest2010.en.fr | 32.7 | 0.596 |
| newstest2011.en.fr | 34.3 | 0.611 |
| newstest2012.en.fr | 31.8 | 0.592 |
| newstest2013.en.fr | 33.2 | 0.589 |
| Tatoeba.en.fr | 50.5 | 0.672 |