sufian7755 commited on
Commit
1406ec8
·
verified ·
1 Parent(s): 75b365e

import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM

# Load the DeepSeek-R1 model
model_name = "deepseek-ai/DeepSeek-R1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

# Function for chatting
def chat_with_ai(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response

# Gradio interface
ui = gr.Interface(
fn=chat_with_ai,
inputs=gr.Textbox(label="Ask me anything..."),
outputs="text",
title="💬 DeepSeek-R1 AI",
description="Chat with your own DeepSeek-R1 model hosted on Hugging Face!"
)

ui.launch()

Files changed (1) hide show
  1. app.py +1 -0
app.py ADDED
@@ -0,0 +1 @@
 
 
1
+