🚀 SalamandraTA Model Card
SalamandraTA-2b-instruct is a powerful translation LLM, enabling seamless communication across 35 European languages and 3 language varieties.
🚀 Quick Start
SalamandraTA-2b-instruct is a translation LLM that has been instruction-tuned from SalamandraTA-2b-base. The base model results from continually pre-training Salamandra-2b on parallel data and has not been published, but is reserved for internal use. SalamandraTA-2b-instruct is proficient in 35 European languages (plus 3 varieties) and supports translation-related tasks, namely: sentence-level-translation, paragraph-level-translation, automatic post-editing, grammar checking, machine translation evaluation, alternative translations, named-entity-recognition and context-aware translation.
⚠️ Important Note
DISCLAIMER: This version of Salamandra is tailored exclusively for translation tasks. It lacks chat capabilities and has not been trained with any chat instructions.
✨ Features
- Multilingual Proficiency: Supports 35 European languages and 3 language varieties for comprehensive translation.
- Diverse Task Support: Handles sentence-level, paragraph-level translation, automatic post - editing, grammar checking, and more.
📦 Installation
No installation steps are provided in the original document, so this section is skipped.
💻 Usage Examples
Basic Usage
from datetime import datetime
from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
import torch
model_id = "BSC-LT/salamandraTA-2b-instruct"
source = 'Spanish'
target = 'Catalan'
sentence = "Ayer se fue, tomó sus cosas y se puso a navegar. Una camisa, un pantalón vaquero y una canción, dónde irá, dónde irá. Se despidió, y decidió batirse en duelo con el mar. Y recorrer el mundo en su velero. Y navegar, nai-na-na, navegar"
text = f"Translate the following text from {source} into {target}.\n{source}: {sentence} \n{target}:"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto",
torch_dtype=torch.bfloat16
)
message = [ { "role": "user", "content": text } ]
date_string = datetime.today().strftime('%Y-%m-%d')
prompt = tokenizer.apply_chat_template(
message,
tokenize=False,
add_generation_prompt=True,
date_string=date_string
)
inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
input_length = inputs.shape[1]
outputs = model.generate(input_ids=inputs.to(model.device),
max_new_tokens=400,
early_stopping=True,
num_beams=5)
print(tokenizer.decode(outputs[0, input_length:], skip_special_tokens=True))
Advanced Usage
General translation
source = 'Catalan'
target = 'Galician'
source_sentence = "Als antics egipcis del període de l'Imperi Nou els fascinaven els monuments dels seus predecessors, que llavors tenien més de mil anys."
text = f"Translate the following text from {source} into {target}.\n{source}: {source_sentence} \n{target}:"
Post - editing
source = 'Catalan'
target = 'English'
source_sentence = 'Rafael Nadal i Maria Magdalena van inspirar a una generació sencera.'
machine_translation = 'Rafael Christmas and Maria the Muffin inspired an entire generation each in their own way.'
text = f"Please fix any mistakes in the following {source}-{target} machine translation or keep it unedited if it's correct.\nSource: {source_sentence} \nMT: {machine_translation} \nCorrected:"
Paragraph - level translation
source = 'English'
target = 'Asturian'
text = """Please translate this text from {} into {}.\n{}: President Donald Trump, who campaigned on promises to crack down on illegal immigration, has raised alarms in the U.S. dairy industry with his threat to impose 25% tariffs on Mexico and Canada by February 2025. This move is part of a broader strategy to declare a national emergency at the southern border to halt illegal migration completely. However, the implications for the agriculture sector, particularly dairy, are significant. Approximately half of the U.S. dairy industry's workforce consists of immigrant labor, many of whom are undocumented. The National Milk Producers Federation estimates that removing immigrant workers could decimate the dairy herd by 2.1 million cows and slash milk production by nearly 50 billion pounds, leading to a dramatic 90.4% increase in milk prices. The complex perspectives of Americans on undocumented workers were highlighted in a Pew Research Center study. While 64% of U.S. adults support legal pathways for undocumented immigrants, 35% oppose it—a gap that has been narrowing recently. Factors influencing public opinion include the belief that immigrants should have jobs and pass security checks, contrasted by concerns about lawbreakers being rewarded, fairness for legal migrants, and resource allocation.
{}:""".format(source, target, source, target)
Named - entity recognition
text = """Analyse the following tokenized text and mark the tokens containing named entities.
Use the following annotation guidelines with these tags for named entities:
- ORG (Refers to named groups or organizations)
- PER (Refers to individual people or named groups of people)
- LOC (Refers to physical places or natural landmarks)
- MISC (Refers to entities that don't fit into standard categories).
Prepend B- to the first token of a given entity and I- to the remaining ones if they exist.
If a token is not a named entity, label it as O.
Input: ['La', 'defensa', 'del', 'antiguo', 'responsable', 'de', 'la', 'RFEF', 'confirma', 'que', 'interpondrá', 'un', 'recurso.']
Marked: """
Grammar checker
source = 'Catalan'
sentence = 'Entonses, el meu jefe m’ha dit que he de treballar els fins de setmana.'
text = f"Please fix any mistakes in the following {source} sentence or keep it unedited if it's correct.\nSentence: {sentence} \nCorrected:"
📚 Documentation
Model Details
Description
SalamandraTA-2b-base is a continual pre-training of Salamandra-2b using parallel data, resulting in a total of 424B tokens processed during training.
Architecture
Property |
Details |
Total Parameters |
2,253,490,176 |
Embedding Parameters |
524,288,000 |
Layers |
24 |
Hidden size |
2,048 |
Attention heads |
16 |
Context length |
8,192 |
Vocabulary size |
256,000 |
Precision |
bfloat16 |
Embedding type |
RoPE |
Activation Function |
SwiGLU |
Layer normalization |
RMS Norm |
Flash attention |
✅ |
Grouped Query Attention |
❌ |
Num. query groups |
N/A |
Intended Use
Direct Use
The model is intended for both research and commercial use in any of the languages included in the training data for general machine translation tasks.
Out - of - scope Use
The model is not intended for malicious activities, such as harming others or violating human rights. Any downstream application must comply with current laws and regulations. Irresponsible usage in production environments without proper risk assessment and mitigation is also discouraged.
Hardware and Software
Training Framework
SalamandraTA-2b-base was continually pre-trained using NVIDIA’s NeMo Framework, which leverages PyTorch Lightning for efficient model training in highly distributed settings.
SalamandraTA-2b-instruct was produced with FastChat.
Compute Infrastructure
All models were trained on MareNostrum 5, a pre-exascale EuroHPC supercomputer hosted and operated by Barcelona Supercomputing Center.
The accelerated partition is composed of 1,120 nodes with the following specifications:
- 4x Nvidia Hopper GPUs with 64GB HBM2 memory
- 2x Intel Sapphire Rapids 8460Y+ at 2.3Ghz and 32c each (64 cores)
- 4x NDR200 (BW per node 800Gb/s)
- 512 GB of Main memory (DDR5)
- 460GB on NVMe storage
Data
Pretraining Data
The pretraining corpus consists of 424 billion tokens of Catalan-centric, Spanish-centric, and English-centric parallel data, including all of the official European languages plus Catalan, Basque, Galician, Asturian, Aragonese and Aranese. It amounts to 6,574,251,526 parallel sentence pairs.
This highly multilingual corpus is predominantly composed of data sourced from OPUS, with additional data taken from the NTEU Project, Aina Project, and other sources (see: Data Sources and References). Where little parallel Catalan <-> xx data could be found, synthetic Catalan data was generated from the Spanish side of the collected Spanish <-> xx corpora using Projecte Aina’s Spanish-Catalan model. The final distribution of languages was as below:
Click the expand button below to see the full list of corpora included in the training data.
Data Sources
Dataset |
Ca-xx Languages |
Es-xx Langugages |
En-xx Languages |
AINA |
en |
|
|
ARANESE-SYNTH-CORPUS-BSC |
arn |
|
|
BOUA-SYNTH-BSC |
|
val |
|
BOUMH |
|
val |
|
BOUA-PILAR |
|
val |
|
CCMatrix |
eu |
|
ga |
DGT |
|
bg,cs,da,de,el ,et,fi,fr,ga,hr,hu,lt,lv,mt,nl,pl,pt,ro,sk,sl,sv |
da,et,ga,hr,hu,lt,lv,mt,sh,sl |
DOGV-SYNTH-BSC |
|
val |
|
DOGV-PILAR |
|
val |
|
ELRC-EMEA |
|
bg,cs,da,hu,lt,lv,mt,pl,ro,sk,sl |
et,hr,lv,ro,sk,sl |
EMEA |
|
bg,cs,da,el,fi,hu,lt,mt,nl,pl,ro,sk,sl,sv |
et,mt |
EUBookshop |
lt,pl,pt |
cs,da,de,el,fi,fr,ga,it,lv,mt,nl,pl,pt,ro,sk,sl,sv |
cy,ga |
Europarl |
|
bg,cs,da,el,en,fi,fr,hu,lt,lv,nl,pl,pt ,ro,sk,sl,sv |
|
Europat |
|
en,hr |
no |
GAITU Corpus |
|
|
eu |
KDE4 |
bg,cs,da,de,el ,et,eu,fi,fr,ga,gl,hr,it,lt,lv,nl,pl,pt,ro,sk,sl,sv |
bg,ga,hr |
cy,ga,nn,oc |
GlobalVoices |
bg,de,fr,it,nl,pl,pt |
bg,de,fr,pt |
|
GNOME |
eu,fr,ga,gl,pt |
ga |
cy,ga,nn |
JRC-Arquis |
|
cs,da,et,fr,lt,lv,mt,nl,pl ,ro,sv |
et |
LES-CORTS-VALENCIANES-SYNTH-BSC |
|
val |
|
MaCoCu |
en |
|
hr,mt,uk |
MultiCCAligned |
bg,cs,de,el,et,fi,fr,hr,hu,it,lt,lv,nl,pl,ro,sk,sv |
bg,fi,fr,hr,it,lv,nl,pt |
bg,cy,da,et,fi,hr,hu,lt,lv,no,sl,sr,uk |
MultiHPLT |
en, et,fi,ga,hr,mt |
|
fi,ga,gl,hr,mt,nn,sr |
MultiParaCrawl |
bg,da |
de,en,fr,ga,hr,hu,it,mt,pt |
bg,cs,da,de,el,et,fi,fr,ga,hr,hu,lt,lv,mt,nn,pl,ro,sk,sl,uk |
MultiUN |
|
fr |
|
News-Commentary |
|
fr |
|
NLLB |
bg,da,el,en,et,fi,fr,gl,hu,it ,lt,lv,pt,ro,sk,sl |
bg,cs,da,de,el ,et,fi,fr,hu,it,lt,lv,nl,pl,pt ,ro,sk,sl,sv |
bg,cs,cy,da,de,el,et,fi,fr,ga,hr,hu,it,lt,lv,mt,nl,no,oc,pl,pt,ro,ru,sk,sl,sr,sv,uk |
NÓS Authentic Corpus |
|
|
gl |
NÓS Synthetic Corpus |
|
|
gl |
NTEU |
|
bg,cs,da,de,el,en,et,fi,fr,ga,hr,hu,it,lt,lv,mt,nl,pl,pt,ro,sk,sl,sv |
da,et,ga,hr,lt,lv,mt,ro,sk,sl,sv |
OpenSubtitles |
bg,cs,da,de,el ,et,eu,fi,gl,hr,hu,lt,lv,nl,pl,pt,ro,sk,sl,sv |
da,de,fi,fr,hr,hu,it,lv,nl |
bg,cs,de,el,et,hr,fi,fr,hr,hu,no,sl,sr |
OPUS-100 |
en |
|
gl |
StanfordNLP-NMT |
|
|
cs |
Tatoeba |
de,pt |
pt |
|
TildeModel |
|
bg |
et,hr,lt,lv,mt |
UNPC |
|
en,fr |
ru |
PILAR-VALENCIAN-AUTH |
|
val |
|
PILAR-VALENCIAN-SYNTH |
|
val |
|
WikiMatrix |
bg,cs,da,de,el ,et,eu,fi,fr,gl,hr,hu,it,lt,nl,pl,pt,ro,sk,sl,sv |
bg,en,fr,hr,it,pt |
oc,sh |
Wikimedia |
|
|
cy,nn |
XLENT |
eu,ga,gl |
ga |
cy,et,ga,gl,hr,oc,sh |
Datasets with "-BSC" in their names (e.g., BOUA-SYNTH-BSC, DOGV-SYNTH-BSC) are synthetic datasets obtained by machine translating pre-existing monolingual corpora with our own seq-to-seq models. These datasets were generated internally for model training and are not published.
To consult the data summary document with the respective licences, please send an e-mail to ipr@bsc.es.
References
- Aulamo, M., Sulubacak, U., Virpioja, S., & Tiedemann, J. (2020). OpusTools and Parallel Corpus Diagnostics. In N. Calzolari, F. Béchet, P. Blache, K. Choukri, C. Cieri, T. Declerck, S. Goggi, H. Isahara, B. Maegaard, J. Mariani, H. Mazo, A. Moreno, J. Odijk, & S. Piperidis (Eds.), Proceedings of the Twelfth Language Resources and Evaluation Conference (pp. 3782–3789). European Language Resources Association. https://aclanthology.org/2020.lrec-1.467
- Chaudhary, V., Tang, Y., Guzmán, F., Schwenk, H., & Koehn, P. (2019). Low-Resource Corpus Filtering Using Multilingual Sentence Embeddings. In O. Bojar, R. Chatterjee, C. Federmann, M. Fishel, Y. Graham, B. Haddow, M. Huck, A. J. Yepes, P. Koehn, A. Martins, C. Monz, M. Negri, A. Névéol, M. Neves, M. Post, M. Turchi, & K. Verspoor (Eds.), Proceedings of the Fourth Conference on Machine Translation (Volume 3: Shared Task Papers, Day 2) (pp. 261–266). Association for Computational Linguistics. https://doi.org/10.18653/v1/W19-5435
- DGT-Translation Memory—European Commission. (n.d.). Retrieved November 4, 2024, from https://joint-research-centre.ec.europa.eu/language-technology-resources/dgt-translation-memory_en
- Eisele, A., & Chen, Y. (2010). MultiUN: A Multilingual Corpus from United Nation Documents. In N. Calzolari,
📄 License
The model is released under the Apache-2.0 license.