Weakly Supervised Sentence Embeddings

Machine Learning
Introduced by
Ratner et al. (weak supervision framework); Reimers & Gurevych (sentence embeddings)
Year
2016–2019
Type
Representation learning under weak supervision
Family
Deep learning / NLP / CV

What does it do?

Weakly supervised sentence embeddings train dense sentence representations from noisy, heuristic, or programmatically generated labels rather than costly human annotation.

Labeling functions (rules, distant-supervision signals, or lightweight classifiers) supply approximate supervision, which a label model aggregates into probabilistic labels that guide the sentence encoder.

The intuition behind the method

Annotating thousands of sentences by hand is expensive, but domain knowledge often exists as simple rules: a sentence containing 'adverse event' likely describes a clinical complication, and a review with many exclamation marks is probably positive. Weak supervision turns such heuristics into probabilistic training signals. A pre-trained transformer encoder is then fine-tuned on these noisy labels, learning to place semantically related sentences close together in vector space without clean gold labels. The result is a representation for classification, retrieval, or clustering in settings where the annotation budget does not allow full supervision.

History

Weak supervision as used here was formalized by Ratner et al. (2016) in data programming, which framed the generation of training labels from user-written labeling functions as a generative modelling problem. Reimers and Gurevych (2019) described Siamese BERT networks for producing sentence vectors, which is the encoder family often used in these pipelines. Pairing weak-supervision label generation with transformer fine-tuning is a later practice that builds on these works rather than being established by either one.

When to use it

Choose weakly supervised sentence embeddings when you have a large unlabeled text collection, usable domain heuristics or structured knowledge sources that can be turned into labeling functions, and too little annotation budget for full supervision. They can be useful where general-purpose embeddings perform poorly, such as biomedical, legal, or financial text, and where label noise is unavoidable, as in social media or clinical notes. Do not use them when a substantial clean labeled set is available, since full supervised fine-tuning is the more direct route. Also avoid them when the domain offers no reliable labeling functions: poor or conflicting functions can degrade the representation and may fall below a simple zero-shot baseline in some settings, so compare against that baseline on the target task.

Limitations and considerations

  • Quality depends on the coverage and accuracy of the labeling functions; inaccurate functions or functions that fire on few sentences degrade the training signal.
  • The basic label model assumes that labeling functions are conditionally independent given the true label. This assumption may not hold exactly in practice, and correlated functions can make the model overweight a shared signal.
  • Fine-tuning a large transformer encoder costs more compute than using static or off-the-shelf sentence vectors.
  • Without clean gold labels, measuring performance requires a manually annotated test set, which reintroduces annotation cost.
  • When a clean labeled dataset of moderate size is available, full supervised fine-tuning is typically stronger; the crossover point depends on the task and is not fixed.

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

Strengths

  • Makes supervision feasible for a large unlabeled corpus when hand annotation is the bottleneck, because each labeling function can be applied to every sentence at low marginal cost once written.
  • Combines heterogeneous weak signals (keyword rules, knowledge-base lookups, classifier predictions) through a label model that estimates each function's accuracy rather than weighting them by hand.
  • Starts from a pre-trained transformer, so the weak labels only need to shape a task-relevant structure in the embedding space rather than teach language from scratch.
  • Soft labels carry per-sentence confidence into training, so sentences with conflicting signals contribute less certain targets than sentences where the functions agree.
  • The same embeddings can be reused across several downstream tasks, so one weak-supervision effort can serve more than one application.

Applications

  • Biomedical and clinical NLP: classifying patient notes, adverse events, and phenotype descriptions without large annotated corpora.
  • Legal document analysis: embedding contract clauses or case sentences where keyword and structural heuristics can serve as labeling functions.
  • Social media monitoring (illustrative): sentiment or topic representations could be learned from lexical rules and engagement signals, although such signals are noisy and need domain validation.
  • Scientific literature mining (illustrative): distant supervision from citation databases might support clustering and retrieval of research sentences, subject to validation of label accuracy.
  • Low-resource language settings (illustrative): cross-lingual knowledge bases could be used as labeling functions to produce task-aligned embeddings, subject to the same validation.
  • Customer support automation: building intent-embedding models from ticket routing rules and agent-assigned tags.

