Spaces:
Runtime error
Runtime error
Satyam-Singh
commited on
Commit
•
8562d5d
1
Parent(s):
0a12784
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
|
4 |
-
# Load the
|
5 |
model_name = "lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF"
|
6 |
-
|
|
|
7 |
|
8 |
-
# Define the
|
9 |
def generate_text(prompt):
|
10 |
-
|
11 |
-
|
|
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
19 |
)
|
20 |
|
21 |
# Launch the Gradio app
|
22 |
-
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Load the GGUF model and tokenizer
|
5 |
model_name = "lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
|
9 |
+
# Define a function to generate text using the GGUF model
|
10 |
def generate_text(prompt):
|
11 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt")
|
12 |
+
outputs = model.generate(inputs, max_length=50)
|
13 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
14 |
|
15 |
+
# Create a Gradio chatbot interface
|
16 |
+
chatbot = gr.Chatbot(
|
17 |
+
generate_text,
|
18 |
+
title="GGUF Chatbot",
|
19 |
+
description="Talk to the GGUF model!",
|
20 |
+
width=800,
|
21 |
+
height=600,
|
22 |
)
|
23 |
|
24 |
# Launch the Gradio app
|
25 |
+
chatbot.launch()
|