Spaces:
Running
Running
Daryl Lim Claude Opus 4.6 commited on
Commit ·
7d583b2
1
Parent(s): 613b55a
fix: add space between language token and input text
Browse filesMADLAD-400 expects `<2fr> Hello` not `<2fr>Hello`. Without the
space, the tokenizer fails to recognize the language token,
causing garbage repetition in the output.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -57,7 +57,7 @@ def translate(text: str, target_language_name: str) -> str:
|
|
| 57 |
if target_code is None:
|
| 58 |
raise ValueError(f"Unsupported language: {target_language_name}")
|
| 59 |
|
| 60 |
-
input_ids = tokenizer(target_code + text, return_tensors="pt").input_ids.to(device)
|
| 61 |
outputs = model.generate(input_ids=input_ids, max_new_tokens=512)
|
| 62 |
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 63 |
if not isinstance(result, str):
|
|
|
|
| 57 |
if target_code is None:
|
| 58 |
raise ValueError(f"Unsupported language: {target_language_name}")
|
| 59 |
|
| 60 |
+
input_ids = tokenizer(target_code + " " + text, return_tensors="pt").input_ids.to(device)
|
| 61 |
outputs = model.generate(input_ids=input_ids, max_new_tokens=512)
|
| 62 |
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 63 |
if not isinstance(result, str):
|