ffreemt
commited on
Commit
•
9523a2b
1
Parent(s):
5f1d66a
First commit (cloned from https://huggingface.co/spaces/Cran-May/SEA-solo)
Browse files- README.md +6 -6
- README.md-0 +12 -0
- app.py +127 -0
- requirements.txt +3 -0
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: ⚡
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
-
pinned:
|
10 |
---
|
11 |
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: openbuddy-mistral-7b-v13-gguf
|
3 |
emoji: ⚡
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.45.2
|
8 |
app_file: app.py
|
9 |
+
pinned: true
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
README.md-0
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Openbuddy Mistral 7b V13 Gguf
|
3 |
+
emoji: ⚡
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: red
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 4.5.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
11 |
+
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
|
3 |
+
from typing import Iterable
|
4 |
+
|
5 |
+
import gradio as gr
|
6 |
+
from ctransformers import AutoModelForCausalLM
|
7 |
+
from gradio.themes.base import Base
|
8 |
+
from gradio.themes.utils import colors, fonts, sizes
|
9 |
+
|
10 |
+
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
11 |
+
model = AutoModelForCausalLM.from_pretrained("TheBloke/openbuddy-mistral-7B-v13-GGUF", model_file="openbuddy-mistral-7b-v13.Q4_K_S.gguf", model_type="mistral", gpu_layers=0)
|
12 |
+
ins = '''[INST] <<FRIDAY>>
|
13 |
+
Remember that your English name is "Shi-Ci" and your name in Chinese is "兮辞". You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
|
14 |
+
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
|
15 |
+
<</FRIDAY>>
|
16 |
+
{} [/INST]
|
17 |
+
'''
|
18 |
+
|
19 |
+
|
20 |
+
theme = gr.themes.Monochrome(
|
21 |
+
primary_hue="indigo",
|
22 |
+
secondary_hue="blue",
|
23 |
+
neutral_hue="slate",
|
24 |
+
radius_size=gr.themes.sizes.radius_sm,
|
25 |
+
font=[gr.themes.GoogleFont("Open Sans"), "ui-sans-serif", "system-ui", "sans-serif"],
|
26 |
+
)
|
27 |
+
def response(question):
|
28 |
+
res = model(ins.format(question))
|
29 |
+
yield res
|
30 |
+
|
31 |
+
|
32 |
+
examples = [
|
33 |
+
"Hello!"
|
34 |
+
]
|
35 |
+
|
36 |
+
def process_example(args):
|
37 |
+
for x in response(args):
|
38 |
+
pass
|
39 |
+
return x
|
40 |
+
|
41 |
+
css = ".generating {visibility: hidden}"
|
42 |
+
|
43 |
+
# Based on the gradio theming guide and borrowed from https://huggingface.co/spaces/shivi/dolly-v2-demo
|
44 |
+
class SeafoamCustom(Base):
|
45 |
+
def __init__(
|
46 |
+
self,
|
47 |
+
*,
|
48 |
+
primary_hue: colors.Color | str = colors.emerald,
|
49 |
+
secondary_hue: colors.Color | str = colors.blue,
|
50 |
+
neutral_hue: colors.Color | str = colors.blue,
|
51 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
52 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
53 |
+
font: fonts.Font
|
54 |
+
| str
|
55 |
+
| Iterable[fonts.Font | str] = (
|
56 |
+
fonts.GoogleFont("Quicksand"),
|
57 |
+
"ui-sans-serif",
|
58 |
+
"sans-serif",
|
59 |
+
),
|
60 |
+
font_mono: fonts.Font
|
61 |
+
| str
|
62 |
+
| Iterable[fonts.Font | str] = (
|
63 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
64 |
+
"ui-monospace",
|
65 |
+
"monospace",
|
66 |
+
),
|
67 |
+
):
|
68 |
+
"""Init."""
|
69 |
+
super().__init__(
|
70 |
+
primary_hue=primary_hue,
|
71 |
+
secondary_hue=secondary_hue,
|
72 |
+
neutral_hue=neutral_hue,
|
73 |
+
spacing_size=spacing_size,
|
74 |
+
radius_size=radius_size,
|
75 |
+
font=font,
|
76 |
+
font_mono=font_mono,
|
77 |
+
)
|
78 |
+
super().set(
|
79 |
+
button_primary_background_fill="linear-gradient(90deg, *primary_300, *secondary_400)",
|
80 |
+
button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
|
81 |
+
button_primary_text_color="white",
|
82 |
+
button_primary_background_fill_dark="linear-gradient(90deg, *primary_600, *secondary_800)",
|
83 |
+
block_shadow="*shadow_drop_lg",
|
84 |
+
button_shadow="*shadow_drop_lg",
|
85 |
+
input_background_fill="zinc",
|
86 |
+
input_border_color="*secondary_300",
|
87 |
+
input_shadow="*shadow_drop",
|
88 |
+
input_shadow_focus="*shadow_drop_lg",
|
89 |
+
)
|
90 |
+
|
91 |
+
|
92 |
+
seafoam = SeafoamCustom()
|
93 |
+
|
94 |
+
|
95 |
+
with gr.Blocks(theme=seafoam, analytics_enabled=False, css=css) as demo:
|
96 |
+
with gr.Column():
|
97 |
+
gr.Markdown(
|
98 |
+
""" ## Shi-Ci Extensional Analyzer
|
99 |
+
|
100 |
+
Type in the box below and click the button to generate answers to your most pressing questions!
|
101 |
+
|
102 |
+
"""
|
103 |
+
)
|
104 |
+
|
105 |
+
with gr.Row():
|
106 |
+
|
107 |
+
with gr.Column(scale=3):
|
108 |
+
instruction = gr.Textbox(placeholder="Enter your question here", label="Question", elem_id="q-input")
|
109 |
+
|
110 |
+
with gr.Box():
|
111 |
+
gr.Markdown("**Answer**")
|
112 |
+
output = gr.Markdown(elem_id="q-output")
|
113 |
+
submit = gr.Button("Generate", variant="primary")
|
114 |
+
gr.Examples(
|
115 |
+
examples=examples,
|
116 |
+
inputs=[instruction],
|
117 |
+
cache_examples=True,
|
118 |
+
fn=process_example,
|
119 |
+
outputs=[output],
|
120 |
+
)
|
121 |
+
|
122 |
+
|
123 |
+
|
124 |
+
submit.click(response, inputs=[instruction], outputs=[output])
|
125 |
+
instruction.submit(response, inputs=[instruction], outputs=[output])
|
126 |
+
|
127 |
+
demo.queue(concurrency_count=1).launch(debug=False,share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
ctransformers
|
2 |
+
gradio
|
3 |
+
huggingface-hub
|