Update app.py
Browse files
app.py
CHANGED
|
@@ -31,9 +31,9 @@ def translate_text(text, lang=None, progress=gr.Progress(track_tqdm=True)):
|
|
| 31 |
if lang is None:
|
| 32 |
return text
|
| 33 |
system_message = "You are a helpful AI assistant."
|
| 34 |
-
max_tokens =
|
| 35 |
-
temperature = 0.
|
| 36 |
-
top_p = 0.
|
| 37 |
|
| 38 |
# Build conversation history
|
| 39 |
messages = []
|
|
@@ -62,11 +62,11 @@ def translate_text(text, lang=None, progress=gr.Progress(track_tqdm=True)):
|
|
| 62 |
temperature=temperature,
|
| 63 |
top_p=top_p,
|
| 64 |
do_sample=True if temperature > 0 else False,
|
| 65 |
-
pad_token_id=
|
| 66 |
)
|
| 67 |
|
| 68 |
# Decode only the new tokens
|
| 69 |
-
response =
|
| 70 |
|
| 71 |
return response
|
| 72 |
|
|
|
|
| 31 |
if lang is None:
|
| 32 |
return text
|
| 33 |
system_message = "You are a helpful AI assistant."
|
| 34 |
+
max_tokens = 1024
|
| 35 |
+
temperature = 0.1
|
| 36 |
+
top_p = 0.05
|
| 37 |
|
| 38 |
# Build conversation history
|
| 39 |
messages = []
|
|
|
|
| 62 |
temperature=temperature,
|
| 63 |
top_p=top_p,
|
| 64 |
do_sample=True if temperature > 0 else False,
|
| 65 |
+
pad_token_id=tokenizer_trans.eos_token_id
|
| 66 |
)
|
| 67 |
|
| 68 |
# Decode only the new tokens
|
| 69 |
+
response = tokenizer_trans.decode(outputs[0][tokenized_chat.shape[-1]:], skip_special_tokens=True)
|
| 70 |
|
| 71 |
return response
|
| 72 |
|