This chapter shows how active learning extends beyond simple image and document classification to more complex tasks where the model must identify objects, spans, pixels, or generated outputs. The main idea stays the same: use uncertainty and diversity to choose the most valuable items for human review, but define those concepts in a way that matches the real task. In practice, that means deciding whether the model should focus on whole images, specific objects, boundaries, spans, or labels, and making sure sampling reflects what actually matters in deployment.
For object detection and semantic segmentation, the chapter emphasizes separating label confidence from localization confidence, using metrics such as F-score, IoU, and mAP where appropriate. Uncertainty can come from softmax probabilities, ensembles, or Monte Carlo dropout, while diversity usually requires cropping or masking to keep the focus on the object or region of interest instead of the background. The same logic applies to representative and cluster-based sampling, but the book warns that these methods can be biased if training data and unlabeled data are encoded differently or if context and background dominate the representation.
The chapter then adapts these principles to sequence labeling, language generation, video, speech, and information retrieval. For sequence tasks, spans must be sampled with enough surrounding context, and uncertainty may need to include boundary tokens as well as the tokens inside the span. For language generation, evaluation is harder because there may be multiple valid outputs, so uncertainty is less straightforward, but diversity and transfer learning still help. Across all tasks, the recurring message is to align sampling, evaluation, and annotation design with the use case, stratify when needed to avoid bias, and choose how many examples to review based on annotation cost, task complexity, and the type of model errors that matter most.
An illustration of the problem of identifying uncertainty and diversity in object detection tasks. The object we care about—the bicycle—is a small percentage of the pixels in the bounding box that surrounds it. Even a modest amount of context is twice the number of pixels, and the image as a whole is 10 times the number of pixels of the bounding box. Therefore, if we tried to calculate uncertainty or diversity across the whole image, we would risk focusing on a lot of irrelevant information.
An example of IoU for measuring the accuracy of a bounding box. The accuracy is calculated as the area that intersects the predicted bounding box with the actual bounding box, divided by the area that is the union of the two boxes.
An example prediction heat map for an object, showing low variation (left) and high variation (right). The high variation is evidence of more uncertainty in the model; therefore, the right example is a good candidate for human evaluation. You can generate multiple predictions by using ensemble models, getting predictions from multiple models and changing the parameters, using a subset of features or a subset of items, or introducing random variation into your models in some other way. Within a single model, you can generate multiple predictions for a single item by using a dropout over a random selection of neurons for each prediction (known as Monte Carlo dropouts). You can also combine both methods: create an ensemble of models, and use dropouts for multiple predictions per model.
An example of an object—a bicycle—in an image in which 99% of the image is not the bicycle. The bicycle and immediate context captured by the dotted line should be enough for identifying that the object is a bicycle. With some strategies, such as representative sampling and clustering, we need to crop or mask the image to target these areas.
Stratifying by confidence: sampling an equal number of items at 0–10% confidence, 10–20% confidence, and so on up to 90–100% confidence. In this example, one item is sampled from each 10% confidence interval for label A. Stratifying by confidence helps most when you have a large number imbalance between labels.
An example of object detection using a polygon rather than a bounding box. You can use the same active learning methods for both bounding boxes and polygons, with the extra option to have a closer mask for a polygon.
An example of semantic segmentation in which every pixel is labeled. This kind of colored photograph is what a lot of semantic segmentation tools look like: a coloring-in exercise. We’ll cover those tools later in the book, especially in chapter 10. If you’re looking at this image in black and white, the contrasting shades of gray should give you a good idea of what it would look like in color. If the objects receive a label (the four trees are labeled separately, for example), the task is known as instance segmentation.
An example of stratified sampling by label applied to segmentation. For this example task, assume that we care about errors related to human and bicycle pixels more than we care about errors related to tree and sky pixels. Our active learning sample will consist of a 90:10 split: 90% will be the most confusing samples for the labels that we care about most, and 10% will be about the labels that we don’t care about. Note that the pixels bordering the sky and trees vastly outnumber the pixels bordering humans and bicycles, so stratified sampling helps us focus on the errors that we care about most. Therefore, your sampling strategy might diverge from your accuracy evaluation strategy, in which you can simply apply relative weights of 90% and 10% to high- or low-value errors. The uncertainty sampling metrics don’t lend themselves as easily to this kind of weighting, so unless you are confident enough in your statistics skills to tune your weighting strategy, use this stratification method.
Table 6.1 An example sequence labels: keyword detection and two types of named entities, diseases, and locations. Label B (beginning) is applied to the beginning of the span, and Label I (inside) is applied to the other words within the span, allowing us to unambiguously distinguish spans that are next to each other, such as “San Francisco” and “supermarket”. This process is called IOB tagging, in which O (outside) is the nonlabel. (O is omitted from this table for readability.)
Table 6.2 An example of location identification and confidence associated with each label. The table shows an error in that only “San” from “San Francisco” is a location, but “Francisco” was reasonably high confidence. So we want to make sure that we take into account information outside the predicted spans when calculating confidence.
Three ways to encode predicted spans for active learning: using one-hot encoding to encode each token as its own feature (top left); using a noncontextual vector (embedding) such as word2vec (top right); and using a contextual embedding such as BERT (bottom). You can also experiment with average pooling (avepool) in place of or in addition to maximum pooling (maxpool).
Table 6.3 An example of a full-sequence parse, showing POS tags (labels) such as nouns, verbs, adverbs (Adv), proper nouns (PRP), and so on
Summary
- In many use cases, you want to identify or extract information within an image or document rather than label the entire image or document. The same active learning strategies can be applied to these use cases. Understanding the right strategy helps you understand the kinds of problems to which you can apply active learning and how to build the right strategy for your use case.
- You need to crop or mask your images and documents to get the most out of some active learning strategies. The right cropping or masking strategy produces better samples for human review, and understanding when you need to crop or mask your items helps you select the right method for your use cases.
- Active learning can be applied to many tasks beyond computer vision and NLP, including information retrieval, speech recognition, and videos. Understanding the broader landscape of active learning application areas will help you adapt any machine learning problem.
- The number of items to select for human review in each iteration of advanced active learning is highly specific to your data. Understanding the right strategy for your data is important for deploying the most efficient human-in-the-loop machine learning systems for your problems.
Human-in-the-Loop Machine Learning ebook for free