Skip to main content

Model Inference

A selection of example task files for using various models in inference tasks are shown below using the bitfount.InferenceAndCSVReport protocol. This protocol is the most appropriate protocol for most inference tasks as it runs the inference and then writes a CSV report of the results to the Pod-side. Alternatively, you may use the bitfount.InferenceAndReturnCSVReport which instead sends the CSV results back to the modeller. This is useful if the dataset is remote from the task initiator i.e. on a different machine.

Reminder

The Pod is the entity that contains the datasets to run the task on. The modeller is the entity that initiates the task.

Bitfount-hosted models

An example task file for using a Bitfount-hosted model for inference is shown below. In this case, the model is a binary classification model for predicting chronic kidney disease based on a set of features. The features are not templated in this example meaning that only datasets with all those exact column names would be deemed compatible with the task.

modeller:
identity_verification_method: key-based

pods:
identifiers:
- <replace-with-dataset-identifier>

batched_execution: true

task:
protocol:
name: bitfount.InferenceAndCSVReport
algorithm:
- name: bitfount.ModelInference
model:
bitfount_model:
username: amin-nejad
model_ref: ChronicKidneyDiseaseModel
model_version: 1
- name: bitfount.CSVReportAlgorithm
data_structure:
select:
include:
- Age
- Gender
- Creatinine (mg/dL)
- Albumin (g/dL)
- HbA1c (%)
- Glucose (mg/dL)
- Triglycerides (mg/dL)

Hugging Face models

An example task file for using a Hugging Face text classification model for sentiment analysis is shown below:

modeller:
identity_verification_method: key-based

pods:
identifiers:
- <replace-with-dataset-identifier>

batched_execution: true

task:
protocol:
name: bitfount.InferenceAndCSVReport
algorithm:
- name: bitfount.HuggingFaceTextClassificationInference
arguments:
top_k: 3
model_id: finiteautomata/bertweet-base-sentiment-analysis
target_column_name: "{{ target_column_name }}"
- name: bitfount.CSVReportAlgorithm

template:
target_column_name:
label: "Target column"
type:
schema_column_name:
semantic_type: text

TIMM models

The below example task file shows how to use a TIMM model in a multiclass image classification task using the Retfound (Retina foundation) model

modeller:
identity_verification_method: key-based

pods:
identifiers:
- <replace-with-dataset-identifier>

batched_execution: True

task:
protocol:
name: bitfount.InferenceAndCSVReport
algorithm:
- name: bitfount.TIMMInference
arguments:
model_id: "bitfount/RETFound_MAE_OCT_CNV_DME_DRU"
class_outputs:
- CNV (%)
- DME (%)
- DRUSEN (%)
- NORMAL (%)
- name: bitfount.CSVReportAlgorithm
arguments:
original_cols:
- _original_filename
- Filename
data_structure:
schema_requirements: "partial"
select:
include:
- "{{ image_column_name }}"

template:
image_column_name:
label: "Image column"
tooltip: "The dataset column that contains image data for predictions"
default: "Pixel Data 0"
type:
schema_column_name:
semantic_type: "image"