Spaces:
Running
Running
Commit
·
d3c4401
1
Parent(s):
d2931c1
add response text
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ system_instructions = """<s> [INST] You will be provided with text, and your tas
|
|
9 |
|
10 |
def generate_translation(prompt):
|
11 |
generate_kwargs = dict(
|
12 |
-
temperature=0.
|
13 |
max_new_tokens=1024,
|
14 |
top_p=0.95,
|
15 |
repetition_penalty=1.0,
|
@@ -22,6 +22,9 @@ def generate_translation(prompt):
|
|
22 |
formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
23 |
output = ""
|
24 |
|
|
|
|
|
|
|
25 |
emoji_pattern = r"[^\u0021-\u007E\u00A0-\uD7FF\uE000-\uFDCF\uFF00-\uFFEF\u10000-\u10FFFF\u0300-\u036F\u1F00-\u1F1F\u1F20-\u1F7F\u2600-\u26FF\u2700-\u27BF]+?"
|
26 |
|
27 |
filtered_output = re.findall(emoji_pattern, output)
|
@@ -47,6 +50,9 @@ def generate_emoji_translation(prompt):
|
|
47 |
formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
48 |
output = ""
|
49 |
|
|
|
|
|
|
|
50 |
return output
|
51 |
|
52 |
with gr.Blocks() as demo:
|
|
|
9 |
|
10 |
def generate_translation(prompt):
|
11 |
generate_kwargs = dict(
|
12 |
+
temperature=0.9,
|
13 |
max_new_tokens=1024,
|
14 |
top_p=0.95,
|
15 |
repetition_penalty=1.0,
|
|
|
22 |
formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
23 |
output = ""
|
24 |
|
25 |
+
for response in stream:
|
26 |
+
output += response.text
|
27 |
+
|
28 |
emoji_pattern = r"[^\u0021-\u007E\u00A0-\uD7FF\uE000-\uFDCF\uFF00-\uFFEF\u10000-\u10FFFF\u0300-\u036F\u1F00-\u1F1F\u1F20-\u1F7F\u2600-\u26FF\u2700-\u27BF]+?"
|
29 |
|
30 |
filtered_output = re.findall(emoji_pattern, output)
|
|
|
50 |
formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
51 |
output = ""
|
52 |
|
53 |
+
for response in stream:
|
54 |
+
output += response.text
|
55 |
+
|
56 |
return output
|
57 |
|
58 |
with gr.Blocks() as demo:
|