RamAnanth1 commited on
Commit
3fb614b
1 Parent(s): 3730e3a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -0
app.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ theme = gr.themes.Monochrome(
5
+ primary_hue="indigo",
6
+ secondary_hue="blue",
7
+ neutral_hue="slate",
8
+ radius_size=gr.themes.sizes.radius_sm,
9
+ font=[gr.themes.GoogleFont("Open Sans"), "ui-sans-serif", "system-ui", "sans-serif"],
10
+ )
11
+
12
+ instruct_pipeline = pipeline(model="databricks/dolly-v2-12b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
13
+ def generate(instruction):
14
+ return instruct_pipeline(instruction)
15
+
16
+
17
+ examples = [
18
+ "Instead of making a peanut butter and jelly sandwich, what else could I combine peanut butter with in a sandwich? Give five ideas",
19
+ "How do I make a campfire?",
20
+ "Write me a tweet about the launch of Dolly 2.0, a new LLM"
21
+
22
+ ]
23
+
24
+
25
+ def process_example(args):
26
+ for x in generate(args):
27
+ pass
28
+ return x
29
+
30
+ css = ".generating {visibility: hidden}" + share_btn_css
31
+
32
+ with gr.Blocks(theme=theme, analytics_enabled=False, css=css) as demo:
33
+ with gr.Column():
34
+ gr.Markdown(
35
+ """ ## Dolly 2.0
36
+ Dolly 2.0 is a 12B parameter language model based on the EleutherAI pythia model family and fine-tuned exclusively on a new, high-quality human generated instruction following dataset, crowdsourced among Databricks employees
37
+
38
+ Type in the box below and click the button to generate answers to your most pressing questions!
39
+
40
+ """
41
+ )
42
+ with gr.Row():
43
+ with gr.Column(scale=3):
44
+ instruction = gr.Textbox(placeholder="Enter your question here", label="Question", elem_id="q-input")
45
+
46
+ with gr.Box():
47
+ gr.Markdown("**Answer**")
48
+ output = gr.Markdown(elem_id="q-output")
49
+ submit = gr.Button("Generate", variant="primary")
50
+ gr.Examples(
51
+ examples=examples,
52
+ inputs=[instruction],
53
+ cache_examples=False,
54
+ fn=process_example,
55
+ outputs=[output],
56
+ )
57
+
58
+
59
+ submit.click(generate, inputs=[instruction], outputs=[output])
60
+ instruction.submit(generate, inputs=[instruction], outputs=[output])
61
+
62
+ demo.queue(concurrency_count=16).launch(debug=True)