Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
|
4 |
-
# Load pre-trained
|
5 |
model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
6 |
-
tokenizer =
|
7 |
-
model =
|
8 |
|
9 |
def generate_response(message, history):
|
10 |
# Combine the conversation history with the new message
|
@@ -13,7 +13,7 @@ def generate_response(message, history):
|
|
13 |
# Tokenize input text
|
14 |
inputs = tokenizer.encode(input_text, return_tensors="pt")
|
15 |
|
16 |
-
# Generate response using
|
17 |
outputs = model.generate(inputs, max_length=50, num_return_sequences=1)
|
18 |
|
19 |
# Decode generated text
|
@@ -24,8 +24,8 @@ def generate_response(message, history):
|
|
24 |
# Create ChatInterface
|
25 |
demo = gr.ChatInterface(
|
26 |
fn=generate_response,
|
27 |
-
title="Chat with
|
28 |
-
description="A simple chatbot powered by
|
29 |
)
|
30 |
|
31 |
# Launch the app
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Load pre-trained model and tokenizer
|
5 |
model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name) # Use AutoTokenizer to automatically detect the correct tokenizer
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name) # Use AutoModelForCausalLM for causal language models
|
8 |
|
9 |
def generate_response(message, history):
|
10 |
# Combine the conversation history with the new message
|
|
|
13 |
# Tokenize input text
|
14 |
inputs = tokenizer.encode(input_text, return_tensors="pt")
|
15 |
|
16 |
+
# Generate response using the model
|
17 |
outputs = model.generate(inputs, max_length=50, num_return_sequences=1)
|
18 |
|
19 |
# Decode generated text
|
|
|
24 |
# Create ChatInterface
|
25 |
demo = gr.ChatInterface(
|
26 |
fn=generate_response,
|
27 |
+
title="Chat with DeepSeek",
|
28 |
+
description="A simple chatbot powered by DeepSeek."
|
29 |
)
|
30 |
|
31 |
# Launch the app
|