Balancing Global Quality and Pronoun-Specific Feedback for Context-Aware Machine Translation
Paper • 2501.03008 • Published
How to use satanicmangoes/nllb-600m-en-de-context-sft with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "translation" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# pip install "transformers<5.0.0"
from transformers import pipeline
pipe = pipeline("translation", model="satanicmangoes/nllb-600m-en-de-context-sft") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("satanicmangoes/nllb-600m-en-de-context-sft")
model = AutoModelForSeq2SeqLM.from_pretrained("satanicmangoes/nllb-600m-en-de-context-sft", device_map="auto")This model is from the paper Balancing Global Quality and Pronoun-Specific Feedback for Context-Aware Machine Translation.
NLLB-200-distilled-600M fine-tuned to translate a sentence given its preceding source sentence, from the ProNMT project (Balancing Global Quality and Pronoun-Specific Feedback for Context-Aware Machine Translation). Code and data: https://github.com/Harshit2807161/ProNMT
<context> PREVIOUS ENGLISH SENTENCE </context> CURRENT ENGLISH SENTENCE
The model outputs the German translation of the current sentence only.
facebook/nllb-200-distilled-600M.from transformers import AutoModelForSeq2SeqLM, NllbTokenizerFast
repo = "satanicmangoes/nllb-600m-en-de-context-sft"
tokenizer = NllbTokenizerFast.from_pretrained(repo, src_lang="eng_Latn", tgt_lang="deu_Latn")
model = AutoModelForSeq2SeqLM.from_pretrained(repo)
src = '<context> I met the Commissioner yesterday. </context> She said the report would be ready soon.'
inputs = tokenizer(src, return_tensors="pt")
out = model.generate(**inputs, forced_bos_token_id=tokenizer.convert_tokens_to_ids("deu_Latn"))
print(tokenizer.decode(out[0], skip_special_tokens=True))
CC-BY-NC-4.0, inherited from NLLB-200.
Base model
facebook/nllb-200-distilled-600M