Active Learning Implementation for Data Labeling Optimization

We design and deploy artificial intelligence systems: from prototype to production-ready solutions. Our team combines expertise in machine learning, data engineering and MLOps to make AI work not in the lab, but in real business.
Showing 1 of 1All 1564 services
Active Learning Implementation for Data Labeling Optimization
Medium
~1-2 weeks
Frequently Asked Questions

AI Development Areas

AI Solution Development Stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1347
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1247
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    948
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1183
  • image_logo-advance_0.webp
    B2B Advance company logo design
    642
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    921

Data labeling is the most expensive part of an ML project. For NLP with hundreds of thousands of examples, the annotation budget often exceeds the training budget. We've seen projects where clients spent 80% of their time on manual labeling, yet metric improvement was only 2%. The reason: 90% of examples the model recognizes confidently — labeling them is pointless. Active Learning (AL) solves this: the algorithm itself selects 'hard' objects where model confidence is low. Only those need labeling. Result: 5-10x savings on labeling budget while maintaining quality at 90% of full labeling. This technique, also known as active selection learning, focuses on the most informative examples. AL is a key technique for labeling automation. Our engineers implement this method end-to-end: from strategy selection to platform integration. This article covers the main strategies, code, and implementation experience.

Active Learning is a machine learning method where the algorithm selects the most informative examples for labeling.

Which strategies work best?

In practice we use three main selection strategies:

Strategy Principle When to apply
Uncertainty Sampling Selects examples with maximum model uncertainty (entropy, margin, least confidence) Classification, regression — any task with probabilistic output
Query by Committee An ensemble of models votes; examples with maximum vote disagreement are selected No data for probability calibration, robustness needed
Core-Set Sampling Selects examples maximally distant from already labeled ones (geometric coverage) Need diversity in dataset, avoid duplicate uncertainty

Uncertainty Sampling

The classic approach — the model predicts probabilities and we select examples with the lowest confidence. Implementation typically uses entropy:

import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.base import BaseEstimator

class UncertaintySampler:
    def __init__(self, model: BaseEstimator, strategy='entropy'):
        self.model = model
        self.strategy = strategy

    def query(self, X_unlabeled: np.ndarray, n_instances: int = 10) -> np.ndarray:
        proba = self.model.predict_proba(X_unlabeled)

        if self.strategy == 'entropy':
            scores = -np.sum(proba * np.log(proba + 1e-10), axis=1)
        elif self.strategy == 'margin':
            sorted_proba = np.sort(proba, axis=1)
            scores = 1 - (sorted_proba[:, -1] - sorted_proba[:, -2])
        elif self.strategy == 'least_confident':
            scores = 1 - proba.max(axis=1)

        return np.argsort(scores)[-n_instances:]

Uncertainty Sampling is simple to implement and works for any model with predict_proba. However, it does not account for diversity, so it may select similar uncertain examples.

Query by Committee

Here we train not one model but an ensemble (e.g., on bootstrap samples). Disagreement among committee members indicates informativeness:

from sklearn.base import clone

class CommitteeSampler:
    def __init__(self, base_estimator, n_members=5):
        self.committee = [clone(base_estimator) for _ in range(n_members)]

    def fit_committee(self, X_labeled, y_labeled):
        n = len(X_labeled)
        for member in self.committee:
            bootstrap_idx = np.random.choice(n, n, replace=True)
            member.fit(X_labeled[bootstrap_idx], y_labeled[bootstrap_idx])

    def query(self, X_unlabeled, n_instances=10):
        predictions = np.array([
            member.predict(X_unlabeled) for member in self.committee
        ])
        vote_entropy = []
        for sample_idx in range(X_unlabeled.shape[0]):
            votes = predictions[:, sample_idx]
            unique, counts = np.unique(votes, return_counts=True)
            probs = counts / len(votes)
            entropy = -np.sum(probs * np.log(probs + 1e-10))
            vote_entropy.append(entropy)
        return np.argsort(vote_entropy)[-n_instances:]

This strategy is more robust to overfitting and often yields better quality gains.

Core-Set Sampling

If we want to cover the entire feature space, not just decision boundaries, we use Core-Set. It selects points maximally distant from already labeled ones:

from sklearn.metrics import pairwise_distances

def core_set_selection(X_labeled, X_unlabeled, n_instances):
    selected_indices = []
    labeled_pool = X_labeled.copy()
    for _ in range(n_instances):
        distances = pairwise_distances(X_unlabeled, labeled_pool)
        min_distances = distances.min(axis=1)
        best_idx = np.argmax(min_distances)
        selected_indices.append(best_idx)
        labeled_pool = np.vstack([labeled_pool, X_unlabeled[best_idx]])
    return np.array(selected_indices)

In our benchmarks, Query by Committee yields up to 30% higher model accuracy compared to Uncertainty Sampling on noisy datasets. Core-Set Sampling covers the feature space 5x more efficiently than random selection.

Limitations of Active Learning

If the dataset is already balanced and contains few 'easy' examples, the gain may be small. We always perform a preliminary analysis: build a learning curve on a sample to understand the savings potential. For one project, the preliminary test showed only 20% savings, so we recommended against implementation.

