BERT (3) 썸네일형 리스트형 BERT 사전학습 모형에 대한 미세조정학습 (3) 15.3 파이토치를 이용한 미세조정학습 del model del trainer torch.cuda.empty_cache() from torch.utils.data import DataLoader train_loader = DataLoader(train_dataset, shuffle=True, batch_size=8) from transformers import BertModel bert_model = BertModel.from_pretrained('bert-base-uncased') # BERT를 포함한 신경망 모형 class MyModel(torch.nn.Module): def __init__(self, pretrained_model, token_size, num_labels): super(MyMode.. BERT의 이해와 간단한 활용 (2) 14.4 사전학습된 BERT 모형의 직접 사용방법 pip install transformers from transformers import pipeline clf = pipeline("sentiment-analysis") result = clf("what a beautiful day!")[0] print("감성분석 결과: %s, 감성스코어: %0.4f" % (result['label'], result['score'])) """ 감성분석 결과: POSITIVE, 감성스코어: 0.9999 """ from transformers import pipeline text_generator = pipeline("text-generation") result = text_generator("Alice was beginn.. BERT의 이해와 간단한 활용 (1) 14.1 왜 언어 모델이 중요한가? 언어 모델: 문장 혹은 단어의 시퀀스에 대해 확률을 할당하는 모델 GPT(Generative Pre-trained Transformer)가 언어 모델로 학습한 대표적인 모형 14.2 BERT의 구조 BERT는 언어 모델 기반의 학습을 이용해 언어에 대한 이해를 높이는 데 목적이 있음 GPT가 단방향 혹은 순방향으로만 셀프 어텐션만 사용하는 것에 비해 BERT는 양방향 셀프 어텐션을 모두 활용할 수 있음 14.3 언어모델을 이용한 사전학습과 미세조정학습 사전학습: 언어에 대한 이해를 높이기 위한 비지도학습 미세조정학습: 실제 수행하고자 하는 작업에 대한 지도학습 BERT는 'masking', 단어를 가리고, 가린 단어를 예측하게 하는 것으로 언어 모델을 학습 BERT에서.. 이전 1 다음