Eric Nangomba commited on
Commit
978cd40
·
verified ·
1 Parent(s): c41e689

Create dolphin-2.9-llama3-8b-q3_K_M.gguf

Browse files
Files changed (1) hide show
  1. dolphin-2.9-llama3-8b-q3_K_M.gguf +125 -0
dolphin-2.9-llama3-8b-q3_K_M.gguf ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+ from typing import Iterable
3
+ import gradio as gr
4
+ from radio.themes.base import Base
5
+ from radio.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="cognitivecomputations/dolphin-2.9-llama3-8b-gguf", filename="dolphin-2.9-llama3-8b-q3_K_M.gguf", local_dir=".")
11
+ llm = Llama(model_path="./dolphin-2.9-llama3-8b-q3_K_M.gguf")
12
+
13
+ ins = '''<|im_start|>system
14
+ {system}<|im_end|>
15
+ <|im_start|>user
16
+ {question}<|im_end|>
17
+ <|im_start|>assistant
18
+ '''
19
+
20
+ theme = gr.themes.Monochrome(
21
+ primary_hue="red",
22
+ secondary_hue="orange",
23
+ neutral_hue="neutral",
24
+ radius_size=gr.themes.sizes.radius_sm,
25
+ font=[gr.themes.GoogleFont("Space Grotesk"), "ui-sans-serif", "system-ui", "sans-serif"],
26
+ )
27
+
28
+ def generate(instruction, system_prompt):
29
+ prompt = ins.format(question=instruction, system=system_prompt)
30
+ response = llm(prompt, stop=['<|im_start|>user', '<|im_end|>'])
31
+ result = response['choices'][0]['text']
32
+ return result
33
+
34
+ examples = [
35
+ "How do dogs bark?",
36
+ "Why are apples red?",
37
+ "How do I make a campfire?",
38
+ "Why do cats love to chirp at something?"
39
+ ]
40
+
41
+ def process_example(args):
42
+ for x in generate(args):
43
+ pass
44
+ return x
45
+
46
+ css = ".generating {visibility: hidden}"
47
+
48
+ class BlueTheme(Base):
49
+ def __init__(
50
+ self,
51
+ *,
52
+ primary_hue: colors.Color | str = colors.blue,
53
+ secondary_hue: colors.Color | str = colors.cyan,
54
+ neutral_hue: colors.Color | str = colors.neutral,
55
+ spacing_size: sizes.Size | str = sizes.spacing_md,
56
+ radius_size: sizes.Size | str = sizes.radius_md,
57
+ font: fonts.Font
58
+ | str
59
+ | Iterable[fonts.Font | str] = (
60
+ fonts.GoogleFont("Inter"),
61
+ "ui-sans-serif",
62
+ "sans-serif",
63
+ ),
64
+ font_mono: fonts.Font
65
+ | str
66
+ | Iterable[fonts.Font | str] = (
67
+ fonts.GoogleFont("Space Grotesk"),
68
+ "ui-monospace",
69
+ "monospace",
70
+ ),
71
+ ):
72
+ super().__init__(
73
+ primary_hue=primary_hue,
74
+ secondary_hue=secondary_hue,
75
+ neutral_hue=neutral_hue,
76
+ spacing_size=spacing_size,
77
+ radius_size=radius_size,
78
+ font=font,
79
+ font_mono=font_mono,
80
+ )
81
+ super().set(
82
+ button_primary_background_fill="linear-gradient(90deg, *primary_300, *secondary_400)",
83
+ button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
84
+ button_primary_text_color="white",
85
+ button_primary_background_fill_dark="linear-gradient(90deg, *primary_600, *secondary_800)",
86
+ block_shadow="*shadow_drop_lg",
87
+ button_shadow="*shadow_drop_lg",
88
+ input_background_fill="zinc",
89
+ input_border_color="*secondary_300",
90
+ input_shadow="*shadow_drop",
91
+ input_shadow_focus="*shadow_drop_lg",
92
+ )
93
+
94
+
95
+ custom_theme = BlueTheme()
96
+
97
+ with gr.Blocks(theme=custom_theme, analytics_enabled=False, css=css) as demo:
98
+ with gr.Column():
99
+ gr.Markdown(
100
+ """ # 🦙 Dolphin4ALL
101
+ llama3 8b (q3_k_m)
102
+ Type in the box below and click the button to generate answers to your most pressing questions!
103
+ """)
104
+
105
+ with gr.Row():
106
+ with gr.Column(scale=3):
107
+ instruction = gr.Textbox(placeholder="Enter your question here", label="Question Prompts")
108
+ sys_prompt = gr.Textbox(placeholder="Enter your system instructions here", label="System Prompts")
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=False,
118
+ fn=process_example,
119
+ outputs=[output],
120
+ )
121
+
122
+ submit.click(generate, inputs=[instruction, sys_prompt], outputs=[output])
123
+ instruction.submit(generate, inputs=[instruction, sys_prompt], outputs=[output])
124
+
125
+ demo.queue(concurrency_count=1).launch(debug=True)