Edit model card

t5-base-korean-summarization

This is T5 model for korean text summarization.

Usage (HuggingFace Transformers)

import nltk
nltk.download('punkt')
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

model = AutoModelForSeq2SeqLM.from_pretrained('eenzeenee/t5-base-korean-summarization')
tokenizer = AutoTokenizer.from_pretrained('eenzeenee/t5-base-korean-summarization')

prefix = "summarize: "
sample = """
    μ•ˆλ…•ν•˜μ„Έμš”? 우리 (2ν•™λ…„)/(이 ν•™λ…„) μΉœκ΅¬λ“€ 우리 μΉœκ΅¬λ“€ 학ꡐ에 κ°€μ„œ μ§„μ§œ (2ν•™λ…„)/(이 ν•™λ…„) 이 되고 μ‹Άμ—ˆλŠ”λ° 학ꡐ에 λͺ» κ°€κ³  μžˆμ–΄μ„œ λ‹΅λ‹΅ν•˜μ£ ? 
    κ·Έλž˜λ„ 우리 μΉœκ΅¬λ“€μ˜ μ•ˆμ „κ³Ό 건강이 μ΅œμš°μ„ μ΄λ‹ˆκΉŒμš” μ˜€λŠ˜λΆ€ν„° μ„ μƒλ‹˜μ΄λž‘ 맀일 맀일 κ΅­μ–΄ 여행을 λ– λ‚˜λ³΄λ„λ‘ ν•΄μš”. 
    μ–΄/ μ‹œκ°„μ΄ 벌써 μ΄λ ‡κ²Œ λλ‚˜μš”? λŠ¦μ—ˆμ–΄μš”. λŠ¦μ—ˆμ–΄μš”. 빨리 κ΅­μ–΄ 여행을 λ– λ‚˜μ•Ό λΌμš”. 
    그런데 μ–΄/ ꡭ어여행을 λ– λ‚˜κΈ° 전에 μš°λ¦¬κ°€ 쀀비물을 챙겨야 되겠죠? κ΅­μ–΄ 여행을 λ– λ‚  μ€€λΉ„λ¬Ό, κ΅μ•ˆμ„ μ–΄λ–»κ²Œ 받을 수 μžˆλŠ”μ§€ μ„ μƒλ‹˜μ΄ μ„€λͺ…을 ν•΄μ€„κ²Œμš”. 
    (EBS)/(μ΄λΉ„μ—μŠ€) μ΄ˆλ“±μ„ κ²€μƒ‰ν•΄μ„œ λ“€μ–΄κ°€λ©΄μš” 첫화면이 μ΄λ ‡κ²Œ λ‚˜μ™€μš”. 
    자/ κ·ΈλŸ¬λ©΄μš” μ—¬κΈ° (X)/(μ—‘μŠ€) 눌러주(κ³ μš”)/(κ΅¬μš”). μ €κΈ° (동그라미)/(λ˜₯그라미) (EBS)/(μ΄λΉ„μ—μŠ€) (2μ£Ό)/(이 μ£Ό) λΌμ΄λΈŒνŠΉκ°•μ΄λΌκ³  λ˜μ–΄μžˆμ£ ? 
    κ±°κΈ°λ₯Ό λ°”λ‘œ κ°€κΈ°λ₯Ό λˆ„λ¦…λ‹ˆλ‹€. 자/ (λˆ„λ₯΄λ©΄μš”)/(눌λ₯΄λ©΄μš”). μ–΄λ–»κ²Œ λ˜λƒ? b/ λ°‘μœΌλ‘œ λ‚΄λ €μš” λ‚΄λ €μš” λ‚΄λ €μš” μ­‰ λ‚΄λ €μš”. 
    우리 λͺ‡ 학년이죠? μ•„/ (2ν•™λ…„)/(이 ν•™λ…„) 이죠 (2ν•™λ…„)/(이 ν•™λ…„)의 무슨 κ³Όλͺ©? κ΅­μ–΄. 
    μ΄λ²ˆμ£ΌλŠ” (1μ£Ό)/(일 μ£Ό) μ°¨λ‹ˆκΉŒμš” μ—¬κΈ° κ΅μ•ˆ. λ‹€μŒμ£ΌλŠ” μ—¬κΈ°μ„œ λ‹€μš΄μ„ λ°›μœΌλ©΄ λΌμš”. 
    이 κ΅μ•ˆμ„ 클릭을 ν•˜λ©΄, μ§œμž”/. μ΄λ ‡κ²Œ κ΅μž¬κ°€ λ‚˜μ˜΅λ‹ˆλ‹€ .이 κ΅μ•ˆμ„ (λ‹€μš΄)/(λ”°μš΄)λ°›μ•„μ„œ 우리 ꡭ어여행을 λ– λ‚  μˆ˜κ°€ μžˆμ–΄μš”. 
    그럼 우리 μ§„μ§œλ‘œ κ΅­μ–΄ 여행을 ν•œλ²ˆ λ– λ‚˜λ³΄λ„λ‘ ν•΄μš”? κ΅­μ–΄μ—¬ν–‰ 좜발. 자/ (1단원)/(일 단원) 제λͺ©μ΄ λ­”κ°€μš”? ν•œλ²ˆ μ°Ύμ•„λ΄μš”. 
    μ‹œλ₯Ό μ¦κ²¨μš” μ—μš”. κ·Έλƒ₯ μ‹œλ₯Ό μ½μ–΄μš” κ°€ μ•„λ‹ˆμ—μš”. μ‹œλ₯Ό 즐겨야 λΌμš” 즐겨야 돼. μ–΄λ–»κ²Œ 즐길까? 일단은 λ‚΄λ‚΄ μ‹œλ₯Ό μ¦κΈ°λŠ” 방법에 λŒ€ν•΄μ„œ 곡뢀λ₯Ό ν•  κ±΄λ°μš”. 
    그럼 μ˜€λŠ˜μ€μš” μ–΄λ–»κ²Œ μ¦κΈΈκΉŒμš”? 였늘 곡뢀할 λ‚΄μš©μ€μš” μ‹œλ₯Ό μ—¬λŸ¬ 가지 λ°©λ²•μœΌλ‘œ 읽기λ₯Ό κ³΅λΆ€ν• κ²λ‹ˆλ‹€. 
    μ–΄λ–»κ²Œ μ—¬λŸ¬κ°€μ§€ λ°©λ²•μœΌλ‘œ μ½μ„κΉŒ 우리 곡뢀해 보도둝 ν•΄μš”. 였늘의 μ‹œ λ‚˜μ™€λΌ μ§œμž”/! μ‹œκ°€ λ‚˜μ™”μŠ΅λ‹ˆλ‹€ μ‹œμ˜ 제λͺ©μ΄ λ­”κ°€μš”? λ‹€νˆ° λ‚ μ΄μ—μš” λ‹€νˆ° λ‚ . 
    λˆ„κ΅¬λž‘ λ‹€ν‰œλ‚˜ λ™μƒμ΄λž‘ λ‹€ν‰œλ‚˜ μ–Έλ‹ˆλž‘ μΉœκ΅¬λž‘? λˆ„κ΅¬λž‘ λ‹€ν‰œλŠ”μ§€ μ„ μƒλ‹˜μ΄ μ‹œλ₯Ό 읽어 쀄 ν…Œλ‹ˆκΉŒ ν•œλ²ˆ 생각을 해보도둝 ν•΄μš”."""

