michaelfeil's picture
Upload folder using huggingface_hub
76ec296
metadata
language:
  - en
  - es
tags:
  - ctranslate2
  - translation
license: apache-2.0

# Fast-Inference with Ctranslate2

Speedup inference by 2x-8x using int8 inference in C++

quantized version of Helsinki-NLP/opus-mt-en-es

pip install hf-hub-ctranslate2>=1.0.0 ctranslate2>=3.13.0

Converted using

ct2-transformers-converter --model Helsinki-NLP/opus-mt-en-es --output_dir /home/michael/tmp-ct2fast-opus-mt-en-es --force --copy_files README.md generation_config.json tokenizer_config.json vocab.json source.spm .gitattributes target.spm --quantization float16

Checkpoint compatible to ctranslate2 and hf-hub-ctranslate2

  • compute_type=int8_float16 for device="cuda"
  • compute_type=int8 for device="cpu"
from hf_hub_ctranslate2 import TranslatorCT2fromHfHub, GeneratorCT2fromHfHub
from transformers import AutoTokenizer

model_name = "michaelfeil/ct2fast-opus-mt-en-es"
# use either TranslatorCT2fromHfHub or GeneratorCT2fromHfHub here, depending on model.
model = TranslatorCT2fromHfHub(
        # load in int8 on CUDA
        model_name_or_path=model_name, 
        device="cuda",
        compute_type="int8_float16",
        tokenizer=AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-es")
)
outputs = model.generate(
    text=["How do you call a fast Flan-ingo?", "User: How are you doing?"],
)
print(outputs)

Licence and other remarks:

This is just a quantized version. Licence conditions are intended to be idential to original huggingface repo.

Original description

eng-spa

Benchmarks

testset BLEU chr-F
newssyscomb2009-engspa.eng.spa 31.0 0.583
news-test2008-engspa.eng.spa 29.7 0.564
newstest2009-engspa.eng.spa 30.2 0.578
newstest2010-engspa.eng.spa 36.9 0.620
newstest2011-engspa.eng.spa 38.2 0.619
newstest2012-engspa.eng.spa 39.0 0.625
newstest2013-engspa.eng.spa 35.0 0.598
Tatoeba-test.eng.spa 54.9 0.721

System Info: