Instructions to use Sunbird/translate-nllb-1.3b-salt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sunbird/translate-nllb-1.3b-salt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Sunbird/translate-nllb-1.3b-salt")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Sunbird/translate-nllb-1.3b-salt") model = AutoModelForSeq2SeqLM.from_pretrained("Sunbird/translate-nllb-1.3b-salt") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Sunbird/translate-nllb-1.3b-salt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Sunbird/translate-nllb-1.3b-salt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sunbird/translate-nllb-1.3b-salt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Sunbird/translate-nllb-1.3b-salt
- SGLang
How to use Sunbird/translate-nllb-1.3b-salt with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Sunbird/translate-nllb-1.3b-salt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sunbird/translate-nllb-1.3b-salt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Sunbird/translate-nllb-1.3b-salt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Sunbird/translate-nllb-1.3b-salt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Sunbird/translate-nllb-1.3b-salt with Docker Model Runner:
docker model run hf.co/Sunbird/translate-nllb-1.3b-salt
Model details
This machine translation model can convert single sentences from and to any combination of the following languages:
| ISO 693-3 | Language name |
|---|---|
| eng | English |
| ach | Acholi |
| lgg | Lugbara |
| lug | Luganda |
| nyn | Runyankole |
| teo | Ateso |
It was trained on the SALT dataset and a variety of additional external data resources, including back-translated news articles, FLORES-200, MT560 and LAFAND-MT. The base model was facebok/nllb-200-1.3B, with tokens adapted to add support for languages not originally included.
Usage example
tokenizer = transformers.NllbTokenizer.from_pretrained(
'Sunbird/translate-nllb-1.3b-salt')
model = transformers.M2M100ForConditionalGeneration.from_pretrained(
'Sunbird/translate-nllb-1.3b-salt')
text = 'Where is the hospital?'
source_language = 'eng'
target_language = 'lug'
language_tokens = {
'eng': 256047,
'ach': 256111,
'lgg': 256008,
'lug': 256110,
'nyn': 256002,
'teo': 256006,
}
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
inputs = tokenizer(text, return_tensors="pt").to(device)
inputs['input_ids'][0][0] = language_tokens[source_language]
translated_tokens = model.to(device).generate(
**inputs,
forced_bos_token_id=language_tokens[target_language],
max_length=100,
num_beams=5,
)
result = tokenizer.batch_decode(
translated_tokens, skip_special_tokens=True)[0]
# Eddwaliro liri ludda wa?
Evaluation metrics
Results on salt-dev:
| Source language | Target language | BLEU |
|---|---|---|
| ach | eng | 28.371 |
| lgg | eng | 30.45 |
| lug | eng | 41.978 |
| nyn | eng | 32.296 |
| teo | eng | 30.422 |
| eng | ach | 20.972 |
| eng | lgg | 22.362 |
| eng | lug | 30.359 |
| eng | nyn | 15.305 |
| eng | teo | 21.391 |
- Downloads last month
- 705
Model tree for Sunbird/translate-nllb-1.3b-salt
Dataset used to train Sunbird/translate-nllb-1.3b-salt
Viewer β’ Updated β’ 80.8k β’ 221 β’ 16