Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Finetunning-Using-SantaCoder.py

Fine-Tuning SantaCoder for Code/Text Generation 💻 Let's enhance and simplify the provided text:

Fine-Tuning SantaCoder for Code and Text Generation 💻 In this guide, we will learn how to fine-tune the SantaCoder model to generate code and text. SantaCoder is a large model pre-trained on Python, Java, and JavaScript. We will focus on fine-tuning it using datasets like The Stack and GitHub-Jupyter.

Setup and Fine-Tuning with The Stack Dataset You can fine-tune SantaCoder using the provided code and The Stack dataset. Here are the steps:

  1. Clone Repository and Install Packages: First, clone the repository and install necessary packages:

git clone https://github.com/bigcode/santacoder-finetuning.git cd santacoder-finetuning pip install -r requirements.txt

  1. Log In to HuggingFace Hub and Weights & Biases: Make sure you're logged in to HuggingFace Hub and Weights & Biases:

huggingface-cli login wandb login

  1. Understanding the train.py Script: Take a look at the train.py script. It does the following:

Loads the dataset Loads the model with specified hyperparameters Pre-processes the dataset for model input Performs training and evaluation

  1. Fine-Tuning Examples: Here are examples of how to run fine-tuning on The Stack dataset:

For instance, fine-tune on the Ruby subset of the dataset:

python train.py \
    --model_path="bigcode/santacoder" \
    --dataset_name="bigcode/the-stack-dedup" \
    --subset="data/shell" \
    --data_column "content" \
    --split="train" \
    --seq_length 2048 \
    --max_steps 30000 \
    --batch_size 2 \
    --gradient_accumulation_steps 8 \
    --learning_rate 5e-5 \
    --num_warmup_steps 500 \
    --eval_freq 3000 \
    --save_freq 3000 \
    --log_freq 1 \
    --num_workers="$(nproc)" \
    --no_fp16

To run training on multiple GPUs:

python -m torch.distributed.launch \
    --nproc_per_node number_of_gpus train.py \
    --model_path="bigcode/santacoder" \
    --dataset_name="bigcode/the-stack-dedup" \
    --subset="data/shell" \
    --data_column "content" \
    --split="train" \
    --seq_length 2048 \
    --max_steps 30000 \
    --batch_size 2 \
    --gradient_accumulation_steps 8 \
    --learning_rate 5e-5 \
    --num_warmup_steps 500 \
    --eval_freq 3000 \
    --save_freq 3000 \
    --log_freq 1 \
    --num_workers="$(nproc)" \
    --no_fp16

You can also fine-tune on other text datasets by changing the data_column argument.

  1. Uploading Trained Checkpoints: To upload your trained checkpoint to the HuggingFace model hub, follow these steps:

Create a new model repository here. Clone the repository locally and add the necessary files (tokenizer, config, model weights, etc.). Push the files to your model repository. Create a model card to provide details about your model's purpose, training data, and performance. That's it! With these steps, you can fine-tune SantaCoder for code and text generation tasks and share your trained model with the community. Happy fine-tuning! 🚀

Note: This guide is inspired by Hugging Face's Wave2vec fine-tuning week.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages