added a prepend >>nob<< for Norwegian right before tokenization
Browse files
app.py
CHANGED
@@ -96,6 +96,10 @@ async def translate(request: Request):
|
|
96 |
full_translation = []
|
97 |
|
98 |
for chunk in chunks:
|
|
|
|
|
|
|
|
|
99 |
inputs = tokenizer(chunk, return_tensors="pt", padding=True, truncation=True)
|
100 |
inputs = {k: v.to(model.device) for k, v in inputs.items()}
|
101 |
outputs = model.generate(**inputs, num_beams=5, length_penalty=1.2, early_stopping=True)
|
|
|
96 |
full_translation = []
|
97 |
|
98 |
for chunk in chunks:
|
99 |
+
|
100 |
+
if model_id == "Confused404/eng-gmq-finetuned_v2-no":
|
101 |
+
chunk = f">>nob<< {chunk}"
|
102 |
+
|
103 |
inputs = tokenizer(chunk, return_tensors="pt", padding=True, truncation=True)
|
104 |
inputs = {k: v.to(model.device) for k, v in inputs.items()}
|
105 |
outputs = model.generate(**inputs, num_beams=5, length_penalty=1.2, early_stopping=True)
|