inputs = [prefix + sample]


inputs = tokenizer(inputs, max_length=512, truncation=True, return_tensors="pt")
output = model.generate(**inputs, num_beams=3, do_sample=True, min_length=10, max_length=64)
decoded_output = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
result = nltk.sent_tokenize(decoded_output.strip())[0]

print('RESULT >>', result)

RESULT >> κ΅­μ–΄ 여행을 λ– λ‚˜κΈ° 전에 κ΅­μ–΄ 여행을 λ– λ‚  μ€€λΉ„λ¬Όκ³Ό κ΅μ•ˆμ„ μ–΄λ–»κ²Œ 받을 수 μžˆλŠ”μ§€ μ„ μƒλ‹˜μ΄ μ„€λͺ…ν•΄ μ€€λ‹€.

Evalutation Result

  • Korean Paper Summarization Dataset(λ…Όλ¬Έμžλ£Œ μš”μ•½)
    ROUGE-2-R 0.09868624890432466
    ROUGE-2-P 0.9666714545849712
    ROUGE-2-F 0.17250881441169427
    
  • Korean Book Summarization Dataset(λ„μ„œμžλ£Œ μš”μ•½)
    ROUGE-2-R 0.1575686156943213
    ROUGE-2-P 0.9718318136896944
    ROUGE-2-F 0.26548116834852586
    
  • Korean Summary statement and Report Generation Dataset(μš”μ•½λ¬Έ 및 레포트 생성 데이터)
    ROUGE-2-R 0.0987891733555808
    ROUGE-2-P 0.9276946867981899
    ROUGE-2-F 0.17726493110448185
    

Training

The model was trained with the parameters:

  • training arguments
Seq2SeqTrainingArguments(
    per_device_train_batch_size=8,
    per_device_eval_batch_size=8,
    auto_find_batch_size=False,
    weight_decay=0.01,
    learning_rate=4e-05,
    lr_scheduler_type=linear,
    num_train_epochs=3,
    fp16=True)

Model Architecture

