ラボの設定手順と要件
アカウントと進行状況を保護します。このラボを実行するには、常にシークレット ブラウジング ウィンドウとラボの認証情報を使用してください。

Google DeepMind: Train a Small Language Model (Challenge Lab)

ラボ 1時間 universal_currency_alt クレジット: 5 show_chart 上級
info このラボでは、学習をサポートする AI ツールが組み込まれている場合があります。
このコンテンツはまだモバイル デバイス向けに最適化されていません。
快適にご利用いただくには、メールで送信されたリンクを使用して、デスクトップ パソコンでアクセスしてください。

GSP531

Google Cloud self-paced labs logo

Overview

Important: To earn the skill badge, you must be enrolled in the challenge lab course. Please ensure you are enrolled before you begin this lab.

In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure out how to complete the tasks on your own! An automated scoring system (shown on this page) will provide feedback on whether you have completed your tasks correctly.

When you take a challenge lab, you will not be taught new Google Cloud concepts. You are expected to extend your learned skills, like changing default values and reading and researching error messages to fix your own mistakes.

To score 100% you must successfully complete all tasks within the time period!

This challenge lab is recommended for students who have completed the Google DeepMind: 01 Build Your Own Small Language Model course. To build a stronger foundation and see how this lab fits into the broader curriculum, we encourage you to explore the Google DeepMind AI Research Foundations learning path.

Now, it's time to apply what you've learned to a practical, real-world scenario. You will step into the role of a developer for Cymbal Chat, a startup specializing in custom AI. Your mission is to use a provided dataset of short children's stories in Arabic to build the foundational codebase they need to meet the lab's objectives. Are you ready for the challenge?

Topics tested

  • Tokenizer: Build a character-level tokenizer for Arabic text.
  • N-gram text generator: Develop an n-gram based text generator as a baseline model.
  • Data preparation: Prepare a dataset of Arabic text for training a character-based transformer language model.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.

This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

You must wait for the lab to provision before making any changes to the environment. The necessary pre-configured components will be available once the lab is ready.

Challenge scenario

Cymbal Chat: Develop a Chatbot for the Arabic-Speaking Market

Cymbal Chat is a startup that specializes in custom AI language models. For certain Arabic natural language processing (NLP) tasks, character-based language models can outperform word-based models. Cymbal Chat plans to explore this approach for its new prototype.

A customer has requested a language model for Arabic speakers to generate simple, coherent stories. To fulfill this, you must develop the foundational tools and data preparation framework for training robust, character-based language models.

You are expected to have the skills and knowledge for these tasks, so don't expect step-by-step guides to be provided.

Task 1. Import the notebook, define helper functions, and load data

For this task, you import the necessary libraries and load the Arabic stories dataset. Do not modify the pre-written code cells in the Jupyter Notebook that are labeled accordingly.

Import the notebook

  1. In the Google Cloud console, navigate to Vertex AI > Colab Enterprise > My notebooks.

  2. Select the region.

  3. Click Import.

  4. On the Import notebooks form, select Cloud Storage.

  5. For Notebook file path, enter .

  6. Click Import. The notebook, gdm_challenge_lab.ipynb, will open in a new tab upon completion.

Execute the notebook in Colab

  1. Connect to the runtime: To execute the cells, you must first connect the notebook gdm_challenge_lab.ipynb to a runtime environment:

    • In the notebook, click the Additional connection options expander arrow (top right corner).
    • Select Connect to a runtime.
    • In the Connect to Vertex AI runtime dialog, select Connect to an existing runtime.
    • Select the existing runtime colab-cpu-runtime.
    • Click Connect.
    • If you are prompted with a dialog to authenticate, select the student username as the account to authenticate with.
  2. Review the narrative in Task 1. Define helper functions and load data to understand the purpose of the code cells.

  3. Execute each cell in this section to define the helper functions and load the dataset.

Note: Carefully follow the instructions in the Jupyter Notebook. Complete the tasks in the TODO sections, and do not modify the code cells marked You are not required to add or modify code.

Task 2. Configure the character tokenizer

In this task, you complete the SimpleArabicCharacterTokenizer class, a character-level tokenizer for Arabic text.

This class contains two methods:

  • character_tokenize: Converts raw Arabic text into a list of single-character tokens.
  • join_text: Joins a list of character tokens back into a single string without padding.

Build the 'SimpleArabicCharacterTokenizer' class

Your code is required in the [TODO - Add your code here] sections. Carefully read the notebook instructions, and ensure you have completed the character_tokenize and join_text methods.

  1. character_tokenize: This method should return a list of single-character strings in the same order as the input text.

  2. join_text: This method should return a single string by joining the input tokens without any intervening characters.

