Spaces:
Running
Running
Update src/translate/Translate.py
Browse files
src/translate/Translate.py
CHANGED
@@ -78,6 +78,8 @@ def gemma_direct(requestValue: str, model: str = 'Gargaz/gemma-2b-romanian-bette
|
|
78 |
# limit max_new_tokens to 150% of the requestValue
|
79 |
prompt = f"Translate this text to Romanian: {requestValue}"
|
80 |
|
|
|
|
|
81 |
input_ids = tokenizer.encode(request_value, add_special_tokens=True)
|
82 |
num_tokens = len(input_ids)
|
83 |
# Estimate output length (e.g., 50% longer)
|
@@ -85,8 +87,6 @@ def gemma_direct(requestValue: str, model: str = 'Gargaz/gemma-2b-romanian-bette
|
|
85 |
max_new_tokens += max_new_tokens % 2 # ensure it's even
|
86 |
|
87 |
messages = [{"role": "user", "content": prompt}]
|
88 |
-
tokenizer = AutoTokenizer.from_pretrained("Gargaz/gemma-2b-romanian-better")
|
89 |
-
model = AutoModelForCausalLM.from_pretrained("Gargaz/gemma-2b-romanian-better").to(device)
|
90 |
|
91 |
inputs = tokenizer.apply_chat_template(
|
92 |
messages,
|
|
|
78 |
# limit max_new_tokens to 150% of the requestValue
|
79 |
prompt = f"Translate this text to Romanian: {requestValue}"
|
80 |
|
81 |
+
tokenizer = AutoTokenizer.from_pretrained("Gargaz/gemma-2b-romanian-better")
|
82 |
+
model = AutoModelForCausalLM.from_pretrained("Gargaz/gemma-2b-romanian-better").to(device)
|
83 |
input_ids = tokenizer.encode(request_value, add_special_tokens=True)
|
84 |
num_tokens = len(input_ids)
|
85 |
# Estimate output length (e.g., 50% longer)
|
|
|
87 |
max_new_tokens += max_new_tokens % 2 # ensure it's even
|
88 |
|
89 |
messages = [{"role": "user", "content": prompt}]
|
|
|
|
|
90 |
|
91 |
inputs = tokenizer.apply_chat_template(
|
92 |
messages,
|