Spaces:
Runtime error
Runtime error
Commit
·
6033369
1
Parent(s):
35339b8
updated strategy 3 prompt for vicuna and llama
Browse files
app.py
CHANGED
@@ -132,14 +132,18 @@ def vicuna_strategies_respond(strategy, task_name, task_ling_ent, message, chat_
|
|
132 |
elif (strategy == "S2"):
|
133 |
formatted_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
134 |
elif (strategy == "S3"):
|
135 |
-
|
|
|
|
|
136 |
elif (task_name == "Chunking"):
|
137 |
if (strategy == "S1"):
|
138 |
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence one per line: "{message}"'''
|
139 |
elif (strategy == "S2"):
|
140 |
formatted_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
141 |
elif (strategy == "S3"):
|
142 |
-
|
|
|
|
|
143 |
|
144 |
print('Vicuna Strategy Fn - Prompt + Context:')
|
145 |
print(formatted_prompt)
|
@@ -152,7 +156,7 @@ def vicuna_strategies_respond(strategy, task_name, task_ling_ent, message, chat_
|
|
152 |
bot_message = bot_message.replace(formatted_prompt, '')
|
153 |
print(bot_message)
|
154 |
|
155 |
-
chat_history.
|
156 |
time.sleep(2)
|
157 |
return task_name, "", chat_history
|
158 |
|
@@ -164,14 +168,18 @@ def llama_strategies_respond(strategy, task_name, task_ling_ent, message, chat_h
|
|
164 |
elif (strategy == "S2"):
|
165 |
formatted_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
166 |
elif (strategy == "S3"):
|
167 |
-
|
|
|
|
|
168 |
elif (task_name == "Chunking"):
|
169 |
if (strategy == "S1"):
|
170 |
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence one per line: "{message}"'''
|
171 |
elif (strategy == "S2"):
|
172 |
formatted_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
173 |
elif (strategy == "S3"):
|
174 |
-
|
|
|
|
|
175 |
|
176 |
# print('Llama Strategies - Prompt + Context:')
|
177 |
# print(formatted_prompt)
|
@@ -346,10 +354,10 @@ def interface():
|
|
346 |
|
347 |
# vicuna_strategies_respond(strategy, task_name, task_ling_ent, message, chat_history):
|
348 |
# Event Handlers for Vicuna Chatbot POS/Chunk
|
349 |
-
task_btn.click(vicuna_strategies_respond, inputs=[strategy1, task, task_linguistic_entities, task_prompt, vicuna_S1_chatbot],
|
350 |
-
|
351 |
-
task_btn.click(vicuna_strategies_respond, inputs=[strategy2, task, task_linguistic_entities, task_prompt, vicuna_S2_chatbot],
|
352 |
-
|
353 |
task_btn.click(vicuna_strategies_respond, inputs=[strategy3, task, task_linguistic_entities, task_prompt, vicuna_S3_chatbot],
|
354 |
outputs=[task, task_prompt, vicuna_S3_chatbot])
|
355 |
|
|
|
132 |
elif (strategy == "S2"):
|
133 |
formatted_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
134 |
elif (strategy == "S3"):
|
135 |
+
with open('demonstration_3_42_pos.txt', 'r') as f:
|
136 |
+
demon_pos = f.read()
|
137 |
+
formatted_prompt = f'''"{demon_pos}". Using the POS tag structure above, POS tag the following sentence: "{message}"'''
|
138 |
elif (task_name == "Chunking"):
|
139 |
if (strategy == "S1"):
|
140 |
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence one per line: "{message}"'''
|
141 |
elif (strategy == "S2"):
|
142 |
formatted_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
143 |
elif (strategy == "S3"):
|
144 |
+
with open('demonstration_3_42_chunk.txt', 'r') as f:
|
145 |
+
demon_chunk = f.read()
|
146 |
+
formatted_prompt = f'''"{demon_chunk}". Using the Chunking structure above, Chunk the following sentence: "{message}"'''
|
147 |
|
148 |
print('Vicuna Strategy Fn - Prompt + Context:')
|
149 |
print(formatted_prompt)
|
|
|
156 |
bot_message = bot_message.replace(formatted_prompt, '')
|
157 |
print(bot_message)
|
158 |
|
159 |
+
chat_history.insert(0, (formatted_prompt, bot_message))
|
160 |
time.sleep(2)
|
161 |
return task_name, "", chat_history
|
162 |
|
|
|
168 |
elif (strategy == "S2"):
|
169 |
formatted_prompt = f'''POS tag the following sentence using Universal POS tag set: "{message}"'''
|
170 |
elif (strategy == "S3"):
|
171 |
+
with open('demonstration_3_42_pos.txt', 'r') as f:
|
172 |
+
demon_pos = f.read()
|
173 |
+
formatted_prompt = f'''"{demon_pos}". Using the POS tag structure above, POS tag the following sentence: "{message}"'''
|
174 |
elif (task_name == "Chunking"):
|
175 |
if (strategy == "S1"):
|
176 |
formatted_prompt = f'''Output any {task_ling_ent} in the following sentence one per line: "{message}"'''
|
177 |
elif (strategy == "S2"):
|
178 |
formatted_prompt = f'''Chunk the following sentence in CoNLL 2000 format with BIO tags: "{message}"'''
|
179 |
elif (strategy == "S3"):
|
180 |
+
with open('demonstration_3_42_chunk.txt', 'r') as f:
|
181 |
+
demon_chunk = f.read()
|
182 |
+
formatted_prompt = f'''"{demon_chunk}". Using the Chunking structure above, Chunk the following sentence: "{message}"'''
|
183 |
|
184 |
# print('Llama Strategies - Prompt + Context:')
|
185 |
# print(formatted_prompt)
|
|
|
354 |
|
355 |
# vicuna_strategies_respond(strategy, task_name, task_ling_ent, message, chat_history):
|
356 |
# Event Handlers for Vicuna Chatbot POS/Chunk
|
357 |
+
# task_btn.click(vicuna_strategies_respond, inputs=[strategy1, task, task_linguistic_entities, task_prompt, vicuna_S1_chatbot],
|
358 |
+
# outputs=[task, task_prompt, vicuna_S1_chatbot])
|
359 |
+
# task_btn.click(vicuna_strategies_respond, inputs=[strategy2, task, task_linguistic_entities, task_prompt, vicuna_S2_chatbot],
|
360 |
+
# outputs=[task, task_prompt, vicuna_S2_chatbot])
|
361 |
task_btn.click(vicuna_strategies_respond, inputs=[strategy3, task, task_linguistic_entities, task_prompt, vicuna_S3_chatbot],
|
362 |
outputs=[task, task_prompt, vicuna_S3_chatbot])
|
363 |
|