Online Self-supervised Learning

Machine Learning
Introduced by
Multiple contributors (Gidaris, Fini et al., among others)
Year
2020s
Type
Online unsupervised representation learning
Family
Machine learning

What does it do?

Online self-supervised learning (online SSL) trains neural networks on unlabeled data that arrives sequentially or as a stream, using supervisory signals generated from the data itself (pretext tasks) rather than human labels.

The model is updated as each chunk arrives, so the full dataset does not need to be stored or revisited. The term covers a loose research area rather than a single algorithm, and the setting applies when labels are unavailable and storage or privacy constraints rule out offline training.

The intuition behind the method

Standard self-supervised learning collects a pool of unlabeled data and trains on it in repeated passes. Online SSL drops that assumption: samples or small mini-batches arrive one after another, and the encoder must learn from each chunk before the next one comes in. The main difficulty is catastrophic forgetting, where adapting to recent data overwrites representations of earlier data. Methods for this setting therefore combine incremental updates with a mechanism that keeps past knowledge, such as a replay buffer or a distillation term. Note that some methods with 'online' in the name, such as OBoW, generate their training targets online while training on a fixed dataset; they are related but do not by themselves handle a data stream.

History

Self-supervised learning became a prominent route to unsupervised representation learning in the early 2020s, with contrastive and momentum-based methods such as SimCLR (Chen et al., 2020), MoCo and BYOL. Related work includes OBoW (Gidaris et al., CVPR 2021), which generates bag-of-visual-words targets online while training on a fixed dataset, and 'Self-Supervised Models are Continual Learners' (Fini et al., CVPR 2022), which addresses self-supervised learning in continual settings. No single originator of online SSL is established; it is a loose research area that draws on self-supervised, online and continual learning.

When to use it

Choose online SSL when labels are scarce or absent, data arrives as a continuous stream (for example sensor feeds, video or logs), and storing the full dataset for offline training is impractical because of storage, compute or privacy constraints. It is a reasonable fit when the input distribution changes over time, the continual-learning setting studied by Fini et al. (2022). Do not choose it when the data is static and fits in memory: standard offline self-supervised or supervised training is simpler and is the more natural starting point. Avoid it for very small datasets, where the update signal per step may be too sparse to learn stable structure.

Limitations and considerations

  • Balancing plasticity (adapting to new data) against stability (retaining earlier representations) is a tuning problem whose best setting depends on the dataset.
  • Representation quality typically lags behind offline SSL trained on the full dataset when that dataset is available.
  • Replay buffer size, exemplar selection rule and distillation weight add hyperparameters that cannot be set from a fixed offline validation run in the usual way.
  • Evaluation is harder than in standard SSL because the encoder changes after every update, so a single final score does not describe behaviour across the stream.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Learns from unlabeled data as it arrives, so no manual annotation is needed for pretraining.
  • Does not require holding the full history in memory; the state kept is the model plus, optionally, a small replay buffer.
  • Updates the model continuously, which suits settings where input distributions drift.
  • Suits privacy-constrained deployments where raw data cannot be retained or centralised.

Applications

  • Continuous visual representation learning from unlabeled video or camera streams.
  • Autonomous robotics where the agent must adapt its perception model to new environments on the fly.
  • Medical time-series monitoring with privacy constraints that prevent central data storage.
  • Edge-device learning where memory and compute budgets preclude offline batch training.
  • Natural language or speech encoding from streaming text or audio without labeled transcripts.

How it works

How it works

1

Data arrives as a sequence of samples or small buffers rather than as a fixed, pre-collected dataset, so training cannot assume that the full dataset is available at once or that samples are independent and identically distributed over time. Implementations either keep a small replay buffer of past examples or keep none; keeping none saves memory but leaves the forgetting-mitigation step with less to work with.

2

