Refactor model loading and update response function in app.py; modify requirements.txt
Browse files- app.py +16 -12
- requirements.txt +0 -0
app.py
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
max_new_tokens=256,
|
| 9 |
-
repetition_penalty=1.1,
|
| 10 |
-
temperature=0.7
|
| 11 |
-
)
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
iface.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
+
from ctransformers import AutoModelForCausalLM
|
| 5 |
|
| 6 |
+
# Download the model
|
| 7 |
+
repo_id = "TheBloke/zephyr-7b-beta-GGUF"
|
| 8 |
+
filename = "zephyr-7b-beta.Q4_K_S.gguf"
|
| 9 |
+
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Load the model
|
| 12 |
+
llm = AutoModelForCausalLM.from_pretrained(model_path, model_type='llama')
|
| 13 |
|
| 14 |
+
# Define the response function
|
| 15 |
+
def respond(prompt):
|
| 16 |
+
return llm(prompt)
|
| 17 |
|
| 18 |
+
# Create the Gradio interface
|
| 19 |
+
iface = gr.Interface(fn=respond, inputs="text", outputs="text", title="SimonGPT")
|
| 20 |
+
|
| 21 |
+
# Launch the app
|
| 22 |
iface.launch()
|
requirements.txt
CHANGED
|
Binary files a/requirements.txt and b/requirements.txt differ
|
|
|