Overview
To import annotations in Labelbox, you need to create an annotations payload. In this section, we provide this payload for every supported annotation type.Annotation payload types
Labelbox supports two formats for the annotations payload:-
Python annotation types (recommended)
- Provides a seamless transition between third-party platforms, machine learning pipelines, and Labelbox.
- Allows you to build annotations locally with local file paths, numpy arrays, or URLs
- Easily convert Python Annotation Type format to NDJSON format to quickly import annotations to Labelbox
- Supports one-level nested classification (radio, checklist, or free-form text) under a tool or classification annotation.
-
JSON
- Skips formatting annotation payload in the Labelbox Python annotation type
- Supports any levels of nested classification (radio, checklist, or free-form text) under a tool or classification annotation.
Label import types
Labelbox supports two types of label imports:- Model-assisted labeling (MAL)
- This workflow allows you to import computer-generated predictions (or simply annotations created outside of Labelbox) as pre-labels on an asset.
- Ground truth
- This workflow functionality allows you to bulk import your ground truth annotations from an external or third-party labeling system into Labelbox Annotate. Using the label import API to import external data is a useful way to consolidate and migrate all annotations into Labelbox as a single source of truth.
Supported annotations
The following annotations are supported for a LLM human preference data row:-
Tool
- Message ranking
- Single message selection
- Multiple message selection
-
Classification
- Radio (single-choice)
- Checklist (multi-choice)
- Free-form text
Message and global-based annotations
Radio and free-form text annotations can be both message and global based. To make a message-based annotation global, remove themessage_id
key inside the annotation.Tools
Message ranking
Single message selection
Multiple message selection
Classifications
Radio
Checklist
Free-form text
Example: Import pre-labels or ground truths
The steps to import annotations as pre-labels (machine-assisted learning) are similar to the steps to import annotations as ground truth labels, and we will describe the slight differences for each scenario.Before you start
The below imports are needed to use the code examples in this section.Step 1: Import data rows
You need to import data rows to Catalog to attach annotations. This example shows how to create a data row in Catalog by attaching it to a dataset .Step 2: Set up ontology
Your project ontology needs to support the classifications required by your annotations. To ensure accurate schema feature mapping, the value used as the name parameter needs to match the value of the name field in your annotation. For example, if you provide a nameannotation_name
for your message ranking annotation, you need to name the message ranking tool as anotations_name
when setting up your ontology. The same alignment must hold true for the other tools and classifications that you create in the ontology.
This example shows how to create an ontology containing all supported annotation types .
Step 3: Set up a labeling project
Use the following code to create an offline multimodal evaluation project:Step 4: Send data rows to project
Use the following code to send data rows to the project you just created:Step 5: Create annotation payloads
To declare payloads, you can use Python annotation types (preferred) or NDJSON objects. To understand annotation payloads, see overview. These examples demonstrate each format and how to compose annotations into labels attached to data rows.Replace placeholder fields with actual values
Replacemessage_id
and model_config_name
with the actual message ID and model configuration name before appending annotations.Step 6: Import annotation payload
For prelabeled (model-assisted labeling) scenarios, pass your payload as the value of thepredictions
parameter. For ground truths, pass the payload to the labels
parameter.