Skip to content

Gemini fine‐tuning (advanced)

Juan Gabriel Griggio edited this page Nov 25, 2024 · 1 revision

Fine-tuning intro

Gemini fine-tuning is a way to make the Gemini model better at specific tasks by training it on a new dataset. This dataset contains examples of the desired inputs and outputs, allowing the model to learn the nuances of the task and improve its performance.

In the case of Topic Mine, fine-tuning allows the artificial intelligence to generate text that has a look and feel more in line with the current style of the brand.

You can learn more and see the technical details about Gemini fine-tuning here.

Dataset

To fine-tune Gemini, you need to prepare a high-quality dataset that is relevant to the task you want to improve, which is generating ad texts in this case. This dataset should be diverse and contain as many real-world examples as possible. Once you have your dataset, you can use the Gemini API or Vertex AI to fine-tune the model.

The dataset for this case should look something like this:

training_data = [
  {
    "text_input": "Generate 4 texts of less than 90 characters for a Google Ads ad for the term 'Google Pixel 9 Pro'.",
    "output": "[
                 'Pixel 9 Pro: Unbeatable camera. Pure Google',
                 'Pixel 9 Pro: The ultimate Android experience',
                 'Upgrade to Pixel 9 Pro. Trade in your old phone',
                 'Pixel 9 Pro: Capture stunning photos'
               ]"
  },
  ...
]

The text input should be as close as the prompts that you will use as possible, and you should add as much examples as you can.

Using your fine tuned model in Topic Mine

To use your fine-tuned model, simply specify the model name in the config.json file like this:

{
  ...
  "gemini_model": "tunedModels/my-fine-tuned-model",
  ...
}