SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2604.12015 · 2026

UCS: Estimating Unseen Coverage for Improved In-Context Learning

Weijie Su, Qi Long, Xiang Li, Jiayi Xin, Weiqing He, Tianqi Shang, Evan Qiang

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 0 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2604.12015.json · badge: /api/ran/2604.12015.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Raina-Xin/UCS community
Papers with Code archive
5 ran · 0 no recorded run
FunctionStatusWhere it lives
SGTSpectrumState Ran
ran on a synthesized input
Raina-Xin/UCS/selection.py
code served (permissive licence) · get_code("ea39531e989f3aea")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned NoneType. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from collections import Counter, defaultdict
import scipy.stats

def smooth_counts_powerlaw(counts, k=None):
    from scipy.optimize import curve_fit
    if k is None:
        k = len(counts)
    r_nonzero = np.arange(1, len(counts) + 1)

    def power_law(r, C, alpha, beta):
        return C * (beta + r) ** (-alpha)
    params, _ = curve_fit(power_law, r_nonzero[:k], counts[:k])
    C_fit, alpha_fit, beta_fit = params
    fitted_data = power_law(r_nonzero, C_fit, alpha_fit, beta_fit)
    return fitted_data

def smoothed_good_toulmin_sgt(counts, t_list, bin_size=20, smooth_count=False, adaptive=False, mute=False, offset=1):
    """Estimates unseen knowledge using the Smoothed Good-Toulmin estimator with the given SGT formula."""
    assert 1 <= offset <= 2
    if type(t_list) is int:
        t_list = [t_list]
    freq_counts = defaultdict(int, counts)
    n_seen = np.sum([appear * number for appear, number in counts.items()])
    n_knowledge = np.sum([number for appear, number in counts.items()])
    if not mute:
        print(f'    With N={n_seen}, # seen = {n_knowledge}\n')
    if smooth_count:
        freq_spectrum = np.array([freq_counts[k] for k in range(1, 1 + len(freq_counts))])
        fitted_counts = smooth_counts_powerlaw(freq_spectrum)
        freq_counts = {i: int(fitted_counts[i - 1]) for i in np.arange(1, len(fitted_counts) + 1)}

    def estimate_for_bin_size(bin_size):
        unseen_estimates = []
        unseen_stds = []
        for t in t_list:
            unseen_estimate = 0
            unseen_variance = 0
            for s in range(1, bin_size + 1):
                freq_s = freq_counts[s]
                probability = 1 - scipy.stats.binom.cdf(s - 1, bin_size, offset / (t + offset))
                delta = -(-t) ** s * probability
                unseen_estimate += delta * freq_s
                unseen_variance += delta ** 2 * freq_s
            unseen_estimate = int(max(0, unseen_estimate))
            unseen_std = int(np.sqrt(max(0, unseen_variance)))
            unseen_estimates.append(unseen_estimate)
            unseen_stds.append(unseen_std)
            if not mute:
                print(f'    With N={n_seen}, t={t}, # unseen = {unseen_estimate} with std = {unseen_std}')
        return (unseen_estimates, unseen_stds)
    return estimate_for_bin_size(bin_size)

class SGTSpectrumState:

    def __init__(self, t: int, bin_size: int, smooth_count: bool, offset: float, ignore_label: int=-1):
        self.t = t
        self.bin_size = bin_size
        self.smooth_count = smooth_count
        self.offset = offset
        self.ignore_label = ignore_label
        self.type_counts = Counter()
        self.freq_by_s = defaultdict(int)
        self.seen = 0

    def add(self, c: int) -> None:
        if c == self.ignore_label:
            return
        m = self.type_counts[c]
        if m > 0:
            self.freq_by_s[m] -= 1
            if self.freq_by_s[m] == 0:
                del self.freq_by_s[m]
        else:
            self.seen += 1
        self.type_counts[c] += 1
        self.freq_by_s[m + 1] += 1

    def khat(self) -> float:
        if self.seen == 0:
            return 0.0
        unseen_list, _ = smoothed_good_toulmin_sgt(dict(self.freq_by_s), t_list=[self.t], bin_size=self.bin_size, smooth_count=self.smooth_count, mute=True, offset=self.offset)
        unseen_hat = float(unseen_list[0])
        if not np.isfinite(unseen_hat) or unseen_hat < 0:
            unseen_hat = 0.0
        return float(self.seen + unseen_hat)