Choosing Between Committee and Uncertainty Sampling

Committee works better with noisy data and when model probability calibration is inaccurate. In practice we often combine both strategies within one cycle: use Committee for diversity in early iterations, then switch to Uncertainty for precision.

Active Learning for NER

For sequence labeling we use token-level uncertainty. We aggregate entropy over all tokens in a sentence — select the most uncertain sentences:

import torch
from transformers import AutoModelForTokenClassification, AutoTokenizer

def ner_uncertainty_sampling(texts, model, tokenizer, n_instances=20):
    sentence_uncertainties = []
    for i, text in enumerate(texts):
        inputs = tokenizer(text, return_tensors='pt', truncation=True, max_length=512)
        with torch.no_grad():
            outputs = model(**inputs)
        probs = torch.softmax(outputs.logits, dim=-1).squeeze()
        token_entropy = -(probs * torch.log(probs + 1e-10)).sum(dim=-1)
        sentence_uncertainty = token_entropy.max().item()
        sentence_uncertainties.append((i, sentence_uncertainty))
    sentence_uncertainties.sort(key=lambda x: x[1], reverse=True)
    return [idx for idx, _ in sentence_uncertainties[:n_instances]]

This approach yields 3-5x savings for NER datasets. For an NER dataset with 100k sentences, we achieved a 3x reduction in labeling effort.

Full Active Learning Pipeline

class ActiveLearningPipeline:
    def __init__(self, model, sampler, labeling_budget):
        self.model = model
        self.sampler = sampler
        self.budget = labeling_budget
        self.labeled_count = 0
        self.performance_history = []

    def run(self, X_initial, y_initial, X_pool, batch_size=20):
        X_labeled, y_labeled = X_initial.copy(), y_initial.copy()
        X_unlabeled = X_pool.copy()
        while self.labeled_count < self.budget and len(X_unlabeled) > 0:
            self.model.fit(X_labeled, y_labeled)
            current_metric = self.evaluate(X_labeled, y_labeled)
            self.performance_history.append({
                'n_labeled': len(X_labeled),
                'metric': current_metric
            })
            query_idx = self.sampler.query(X_unlabeled, n_instances=batch_size)
            new_y = get_labels_from_annotator(X_unlabeled[query_idx])
            X_labeled = np.vstack([X_labeled, X_unlinked[query_idx]])
            y_labeled = np.concatenate([y_labeled, new_y])
            X_unlabeled = np.delete(X_unlabeled, query_idx, axis=0)
            self.labeled_count += batch_size
        return self.performance_history

This code illustrates the full cycle — we adapt it to your infrastructure.

How we implement active learning in your project

The typical process consists of 5 steps:

  1. Data and business task analysis — define metrics, dataset structure, available annotation types.
  2. Selection strategy choice — test Uncertainty Sampling, Committee and Core-Set on your task; choose the best based on learning curve.
  3. Pipeline development — implement the cycle: train → select → label → retrain. Integrate with platforms Label Studio or Scale AI.
  4. Pilot launch — on a small dataset (1000-5000 examples) verify effectiveness.
  5. Production — automate the process, set up metric monitoring (latency p99, GPU utilization) and cycle restarts.

Our team has over 5 years of experience in active learning, having implemented it for 15+ projects.

Timelines and cost

Stage Duration
Basic pipeline (Uncertainty Sampling + Label Studio integration) 2-3 weeks
Extended (Committee + Core-Set + NLP/NER) 6-8 weeks
Custom cold strategy for specific data from 8 weeks

Cost is determined after analysis. Implementation costs start at $5,000, with typical savings exceeding $100,000 per year for large projects.

What's included in the deployment

  • Working active learning pipeline integrated with your labeling system
  • Metrics dashboard: model quality dynamics, budget savings, distribution of selected examples
  • Documentation and user guide
  • 3 months of post-launch support

We have implemented active learning for 15+ projects in NLP and Computer Vision. One recent case: a review classification task — we reduced labeling volume from 50,000 to 8,000 examples while maintaining F1 at 0.94. In a recent project, we achieved a 6x reduction in labeling costs while model F1 score dropped only 0.01.

Active Learning is a proven methodology that has already saved our clients millions of rubles. We guarantee implementation quality and transparent results.

Contact us: tell us about your task — we'll propose the optimal active learning strategy. Get a free consultation from a machine learning engineer.

How Do AutoGluon, FLAML, and Vertex AI AutoML Work and When to Use Them?

When a business wants to quickly get a model, we offer implementation of AutoML platforms. This is not a 'make me AI' button, but automation of hyperparameter tuning and algorithm selection. The difference is critical: without quality data and proper problem formulation, even the best platform will produce garbage. But for specific tasks, AutoML saves weeks of manual iterations.

AutoML automates model selection and hyperparameter tuning. On structured tabular data, modern systems compete with manual ML engineering. For example, on Kaggle competitions, AutoGluon without any tuning reaches the top 10% on many datasets. The reason: it builds an ensemble of LightGBM, XGBoost, CatBoost, neural networks, and RF with stacking — such an ensemble often outperforms the single best model by 5–10% in metric.

