Spaces:
Sleeping
Sleeping
File size: 1,121 Bytes
1df04ca 12edf30 1df04ca 7f2ecf4 1df04ca 05cacf9 1df04ca e342ee2 1df04ca |
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
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
TOKENIZER_REPO = "MediaTek-Research/Breeze-7B-Instruct-v1_0"
tokenizer = AutoTokenizer.from_pretrained(TOKENIZER_REPO,local_files_only=False,use_fast=True,force_download=True)
model = AutoModelForCausalLM.from_pretrained(
TOKENIZER_REPO,
device_map="auto",
local_files_only=True,
torch_dtype=torch.bfloat16,
)
def generate(text):
chat_data = []
text = text.strip()
if text:
chat_data.append({"role": "system", "content": text})
outputs = model.generate(tokenizer.apply_chat_template(chat, return_tensors="pt"),
max_new_tokens=128,
top_p=0.01,
top_k=85,
repetition_penalty=1.1,
temperature=0.01)
print(tokenizer.decode(outputs[0]))
return tokenizer.decode(outputs[0])
gradio_app = gr.Interface(
generate,
inputs=gr.Text(),
outputs=gr.Text(),
title="test",
)
if __name__ == "__main__":
gradio_app.launch() |