A pretext task produces a training signal from the raw input without annotation. Common families are contrastive objectives, masked prediction, clustering-based or visual-word targets, and distillation between an online encoder and a slowly updated target network (as in BYOL-style methods). OBoW (Gidaris et al., 2021) is an example of generating visual-word targets online during training, but on a fixed dataset rather than a stream. The choice matters in a streaming setting because contrastive objectives need enough diverse samples within each batch to form negative pairs, which a small or sparse stream may not supply.

3

Parameters are updated incrementally, typically by stochastic gradient descent on each arriving mini-batch, instead of over repeated epochs of a fixed dataset. Consecutive batches are drawn from a sequence rather than a shuffled pool, which can change the effective update behaviour. The learning rate, the momentum or target-network update rate, and the update frequency should therefore be tuned on a held-out labeled check rather than copied from offline training.

4

Forgetting is limited by experience replay (a small exemplar buffer), by distillation losses that pull the current model toward past representations, or by projection heads that separate transferable features from task-specific ones. Fini et al. (2022) study self-supervised models in continual learning and use such mechanisms. Each option trades memory or extra computation against stability, and the choice depends on the data and the available budget.

5

The encoder is used downstream for linear probing, supervised fine-tuning on a small labeled set, or direct feature extraction. Because the encoder keeps changing, a downstream model fitted to its features at one point may not match features produced later, so representation quality should be re-checked at intervals.

Common pitfalls

  • Treating sequential updates as equivalent to offline training and omitting any check for forgetting.
  • Evaluating only on the most recent chunk; a held-out labeled set covering all earlier distributions is needed to detect forgetting.
  • Reusing a learning rate and update schedule from offline training without re-tuning them on a held-out check, since consecutive correlated batches change update behaviour.
  • Confusing online SSL with online supervised learning: the pretext loss uses no labels, so the loss design and monitoring must be set up differently.
  • Assuming the representation stays useful after many updates without re-running downstream linear probes at intervals.

Frequently asked questions

How does online SSL differ from standard (offline) SSL?

Standard SSL collects a large fixed dataset first, then trains for many epochs over it. Online SSL processes data sequentially as it arrives and updates the model incrementally, without revisiting the entire history. This makes it suitable for streaming or privacy-constrained settings where the full dataset is never available at once.

Is a replay buffer always necessary?

No. Some methods, such as those using distillation or slowly moving target networks, aim to reduce forgetting without storing past examples. A small replay buffer is one common way to reduce forgetting; whether it improves representations for a given stream should be checked on a held-out labeled set.

Can online SSL be used with very small streams of data?

Sparse data streams make learning difficult because pretext tasks such as contrastive learning need sufficient within-batch diversity to form useful negative pairs. Very small mini-batches or very slow arrival rates can degrade representation quality. If possible, bootstrap the model with offline pre-training first.

How do I evaluate the representations over time?

Use periodic linear-probe evaluations on a fixed held-out labeled set: freeze the encoder at regular intervals and train a lightweight linear classifier on top. Report accuracy on data from earlier parts of the stream as well as recent ones, so the results show both learning progress and any forgetting. The probe interval is a practical choice that depends on stream length and compute budget.

Which pretext tasks suit the online setting?

No single pretext task is established as best for online training. The choice depends on data modality, batch size and hardware budget. Distillation-style objectives (BYOL-style) and clustering-based targets are alternatives to contrastive learning, and because contrastive learning relies on within-batch negatives, its behaviour under small or sparse batches should be tested directly.

Related methods

Sources

  1. Gidaris, S., Bursuc, A., Komodakis, N., Perez, P., & Cord, M. (2021). OBoW: Online Bag-of-Visual-Words Generation for Self-Supervised Learning. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 6830–6840.

    Open publication reference
  2. Fini, E., Da Costa, V. G. T., Alameda-Pineda, X., Ricci, E., Alahari, K., & Mairal, J. (2022). Self-Supervised Models are Continual Learners. Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 9621–9630.

    Open publication reference