Spaces:
Runtime error
Runtime error
Commit
·
04fc021
1
Parent(s):
cc5a0c8
test
Browse files
app.py
CHANGED
@@ -51,6 +51,14 @@ for i, j in zip(ents, ents_prompt):
|
|
51 |
|
52 |
model_mapping = {
|
53 |
'gpt3.5': 'gpt2',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
with open('sample_uniform_1k_2.txt', 'r') as f:
|
@@ -85,50 +93,62 @@ with open('demonstration_3_42_parse.txt', 'r') as f:
|
|
85 |
# Your existing code
|
86 |
theme = gr.themes.Soft()
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
#
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
'Chunking': {
|
99 |
-
'strategy1': 'template_all',
|
100 |
-
'strategy2': 'prompt2_chunk',
|
101 |
-
'strategy3': 'demon_chunk',
|
102 |
-
},
|
103 |
-
'Parsing': {
|
104 |
-
'strategy1': 'template_all',
|
105 |
-
'strategy2': 'prompt2_parse',
|
106 |
-
'strategy3': 'demon_parse',
|
107 |
-
},
|
108 |
-
}
|
109 |
|
110 |
# Dropdown options for model and task
|
111 |
model_options = list(model_mapping.keys())
|
112 |
task_options = ['POS', 'Chunking', 'Parsing']
|
113 |
|
|
|
|
|
114 |
# Function to process text based on model and task
|
115 |
def process_text(model_name, task, text):
|
116 |
gid_list = selected_idx[0:20]
|
117 |
|
118 |
for gid in tqdm(gid_list, desc='Query'):
|
119 |
text = ptb[gid]['text']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
-
if model_name in pipelines:
|
122 |
-
strategy1 = task_prompts[task]['strategy1'].format(text)
|
123 |
-
strategy2 = task_prompts[task]['strategy2'].format(text)
|
124 |
-
strategy3 = task_prompts[task]['strategy3'].format(text)
|
125 |
-
|
126 |
-
# Extract generated text from the model's response
|
127 |
-
response1 = pipelines[model_name](strategy1)[0]['generated_text']
|
128 |
-
response2 = pipelines[model_name](strategy2)[0]['generated_text']
|
129 |
-
response3 = pipelines[model_name](strategy3)[0]['generated_text']
|
130 |
-
|
131 |
-
return response1, response2, response3
|
132 |
|
133 |
# Gradio interface
|
134 |
iface = gr.Interface(
|
@@ -143,9 +163,11 @@ iface = gr.Interface(
|
|
143 |
gr.Textbox(label="Strategy 2 Instruction Result"),
|
144 |
gr.Textbox(label="Strategy 3 Structured Prompting Result"),
|
145 |
],
|
146 |
-
title="LLM Evaluator For Linguistic Scrutiny",
|
147 |
-
theme=theme,
|
148 |
live=False,
|
149 |
)
|
150 |
|
151 |
iface.launch()
|
|
|
|
|
|
51 |
|
52 |
model_mapping = {
|
53 |
'gpt3.5': 'gpt2',
|
54 |
+
#'vicuna-7b': 'lmsys/vicuna-7b-v1.3',
|
55 |
+
#'vicuna-13b': 'lmsys/vicuna-13b-v1.3',
|
56 |
+
#'vicuna-33b': 'lmsys/vicuna-33b-v1.3',
|
57 |
+
#'fastchat-t5': 'lmsys/fastchat-t5-3b-v1.0',
|
58 |
+
#'llama-7b': './llama/hf/7B',
|
59 |
+
#'llama-13b': './llama/hf/13B',
|
60 |
+
#'llama-30b': './llama/hf/30B',
|
61 |
+
#'alpaca': './alpaca-7B',
|
62 |
}
|
63 |
|
64 |
with open('sample_uniform_1k_2.txt', 'r') as f:
|
|
|
93 |
# Your existing code
|
94 |
theme = gr.themes.Soft()
|
95 |
|
96 |
+
|
97 |
+
gpt_pipeline = pipeline(task="text2text-generation", model="gpt2")
|
98 |
+
#vicuna7b_pipeline = pipeline(task="text2text-generation", model="lmsys/vicuna-7b-v1.3")
|
99 |
+
#vicuna13b_pipeline = pipeline(task="text2text-generation", model="lmsys/vicuna-13b-v1.3")
|
100 |
+
#vicuna33b_pipeline = pipeline(task="text2text-generation", model="lmsys/vicuna-33b-v1.3")
|
101 |
+
#fastchatT5_pipeline = pipeline(task="text2text-generation", model="lmsys/fastchat-t5-3b-v1.0")
|
102 |
+
#llama7b_pipeline = pipeline(task="text2text-generation", model="./llama/hf/7B")
|
103 |
+
#llama13b_pipeline = pipeline(task="text2text-generation", model="./llama/hf/13B")
|
104 |
+
#llama30b_pipeline = pipeline(task="text2text-generation", model="./llama/hf/30B")
|
105 |
+
#alpaca_pipeline = pipeline(task="text2text-generation", model="./alpaca-7B")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
# Dropdown options for model and task
|
108 |
model_options = list(model_mapping.keys())
|
109 |
task_options = ['POS', 'Chunking', 'Parsing']
|
110 |
|
111 |
+
|
112 |
+
|
113 |
# Function to process text based on model and task
|
114 |
def process_text(model_name, task, text):
|
115 |
gid_list = selected_idx[0:20]
|
116 |
|
117 |
for gid in tqdm(gid_list, desc='Query'):
|
118 |
text = ptb[gid]['text']
|
119 |
+
|
120 |
+
if model_name is 'gpt3.5':
|
121 |
+
if task == 'POS':
|
122 |
+
strategy1 = template_all.format(text)
|
123 |
+
strategy2 = prompt2_pos.format(text)
|
124 |
+
strategy3 = demon_pos
|
125 |
+
return (gpt_pipeline(strategy1), gpt_pipeline(strategy2), gpt_pipeline(strategy3))
|
126 |
+
elif task == 'Chunking':
|
127 |
+
strategy1 = template_all.format(text)
|
128 |
+
strategy2 = prompt2_chunk.format(text)
|
129 |
+
strategy3 = demon_chunk
|
130 |
+
return (gpt_pipeline(strategy1), gpt_pipeline(strategy2), gpt_pipeline(strategy3))
|
131 |
+
elif task == 'Parsing':
|
132 |
+
strategy1 = template_all.format(text)
|
133 |
+
strategy2 = prompt2_parse.format(text)
|
134 |
+
strategy3 = demon_parse
|
135 |
+
return (gpt_pipeline(strategy1), gpt_pipeline(strategy2), gpt_pipeline(strategy3))
|
136 |
+
|
137 |
+
# Define prompts for each strategy based on the task
|
138 |
+
#strategy_prompts = {
|
139 |
+
# 'Strategy 1': template_all.format(text),
|
140 |
+
# 'Strategy 2': {
|
141 |
+
# 'POS': prompt2_pos.format(text),
|
142 |
+
# 'Chunking': prompt2_chunk.format(text),
|
143 |
+
# 'Parsing': prompt2_parse.format(text),
|
144 |
+
# }.get(task, "Invalid Task Selection for Strategy 2"),
|
145 |
+
# 'Strategy 3': {
|
146 |
+
# 'POS': demon_pos,
|
147 |
+
# 'Chunking': demon_chunk,
|
148 |
+
# 'Parsing': demon_parse,
|
149 |
+
# }.get(task, "Invalid Task Selection for Strategy 3"),
|
150 |
+
#}
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
# Gradio interface
|
154 |
iface = gr.Interface(
|
|
|
163 |
gr.Textbox(label="Strategy 2 Instruction Result"),
|
164 |
gr.Textbox(label="Strategy 3 Structured Prompting Result"),
|
165 |
],
|
166 |
+
title = "LLM Evaluator For Linguistic Scrutiny",
|
167 |
+
theme = theme,
|
168 |
live=False,
|
169 |
)
|
170 |
|
171 |
iface.launch()
|
172 |
+
|
173 |
+
|