Trang này cung cấp hướng dẫn thiết lập để sử dụng Gemma trong Colab. Một số
các hướng dẫn này cũng có thể áp dụng được cho các môi trường phát triển khác.
Truy cập vào Gemma
Trước khi sử dụng Gemma lần đầu tiên, bạn phải yêu cầu quyền truy cập vào
thông qua Kaggle. Trong quá trình này, bạn sẽ phải sử dụng một Kaggle
để chấp nhận chính sách sử dụng và điều khoản cấp phép của Gemma.
Nếu chưa có tài khoản Kaggle, bạn có thể đăng ký một tài khoản tại
kaggle.com. Sau đó, hãy hoàn tất các bước sau:
Hoàn tất biểu mẫu đồng ý rồi chấp nhận các điều khoản và điều kiện.
Chọn một môi trường thời gian chạy Colab
Để hoàn tất hướng dẫn về Colab, bạn phải có một môi trường thời gian chạy Colab đủ
để chạy mô hình Gemma. Để bắt đầu, bạn có thể
sử dụng GPU T4:
Ở phía trên bên phải của cửa sổ Colab, hãy chọn ▾
(Các lựa chọn kết nối khác).
Chọn Thay đổi loại thời gian chạy.
Trong Trình tăng tốc phần cứng, hãy chọn GPU T4.
Định cấu hình khoá API
Để sử dụng Gemma, bạn phải cung cấp tên người dùng Kaggle và khoá API Kaggle. Người nhận
tạo và định cấu hình các giá trị này, hãy làm theo các bước sau:
Để tạo khoá API Kaggle, hãy chuyển đến thẻ Tài khoản của người dùng Kaggle
cấu hình và chọn Create New Token (Tạo mã thông báo mới). Thao tác này sẽ kích hoạt quá trình tải xuống
Tệp kaggle.json chứa thông tin đăng nhập API của bạn.
Mở kaggle.json trong trình chỉnh sửa văn bản. Nội dung sẽ có dạng như
sau:
Trong Colab, hãy chọn Bí mật (🔑) rồi thêm tên người dùng Kaggle và Kaggle
Khoá API. Lưu trữ tên người dùng của bạn dưới tên KAGGLE_USERNAME và API của bạn
dưới tên KAGGLE_KEY.
Giờ đây, bạn đã sẵn sàng hoàn tất các bước thiết lập còn lại trong Colab. Nếu bạn
làm theo hướng dẫn về Colab, hãy chuyển đến Colab và đặt các biến môi trường.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2024-08-05 UTC."],[],[],null,["# Gemma setup\n\nThis page provides setup instructions for using Gemma in Colab. Some of the\ninstructions are applicable to other development environments as well.\n\nGet access to Gemma\n-------------------\n\nBefore using Gemma for the first time, you must request access to the\nmodel through Kaggle. As part of the process, you'll have to use a Kaggle\naccount to accept the Gemma use policy and license terms.\n\nIf you don't already have a Kaggle account, you can register for one at\n[kaggle.com](https://www.kaggle.com). Then complete the following steps:\n\n1. Go to the [Gemma model card](https://www.kaggle.com/models/google/gemma) and select **Request Access**.\n2. Complete the consent form and accept the terms and conditions.\n\nSelect a Colab runtime\n----------------------\n\nTo complete a Colab tutorial, you must have a Colab runtime with sufficient\nresources to run the Gemma model. To [get started](./get_started), you can\nuse a T4 GPU:\n\n1. In the upper-right of the Colab window, select ▾ (**Additional connection options**).\n2. Select **Change runtime type**.\n3. Under **Hardware accelerator** , select **T4 GPU**.\n\nConfigure your API key\n----------------------\n\nTo use Gemma, you must provide your Kaggle username and a Kaggle API key. To\ngenerate and configure these values, follow these steps:\n\n1. To generate a Kaggle API key, go to the **Account** tab of your Kaggle [user\n profile](https://www.kaggle.com/settings) and select **Create New Token** . This will trigger the download of a `kaggle.json` file containing your API credentials.\n2. Open `kaggle.json` in a text editor. The contents should look something like\n this:\n\n {\"username\":\"your_username\",\"key\":\"012345678abcdef012345678abcdef1a\"}\n\n3. In Colab, select **Secrets** (🔑) and add your Kaggle username and Kaggle\n API key. Store your username under the name `KAGGLE_USERNAME` and your API\n key under the name `KAGGLE_KEY`.\n\n | **Note:** Kaggle notebooks have a key storage feature under **Add-ons** \\\u003e **Secrets**, along with instructions for accessing stored keys.\n\nNow you're ready to complete the remaining setup steps in Colab. If you're\nworking through a Colab tutorial, go to Colab and set the environment variables.\n| **Tip:** As an alternative to setting environment variables, you can use `kagglehub` to [authenticate](https://github.com/Kaggle/kagglehub?tab=readme-ov-file#authenticate)."]]