BiA-Bob#
bia_bob
is a Python library that connects Jupyter with large language models (LLM) and custom bio-image analysis instructions.
Commonly, it uses OpenAIs/GPT models as default. For training purposes, we will use the LLM infrastructure of ScaDS.AI in the National Compute Center ZIH TU Dresden.
When using bia-bob to prompt LLMs, the prompts you enter including existing variable names etc. are sent to the LLM provider. Do not submit any sensitive, secret or private information. Also check bia-bob’s code recommendations before executing them. LLMs make mistakes.
First, we configure bia-bob:
# load secret API key. You must unpack the contents of api_key.zip
# into the same folder before going ahead.
from dotenv import load_dotenv
load_dotenv()
import os
from bia_bob import bob
bob.initialize(endpoint='https://llm.scads.ai/v1', model='openai/gpt-oss-120b', api_key=os.environ.get('SCADSAI_API_KEY'))
Prompting#
You can prompt for a single short task using %bob
.
%bob print hello world.
Print the string “hello world” to the console.
print("hello world")
print("hello world")
hello world
More advanced multi-line tasks can be prompted using %%bob
.
%%bob
load data/blobs.tif and show it
Load the TIFF file data/blobs.tif
into a NumPy array and display it interactively.
from skimage.io import imread
import stackview
# 1. Load the image
image = imread('data/blobs.tif')
# 2. Display interactively
stackview.insight(image)
|
|
from skimage.io import imread
import stackview
image = imread("data/blobs.tif")
stackview.insight(image)
|
|
Exercise#
Ask Bob to plot a sigmoid curve.
%%bob
Generate a notebook that loads this image, segments the bright blobs and visualizes the segmented image.
A notebook has been saved as bright_blob_segmentation.ipynb.