Spaces:
Runtime error
Runtime error
File size: 866 Bytes
d9d7c3d 56ecac6 48029da 2076374 c42973a 56ecac6 91f59b7 8a9a668 4250da2 bd48d11 56ecac6 d9d7c3d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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() |