Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,52 @@ from llama_index.llms.llama_utils import (
|
|
9 |
completion_to_prompt,
|
10 |
)
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
MODELS_PATH = "./models"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
mistral_model_path = hf_hub_download(
|
15 |
repo_id= "TheBloke/Mistral-7B-Instruct-v0.2-GGUF",
|
@@ -19,6 +64,7 @@ mistral_model_path = hf_hub_download(
|
|
19 |
|
20 |
|
21 |
|
|
|
22 |
"""Step 3 : if you use GPU then make sure ( n_gpu_layers":1) at least 1, you can increase or decrease it based on your GPU performance"""
|
23 |
|
24 |
llm = LlamaCPP(
|
@@ -109,8 +155,8 @@ def predict(message, history):
|
|
109 |
|
110 |
with gr.Blocks() as UI:
|
111 |
|
112 |
-
models=gr.Dropdown(["CodeLlama-7B","Llama-2-13B-chat","Falcon-7B-Instruct" "Mistral-7B-Instruct-v0.2", "zephyr-7B-beta",
|
113 |
-
"vicuna-7B-v1.5"],value=["CodeLlama-7B","Llama-2-13B-chat","Falcon-7B-Instruct" "Mistral-7B-Instruct-v0.2", "zephyr-7B-beta",
|
114 |
"vicuna-7B-v1.5"], label="please select at least one model", info="default model is Mistral-7B-Instruct-v0.2")
|
115 |
textInfo = gr.Textbox(value="current model is Mistral-7B-Instruct-v0.2",label="Model Status");
|
116 |
# Chatbot interface
|
@@ -126,8 +172,8 @@ with gr.Blocks() as UI:
|
|
126 |
undo_btn="Delete Previous",
|
127 |
clear_btn="Clear",
|
128 |
)
|
|
|
129 |
|
130 |
-
models.change(fn=
|
131 |
-
|
132 |
if __name__ == "__main__":
|
133 |
UI.launch(debug=True) #
|
|
|
9 |
completion_to_prompt,
|
10 |
)
|
11 |
|
12 |
+
def download(model):
|
13 |
+
repo_id = model_info[model]["repo_id"]
|
14 |
+
filename = model_info[model]["filename"]
|
15 |
+
|
16 |
+
model_path = hf_hub_download(
|
17 |
+
repo_id=repo_id,
|
18 |
+
filename=filename,
|
19 |
+
resume_download=True,
|
20 |
+
cache_dir=MODELS_PATH,
|
21 |
+
)
|
22 |
+
|
23 |
+
return model_path
|
24 |
+
|
25 |
+
for model_name in models:
|
26 |
+
download(model_name)
|
27 |
+
|
28 |
+
|
29 |
MODELS_PATH = "./models"
|
30 |
+
models = ["Llama-2-13B-chat", "Mistral-7B-Instruct-v0.2", "zephyr-7B-beta", "vicuna-7B-v1.5", "CodeLlama-7B","Falcon-7B-Instruct"]
|
31 |
+
model_info = {
|
32 |
+
"Llama-2-13B-chat": {
|
33 |
+
"repo_id": "TheBloke/Llama-2-13B-chat-GGUF",
|
34 |
+
"filename": "llama-2-13b-chat.Q4_K_M.gguf",
|
35 |
+
},
|
36 |
+
"Mistral-7B-Instruct-v0.2": {
|
37 |
+
"repo_id": "TheBloke/Mistral-7B-Instruct-v0.2-GGUF",
|
38 |
+
"filename": "mistral-7b-instruct-v0.2.Q4_K_M.gguf",
|
39 |
+
},
|
40 |
+
"zephyr-7B-beta": {
|
41 |
+
"repo_id": "TheBloke/zephyr-7B-beta-GGUF",
|
42 |
+
"filename": "zephyr-7b-beta.Q4_K_M.gguf",
|
43 |
+
},
|
44 |
+
"vicuna-7B-v1.5": {
|
45 |
+
"repo_id": "TheBloke/vicuna-7B-v1.5-GGUF",
|
46 |
+
"filename": "vicuna-7b-v1.5.Q4_K_M.gguf",
|
47 |
+
},
|
48 |
+
"CodeLlama-7B": {
|
49 |
+
"repo_id": "TheBloke/CodeLlama-7B-GGUF",
|
50 |
+
"filename": "codellama-7b.Q4_K_M.gguf",
|
51 |
+
},
|
52 |
+
"Falcon-7B-Instruct": {
|
53 |
+
"repo_id": "TheBloke/Falcon-7B-Instruct-GGML",
|
54 |
+
"filename": "falcon-7b-instruct.ggccv1.q4_1.bin",
|
55 |
+
},
|
56 |
+
|
57 |
+
}
|
58 |
|
59 |
mistral_model_path = hf_hub_download(
|
60 |
repo_id= "TheBloke/Mistral-7B-Instruct-v0.2-GGUF",
|
|
|
64 |
|
65 |
|
66 |
|
67 |
+
|
68 |
"""Step 3 : if you use GPU then make sure ( n_gpu_layers":1) at least 1, you can increase or decrease it based on your GPU performance"""
|
69 |
|
70 |
llm = LlamaCPP(
|
|
|
155 |
|
156 |
with gr.Blocks() as UI:
|
157 |
|
158 |
+
models=gr.Dropdown(["CodeLlama-7B","Llama-2-13B-chat","Falcon-7B-Instruct" ,"Mistral-7B-Instruct-v0.2", "zephyr-7B-beta",
|
159 |
+
"vicuna-7B-v1.5"],value=["CodeLlama-7B","Llama-2-13B-chat","Falcon-7B-Instruct", "Mistral-7B-Instruct-v0.2", "zephyr-7B-beta",
|
160 |
"vicuna-7B-v1.5"], label="please select at least one model", info="default model is Mistral-7B-Instruct-v0.2")
|
161 |
textInfo = gr.Textbox(value="current model is Mistral-7B-Instruct-v0.2",label="Model Status");
|
162 |
# Chatbot interface
|
|
|
172 |
undo_btn="Delete Previous",
|
173 |
clear_btn="Clear",
|
174 |
)
|
175 |
+
ization,inputs=[models],outputs=[textInfo])
|
176 |
|
177 |
+
models.change(fn=model_initial
|
|
|
178 |
if __name__ == "__main__":
|
179 |
UI.launch(debug=True) #
|