Skip to content

This repository demonstrates how to fine-tune the Google Gemma 2 2B model to improve its performance on Japanese instruction-following tasks. It serves as a practical guide for developers and researchers interested in adapting large language models for specific languages or domains using state-of-the-art techniques in 2024.

License

Notifications You must be signed in to change notification settings

qianniu95/gemma2_2b_finetune_jp_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Fine-Tuning Google Gemma for Japanese Instructions

Project Overview

This project demonstrates how to fine-tune the Google Gemma 2 2B model to improve its performance on Japanese instruction-following tasks. It utilizes the Hugging Face ecosystem, including transformers, datasets, and trl libraries, to efficiently fine-tune the model using QLoRA (Quantized Low-Rank Adaptation) technique.

Features

  • Fine-tuning Google Gemma 2 2B model for Japanese language tasks
  • Utilization of QLoRA for efficient fine-tuning
  • Dataset preparation and formatting for instruction tuning
  • Integration with Hugging Face's transformers and trl libraries
  • Model evaluation and inference examples

Requirements

  • PyTorch
  • Transformers
  • Datasets
  • TRL (Transformer Reinforcement Learning)
  • Accelerate
  • PEFT (Parameter-Efficient Fine-Tuning)
  • BitsAndBytes

Usage

  1. Prepare your dataset:

    • The notebook uses the "Mustain/JapaneseQADataset" from Hugging Face, but you can replace it with your own dataset.
    • Ensure your dataset is in the correct format (conversation or instruction format).
  2. Set up your environment:

    • Make sure you have access to a GPU for faster training.
    • Set your Hugging Face token for accessing the Gemma model.
  3. Run the notebook:

    • Follow the steps in the notebook to load the model, prepare the dataset, and start the fine-tuning process.
  4. Evaluate the model:

    • Use the provided evaluation code to test your fine-tuned model on new Japanese instructions.

Key Components

  • Model: Google Gemma 2 2B
  • Fine-tuning Method: QLoRA (Quantized Low-Rank Adaptation)
  • Training Framework: TRL's SFTTrainer
  • Dataset: Japanese Q&A dataset (customizable)

Results

The notebook demonstrates how the fine-tuned model improves in following Japanese instructions compared to the base model. Specific results may vary based on your dataset and training parameters.

Customization

You can easily adapt this notebook for other languages or specific domains by:

  • Changing the base model (e.g., to Gemma 2 9B or other models)
  • Using a different dataset relevant to your task
  • Adjusting hyperparameters in the TrainingArguments and LoraConfig

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

This repository demonstrates how to fine-tune the Google Gemma 2 2B model to improve its performance on Japanese instruction-following tasks. It serves as a practical guide for developers and researchers interested in adapting large language models for specific languages or domains using state-of-the-art techniques in 2024.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published