train / app.py
MJ106's picture
Update app.py
798e894 verified
raw
history blame contribute delete
No virus
710 Bytes
import streamlit as st
from transformers import AutoModelForCausalLM
# TO-DD: ??? λΆ€λΆ„μ˜ μ½”λ“œλ₯Ό μ™„μ„±ν•˜μ‹œμ˜€
AutoModelForCausalLM = AutoModelForCausalLM.from_pretrained(task="translation", model="maywell/Synatra-7B-v0.3-Translation", tokenizer="maywell/Synatra-7B-v0.3-Translation")
device = "cuda" # the device to load the model onto
messages = [
{"role": "user", "content": "λ°”λ‚˜λ‚˜λŠ” μ›λž˜ ν•˜μ–€μƒ‰μ΄μ•Ό?"},
]
encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
model_inputs = encodeds.to(device)
model.to(device)
generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
decoded = tokenizer.batch_decode(generated_ids)
print(decoded[0])