mirnaaiman commited on
Commit
562a1db
·
verified ·
1 Parent(s): 49c746a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -1,8 +1,6 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load a text generation pipeline from a Hugging Face model
5
- # You can replace this model with "meta-llama/Llama-2-7b-chat-hf" or "mistralai/Mistral-7B-Instruct" if available and compatible
6
  generator = pipeline("text-generation", model="meta-llama/Llama-2-7b-chat-hf")
7
 
8
  def evaluate_response(prompt):
@@ -10,7 +8,7 @@ def evaluate_response(prompt):
10
  outputs = generator(prompt, max_new_tokens=150, do_sample=True, temperature=0.7)
11
  generated_text = outputs[0]['generated_text']
12
 
13
- # Simple quality evaluation: check length of generated response
14
  word_count = len(generated_text.split())
15
  quality = "Good" if word_count > 10 else "Poor"
16
 
@@ -21,7 +19,7 @@ iface = gr.Interface(
21
  inputs=gr.Textbox(lines=4, label="Enter your prompt"),
22
  outputs=[gr.Textbox(label="Model Response"), gr.Textbox(label="Quality Analysis")],
23
  title="Model Understanding Test",
24
- description="Enter instructions or a question, the app sends it to a language model and evaluates the response quality."
25
  )
26
 
27
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
 
4
  generator = pipeline("text-generation", model="meta-llama/Llama-2-7b-chat-hf")
5
 
6
  def evaluate_response(prompt):
 
8
  outputs = generator(prompt, max_new_tokens=150, do_sample=True, temperature=0.7)
9
  generated_text = outputs[0]['generated_text']
10
 
11
+ # Simple quality evaluation: check if response length > 10 words
12
  word_count = len(generated_text.split())
13
  quality = "Good" if word_count > 10 else "Poor"
14
 
 
19
  inputs=gr.Textbox(lines=4, label="Enter your prompt"),
20
  outputs=[gr.Textbox(label="Model Response"), gr.Textbox(label="Quality Analysis")],
21
  title="Model Understanding Test",
22
+ description="Enter a prompt, get a model response, and see an automatic quality evaluation."
23
  )
24
 
25
  if __name__ == "__main__":