Spaces:
Runtime error
Runtime error
Commit
·
2ba8da5
1
Parent(s):
d4e59c1
test
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
import random
|
3 |
-
import time
|
4 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
5 |
|
6 |
# Load Vicuna 7B model and tokenizer
|
@@ -8,14 +7,6 @@ model_name = "lmsys/vicuna-7b-v1.3"
|
|
8 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
9 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
|
11 |
-
def respond_vicuna(message, chat_history, vicuna_chatbot):
|
12 |
-
input_ids = tokenizer.encode(message, return_tensors="pt")
|
13 |
-
output = model.generate(input_ids, max_length=50, num_beams=5, no_repeat_ngram_size=2)
|
14 |
-
bot_message = tokenizer.decode(output[0], skip_special_tokens=True)
|
15 |
-
chat_history.append((message, bot_message))
|
16 |
-
time.sleep(2)
|
17 |
-
return "", chat_history
|
18 |
-
|
19 |
with gr.Blocks() as demo:
|
20 |
gr.Markdown("# LLM Evaluator With Linguistic Scrutiny")
|
21 |
|
@@ -39,6 +30,7 @@ with gr.Blocks() as demo:
|
|
39 |
prompt = gr.Textbox(show_label=False, placeholder="Enter prompt")
|
40 |
send_button_POS = gr.Button("Send", scale=0)
|
41 |
clear = gr.ClearButton([prompt, vicuna_chatbot1])
|
|
|
42 |
with gr.Tab("Chunk"):
|
43 |
gr.Markdown("Strategy 1 QA")
|
44 |
with gr.Row():
|
@@ -60,15 +52,12 @@ with gr.Blocks() as demo:
|
|
60 |
send_button_Chunk = gr.Button("Send", scale=0)
|
61 |
clear = gr.ClearButton([prompt_chunk, vicuna_chatbot1_chunk])
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
chat_history.append((message, bot_message))
|
68 |
-
time.sleep(2)
|
69 |
-
return "", chat_history
|
70 |
|
71 |
-
#
|
72 |
-
prompt.submit(
|
73 |
|
74 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import random
|
|
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
|
5 |
# Load Vicuna 7B model and tokenizer
|
|
|
7 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
with gr.Blocks() as demo:
|
11 |
gr.Markdown("# LLM Evaluator With Linguistic Scrutiny")
|
12 |
|
|
|
30 |
prompt = gr.Textbox(show_label=False, placeholder="Enter prompt")
|
31 |
send_button_POS = gr.Button("Send", scale=0)
|
32 |
clear = gr.ClearButton([prompt, vicuna_chatbot1])
|
33 |
+
|
34 |
with gr.Tab("Chunk"):
|
35 |
gr.Markdown("Strategy 1 QA")
|
36 |
with gr.Row():
|
|
|
52 |
send_button_Chunk = gr.Button("Send", scale=0)
|
53 |
clear = gr.ClearButton([prompt_chunk, vicuna_chatbot1_chunk])
|
54 |
|
55 |
+
# Define the Gradio interface
|
56 |
+
def chatbot_interface(prompt):
|
57 |
+
vicuna_response = generate_response(model, tokenizer, prompt)
|
58 |
+
return {"Vicuna-7B": vicuna_response}
|
|
|
|
|
|
|
59 |
|
60 |
+
# Use the chatbot_interface function in the prompt.submit() method
|
61 |
+
prompt.submit(chatbot_interface, [prompt, vicuna_chatbot1, vicuna_chatbot1_chunk])
|
62 |
|
63 |
demo.launch()
|