Simonsbs commited on
Commit
f2b15c9
·
1 Parent(s): 2f79813

Refactor model loading and update response function in app.py; modify requirements.txt

Browse files
Files changed (2) hide show
  1. app.py +16 -12
  2. requirements.txt +0 -0
app.py CHANGED
@@ -1,18 +1,22 @@
 
1
  import gradio as gr
2
- from transformers import AutoModel
 
3
 
4
- # Load the quantized model
5
- model = AutoModel.from_pretrained(
6
- "TheBloke/zephyr-7B-beta-GGUF",
7
- model_type="llama",
8
- max_new_tokens=256,
9
- repetition_penalty=1.1,
10
- temperature=0.7
11
- )
12
 
13
- def chat(prompt):
14
- return model(prompt)
15
 
16
- iface = gr.Interface(fn=chat, inputs="text", outputs="text", title="SimonGPT")
 
 
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