-
06_summarization.ipynbtransformer 2024. 8. 7. 16:09
출처
https://product.kyobobook.co.kr/detail/S000200330771아래그림 설명
출처:
BLEU
출처: https://wikidocs.net/31695
BLEU
모델의 out에서 n-gram으로 따져봤을때 정답에 얼마나 많이 포함되있느냐를 precision의 개념
모델이 생성한 candidate에서의 ngram들이 reference에서 얼마나 많이 포함되있느냐를 precision의 개념
수치적으로 정확도계산
번역이나 요약을 했을때 평가할수 있는 지표
y=e^x
아래그림)
candidate = prediction
reference = 정답
모델이 내놓은 prediction 의 너무 짧으면(the the the the 가아니고 the하나만 있으면 너무짧음) 안되니까 BP를 곱함
penalty를 곱함
import pandas as pd import numpy as np bleu_metric.add( prediction="the the the the the the", reference=["the cat is on the mat"]) results = bleu_metric.compute(smooth_method="floor", smooth_value=0) results["precisions"] = [np.round(p, 2) for p in results["precisions"]] pd.DataFrame.from_dict(results, orient="index", columns=["Value"])
아래그림
bigram일때 candidate의 on mat이 reference에 없으니까
bigram일때
prediction : the cat, cat is, is on , on mat (연속된 두개) ->4개 total
이중 reference에 들어간것은 the cat, cat is, is on -> 3개 counts
precision: 3/4 = 0.75
아래그림
BLEU, ROUGE차이
출처: https://jrc-park.tistory.com/273
BLEU - 번역작업에 많이 쓰고
- candidate가 reference에 있는갯수
ROUGE - 요약에 많이쓰임
- reference가 candidate에 있는갯수
아래그림)
gpt2는 요약작업에서 pretrain만 되어있어서 finetuning된 bart, pegasus 가 훨씬 요약 잘해서 rouge score 가 높다.
아래그림)
batch size로 제일 긴 max length를 정해서 짧은건 패딩붙이고 기준보다 긴거는 자른다.
'transformer' 카테고리의 다른 글
08_model-compression.ipynb (0) 2024.08.26 07_question-answering_v2.ipynb (0) 2024.08.16 05_text-generation.ipynb (0) 2024.07.31 04_multilingual-ner.ipynb (0) 2024.07.26 03_transformer 파해치기 https://nlpinkorean.github.io/illustrated-transformer/ (0) 2024.07.12