본문 바로가기

OLoRA 리뷰 PEFT 라이브러리를 보다가 LoRA의 학습을 발전시킨 OLoRA를 발견하여 리뷰해본다.기본 정보Title: OLoRA: Orthonormal Low-Rank Adaptation of LLMs저자: Kerim Büyükakyüz(Sicim AI)링크: https://arxiv.org/abs/2406.01775내용 정리요약LoRA를 구성하는 AB matrix를 pretrained 파라미터인 W matrix를 QR decomposition해서 얻은 QR matrix로 간주하였다. 여기서 Q matrix가 orthonormal 한데 이런 특성 때문에 학습의 안정성을 높이고 모델의 최종 성능을 높일 수 있었다고 한다. 제목의 Orthonormal은 이렇게 해서 얻은 matrix Q가 orthonormal하..
Accelerate + deepspeed 학습시 deepspeed config 정보 가져오기 Accelerate launch로 실행한 학습 코드 상에서 deepspeed의 config 정보들을 활용하고 싶을 때가 있어서 찾아봤다. training_args = TrainingArguments()# TrainingArguments 객체 생성 과정에서 accelerate_config.yaml, deepspeed_config.json# 정보들이 training_args에 저장된다.# accelerate_config.yaml의 deepspeed config 내용: training_args.deepspeed_plugin# deepspeed config.json 내용: training_args.deepspeed_plugin.hf_ds_config.config
Greedy decoding 사용 시 output의 일관성 Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations? 논문을 읽다가 의문이 가는 문구를 발견했다. "Greedy decoding always predicts the correct answer.""Greedy decoding sometimes (but not always) predicts the correct answer." Greedy decoding을 사용하면 동일한 input에 대해 항상 output이 같을 텐데, 왜 이런 문장을 썼을까? 물론 나도 이런 경험을 한 적이 있어서 의문이 든 김에 조사해봐야겠다고 생각했다. 다행히 검색해보니 누군가가 트윗(현재 X)을 남겼다. https://twitter.com/cwolferesearch/st..
[Transformers] IterableDatasetShard의 동작 분산학습 환경에서 IterableDataset을 사용하려고 하는데 데이터셋길이가 달라 문제가 발생한다. 보통의 경우에는 DataLoader에 drop_last=True 옵션을 주면 배치 사이즈가 다른 마지막 배치를 무시할 수 있다. [ [[0, 1, 2], [3, 4, 5], [6, 7, 8]], [[9, 10, 11], [12, 13], [14, 15]] ] 그런데 LLM을 학습할 때 배치 사이즈가 1로 학습하면 아예 배치 자체의 길이가 달라지는 경우가 생긴다. [ [[0], [1], [2]], [[3], [], [] ]
[PyTorch] IterableDataset의 split 안된다... 생각해보면 안되는 게 당연하 것 같기도...
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn LLaMA2 모델에 peft library를 통해 LoRA를 적용시키고 학습하면 위와 같은 에러가 나면서 backward()가 되지 않는다. 실제로 LoRA를 적용한 후 require_grad가 true인 파라미터들을 보면, input_embedding, lm_head에 require_grad가 false로 되어 있다. 이를 하기 위해 "model.enable_input_require_grads()"를 추가해준다. 함수에 대한 설명은 "Enables the gradients for the input embeddings. This is useful for fine-tuning adapter weights while keeping the model weights fixed." 이다. 코드를 살펴보면, inp..
LLaMA2 LoRA 적용과 tokenizer의 padding_side LLaMa2에 LoRA를 적용해보고 있는데, 이상하게 loss가 NaN이 되면서 학습이 되지 않았다. 이래저라 검색을 해보다가 우연히 어떤 블로그 글에서 tokenizer의 padding_side를 "right"로 바꾸는 걸 보고 적용해봤다. 불러온 LLaMa2 모델의 tokenizer의 기본 padding_side가 "left"로 되어 있었고, "right"로 바꿔준 뒤 학습했더니 loss가 잘 떨어졌다.
NotImplementedError: Cannot copy out of meta tensor; no data! Accelerate library 환경에서 FSDP를 이용해 distributed learning을 해보고 있는 중에 "NotImplementedError: Cannot copy out of meta tensor; no data!" 에러가 나서 해결 방안을 찾아봤다. 해결 방안: config 파일의 "fsdp_cpu_ram_efficient_loading" 값을 false로 하면 된다. 참고 링크: https://github.com/huggingface/transformers/issues/26510