KoBART ๊ธฐ๋ฐ ํ๊ตญ์ด ์ฌ๋ญ ๋ฒ์ญ๊ธฐ
์ด ๋ชจ๋ธ์ KoBART๋ฅผ ํ์ธํ๋ํ์ฌ ํ๊ตญ์ด ๋น์์ด๋ฅผ ํ์ค์ด๋ก ๋ฒ์ญํด์ฃผ๋ ๋ฒ์ญ๊ธฐ์ ๋๋ค.
์ฌ์ฉํ ๋ชจ๋ธ
๋ฐ์ดํฐ์
AI Hub์ ํ ์คํธ ์ค๋ฆฌ๊ฒ์ฆ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ์์ต๋๋ค.
์ฌ์ฉ ์์
Input Text: ์ผ์ด ๋ฏธ์น๋์ ๊บผ์ ธ
Generated Text: ์ด๋ฐ, ์ ๋ฐ ๊ทธ๋ง ์ข ํด์ค.
ํ์ต ์ธ๋ถ์ ๋ณด
ํ์ดํผ ํ๋ผ๋ฏธํฐ(๋ฏธ์)
training_args = TrainingArguments(
)
ํ์ต ํ๊ฒฝ
โข GPU: NVIDIA RTX A5000
โข ํ์ต ์๊ฐ: ์ฝ 3์๊ฐ
ํ์ต ๊ฒฐ๊ณผ (๋ฏธ์)
| Step | Training Loss | Validation Loss |
|---|---|---|
| 0 | 0. | 0.0 |
์ฌ์ฉ ๋ฐฉ๋ฒ
๋ชจ๋ธ์ ์ ๋ ฅ ๋ฌธ์ฅ์ ์์ ๋ฐ๋์
[์ํ]ํ ํฐ์ ๋ถ์ฌ์ผ ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํฉ๋๋ค.
import torch
from transformers import BartForConditionalGeneration, PreTrainedTokenizerFast
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = BartForConditionalGeneration.from_pretrained("heloolkjdasklfjlasdf/slang-kobart").to(device)
tokenizer = PreTrainedTokenizerFast.from_pretrained("heloolkjdasklfjlasdf/slang-kobart")
model.eval()
def refine_text(text):
input_text = "[์ํ] " + text
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
with torch.no_grad():
output = model.generate(
input_ids=input_ids,
max_length=128,
num_beams=5,
early_stopping=True
)
return tokenizer.decode(output[0], skip_special_tokens=True)
# โ
ํ
์คํธ ์์
print("๐งจ ์๋ฌธ:", "์ผ์ด ๋ฏธ์น๋์ ๊บผ์ ธ")
print("โ
์ํ:", refine_text("์ผ์ด ๋ฏธ์น๋์ ๊บผ์ ธ"))
- Downloads last month
- 5
Model tree for heloolkjdasklfjlasdf/slang-kobart
Base model
gogamza/kobart-base-v1