Download app.py from MJ106/train: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/spaces/MJ106/train/resolve/main/app.py
- Command line
-
hf download hf://spaces/MJ106/train/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MJ106/train/resolve/main/app.py
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]) |