nicole-ait commited on
Commit
176e824
·
1 Parent(s): bea420f

by step option; samples;

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  from langchain import PromptTemplate, LLMChain
4
  from langchain.llms import HuggingFaceHub
5
 
6
- template = """Question: {question}
7
 
8
  Answer: Let's think step by step."""
9
 
@@ -13,7 +13,9 @@ def run(
13
  repo_id: gr.Dropdown = None,
14
  temperature: gr.Slider = 0.5,
15
  max_length: gr.Slider = 64,
 
16
  ):
 
17
  prompt = PromptTemplate(template=template, input_variables=["question"])
18
  llm = HuggingFaceHub(
19
  repo_id=repo_id,
@@ -30,7 +32,17 @@ inputs = [
30
  gr.Dropdown(["google/flan-t5-xxl", "google/flan-t5-base"],
31
  value="google/flan-t5-xxl", label="Model", allow_custom_value=True),
32
  gr.Slider(0.0, 1.0, value=0.5, step=0.05, label="Temperature"),
33
- gr.Slider(10, 1000, value=64, label="Max Length"),
 
 
 
 
 
 
 
 
 
 
34
  ]
35
 
36
  title = "Langchain w/ HF Models"
@@ -40,4 +52,5 @@ gr.Interface(
40
  inputs=inputs,
41
  outputs='label',
42
  title=title,
 
43
  ).launch()
 
3
  from langchain import PromptTemplate, LLMChain
4
  from langchain.llms import HuggingFaceHub
5
 
6
+ template_by_step = """Question: {question}
7
 
8
  Answer: Let's think step by step."""
9
 
 
13
  repo_id: gr.Dropdown = None,
14
  temperature: gr.Slider = 0.5,
15
  max_length: gr.Slider = 64,
16
+ by_steq: gr.Checkbox = False,
17
  ):
18
+ template = template_by_step if by_steq else "{question}"
19
  prompt = PromptTemplate(template=template, input_variables=["question"])
20
  llm = HuggingFaceHub(
21
  repo_id=repo_id,
 
32
  gr.Dropdown(["google/flan-t5-xxl", "google/flan-t5-base"],
33
  value="google/flan-t5-xxl", label="Model", allow_custom_value=True),
34
  gr.Slider(0.0, 1.0, value=0.5, step=0.05, label="Temperature"),
35
+ gr.Slider(20, 1000, value=64, label="Max Length"),
36
+ gr.Checkbox(label="Think step by step", value=False),
37
+ ]
38
+
39
+ examples = [
40
+ ["What is the capital of France?"],
41
+ ["What's the Earth total population?"],
42
+ ["Who won the FIFA World Cup in the year 1994?"],
43
+ ["What NFL team won the Super Bowl in the year Justin Bieber was born?"],
44
+ ["Translate the following to French: There are so many plans"],
45
+ ["Write an article to introduce machine learning"],
46
  ]
47
 
48
  title = "Langchain w/ HF Models"
 
52
  inputs=inputs,
53
  outputs='label',
54
  title=title,
55
+ examples=examples,
56
  ).launch()