Spaces:
No application file
No application file
File size: 701 Bytes
54e8c3e fbfc910 54e8c3e c3f5ae6 fbfc910 c3f5ae6 fbfc910 c3f5ae6 fbfc910 c3f5ae6 fbfc910 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load the model and tokenizer from Hugging Face
model_name = "deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Define a function to generate text from the model
def generate_text(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(inputs["input_ids"], max_length=50)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# Create the Gradio interface
iface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
# Launch the app
iface.launch()
|