Sub topic 13
Filtering Synthetic Labels by Confidence and Agreement
Assume you know basic Python, supervised text classification, precision, recall, F1, and basic probability. This chapter focuses on labels produced by an LLM or other noisy labeling sources. The goal is to keep useful labels while rejecting uncertain ones.
Why filter synthetic labels?
A synthetic label is a label created by a program, heuristic, or language model instead of a human annotator. Synthetic labels increase dataset size, but they can also contain mistakes.
Confidence filtering keeps an example only when the labeling source appears sufficiently certain. For an LLM, confidence can come from repeated answers, a model score, or agreement between independent sources.
Agreement is the proportion of valid answers that choose the winning class. If an LLM gives four positive answers and one negative answer, agreement is 4/5, or 0.80.
| Signal | Meaning | Common use |
|---|---|---|
| Agreement | How often sources choose the same class | Keep examples above a threshold |
| Coverage | How often a source gives any label | Find sources that abstain too often |
| Model probability | Estimated probability of a class | Train with soft labels or reject low scores |
| Gold-set accuracy | Correctness on human-labeled examples | Select and calibrate sources |
Repeated LLM answers
One answer can be unstable. Ask the model several times and accept the majority label only when agreement reaches a chosen threshold.
from collections import Counter
LABELS = {"positive", "negative"}
def label_by_agreement(text, ask, attempts=5, minimum=0.8):
prompt = (
"Classify this review as positive or negative. "
"Answer with one word.\n\nReview: " + text
)
answers = []
for _ in range(attempts):
answer = ask(prompt).strip().lower().rstrip(".")
if answer in LABELS:
answers.append(answer)
if not answers:
return None, 0.0
label, count = Counter(answers).most_common(1)[0]
agreement = count / len(answers)
if agreement < minimum:
return None, agreement
return label, agreement
def mock_ask(prompt):
return "positive"
print(label_by_agreement("The battery lasts all day.", mock_ask))The function abstains when no valid answer exists or when agreement is too low. Notice that agreement should normally use valid answers as its denominator. If invalid answers are common, track them separately because they indicate prompt or model problems.
Choosing a threshold
A threshold of 0.8 is a starting point, not a universal rule. A higher threshold usually improves precision but reduces coverage. A lower threshold keeps more data but introduces more noise.
Choose the threshold using a validation set with human labels. Measure precision at several thresholds, then select the lowest threshold that meets the error limit for your application. For safety-sensitive classification, false positives and false negatives may have different costs.
Combining sources
Agreement can come from multiple labeling functions, an LLM and a lexicon, or several independent models. Correlated sources can create misleading agreement. For example, three functions that all search for the same word are not three independent opinions.
Exercise
Exercise
Five valid LLM answers are positive, positive, negative, positive, and positive. With a minimum agreement of 0.8, should the example be kept?
Show answer
Yes. Positive wins with four of five answers, giving agreement of 0.8.