Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ from gradio.themes.utils import colors, fonts, sizes
|
|
7 |
from llama_cpp import Llama
|
8 |
from huggingface_hub import hf_hub_download
|
9 |
|
10 |
-
hf_hub_download(repo_id="Pi3141/alpaca-lora-
|
11 |
-
llm = Llama(model_path="./ggml-model-q4_1.bin",
|
12 |
|
13 |
|
14 |
ins = '''Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
@@ -28,9 +28,18 @@ theme = gr.themes.Monochrome(
|
|
28 |
|
29 |
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
def generate(instruction):
|
32 |
result = ""
|
33 |
-
for x in llm(ins.format(instruction), stop=['### Instruction:', '### End'], stream=True
|
34 |
result += x['choices'][0]['text']
|
35 |
yield result
|
36 |
|
@@ -105,7 +114,7 @@ with gr.Blocks(theme=seafoam, analytics_enabled=False, css=css) as demo:
|
|
105 |
gr.Markdown(
|
106 |
""" ## Alpaca-LoRa
|
107 |
|
108 |
-
is a
|
109 |
|
110 |
Type in the box below and click the button to generate answers to your most pressing questions!
|
111 |
|
|
|
7 |
from llama_cpp import Llama
|
8 |
from huggingface_hub import hf_hub_download
|
9 |
|
10 |
+
hf_hub_download(repo_id="Pi3141/alpaca-lora-7B-ggml", filename="ggml-model-q4_1.bin", local_dir=".")
|
11 |
+
llm = Llama(model_path="./ggml-model-q4_1.bin", n_threads=2)
|
12 |
|
13 |
|
14 |
ins = '''Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
|
|
28 |
|
29 |
|
30 |
|
31 |
+
|
32 |
+
# def generate(instruction):
|
33 |
+
# response = llm(ins.format(instruction))
|
34 |
+
# response = response['choices'][0]['text']
|
35 |
+
# result = ""
|
36 |
+
# for word in response.split(" "):
|
37 |
+
# result += word + " "
|
38 |
+
# yield result
|
39 |
+
|
40 |
def generate(instruction):
|
41 |
result = ""
|
42 |
+
for x in llm(ins.format(instruction), stop=['### Instruction:', '### End'], stream=True):
|
43 |
result += x['choices'][0]['text']
|
44 |
yield result
|
45 |
|
|
|
114 |
gr.Markdown(
|
115 |
""" ## Alpaca-LoRa
|
116 |
|
117 |
+
is a 7B-parameter LLaMA model finetuned to follow instructions. It is trained on the Stanford Alpaca dataset and makes use of the Huggingface LLaMA implementation.
|
118 |
|
119 |
Type in the box below and click the button to generate answers to your most pressing questions!
|
120 |
|