import gradio as gr import spaces from transformers import AutoTokenizer, AutoModelForCausalLM import torch tokenizer = AutoTokenizer.from_pretrained("BirdL/DeepSeek-Coder-V2-Lite-Instruct-FlashAttnPatch", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("BirdL/DeepSeek-Coder-V2-Lite-Instruct-FlashAttnPatch", trust_remote_code=True, device_map="auto", torch_dtype=torch.float16) @spaces.GPU def respond(message, history): inputs = tokenizer(message, return_tensors="pt").input_ids.to("cuda") outputs = model.generate(inputs, max_new_tokens=224, do_sample=False, top_k=50, top_p=0.95, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id) ouputs = (tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True)) return outputs demo = gr.ChatInterface(respond) if __name__ == "__main__": demo.launch()