Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,13 +2,27 @@ import gradio as gr
|
|
2 |
#import transformers
|
3 |
#from transformers import pipeline
|
4 |
from llama_cpp import Llama
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def question_answer(context, question):
|
|
|
10 |
text=context + "\n\nQuestion: \"\"\"\n" + question + "\nPlease use markdown formatting for answer. \nAnswer:\n"
|
11 |
-
llm = Llama(model_path=
|
12 |
output = llm(text, max_tokens=33, stop=["### Response", "\n"], echo=True)
|
13 |
print(output)
|
14 |
return output.choices[0].text
|
|
|
2 |
#import transformers
|
3 |
#from transformers import pipeline
|
4 |
from llama_cpp import Llama
|
5 |
+
from huggingface_hub import hf_hub_download
|
6 |
|
7 |
+
model_repo="TheBloke/Nous-Hermes-13B-GGML"
|
8 |
+
model_filename="nous-hermes-13b.ggmlv3.q4_K_S.bin"
|
9 |
+
|
10 |
+
#model="TheBloke/Nous-Hermes-13B-GGML"
|
11 |
+
#model="https://huggingface.co/TheBloke/Nous-Hermes-13B-GGML/resolve/main/nous-hermes-13b.ggmlv3.q4_K_S.bin"
|
12 |
+
|
13 |
+
def download_model:
|
14 |
+
# See https://github.com/OpenAccess-AI-Collective/ggml-webui/blob/main/tabbed.py
|
15 |
+
repo_id = hub_config.pop("repo_id")
|
16 |
+
filename = hub_config.pop("filename")
|
17 |
+
file = hf_hub_download(
|
18 |
+
repo_id=model_repo, filename=model_filename
|
19 |
+
)
|
20 |
+
return file
|
21 |
|
22 |
def question_answer(context, question):
|
23 |
+
mfile=download_model()
|
24 |
text=context + "\n\nQuestion: \"\"\"\n" + question + "\nPlease use markdown formatting for answer. \nAnswer:\n"
|
25 |
+
llm = Llama(model_path=mfile)
|
26 |
output = llm(text, max_tokens=33, stop=["### Response", "\n"], echo=True)
|
27 |
print(output)
|
28 |
return output.choices[0].text
|