학습 도구의 설정 이름을 읽으며 남긴 메모다. dataclass 이름과 기본값은 원문 작성 당시 기록이며 특정 버전의 완성된 설정 파일이 아니다. 실제 사용 전 해당 패키지의 schema와 도움말을 대조한다. 아래 수치는 권장 기본값으로 제공하지 않는다.
모델과 토크나이저: ModelArguments
- model_name_or_path : Path to the model weight or identifier from huggingface.co/models or modelscope.cn/models.
- adapter_name_or_path : Path to the adapter weight or identifier from huggingface.co/models.
- cache_dir : Where to store the pre-trained models downloaded from huggingface.co or modelscope.cn.
- use_fast_tokenizer : Whether or not to use one of the fast tokenizer (backed by the tokenizers library).
fast tokenizer는 주로 Rust 기반 tokenizers 구현을 사용하는 선택지다. 모델별 tokenizer의 지원과 처리 결과를 확인한다. 모든 입력에서 메모리나 속도가 항상 우수하다고 보장하지 않는다.
- resize_vocab : Whether or not to resize the tokenizer vocab and the embedding layers.
vocabulary와 임베딩 행 수를 맞추는 작업이다. 새 토큰을 추가했다면 모델의 임베딩 크기도 맞춘다. embedding resize가 기존 tokenizer의 토큰 문자열을 자동 제거하는 기능과 같지는 않다.
- split_special_tokens : Whether or not the special tokens should be split during the tokenization process.
split_special_tokens는 special token을 구성 문자·하위 토큰으로 나누어 처리할지에 관한 tokenizer 옵션이다. 위치 정보 보존 옵션으로 해석하지 않는다.
- model_revision : The specific model version to use (can be a branch name, tag name or commit id).
- quantization_bit : The number of bits to quantize the model.
- quantization_type : Quantization data type to use in int4 training.
- double_quantization : Whether or not to use double quantization in int4 training.
- shift_attn : Enable shift short attention (S^2-Attn) proposed by LongLoRA.
1. 입력 시퀀스를 겹치는 여러 개의 작은 windows로 나눕니다.
2. 각 윈도우 내에서는 기존 Transformer처럼 모든 위치 쌍에 대한 attention을 계산합니다.
3. windows간에는 attention을 일부만 계산하고, 나머지는 이전 layer로부터 가져옵니다.
4. 이를 통해 전체 시퀀스에 대한 attention을 근사적으로 계산할 수 있습니다.- Flash_attention2 : The attention calculation is performed by dividing it into small chunks that fit the memory, and this is calculated in parallel. This allows fast and memory-efficient attention calculations even for long sequences.
1. 입력 시퀀스를 작은 chunk로 나눕니다.
2. 각 chunk 내에서는 기존 방식과 동일하게 주의력을 계산합니다.
3. FlashAttention은 attention을 근사하지 않습니다. 타일링과 메모리 접근, 병렬화 방식을 개선하는 정확한 attention 구현입니다.
4. 이 과정을 병렬로 수행하여 계산 속도를 높입니다.- use_unsloth : Whether or not to use unsloth's optimization for the LoRA training.
- hf_hub_token : Auth token to log in with Hugging Face Hub.
- export_dir : Path to the directory to save the exported model.
- export_size : The file shard size (in GB) of the exported model.
- export_quantization_bit : The number of bits to quantize the exported model.
- export_quantization_dataset : Path to the dataset or dataset name to use in quantizing the exported model.
- export_quantization_nsamples : The number of samples used for quantization.
- export_quantization_maxlen : The maximum length of the model inputs used for quantization.
- export_legacy_format : Whether or not to save the .bin files instead of .safetensors.
- export_hub_model_id : The name of the repository if push the model to the Hugging Face hub.
데이터 처리: DataArguments
- dataset : The name of provided dataset(s) to use. Use commas to separate multiple datasets.
- split : Which dataset split to use for training and evaluation.
- cutoff_len : The maximum length of the model inputs after tokenization.
- 512 : BERT, RoBERTa 등 많은 사전 훈련 언어 모델에서 사용
- 1024, 2048 : 더 긴 문맥을 필요로 하는 모델
- 128, 256 : 단문 분류 등 작은 입력에서 사용
- reserved_label_len : The maximum length reserved for label after tokenization.
- mix_strategy : Strategy to use in dataset mixing (concat/interleave) (undersampling/oversampling).
- eval_num_beams : Number of beams to use for evaluation. This argument will be passed to model.generate
- ignore_pad_token_for_loss : Whether to ignore the tokens corresponding to padded labels in the loss computation or not.
- num_workers : The number of processes to use for the preprocessing.
LoRA 설정: LoraArguments
- additional_target : Name(s) of modules apart from LoRA layers to be set as trainable and saved in the final checkpoint.
- lora_alpha: LoRA 업데이트의 스케일을 조정하는 값. 기본값과 alpha/r 또는 rsLoRA의 스케일 규칙은 구현에서 확인한다.
- lora_dropout : Dropout rate for the LoRA fine-tuning.
- lora_rank : The intrinsic dimension for LoRA fine-tuning.
- create_new_adapter : Whether or not to create a new adapter with randomly initialized weight.
선호 학습과 보상 모델: RLHFArguments
약어 정의는 IPO 논문과 KTO 논문을 대조해 수정했다. FlashAttention의 정확한 attention 계산은 공식 구현 설명을 참고한다.
- dpo_beta: The beta parameter for the DPO loss.
- dpo_loss: 학습 목적 함수 선택을 기록한 옵션이다. IPO·KTO는 서로 다른 학습 방법이며 현재 trainer가 허용하는 값은 버전의 schema로 확인한다.
1. Sigmoid: 시그모이드 함수는 로지스틱 회귀나 인공 신경망에서 자주 사용되는 활성화 함수입니다. S자 모양의 곡선을 가지며, 입력값을 0과 1 사이의 값으로 압축합니다. 이진 분류 문제에서 출력층에 자주 사용됩니다.
2. Hinge: 힌지 손실 함수는 서포트 벡터 머신(SVM)에서 사용되는 비용 함수입니다. 마진 오류에 기반하여 손실을 측정합니다. 최적의 결정 경계를 찾는데 사용됩니다.
3. IPO: Identity-PO. 선호 학습 목적 함수 ΨPO에서 Ψ를 항등함수로 두는 접근입니다.
4. KTO: Kahneman-Tversky Optimization. 생성 결과가 바람직한지에 대한 피드백을 사용하며 전망 이론에 기반한 효용을 최적화합니다.- dpo_ftx : The supervised fine-tuning loss coefficient in DPO training.
- ppo_buffer_size : The number of mini-batches to make experience buffer in a PPO optimization step.
- ppo_epochs : The number of epochs to perform in a PPO optimization step.
- ppo_logger: Log with either "wandb" or "tensorboard" in PPO training.
- wandb
- 클라우드 기반 플랫폼으로 코드 변경 없이 실험 추적이 가능
- 하이퍼파라미터 스위핑, 앙상블, 협업 등 추가 기능 제공
- 모델 아티팩트 추적 및 버전 관리 지원
- 실험 비교, 보고서 생성 등 직관적인 UI 제공
- 웹 대시보드를 통해 언제 어디서나 실험 모니터링 가능
- TensorBoard
- TensorFlow에서 기본적으로 제공하는 시각화 도구
- 로그 데이터를 기반으로 스칼라, 이미지, 오디오, 텍스트 등 다양한 시각화 기능 제공
- 단일 머신에서 실행되며, 로컬 환경에서 사용하기 적합
- 코드에 TensorBoard 로깅 명령어를 추가해야 함
- 실험 관리나 협업 등의 기능은 제한적
- ppo_score_norm : Use score normalization in PPO training.
- ppo_score_norm은 reward model이 제공한 score의 정규화 옵션이다. advantage 정규화나 reward whitening과 같은 설정으로 간주하지 않는다.
- False: Normalization 하지 않습니다.
- ppo_target : Target KL value for adaptive KL control in PPO training.
- ppo_whiten_rewards : Whiten the rewards before compute advantages in PPO training.
- ref_model : Path to the reference model used for the PPO or DPO training.
- ref_model_adapters : Path to the adapters of the reference model.
- ref_model_quantization_bit : The number of bits to quantize the reference model.
- reward_model : Path to the reward model used for the PPO training.
- reward_model_adapters : Path to the adapters of the reward model.
- reward_model_quantization_bit : The number of bits to quantize the reward model.
- reward_model_type : The type of the reward model in PPO training. Lora model only supports lora training. ex) "lora", "full", "api"