T5ForConditionalGeneration(                                                                                                                                             
  (shared): Embedding(50358, 768)                                                                                                                                       
  (encoder): T5Stack(                                                                                                                                                   
    (embed_tokens): Embedding(50358, 768)                                                                                                                               
    (block): ModuleList(                                                                                                                                                
      (0): T5Block(                                                                                                                                                     
        (layer): ModuleList(                                                                                                                                            
          (0): T5LayerSelfAttention(                                                                                                                                    
            (SelfAttention): T5Attention(                                                                                                                               
              (q): Linear(in_features=768, out_features=768, bias=False)
              (k): Linear(in_features=768, out_features=768, bias=False)
              (v): Linear(in_features=768, out_features=768, bias=False)
              (o): Linear(in_features=768, out_features=768, bias=False)
              (relative_attention_bias): Embedding(32, 12)
            )        
            (layer_norm): T5LayerNorm()  
            (dropout): Dropout(p=0.1, inplace=False)
          )        
          (1): T5LayerFF(   
            (DenseReluDense): T5DenseGatedActDense(
              (wi_0): Linear(in_features=768, out_features=2048, bias=False)
              (wi_1): Linear(in_features=768, out_features=2048, bias=False)
              (wo): Linear(in_features=2048, out_features=768, bias=False)
              (dropout): Dropout(p=0.1, inplace=False)
              (act): NewGELUActivation()
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
        )
      )
      (1~11): T5Block(
        (layer): ModuleList(
          (0): T5LayerSelfAttention(
            (SelfAttention): T5Attention(
              (q): Linear(in_features=768, out_features=768, bias=False)
              (k): Linear(in_features=768, out_features=768, bias=False)
              (v): Linear(in_features=768, out_features=768, bias=False)
              (o): Linear(in_features=768, out_features=768, bias=False)
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
          (1): T5LayerFF(
            (DenseReluDense): T5DenseGatedActDense(
              (wi_0): Linear(in_features=768, out_features=2048, bias=False)
              (wi_1): Linear(in_features=768, out_features=2048, bias=False)
              (wo): Linear(in_features=2048, out_features=768, bias=False)
              (dropout): Dropout(p=0.1, inplace=False)
              (act): NewGELUActivation()
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
        )
      )
    )
    (final_layer_norm): T5LayerNorm()
    (dropout): Dropout(p=0.1, inplace=False)
  )
  (decoder): T5Stack(
    (embed_tokens): Embedding(50358, 768)
    (block): ModuleList(
      (0): T5Block(
        (layer): ModuleList(
          (0): T5LayerSelfAttention(
            (SelfAttention): T5Attention(
              (q): Linear(in_features=768, out_features=768, bias=False)
              (k): Linear(in_features=768, out_features=768, bias=False)
              (v): Linear(in_features=768, out_features=768, bias=False)
              (o): Linear(in_features=768, out_features=768, bias=False)
              (relative_attention_bias): Embedding(32, 12)
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
          (1): T5LayerCrossAttention(
            (EncDecAttention): T5Attention(
              (q): Linear(in_features=768, out_features=768, bias=False)
              (k): Linear(in_features=768, out_features=768, bias=False)
              (v): Linear(in_features=768, out_features=768, bias=False)
              (o): Linear(in_features=768, out_features=768, bias=False)
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
          (2): T5LayerFF(
            (DenseReluDense): T5DenseGatedActDense(
              (wi_0): Linear(in_features=768, out_features=2048, bias=False)
              (wi_1): Linear(in_features=768, out_features=2048, bias=False)
              (wo): Linear(in_features=2048, out_features=768, bias=False)
              (dropout): Dropout(p=0.1, inplace=False)
              (act): NewGELUActivation()
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
        )
      )
      (1~11): T5Block(
        (layer): ModuleList(
          (0): T5LayerSelfAttention(
            (SelfAttention): T5Attention(
              (q): Linear(in_features=768, out_features=768, bias=False)
              (k): Linear(in_features=768, out_features=768, bias=False)
              (v): Linear(in_features=768, out_features=768, bias=False)
              (o): Linear(in_features=768, out_features=768, bias=False)
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
          (1): T5LayerCrossAttention(
            (EncDecAttention): T5Attention(
              (q): Linear(in_features=768, out_features=768, bias=False)
              (k): Linear(in_features=768, out_features=768, bias=False)
              (v): Linear(in_features=768, out_features=768, bias=False)
              (o): Linear(in_features=768, out_features=768, bias=False)
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
          (2): T5LayerFF(
            (DenseReluDense): T5DenseGatedActDense(
              (wi_0): Linear(in_features=768, out_features=2048, bias=False)
              (wi_1): Linear(in_features=768, out_features=2048, bias=False)
              (wo): Linear(in_features=2048, out_features=768, bias=False)
              (dropout): Dropout(p=0.1, inplace=False)
              (act): NewGELUActivation()
            )
            (layer_norm): T5LayerNorm()
            (dropout): Dropout(p=0.1, inplace=False)
          )
        )
      )
      (final_layer_norm): T5LayerNorm()                              
    (dropout): Dropout(p=0.1, inplace=False)                                                                                           
  )                                                                
  (lm_head): Linear(in_features=768, out_features=50358, bias=False)                                                                   
)

Citation

  • Raffel, Colin, et al. "Exploring the limits of transfer learning with a unified text-to-text transformer." J. Mach. Learn. Res. 21.140 (2020): 1-67.
Downloads last month
1,204
Safetensors
Model size
276M params
Tensor type
F32
Β·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Model tree for eenzeenee/t5-base-korean-summarization

Finetunes
2 models