region:us
In order to execute this code, if the notebook is run in colab, it can be mount to drive, otherwise files can be accessed and saved locally. 

Once the 3rd cell for hugging face login is run, hugging face will require a login. This will require meta and hugging face access to llama-2. 

The Lora weights are outlined below and are included in the notebook and just need to be run through the cell.

The Training weights are outlined below and are included in the notebook and just need to be run through the cell.


Ensure the datapath is altered as needed. During training, a checkpoint should be saved every 1000 steps.

After training a finetuned model will be output and a tensorboard showing training/epoch loss data. For every 10 steps, the hyperparameters and loss are shown in the trainer_state.json.

# LoRA Config
peft_parameters = LoraConfig(
    lora_alpha=16,
    lora_dropout=0.1,
    r=8,
    bias="none",
    task_type="CAUSAL_LM"
)

# Training Params
train_params = TrainingArguments(
    output_dir="",
    num_train_epochs=3,
    per_device_train_batch_size=4,
    gradient_accumulation_steps=1,
    optim="paged_adamw_32bit",
    save_steps=1000,
    logging_steps=10,
    learning_rate=2e-5,
    weight_decay=0.001,
    fp16=False,
    bf16=False,
    max_grad_norm=0.3,
    max_steps=-1,
    warmup_ratio=0.03,
    group_by_length=True,
    lr_scheduler_type="constant",
    report_to="tensorboard"
)

---
library_name: peft
---
## Training procedure


The following `bitsandbytes` quantization config was used during training:
- load_in_8bit: False
- load_in_4bit: True
- llm_int8_threshold: 6.0
- llm_int8_skip_modules: None
- llm_int8_enable_fp32_cpu_offload: False
- llm_int8_has_fp16_weight: False
- bnb_4bit_quant_type: nf4
- bnb_4bit_use_double_quant: False
- bnb_4bit_compute_dtype: float16
### Framework versions


- PEFT 0.4.0