Spaces:
Runtime error
Runtime error
sigmatuse4
commited on
Commit
•
e648a4e
0
Parent(s):
Duplicate from Kajise/GPT4ALL
Browse files- .gitattributes +34 -0
- README.md +14 -0
- app.py +128 -0
- requirements.txt +2 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: GPT4ALL
|
3 |
+
emoji: 📊
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.33.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: openrail
|
11 |
+
duplicated_from: Kajise/GPT4ALL
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
from typing import Iterable
|
3 |
+
import gradio as gr
|
4 |
+
from gradio.themes.base import Base
|
5 |
+
from gradio.themes.utils import colors, fonts, sizes
|
6 |
+
|
7 |
+
from llama_cpp import Llama
|
8 |
+
from huggingface_hub import hf_hub_download
|
9 |
+
|
10 |
+
hf_hub_download(repo_id="LLukas22/gpt4all-lora-quantized-ggjt", filename="ggjt-model.bin", local_dir=".")
|
11 |
+
llm = Llama(model_path="./ggjt-model.bin")
|
12 |
+
|
13 |
+
ins = '''### Instruction:
|
14 |
+
{}
|
15 |
+
### Response:
|
16 |
+
'''
|
17 |
+
|
18 |
+
theme = gr.themes.Monochrome(
|
19 |
+
primary_hue="purple",
|
20 |
+
secondary_hue="red",
|
21 |
+
neutral_hue="neutral",
|
22 |
+
radius_size=gr.themes.sizes.radius_sm,
|
23 |
+
font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"],
|
24 |
+
)
|
25 |
+
|
26 |
+
def generate(instruction):
|
27 |
+
response = llm(ins.format(instruction), stop=['### Instruction:', '### End'])
|
28 |
+
result = response['choices'][0]['text']
|
29 |
+
return result
|
30 |
+
|
31 |
+
|
32 |
+
examples = [
|
33 |
+
"How do dogs bark?",
|
34 |
+
"Why are apples red?",
|
35 |
+
"How do I make a campfire?",
|
36 |
+
"Why do cats love to chirp at something?"
|
37 |
+
]
|
38 |
+
|
39 |
+
def process_example(args):
|
40 |
+
for x in generate(args):
|
41 |
+
pass
|
42 |
+
return x
|
43 |
+
|
44 |
+
css = ".generating {visibility: hidden}"
|
45 |
+
|
46 |
+
class PurpleTheme(Base):
|
47 |
+
def __init__(
|
48 |
+
self,
|
49 |
+
*,
|
50 |
+
primary_hue: colors.Color | str = colors.purple,
|
51 |
+
secondary_hue: colors.Color | str = colors.red,
|
52 |
+
neutral_hue: colors.Color | str = colors.neutral,
|
53 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
54 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
55 |
+
font: fonts.Font
|
56 |
+
| str
|
57 |
+
| Iterable[fonts.Font | str] = (
|
58 |
+
fonts.GoogleFont("Inter"),
|
59 |
+
"ui-sans-serif",
|
60 |
+
"sans-serif",
|
61 |
+
),
|
62 |
+
font_mono: fonts.Font
|
63 |
+
| str
|
64 |
+
| Iterable[fonts.Font | str] = (
|
65 |
+
fonts.GoogleFont("Space Grotesk"),
|
66 |
+
"ui-monospace",
|
67 |
+
"monospace",
|
68 |
+
),
|
69 |
+
):
|
70 |
+
super().__init__(
|
71 |
+
primary_hue=primary_hue,
|
72 |
+
secondary_hue=secondary_hue,
|
73 |
+
neutral_hue=neutral_hue,
|
74 |
+
spacing_size=spacing_size,
|
75 |
+
radius_size=radius_size,
|
76 |
+
font=font,
|
77 |
+
font_mono=font_mono,
|
78 |
+
)
|
79 |
+
super().set(
|
80 |
+
button_primary_background_fill="linear-gradient(90deg, *primary_300, *secondary_400)",
|
81 |
+
button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
|
82 |
+
button_primary_text_color="white",
|
83 |
+
button_primary_background_fill_dark="linear-gradient(90deg, *primary_600, *secondary_800)",
|
84 |
+
block_shadow="*shadow_drop_lg",
|
85 |
+
button_shadow="*shadow_drop_lg",
|
86 |
+
input_background_fill="zinc",
|
87 |
+
input_border_color="*secondary_300",
|
88 |
+
input_shadow="*shadow_drop",
|
89 |
+
input_shadow_focus="*shadow_drop_lg",
|
90 |
+
)
|
91 |
+
|
92 |
+
|
93 |
+
custom_theme = PurpleTheme()
|
94 |
+
|
95 |
+
with gr.Blocks(theme=custom_theme, analytics_enabled=False, css=css) as demo:
|
96 |
+
with gr.Column():
|
97 |
+
gr.Markdown(
|
98 |
+
""" ## GPT4ALL
|
99 |
+
|
100 |
+
7b quantized 4bit (q4_0)
|
101 |
+
|
102 |
+
Type in the box below and click the button to generate answers to your most pressing questions!
|
103 |
+
|
104 |
+
"""
|
105 |
+
)
|
106 |
+
|
107 |
+
with gr.Row():
|
108 |
+
with gr.Column(scale=3):
|
109 |
+
instruction = gr.Textbox(placeholder="Enter your question here", label="Question", elem_id="q-input")
|
110 |
+
|
111 |
+
with gr.Box():
|
112 |
+
gr.Markdown("**Answer**")
|
113 |
+
output = gr.Markdown(elem_id="q-output")
|
114 |
+
submit = gr.Button("Generate", variant="primary")
|
115 |
+
gr.Examples(
|
116 |
+
examples=examples,
|
117 |
+
inputs=[instruction],
|
118 |
+
cache_examples=False,
|
119 |
+
fn=process_example,
|
120 |
+
outputs=[output],
|
121 |
+
)
|
122 |
+
|
123 |
+
|
124 |
+
|
125 |
+
submit.click(generate, inputs=[instruction], outputs=[output])
|
126 |
+
instruction.submit(generate, inputs=[instruction], outputs=[output])
|
127 |
+
|
128 |
+
demo.queue(concurrency_count=1).launch(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
huggingface-hub
|
2 |
+
llama-cpp-python==0.1.35
|