Spaces:
Sleeping
Sleeping
Commit
·
2144fdb
1
Parent(s):
9c9d121
Try to use pipeline
Browse files
app.py
CHANGED
|
@@ -2,19 +2,21 @@ import gradio as gr
|
|
| 2 |
import spaces
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 6 |
|
| 7 |
model_id = "AverageBusinessUser/aidapal"
|
| 8 |
filename = "aidapal-8k.Q4_K_M.gguf"
|
| 9 |
|
| 10 |
-
torch_dtype = torch.float32 # could be torch.float16 or torch.bfloat16 too
|
| 11 |
print("Downloading model")
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
@spaces.GPU
|
| 16 |
def greet(name):
|
| 17 |
-
return
|
| 18 |
|
| 19 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 20 |
demo.launch()
|
|
|
|
| 2 |
import spaces
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 6 |
|
| 7 |
model_id = "AverageBusinessUser/aidapal"
|
| 8 |
filename = "aidapal-8k.Q4_K_M.gguf"
|
| 9 |
|
|
|
|
| 10 |
print("Downloading model")
|
| 11 |
+
pipe = pipeline(task="text-generation", model_id, gguf_file=filename, device_map="auto")
|
| 12 |
+
|
| 13 |
+
#torch_dtype = torch.float32 # could be torch.float16 or torch.bfloat16 too
|
| 14 |
+
#tokenizer = AutoTokenizer.from_pretrained(model_id, gguf_file=filename)
|
| 15 |
+
#model = AutoModelForCausalLM.from_pretrained(model_id, gguf_file=filename, torch_dtype=torch_dtype)
|
| 16 |
|
| 17 |
@spaces.GPU
|
| 18 |
def greet(name):
|
| 19 |
+
return pipe(name)
|
| 20 |
|
| 21 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 22 |
demo.launch()
|