Spaces:
Sleeping
Sleeping
mutarisi
commited on
Commit
·
da66d9c
1
Parent(s):
3e62e94
debugging statements
Browse files- glossController.py +11 -0
glossController.py
CHANGED
|
@@ -22,6 +22,9 @@ def translateGloss(gloss: str) -> str:
|
|
| 22 |
using the pre-loaded Glossa-BART model.
|
| 23 |
"""
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
inputs = tokenizer(gloss, return_tensors="pt", padding=True, truncation=True)
|
| 26 |
|
| 27 |
# Move inputs to CUDA if the model is on CUDA
|
|
@@ -30,6 +33,14 @@ def translateGloss(gloss: str) -> str:
|
|
| 30 |
|
| 31 |
# Generate the translated sentence
|
| 32 |
outputs = model.generate(**inputs, max_new_tokens=50, do_sample=False)
|
|
|
|
|
|
|
| 33 |
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
return result
|
|
|
|
| 22 |
using the pre-loaded Glossa-BART model.
|
| 23 |
"""
|
| 24 |
|
| 25 |
+
# --- DEBUG STEP 1: Log Input ---
|
| 26 |
+
print(f"DEBUG: Starting translation for gloss: '{gloss}'")
|
| 27 |
+
|
| 28 |
inputs = tokenizer(gloss, return_tensors="pt", padding=True, truncation=True)
|
| 29 |
|
| 30 |
# Move inputs to CUDA if the model is on CUDA
|
|
|
|
| 33 |
|
| 34 |
# Generate the translated sentence
|
| 35 |
outputs = model.generate(**inputs, max_new_tokens=50, do_sample=False)
|
| 36 |
+
|
| 37 |
+
# Decode the output
|
| 38 |
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 39 |
|
| 40 |
+
# Clean up any residual whitespace
|
| 41 |
+
result = result.strip()
|
| 42 |
+
|
| 43 |
+
# --- DEBUG STEP 2: Log Output ---
|
| 44 |
+
print(f"DEBUG: Model generated raw result: '{result}'")
|
| 45 |
+
|
| 46 |
return result
|