实验设置说明和要求
保护您的账号和进度。请务必在无痕浏览器窗口中,使用实验凭证运行此实验。

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. 除非您已完成此实验或想要重新开始,否则请勿点击结束实验,因为点击后系统会清除您的工作并移除该项目

此内容目前不可用

一旦可用,我们会通过电子邮件告知您

太好了!

一旦可用,我们会通过电子邮件告知您

一次一个实验

确认结束所有现有实验并开始此实验

使用无痕浏览模式运行实验

使用无痕模式或无痕浏览器窗口是运行此实验的最佳方式。这可以避免您的个人账号与学生账号之间发生冲突,这种冲突可能导致您的个人账号产生额外费用。