Spaces:
Running
Running
Update src/translate/Translate.py
Browse files
src/translate/Translate.py
CHANGED
@@ -58,7 +58,8 @@ def gemma(requestValue: str, model: str = 'Gargaz/gemma-2b-romanian-better'):
|
|
58 |
messages = [{"role": "user", "content": f"Translate this text to Romanian using a formal tone. Only return the translated text: {requestValue}"}]
|
59 |
if '/' not in model:
|
60 |
model = 'Gargaz/gemma-2b-romanian-better'
|
61 |
-
max_new_tokens
|
|
|
62 |
pipe = pipeline(
|
63 |
"text-generation",
|
64 |
model=model,
|
|
|
58 |
messages = [{"role": "user", "content": f"Translate this text to Romanian using a formal tone. Only return the translated text: {requestValue}"}]
|
59 |
if '/' not in model:
|
60 |
model = 'Gargaz/gemma-2b-romanian-better'
|
61 |
+
# limit max_new_tokens to 150% of the requestValue
|
62 |
+
max_new_tokens = int(len(requestValue) + len(requestValue) * 0.5)
|
63 |
pipe = pipeline(
|
64 |
"text-generation",
|
65 |
model=model,
|