!pip install transformers datasets evaluate accelerate -q
> accelerate 는 병렬처리 등을 위한
train_dataloader = DataLoader(train_tensor, shuffle=True, batch_size=8)
eval_dataloader = DataLoader(eval_tensor, batch_size=8)
model = AutoModelForSequenceClassification.from_pretrained("bert-base-cased", num_labels=5)
optimizer = AdamW(model.parameters(), lr=5e-5)
기존에는 HuggingFace에서 Tokenizer와 Classifier를 각각 따로 불러왔어야만 했다.
그러나, 최근에는 AutoOOOO 등의 Warpper Class가 등장했는데, 이는 hugging Face의 모델명만 입력하면 자동으로 HuggingFace에 등록된 모델을 로딩하는 클래스들이다. 대표적으로, `AutoTokenizer` , `AutoModelForSequenceClassification` 등이 있다. 각각 Tokenizer와 Model에 대한 Auto Class이다.
[참조] https://medium.com/@alexmriggio/lora-low-rank-adaptation-from-scratch-code-and-theory-f31509106650
LoRA: Low-Rank Adaptation from Scratch — Code and Theory
Transformer models can have a lot of parameters which can make fine-tuning them an expensive and time-consuming endeavor that is sometimes…
medium.com
댓글 영역