Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -54,7 +54,8 @@ import json
|
|
| 54 |
import torch
|
| 55 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 56 |
|
| 57 |
-
model_id = "yanolja/YanoljaNEXT-Rosetta-4B"
|
|
|
|
| 58 |
model = AutoModelForCausalLM.from_pretrained(
|
| 59 |
model_id,
|
| 60 |
dtype=torch.bfloat16,
|
|
@@ -97,9 +98,20 @@ messages = [
|
|
| 97 |
]
|
| 98 |
|
| 99 |
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
-
|
| 103 |
input_length = inputs["input_ids"].shape[1]
|
| 104 |
|
| 105 |
with torch.inference_mode():
|
|
@@ -112,7 +124,6 @@ generated_tokens = outputs[0][input_length:]
|
|
| 112 |
translation = tokenizer.decode(generated_tokens, skip_special_tokens=True)
|
| 113 |
|
| 114 |
print(json.dumps(json.loads(translation), indent=2, ensure_ascii=False))
|
| 115 |
-
|
| 116 |
# {
|
| 117 |
# "company_name": "μΌλμλ₯μ€νΈ",
|
| 118 |
# "description": "μΌλμλ₯μ€νΈλ κΈλ‘λ² μ¬ν μ°μ
μ μ΅μ²¨λ¨ κΈ°μ μ μ 곡νλ νμ¬μ
λλ€."
|
|
|
|
| 54 |
import torch
|
| 55 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 56 |
|
| 57 |
+
# model_id = "yanolja/YanoljaNEXT-Rosetta-4B"
|
| 58 |
+
model_id = "/data/nas-2/seungduk/eeve2/babel/datasets/gemma-3-4b-rosetta-revision4-stage2"
|
| 59 |
model = AutoModelForCausalLM.from_pretrained(
|
| 60 |
model_id,
|
| 61 |
dtype=torch.bfloat16,
|
|
|
|
| 98 |
]
|
| 99 |
|
| 100 |
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 101 |
+
print(prompt)
|
| 102 |
+
# <bos><start_of_turn>instruction
|
| 103 |
+
# Translate the user's text to Korean.
|
| 104 |
+
# Context: Simple introduction about a tech company.
|
| 105 |
+
# Tone: Informative and helpful
|
| 106 |
+
# Glossary:
|
| 107 |
+
# - Yanolja NEXT -> μΌλμλ₯μ€νΈ
|
| 108 |
+
# - travel industry -> μ¬ν μ°μ
|
| 109 |
+
# Provide the final translation immediately without any other text.<end_of_turn>
|
| 110 |
+
# <start_of_turn>source
|
| 111 |
+
# {"company_name": "Yanolja NEXT", "description": "Yanolja NEXT is a company that provides cutting-edge technology for the global travel industry."}<end_of_turn>
|
| 112 |
+
# <start_of_turn>translation
|
| 113 |
|
| 114 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 115 |
input_length = inputs["input_ids"].shape[1]
|
| 116 |
|
| 117 |
with torch.inference_mode():
|
|
|
|
| 124 |
translation = tokenizer.decode(generated_tokens, skip_special_tokens=True)
|
| 125 |
|
| 126 |
print(json.dumps(json.loads(translation), indent=2, ensure_ascii=False))
|
|
|
|
| 127 |
# {
|
| 128 |
# "company_name": "μΌλμλ₯μ€νΈ",
|
| 129 |
# "description": "μΌλμλ₯μ€νΈλ κΈλ‘λ² μ¬ν μ°μ
μ μ΅μ²¨λ¨ κΈ°μ μ μ 곡νλ νμ¬μ
λλ€."
|