Skip to main content
Google Colab Many of our Granite recipes include a link to Colab where you can try out sample code. Colab requires a gmail account when you log in the first time. Please refer to the Colab site for instructions on how to use it. Running sample code on Colab using a CPU or a T4 GPU is free, with some usage limitations. Our intention is to provide recipes that do not require a paid Colab subscription for a more powerful GPU. If you find yourself wanting a more powerful GPU on Colab, check out this page. Running our recipes on Colab may also require some third party credentials. Please read each recipe carefully to determine the third-party credentials needed to run that recipe on Colab. Then refer to the instructions below to secure the credentials. Hugging Face Token Hugging Face provides access to a variety of foundation models for downloading. To obtain a free Hugging Face token, do the following:
  1. Go to the Hugging Face site.
  2. Log in if you already have a Hugging Face account. If not, sign up for a free account.
  3. Select your personal icon on the upper right and choose Access Tokens from the drop-down menu.
  4. Select Create new token on the right.
  5. On the Create New Access Token page, select Fine-grained, specify a token name, and select these permissions: “Read access to contents of all repos under your personal namespace” and “Read access to contents of all public gated repos you can access”.
  6. Scroll to the bottom of the page and select Create Token. Save the token value by selecting the Copy button and store in a safe place.
  7. Select Done.
  8. You now need to store your Hugging Face token in Colab. Open Colab and select the key icon in the left column.
  9. Select +Add new secret. Name the secret “HF_TOKEN” and paste the copied token in the Value field.
  10. Slide the Notebook Access slider on the left to the right to enable it (it turns blue).
  11. Close the Secrets dialog.
Replicate API Token Replicate provides access to a variety of foundation models for remote execution. To obtain a Replicate API token, do the following:
  1. Create a Replicate account here by selecting “Try for free”. You will need a GitHub account to do this.
  2. Create a Replicate API Token here. Save the token value by selecting the Copy button and store in a safe place.
  3. Try to add a small amount of free credit to your Replicate account here. You will need some credit in your account to run these notebooks.
  4. You now need to store your Replicate API Token in Colab. Open Colab and select the key icon in the left column.
  5. Select +Add new secret. Name the secret “REPLICATE_API_TOKEN” and paste the copied token in the Value field.
  6. Slide the Notebook Access slider on the left to the right to enable it (it turns blue).
  7. Close the Secrets dialog.
  8. If you find yourself needing more credit in your Replicate account, instructions are provided on the Replicate site.
Watsonx Credentials Watsonx provides access to a variety of foundation models for remote execution. To run notebooks that require watsonx, you will need the following credentials:
  • Watsonx API Key
  • Watsonx Project ID
  • Watsonx URL
If you already have these credentials, go straight to section E below. Otherwise, follow all the instructions in sections A-E. A. Obtain a Watsonx API Key:
  1. If you don’t have an IBM ID, you can obtain a free IBM ID here.
  2. Go to the IBM Cloud web page and sign in with your IBM ID.
  3. If you see the Finish setting up your account pop-up, enter your Account, Company, Billing and Credit Card information. Note: Credit Card information is used to verify your identity. Your card will not be charged at this time. A temporary $1.00 hold is placed on your card while it is being authorized.
  4. Close the Account upgrade in progress pop-up. It may take a few minutes for your account to be upgraded.
  5. Now go to the IBM Cloud page in the same web browser and you should still be logged in.
  6. Click Create for a new IBM Cloud API Key.
  7. Enter “watsonx” for your key name, leave the description blank, and click on Create on the lower right.
  8. Copy the API Key and store it in a safe place.
B. Set up a watsonx plan to run the Watson Machine Learning service:
  1. Go to the watson.ai portal.
  2. If the Provide your information to continue page appears, provide your company name and phone number and select Continue. No consent needs to be provided to continue.
  3. Select the X in the upper right of the Welcome to watsonx pop-up.
  4. On the upper menu bar, select Upgrade to enable your account to run notebooks.
  5. On the Upgrade your watsonx services page, place a check mark next to Watson Machine Learning, and select the Select plan box on the right.
  6. Select the Essentials plan to have sufficient tokens to run notebooks and choose Select on the lower right.
  7. After reading the terms, place a check next to I agree to the terms and click Buy at the lower right.
  8. Select the X in the upper right to close the window summarizing your service.
C. Obtain a Watsonx Project ID:
  1. Click on IBM watsonx on the top banner to return to the watsonx home page.
  2. Click on the + at the right of Projects to create a new project.
  3. In the name field, enter a name and select Create on the lower right.
  4. If the Collaborate to maximize productivity pop-up appears, click X on the upper right to close it.
  5. Select the Manage tab, then use the copy icon to copy the Project ID. Store it in a safe place.
  6. Click IBM watsonx on the page header to go back to the main watsonx page.
  7. In the Discover section select Prompts.
  8. Click on the Earnngs call summary tile.
  9. In the upper right, select Open in Prompt Lab.
  10. Click on the the blue Associate service button.
  11. Place a check next to WatsonMachineLearning and click on the Associate button on the lower right to complete associating the project with the service.
D. Select a Watsonx URL: Select one of these urls and store it in a safe place. E. Store your watsonx credentials in Colab.
  1. Open Colab and select the key icon in the left column.
  2. Select +Add new secret. Name the secret “WATSONX_APIKEY” and paste your Watsonx API Key in the Value field.
  3. Slide the Notebook Access slider on the left to the right to enable it (it turns blue).
  4. Select +Add new secret. Name the secret “WATSONX_PROJECT_ID” and paste your Watsonx Project ID in the Value field.
  5. Slide the Notebook Access slider on the left to the right to enable it (it turns blue).
  6. Select +Add new secret. Name the secret “WATSONX_URL” and paste your Watsonx URL in the Value field.
  7. Slide the Notebook Access slider on the left to the right to enable it (it turns blue).
  8. Close the Secrets dialog.
I