TiberiuCristianLeon commited on
Commit
2afdfd3
·
verified ·
1 Parent(s): fb22ed5

Update src/translate/Translate.py

Browse files
Files changed (1) hide show
  1. src/translate/Translate.py +2 -1
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 = len(requestValue) + len(requestValue) * 0.2
 
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,