Pre-work¶
The labs in the workshop are Jupyter notebooks. The notebooks can be run on your computer or remotely on the Google Colab service. Check out Running the Docling Notebooks section on how to setup the way you want to run the notebooks.
Running the Docling Notebooks¶
The notebooks can be run:
Follow the instructions in one of the sections that follow on how you would like to run the notebooks.
Running the Docling Notebooks Locally¶
It is recommended if you want to run the lab notebooks locally on your computer that you have:
If not, then it recommended to go to the Running the Docling Notebooks Remotely (Colab) section instead.
Running the lab notebooks locally on your computer requires the following steps:
Local Prerequisites¶
- Git
- Python 3.10, 3.11, or 3.12
Clone the Docling Workshop Repository¶
Clone the workshop repo and cd into the repo directory.
git clone https://github.com/IBM/docling-workshop.git
cd docling-workshop
Lab 3: Multimodal RAG with Visual Grounding using Docling requires Replicate.
Replicate AI Cloud Platform¶
Replicate is a cloud platform that will host and serve AI models for you.
-
Create a Replicate account. You will need a GitHub account to do this.
-
Add credit to your Replicate Account (optional). To remove a barrier to entry to try the models on the Replicate platform, use this link to add a small amount of credit to your Replicate account.
-
Create a Replicate API Token.
-
Set your Replicate API Token as an environment variable in your terminal where you will run the notebook:
export REPLICATE_API_TOKEN=<your_replicate_api_token>
Install Jupyter¶
Use a virtual environment
Before installing dependencies and to avoid conflicts in your environment, it is advisable to use a virtual environment (venv).
-
Create virtual environment:
python3 -m venv --upgrade-deps --clear venv
-
Activate the virtual environment by running:
source venv/bin/activate
-
Install Jupyter notebook in the virtual environment:
python3 -m pip install --require-virtualenv notebook ipywidgets
For more information, see the Jupyter installation instructions
-
To open a notebook in Jupyter (in the active virtual environment), run:
jupyter notebook <notebook-file-path>
Running the Docling Notebooks Remotely (Colab)¶
Running the lab notebooks remotely using Google Colab requires the following steps:
!!! note "Notebook execution speed tip" The default execution runtime in Colab uses a CPU. Consider using a different Colab runtime to increase execution speed, especially in situations where you may have other constraints such as a slow network connection. From the navigation bar, select Runtime->Change runtime type
, then select either GPU- or TPU-based hardware acceleration.
Colab Prerequisites¶
- Google Colab requires a Google account that you're logged into
Serving the Granite AI Models for Colab¶
The labs require Granite models to be served by an AI model runtime so that the models can be invoked or called.
Replicate AI Cloud Platform for Colab¶
Replicate is a cloud platform that will host and serve AI models for you.
-
Create a Replicate account. You will need a GitHub account to do this.
-
Add credit to your Replicate Account (optional). To remove a barrier to entry to try the Granite models on the Replicate platform, use this link to add a small amount of credit to your Replicate account.
-
Create a Replicate API Token.
-
Add your Replicate API Token to the Colab Secrets manager to securely store it. Open Google Colab and click on the 🔑 Secrets tab in the left panel. Click "New Secret" and enter
REPLICATE_API_TOKEN
as the key, and paste your token into the value field. Toggle the button on the left to allow notebook access to the secret.