Note: For a detailed description of this task, refer to the notebook.
  1. Save your notebook, and run the cell to test your completed SimpleArabicCharacterTokenizer class.
Note: Please allow a moment for the task to complete, indicated by a green checkmark. If the attempt fails, please retry.

Click Check my progress to verify the objective. Build the SimpleArabicCharacterTokenizer class

Task 3. Generate text from an n-gram model

In this task, you complete the inference loop for a character n-gram model that has been trained on the Arabic stories dataset. This model generates text from a given prompt and supports both random and greedy sampling.

Build the 'generate_text_from_ngram_model' function

Your code is required within the [TODO - Add your code here] sections. Carefully read the notebook's instructions and complete the generate_text_from_ngram_model function to do the following:

  1. Support either random or greedy sampling, based on the sampling_mode argument.

  2. Return the generated tokens as a single string.

  3. Save your notebook, and run the cell to test your n-gram text generator.

Note: Please allow a moment for the task to complete, indicated by a green checkmark. If the attempt fails, please retry.

Click Check my progress to verify the objective. Build the generate_text_from_ngram_model function

Task 4. Prepare the dataset for training

In this task, you build the necessary tools to prepare data for a character-based language model aimed at Arabic speakers. You develop the framework for robust and efficient model training.

Build the 'segment_encoded_sequence' function

  1. Your code is required in the [TODO - Add your code here] sections. Carefully read the notebook instructions to complete the segment_encoded_sequence function.

  2. This function takes an encoded sequence of token IDs and segments it into subsequences. Your implementation should ensure the following:

    • The final subsequence can be up to max_length length but can be shorter. All other subsequences must be exactly max_length.
    • The original sequence can be reconstructed by concatenating the subsequences and removing overlaps.
    • The function returns a list of lists, where each inner list is a subsequence.
  3. Save your notebook, and run the cell to test your completed segment_encoded_sequence function.

Note: Please allow a moment for the task to complete, indicated by a green checkmark. If the attempt fails, please retry.

Click Check my progress to verify the objective. Build the segment_encoded_sequence function

Build the 'create_training_sequences' function

  1. You'll complete the create_training_sequences function. This function takes a dataset, a tokenizer, and a maximum input length to create a pair of 2D padded arrays (inputs and targets) suitable for model training.

  2. Your code is required in the [TODO - Add your code here] sections. Carefully read the notebook instructions to complete the create_training_sequences function. Ensure your implementation:

    • Creates an encoded sequence for all data.
    • Uses segment_encoded_sequence to segment each encoded sequence.
    • Extracts the input and target arrays from the padded arrays for model training.
  3. Save your notebook, and run the cell to test your completed create_training_sequences function.

Note: Please allow a moment for the task to complete, indicated by a green checkmark. If the attempt fails, please retry.

Click Check my progress to verify the objective. Build the create_training_sequences function

Congratulations

Google DeepMind: Train a Small Language Model skill badge

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual last updated on January 08, 2026.

Lab last tested on January 08, 2026.

Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

始める前に

  1. ラボでは、Google Cloud プロジェクトとリソースを一定の時間利用します
  2. ラボには時間制限があり、一時停止機能はありません。ラボを終了した場合は、最初からやり直す必要があります。
  3. 画面左上の [ラボを開始] をクリックして開始します

シークレット ブラウジングを使用する

  1. ラボで使用するユーザー名パスワードをコピーします
  2. プライベート モードで [コンソールを開く] をクリックします

コンソールにログインする

    ラボの認証情報を使用して
  1. ログインします。他の認証情報を使用すると、エラーが発生したり、料金が発生したりする可能性があります。
  2. 利用規約に同意し、再設定用のリソースページをスキップします
  3. ラボを終了する場合や最初からやり直す場合を除き、[ラボを終了] はクリックしないでください。クリックすると、作業内容がクリアされ、プロジェクトが削除されます

このコンテンツは現在ご利用いただけません

利用可能になりましたら、メールでお知らせいたします

ありがとうございます。

利用可能になりましたら、メールでご連絡いたします

1 回に 1 つのラボ

既存のラボをすべて終了して、このラボを開始することを確認してください

シークレット ブラウジングを使用してラボを実行する

このラボを実行するには、シークレット モードまたはシークレット ブラウジング ウィンドウを使用することをおすすめします。これにより、個人アカウントと受講者アカウントの競合を防ぎ、個人アカウントに追加料金が発生することを防ぎます。