Good candidates for AutoML platforms:

  • Standard binary/multiclass classification or regression on tabular data
  • Tasks without strict latency (< 50 ms) or model size (< 10 MB) constraints
  • MVP or baseline before manual optimization
  • Teams without deep ML expertise needing a working prototype in 1–2 weeks

Bad candidates: custom loss, specific architectures, real-time inference with hard constraints, domain-specific tasks (medical imaging, NLP in a rare language).

What Makes AutoGluon the Best Choice for Tabular Data?

AutoGluon-Tabular is the strongest AutoML for tables by most benchmarks. The key feature is multi-level stacking. First-layer models (LightGBM, XGBoost, CatBoost, FastAI tabular, KNN) → their predictions as features → second-layer models. This is configured via num_stack_levels=2.

from autogluon.tabular import TabularPredictor

predictor = TabularPredictor(
    label='target',
    eval_metric='roc_auc',
    path='./ag_models'
).fit(
    train_data,
    time_limit=3600,  # 1 hour
    presets='best_quality',  # vs 'medium_quality', 'high_quality'
)

Preset best_quality includes stacking and ensembles, uses maximum memory and time. medium_quality is a speed/quality balance suitable for >1M rows. optimize_for_deployment removes heavy ensembles, speeds up inference.

A typical pitfall: AutoGluon trains dozens of models and saves all to disk — from 2 to 10 GB for serious tasks. When deploying, export only the final model via predictor.clone_for_deployment(). Be careful with memory: with num_stack_levels=2 on 500k rows, OOM may occur on machines with <32 GB RAM. Solution: ag_args_fit={'num_cpus': 4, 'num_gpus': 0} and excluded_model_types=['NeuralNetFastAI'].

How Does FLAML Save Resources and Time?

FLAML (Fast and Lightweight AutoML) from Microsoft focuses on minimal compute budget while achieving good quality. It uses cost-frugal search: first tries cheap configurations, gradually moving to expensive ones. This yields up to 2x time savings compared to AutoGluon on the same budget, though final quality may be 3–5% lower.

from flaml import AutoML
automl = AutoML()
automl.fit(X_train, y_train, task="classification", time_budget=120, metric="roc_auc")

It is well suited for limited compute budgets, tasks requiring time_budget < 60 sec, and integration into CI/CD pipelines. FLAML also supports LLM fine-tuning via flaml.autogen — automatic prompt tuning for GPT/Claude.

What Are the Use Cases for Vertex AI AutoML?

Google Vertex AI AutoML is the right managed service when:

  • You don't have your own ML infrastructure
  • You need integration with BigQuery, Cloud Storage, Dataflow
  • The task is Computer Vision or NLP (not just tables)
  • You need a managed inference endpoint without DevOps

Training cost is per node hour. For 100k rows and 50 features, training typically takes 2–4 hours. Inference cost is per prediction. For high-load tasks, self-hosted AutoGluon is more cost-effective. Limitations: less control over architecture, model export only to TF SavedModel or TFLite, no ONNX. However, it provides managed feature store, automatic drift monitoring, and MLOps out of the box.

Comparison of Major AutoML Platforms

Characteristic AutoGluon FLAML Vertex AI AutoML
Quality on tables ★★★★★ ★★★★ ★★★★
Training speed ★★★ ★★★★★ ★★★
Infrastructure requirements Own machine/GPU Any environment Google Cloud
Flexibility (custom loss and pipelines) High Medium Low
Best for Production, high-quality Fast experiments Managed service

What Does AutoML Implementation Include?

We provide the full cycle: from quick benchmark to production system with monitoring. Deliverables include:

  • EDA and data preparation (feature engineering, handling missing values, encoding)
  • Training and comparison of 3+ AutoML configurations with metric logging
  • Selection of the best model and its export (ONNX, TF SavedModel, TorchScript)
  • Deployment of inference endpoint (Docker, Kubernetes, serverless)
  • Model card documentation and retraining instructions
  • Team training on platform usage (2 hours)

We guarantee a baseline in 5 business days, production solution in 2–4 weeks depending on complexity.

Work Process and Timelines

  1. Analytics (1–2 days) — requirement gathering, EDA, metric definition.
  2. Benchmark (2–3 days) — run AutoGluon medium_quality, FLAML, Vertex AI. Baseline recording.
  3. Optimization (3–5 days) — feature engineering, manual hyperparameter tuning, stacking.
  4. Test and validation (2–3 days) — evaluation on holdout set, drift check, A/B test.
  5. Deployment (2–4 days) — containerization, CI/CD, monitoring metrics.

Timelines: MVP from 1 week. Full production system with auto-retraining from 3 weeks.

What Sets Us Apart for AutoML Implementation?

We have 5 years of experience and over 20 successful projects implementing AutoML platforms in retail, fintech, and logistics. Certified engineers in AWS Machine Learning and Google Cloud Professional Data Engineer. We don't just run code — we train your team and ensure the model performs stably in production.

Get a consultation on AutoML for your task — leave a request. Or order a free benchmark: we will analyze your data and tell you how much time and money AutoML can save.