INIT_ARGS = {
    't': 10,
    'bin_size': 5,
    'smooth_count': False,
    'offset': 1.5,
    'ignore_label': -1
}

ARGS = {
    'c': 0
}

METHOD = 'add'

if __name__ == '__main__':
    state = SGTSpectrumState(**INIT_ARGS)
    state.add(**ARGS)
    state.add(c=1)
    state.add(c=0)
    state.add(c=2)
    result = state.khat()
    print(f"khat result: {result}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type NoneType — a NoneType output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a NoneType output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
greedy_sgt_selection_fast Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Raina-Xin/UCS/selection.py
code served (permissive licence) · get_code("2c628a194ffc52a5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import random
from collections import Counter, defaultdict

# Set seed for reproducibility
np.random.seed(0)
random.seed(0)

# Create a small cluster_ids array
# Using values 0, 1, 2 as cluster IDs, with some repeated to create a realistic distribution
cluster_ids = np.array([0, 0, 1, 1, 1, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2], dtype=np.int32)

# Create RNG instance
rng = random.Random(42)

# Define ARGS dictionary with all parameters for greedy_sgt_selection_fast
ARGS = {
    'cluster_ids': cluster_ids,
    'budget': 8,
    'seed_size': 2,
    'rng': rng,
    't': 5,
    'bin_size': 20,
    'smooth_count': False,
    'offset': 1.0,
    'ignore_label': -1,
    'candidate_pool_per_step': 256
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
init_seed_indices Ran
ran, honoured the contract we drafted
Raina-Xin/UCS/selection.py
code served (permissive licence) · get_code("0567f974c2773512")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random

# Create a random.Random instance for the rng parameter
rng = random.Random(42)

# Define arguments for init_seed_indices
ARGS = {
    "n_points": 10,
    "seed_size": 3,
    "rng": rng
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
smooth_counts_powerlaw Ran
ran; our contract draft was wrong, not the code
Raina-Xin/UCS/selection.py
code served (permissive licence) · get_code("55eaf59c2948f163")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 1, dtype family float, shape (8,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create sample count data - a small array of counts that follows roughly a power law
counts = np.array([100.0, 50.0, 25.0, 15.0, 10.0, 8.0, 6.0, 5.0], dtype=np.float64)

# Define k as None (default behavior) or a specific value
k = None

ARGS = {
    "counts": counts,
    "k": k,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (8,) — shape (8,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
smoothed_good_toulmin_sgt Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Raina-Xin/UCS/selection.py
code served (permissive licence) · get_code("fd1a96b8bff26ae5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from collections import defaultdict

# Create a small frequency count dictionary
# This represents: 2 items appeared 1 time, 1 item appeared 2 times, etc.
counts = {1: 2, 2: 1, 3: 1, 4: 1}

# Create t_list parameter
t_list = [5, 10]

# Create bin_size parameter
bin_size = 4

# Create smooth_count parameter
smooth_count = False

# Create adaptive parameter
adaptive = False

# Create mute parameter
mute = True

# Create offset parameter
offset = 1

ARGS = {
    "counts": counts,
    "t_list": t_list,
    "bin_size": bin_size,
    "smooth_count": smooth_count,
    "adaptive": adaptive,
    "mute": mute,
    "offset": offset
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 5 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In-context learning (ICL) performance depends critically on which demonstrations are placed in the prompt, yet most existing selectors prioritize heuristic notions of relevance or diversity and provide limited insight into the coverage of a demonstration set. We propose Unseen Coverage Selection (UCS), a training-free, subset-level coverage prior motivated by the principle that a good demonstration set should expose the model to latent cluster unrevealed by the currently selected subset. UCS operationalizes this idea by (1) inducing discrete latent clusters from model-consistent embeddings and (2) estimating the number of unrevealed clusters within a candidate subset via a Smoothed Good-Turing estimator from its empirical frequency spectrum. Unlike previous selection methods, UCS is coverage-based and training-free, and can be seamlessly combined with both query-dependent and queryindependent selection baselines via a simple regularized objective. Experiments on multiple intent-classification and reasoning benchmarks with frontier LLMs show that augmenting strong baselines with UCS consistently improves ICL accuracy by up to 2-6% under the same selection budget, while also yielding insights into task-and model-level latent cluster distributions. Code is available at https: //github.com/Raina-Xin/UCS.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2604.12015")
get_code_for_paper("2604.12015")
have("2604.12015")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2604.12015.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2604.12015.svg)](https://syntology.ai/paper/2604.12015)

Connect an agent — have() is free.