Spaces:
Runtime error
Runtime error
File size: 1,009 Bytes
8cc1f9a fde5a4a dca0cf9 633c1bf fde5a4a 633c1bf fde5a4a 55be32f dca0cf9 fde5a4a fef6bc2 fde5a4a 7514661 fde5a4a 7514661 94082cb b1ce122 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import gradio as gr
import torch
# from transformers import pipeline
import huggingface_hub
import os
hf_token = os.getenv('HF_TOKEN')
huggingface_hub.login(token=hf_token)
model_id = "meta-llama/Llama-3.2-3B-Instruct"
messages = [
{"role": "user", "content": "Who are you?"},
]
# device = "cuda" if torch.cuda.is_available() else "cpu"
# pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1", trust_remote_code=True, device=device)
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1", trust_remote_code=True)
messages = [
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
{"role": "user", "content": "Who are you?"},
]
def model(params):
outputs = pipe(
messages,
max_new_tokens=256,
)
output = outputs[0]["generated_text"][-1]
print(output)
return output
app = gr.Interface(fn=model, inputs="textbox", outputs="textbox")
app.launch() |