How it works

How it works

1

Domain experts or automated pipelines define labeling functions: keyword rules, regex patterns, distant supervision from knowledge bases, or predictions from weak classifiers. Each function covers a subset of sentences and assigns a noisy label; the rest of the sentences remain unlabeled, because the function abstains on them.

2

A generative label model, of the kind introduced in data programming (Ratner et al., 2016), estimates the accuracy of each labeling function and how the functions correlate with one another, without observing true labels. It then combines their outputs into one probabilistic label per sentence, converting sparse and sometimes conflicting signals into a supervision distribution.

3

A sentence encoder, commonly a pre-trained BERT or RoBERTa backbone with mean pooling, is fine-tuned on the probabilistically labeled sentences using a classification-style loss that compares the model's predictions with the label model's probability distribution (for example, cross-entropy against the soft targets). The soft labels let training use the noisy signal while the backbone keeps the linguistic knowledge acquired during pre-training. A Siamese or triplet architecture (as described by Reimers and Gurevych, 2019) can also serve as the encoder, but the per-sentence probabilistic labels must then first be converted into pair or triplet targets, for example by weighting pairs according to label agreement. This conversion is an additional design decision that the practitioner has to choose and validate.

4

At inference time, the encoder maps each sentence to a fixed-dimensional vector through token-level pooling (mean, CLS token, or a learned aggregation). The pooling choice changes the geometry of the vectors and should be validated on the held-out test set rather than assumed.

5

The embeddings serve as features for classification, semantic search, clustering, or cross-lingual alignment. Often a lightweight head or cosine-similarity retrieval is enough, which can reduce the labeled data needed for each new task.

Common pitfalls

  • Writing labeling functions that overlap heavily, so the label model attributes too much weight to a shared signal rather than to independent evidence.
  • Skipping a check of labeling-function coverage and conflict rates before training; low coverage leaves much of the corpus unlabeled and conflict rates show where functions disagree.
  • Treating the label model's output as ground truth and reporting agreement with it as evidence of embedding quality.
  • Forgetting that the test set must remain fully human-annotated; contaminating it with weak labels inflates apparent accuracy.
  • Assuming labeling functions written for one corpus carry over to another; keyword rules tuned on clinical notes can misfire on other text, so each new domain needs its own validation.

Frequently asked questions

How many labeling functions do I need?

There is no fixed minimum. What matters more is that the functions cover a substantial part of the corpus and fire on different subsets of the data, because overlapping functions make it harder for the label model to separate each function's accuracy from its correlation with the others.

Can I use weakly supervised embeddings without a pre-trained transformer?

Yes, but pre-trained transformers (BERT, RoBERTa) provide a strong initialization that compensates for noisy supervision. Training a sentence encoder from scratch under weak supervision generally requires substantially more data and more careful labeling function design to reach comparable quality.

How do I know if my labeling functions are good enough?

Inspect coverage (the fraction of sentences labeled), conflict rate (the fraction where functions disagree), and empirical accuracy on a small manually annotated validation slice. High conflict with low coverage usually signals that the functions need refinement before training.

Is this the same as self-supervised sentence embeddings?

No. Self-supervised methods, such as contrastive pre-training, generate supervision from the structure of the data itself, for example by predicting masked tokens or using data augmentation, without an external label signal. Weakly supervised embeddings explicitly use external labeling functions that encode domain knowledge, typically for a specific downstream task.

What evaluation metric should I report?

Report performance on a manually annotated held-out test set using task-appropriate metrics: F1 (macro or weighted for multi-class), AUC-ROC for binary tasks, and mean average precision or NDCG for retrieval. Always report the size and source of the test annotation.

Related methods

Sources

  1. Ratner, A., De Sa, C., Wu, S., Selsam, D., & Re, C. (2016). Data Programming: Creating Large Training Sets, Quickly. Advances in Neural Information Processing Systems (NeurIPS), 29.

    Open publication reference
  2. Reimers, N., & Gurevych, I. (2019). Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing (EMNLP).

    Open DOI reference