Spaces:
Runtime error
Runtime error
File size: 821 Bytes
3722f7b 46634ed 3722f7b 46634ed |
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 |
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = 'deepseek-ai/deepseek-coder-33b-instruct'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
def call_llm(input_text):
input_ids = tokenizer.encode(input_text, return_tensors="pt")
kwargs = {
"max_length": 500,
"num_return_sequences": 1,
"temperature": 0.7,
"top_k": 50
}
# Generate text
output_ids = model.generate(input_ids, **kwargs)
# Decode and print the output
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
print(output_text)
return output_text
with gr.Blocks() as app:
chat = gr.ChatInterface(
call_llm,
)
app.launch()
|