sifujohn commited on
Commit
db0630c
1 Parent(s): 203beb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -90
app.py CHANGED
@@ -1,92 +1,3 @@
1
- #from huggingface_hub import InferenceClient
2
-
3
  import gradio as gr
4
 
5
- gr.load("models/google/gemma-7b-it")
6
-
7
-
8
- def format_prompt(message, history):
9
- prompt = "<s>"
10
- for user_prompt, bot_response in history:
11
- prompt += f"[INST] {user_prompt} [/INST]"
12
- prompt += f" {bot_response}</s> "
13
- prompt += f"[INST] {message} [/INST]"
14
- return prompt
15
-
16
- def generate(
17
- prompt, history, system_prompt, temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,
18
- ):
19
- temperature = float(temperature)
20
- if temperature < 1e-2:
21
- temperature = 1e-2
22
- top_p = float(top_p)
23
-
24
- generate_kwargs = dict(
25
- temperature=temperature,
26
- max_new_tokens=max_new_tokens,
27
- top_p=top_p,
28
- repetition_penalty=repetition_penalty,
29
- do_sample=True,
30
- seed=42,
31
- )
32
-
33
- additional_inputs=[
34
- gr.Textbox(
35
- label="System Prompt",
36
- max_lines=1,
37
- interactive=True,
38
- ),
39
- gr.Slider(
40
- label="Temperature",
41
- value=0.9,
42
- minimum=0.0,
43
- maximum=1.0,
44
- step=0.05,
45
- interactive=True,
46
- info="Higher values produce more diverse outputs",
47
- ),
48
- gr.Slider(
49
- label="Max new tokens",
50
- value=256,
51
- minimum=0,
52
- maximum=1048,
53
- step=64,
54
- interactive=True,
55
- info="The maximum numbers of new tokens",
56
- ),
57
- gr.Slider(
58
- label="Top-p (nucleus sampling)",
59
- value=0.90,
60
- minimum=0.0,
61
- maximum=1,
62
- step=0.05,
63
- interactive=True,
64
- info="Higher values sample more low-probability tokens",
65
- ),
66
- gr.Slider(
67
- label="Repetition penalty",
68
- value=1.2,
69
- minimum=1.0,
70
- maximum=2.0,
71
- step=0.05,
72
- interactive=True,
73
- info="Penalize repeated tokens",
74
- )
75
- ]
76
-
77
- examples=[["I'm planning a vacation to Japan. Can you suggest a one-week itinerary including must-visit places and local cuisines to try?", None, None, None, None, None, ],
78
- ["Can you write a short story about a time-traveling detective who solves historical mysteries?", None, None, None, None, None,],
79
- ["I'm trying to learn French. Can you provide some common phrases that would be useful for a beginner, along with their pronunciations?", None, None, None, None, None,],
80
- ["I have chicken, rice, and bell peppers in my kitchen. Can you suggest an easy recipe I can make with these ingredients?", None, None, None, None, None,],
81
- ["Can you explain how the QuickSort algorithm works and provide a Python implementation?", None, None, None, None, None,],
82
- ["What are some unique features of Rust that make it stand out compared to other systems programming languages like C++?", None, None, None, None, None,],
83
- ]
84
-
85
- gr.ChatInterface(
86
- fn=generate,
87
- chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
88
- additional_inputs=additional_inputs,
89
- title="Gemma 7b Chat",
90
- examples=examples,
91
- concurrency_limit=20,
92
- ).launch(show_api=False)
 
 
 
1
  import gradio as gr
2
 
3
+ gr.load("models/google/gemma-7b-it").launch()