# Calibrated Similarity

> Measures the semantic novelty of LLM-generated text by quantifying its similarity to the closest segment in the model's pretraining corpus. It probes whether models merely reproduce memorized training data or generalize to produce compositionally distinct outputs. Use when the user has predictions and gold and needs to compute calibrated similarity.

- Skill: `qhjqhj00/calibrated-similarity` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/calibrated-similarity`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/calibrated-similarity/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/calibrated-similarity

---


# calibrated-similarity

> LLM generation novelty through the lens of semantic similarity — Davydov et al. (2025) (arXiv:2510.27313, 2025)

## What this evaluates

Measures the semantic novelty of LLM-generated text by quantifying its similarity to the closest segment in the model's pretraining corpus. It probes whether models merely reproduce memorized training data or generalize to produce compositionally distinct outputs.

## Datasets

- **Dolma (Reddit & Pes2o subsets)** — total 1210; splits: test (1210)
- **GSM8K** — total ?; splits: test (-1)
- **TruthfulQA** — total ?; splits: test (-1)
- **OpenRewriteEval** — total ?; splits: test (-1)

## Metrics

- `calibrated similarity` **(primary)** — range: [0, 1]
  - Computes the maximum semantic similarity between a generated text and any chunk in the pretraining corpus using a two-stage retrieval pipeline (GIST embeddings for coarse retrieval, ColBERTv2 for re-ranking). Scores are calibrated to account for generation length variations.

## Input / output format

**Input**: For open-ended generation: empty string or neutral instruction. For prompted generation: 1000-token context window from a source document. For domain tasks: standard prompts from GSM8K, TruthfulQA, and OpenRewriteEval.

**Output**: Generated text continuation or answer.

## Scoring recipe

```python
def compute_novelty(model, input_text, corpus_chunks, gold_answer):
    gen = model.generate(input_text)
    # Stage 1: Coarse retrieval with GIST embeddings
    candidates = faiss_search(gist_embed(gen), topk=100)
    # Stage 2: Re-ranking with ColBERTv2
    best_chunk = colbertv2_rerank(gen, candidates)[0]
    # Compute raw similarity
    raw_sim = colbertv2_score(gen, best_chunk)
    # Filter for correctness (domain-specific)
    if not is_correct(gen, gold_answer): return None
    # Calibrate for length and return
    return calibrate_similarity(raw_sim, len(gen))
```

## Common pitfalls

- Conflating novelty with hallucination: nonsensical outputs are trivially novel because they do not match training data, so correctness filtering is mandatory.
- Ignoring generation length effects: similarity scores vary systematically with output length, requiring analysis across multiple chunk sizes (k ∈ {50, 100, ..., 500}).
- Relying on lexical matching: surface-level paraphrasing or stylistic shifts can hide high semantic similarity, necessitating token-level late-interaction (ColBERTv2).

## Evidence (verbatim from paper)

> Figure[2] shows that models prompted without context (right plots) achieve higher calibrated similarity scores across chunk sizes than context-conditioned generations (left plots), for both SmolLM and SmolLM2.

## Citation

```bibtex
@misc{davydov2025llm,
  title={LLM generation novelty through the lens of semantic similarity},
  author={Davydov et al. (2025)},
  year={2025},
  note={arXiv:2510.27313}
}
```

- arXiv: 2510.27313

