Spaces:
Sleeping
Sleeping
research14
commited on
Commit
•
7ee30e4
1
Parent(s):
74f594f
added definitions for ling complexity and test new prompt
Browse files
app.py
CHANGED
@@ -75,12 +75,12 @@ def gpt_respond(have_key, tab_name, message, chat_history, max_convo_length = 10
|
|
75 |
formatted_prompt = format_chat_prompt(message, chat_history, max_convo_length)
|
76 |
print('GPT ling ents Prompt + Context:')
|
77 |
print(formatted_prompt)
|
78 |
-
bot_message = chat(user_prompt = f'''Output any <{tab_name}> in the following sentence
|
79 |
chat_history.insert(0, (message, bot_message))
|
80 |
return "", chat_history
|
81 |
|
82 |
def vicuna_respond(tab_name, message, chat_history):
|
83 |
-
formatted_prompt = f'''Output any {tab_name} in the following sentence
|
84 |
print('Vicuna Ling Ents Fn - Prompt + Context:')
|
85 |
print(formatted_prompt)
|
86 |
input_ids = vicuna_tokenizer.encode(formatted_prompt, return_tensors="pt")
|
@@ -97,7 +97,7 @@ def vicuna_respond(tab_name, message, chat_history):
|
|
97 |
return tab_name, "", chat_history
|
98 |
|
99 |
def llama_respond(tab_name, message, chat_history):
|
100 |
-
formatted_prompt = f'''Output any {tab_name} in the following sentence
|
101 |
# print('Llama - Prompt + Context:')
|
102 |
# print(formatted_prompt)
|
103 |
input_ids = llama_tokenizer.encode(formatted_prompt, return_tensors="pt")
|
@@ -119,7 +119,7 @@ def gpt_strategies_respond(have_key, strategy, task_name, task_ling_ent, message
|
|
119 |
formatted_system_prompt = ""
|
120 |
if (task_name == "POS Tagging"):
|
121 |
if (strategy == "S1"):
|
122 |
-
formatted_system_prompt = f'''Output any {task_ling_ent} in the following sentence
|
123 |
elif (strategy == "S2"):
|
124 |
formatted_system_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
125 |
elif (strategy == "S3"):
|
@@ -128,7 +128,7 @@ def gpt_strategies_respond(have_key, strategy, task_name, task_ling_ent, message
|
|
128 |
formatted_system_prompt = f'''"{demon_pos}". Using the POS tag structure above, POS tag the following sentence: "{message}"'''
|
129 |
elif (task_name == "Chunking"):
|
130 |
if (strategy == "S1"):
|
131 |
-
formatted_system_prompt = f'''Output any {task_ling_ent} in the following sentence
|
132 |
elif (strategy == "S2"):
|
133 |
formatted_system_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
134 |
elif (strategy == "S3"):
|
@@ -147,7 +147,7 @@ def vicuna_strategies_respond(strategy, task_name, task_ling_ent, message, chat_
|
|
147 |
formatted_prompt = ""
|
148 |
if (task_name == "POS Tagging"):
|
149 |
if (strategy == "S1"):
|
150 |
-
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence
|
151 |
elif (strategy == "S2"):
|
152 |
formatted_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
153 |
elif (strategy == "S3"):
|
@@ -156,7 +156,7 @@ def vicuna_strategies_respond(strategy, task_name, task_ling_ent, message, chat_
|
|
156 |
formatted_prompt = f'''"{demon_pos}". Using the POS tag structure above, POS tag the following sentence: "{message}"'''
|
157 |
elif (task_name == "Chunking"):
|
158 |
if (strategy == "S1"):
|
159 |
-
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence
|
160 |
elif (strategy == "S2"):
|
161 |
formatted_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
162 |
elif (strategy == "S3"):
|
@@ -183,7 +183,7 @@ def llama_strategies_respond(strategy, task_name, task_ling_ent, message, chat_h
|
|
183 |
formatted_prompt = ""
|
184 |
if (task_name == "POS Tagging"):
|
185 |
if (strategy == "S1"):
|
186 |
-
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence
|
187 |
elif (strategy == "S2"):
|
188 |
formatted_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
189 |
elif (strategy == "S3"):
|
@@ -192,7 +192,7 @@ def llama_strategies_respond(strategy, task_name, task_ling_ent, message, chat_h
|
|
192 |
formatted_prompt = f'''"{demon_pos}". Using the POS tag structure above, POS tag the following sentence: "{message}"'''
|
193 |
elif (task_name == "Chunking"):
|
194 |
if (strategy == "S1"):
|
195 |
-
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence
|
196 |
elif (strategy == "S2"):
|
197 |
formatted_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
198 |
elif (strategy == "S3"):
|
@@ -375,7 +375,7 @@ def interface():
|
|
375 |
task_btn.click(fn=update_textbox, inputs=task_prompt, outputs=user_prompt_2, api_name="task_btn")
|
376 |
|
377 |
# Show features from LFTK
|
378 |
-
task_btn.click(linguistic_features_fn, inputs=[task_prompt], outputs=[linguistic_features_textbox_2])
|
379 |
|
380 |
# Event Handler for GPT 3.5 Chatbot POS/Chunk, user must submit api key before submitting the prompt
|
381 |
# Will activate after getting API key
|
|
|
75 |
formatted_prompt = format_chat_prompt(message, chat_history, max_convo_length)
|
76 |
print('GPT ling ents Prompt + Context:')
|
77 |
print(formatted_prompt)
|
78 |
+
bot_message = chat(user_prompt = f'''Output any <{tab_name}> in the following sentence: "{formatted_prompt}"''')
|
79 |
chat_history.insert(0, (message, bot_message))
|
80 |
return "", chat_history
|
81 |
|
82 |
def vicuna_respond(tab_name, message, chat_history):
|
83 |
+
formatted_prompt = f'''Output any {tab_name} in the following sentence: "{message}"'''
|
84 |
print('Vicuna Ling Ents Fn - Prompt + Context:')
|
85 |
print(formatted_prompt)
|
86 |
input_ids = vicuna_tokenizer.encode(formatted_prompt, return_tensors="pt")
|
|
|
97 |
return tab_name, "", chat_history
|
98 |
|
99 |
def llama_respond(tab_name, message, chat_history):
|
100 |
+
formatted_prompt = f'''Output any {tab_name} in the following sentence: "{message}"'''
|
101 |
# print('Llama - Prompt + Context:')
|
102 |
# print(formatted_prompt)
|
103 |
input_ids = llama_tokenizer.encode(formatted_prompt, return_tensors="pt")
|
|
|
119 |
formatted_system_prompt = ""
|
120 |
if (task_name == "POS Tagging"):
|
121 |
if (strategy == "S1"):
|
122 |
+
formatted_system_prompt = f'''Output any {task_ling_ent} in the following sentence: "{message}"'''
|
123 |
elif (strategy == "S2"):
|
124 |
formatted_system_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
125 |
elif (strategy == "S3"):
|
|
|
128 |
formatted_system_prompt = f'''"{demon_pos}". Using the POS tag structure above, POS tag the following sentence: "{message}"'''
|
129 |
elif (task_name == "Chunking"):
|
130 |
if (strategy == "S1"):
|
131 |
+
formatted_system_prompt = f'''Output any {task_ling_ent} in the following sentence: "{message}"'''
|
132 |
elif (strategy == "S2"):
|
133 |
formatted_system_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
134 |
elif (strategy == "S3"):
|
|
|
147 |
formatted_prompt = ""
|
148 |
if (task_name == "POS Tagging"):
|
149 |
if (strategy == "S1"):
|
150 |
+
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence: "{message}"'''
|
151 |
elif (strategy == "S2"):
|
152 |
formatted_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
153 |
elif (strategy == "S3"):
|
|
|
156 |
formatted_prompt = f'''"{demon_pos}". Using the POS tag structure above, POS tag the following sentence: "{message}"'''
|
157 |
elif (task_name == "Chunking"):
|
158 |
if (strategy == "S1"):
|
159 |
+
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence: "{message}"'''
|
160 |
elif (strategy == "S2"):
|
161 |
formatted_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
162 |
elif (strategy == "S3"):
|
|
|
183 |
formatted_prompt = ""
|
184 |
if (task_name == "POS Tagging"):
|
185 |
if (strategy == "S1"):
|
186 |
+
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence: "{message}"'''
|
187 |
elif (strategy == "S2"):
|
188 |
formatted_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
189 |
elif (strategy == "S3"):
|
|
|
192 |
formatted_prompt = f'''"{demon_pos}". Using the POS tag structure above, POS tag the following sentence: "{message}"'''
|
193 |
elif (task_name == "Chunking"):
|
194 |
if (strategy == "S1"):
|
195 |
+
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence: "{message}"'''
|
196 |
elif (strategy == "S2"):
|
197 |
formatted_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
198 |
elif (strategy == "S3"):
|
|
|
375 |
task_btn.click(fn=update_textbox, inputs=task_prompt, outputs=user_prompt_2, api_name="task_btn")
|
376 |
|
377 |
# Show features from LFTK
|
378 |
+
task_btn.click(linguistic_features_fn, inputs=[task_prompt], outputs=[linguistic_features_textbox_2], info="[Definitions for Complexity Indices](https://docs.google.com/spreadsheets/d/1uXtQ1ah0OL9cmHp2Hey0QcHb4bifJcQFLvYlVIAWWwQ/edit#gid=693915416)]")
|
379 |
|
380 |
# Event Handler for GPT 3.5 Chatbot POS/Chunk, user must submit api key before submitting the prompt
|
381 |
# Will activate after getting API key
|