Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
-
|
4 |
# TO-DD: ??? λΆλΆμ μ½λλ₯Ό μμ±νμμ€
|
5 |
-
pipeline =
|
|
|
|
|
6 |
|
7 |
-
st.title("Hot Dog? Or Not?")
|
8 |
|
9 |
-
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
col1, col2 = st.columns(2)
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
# TO-DO: ??? λΆλΆμ μ½λλ₯Ό μμ±νμμ€
|
17 |
-
predictions = pipeline(image)
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
+
|
4 |
# TO-DD: ??? λΆλΆμ μ½λλ₯Ό μμ±νμμ€
|
5 |
+
pipeline = AutoModelForCausalLM.from_pretrained(task="translation", model="maywell/Synatra-7B-v0.3-Translation", tokenizer="maywell/Synatra-7B-v0.3-Translation")
|
6 |
+
|
7 |
+
device = "cuda" # the device to load the model onto
|
8 |
|
|
|
9 |
|
10 |
+
messages = [
|
11 |
+
{"role": "user", "content": "λ°λλλ μλ νμμμ΄μΌ?"},
|
12 |
+
]
|
13 |
|
14 |
+
encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
|
|
|
15 |
|
16 |
+
model_inputs = encodeds.to(device)
|
17 |
+
model.to(device)
|
|
|
|
|
18 |
|
19 |
+
generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
|
20 |
+
decoded = tokenizer.batch_decode(generated_ids)
|
21 |
+
print(decoded[0])
|