SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2408.09849 · 2024

Importance Weighting Can Help Large Language Models Self-Improve

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 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 0 have no contract verdict; 3 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2408.09849.json · badge: /api/ran/2408.09849.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
rubickkcibur/IWSI canonical (classifier label)
classifier basis: census
4 ran · 3 no recorded run
FunctionStatusWhere it lives
derive_num_from_answer Ran
ran; our contract draft was wrong, not the code
rubickkcibur/IWSI/src/utils/utils.py
code served (permissive licence) · get_code("335e25ec1842885a")
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 str. 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 torch

torch.manual_seed(0)

def derive_num_from_answer(answer_test):
    num = answer_test.split('####')[-1]
    num = num.strip()
    num = num.replace(',', '')
    return num

# The function takes a string parameter answer_test
# It splits by '####', takes the last part, strips whitespace, and removes commas
# We need to provide a string that contains '####' to properly test the function

answer_test = "The answer is #### 1,234"

ARGS = {
    "answer_test": answer_test
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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: none by the harness; any seed is in the setup block
derive_ratings_from_answer Ran
ran; our contract draft was wrong, not the code
rubickkcibur/IWSI/src/utils/utils.py
code served (permissive licence) · get_code("43b2f74033592160")
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 str. 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 re

def derive_ratings_from_answer(answer):
    pattern = '(\\d+\\.?\\d*)'
    ret = re.search(pattern, answer)
    if ret is None:
        return None
    num = ret.group(1)
    if len(num) > 20:
        num = num[:20]
    return num

# Test case 1: Answer with a simple integer
answer_1 = "The rating is 8"

# Test case 2: Answer with a decimal number
answer_2 = "Score: 7.5 out of 10"

# Test case 3: Answer with a very long number (to test truncation)
answer_3 = "The number is 123456789012345678901234567890"

# Test case 4: Answer with no number
answer_4 = "No rating provided here"

ARGS = {
    "answer": "The answer is 4.2 stars"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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: none by the harness; any seed is in the setup block
format_ground_truth_answer Ran
ran; our contract draft was wrong, not the code
rubickkcibur/IWSI/src/utils/utils.py
code served (permissive licence) · get_code("8caa1a3b5af71291")
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 str. 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 re

def format_ground_truth_answer(ground: str):
    ground = ground.replace('####', 'The answer is')
    ground = re.sub('<<.*?>>', '', ground)
    return ground

ARGS = {
    'ground': 'Some text #### more text <<remove this>> and this <<too>> final text'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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: none by the harness; any seed is in the setup block
test_batch_loss Ran
ran, honoured the contract we drafted
rubickkcibur/IWSI/src/utils/evaluation.py
code served (permissive licence) · get_code("ed1617f12fd3d7a4")
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 float, ndim 0, dtype family float, shape () 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 torch
import torch.nn as nn
import copy

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.eos_token = "</s>"
    
    def __call__(self, sentences, add_special_tokens=True, max_length=None, 
                 truncation=False, padding=False, return_tensors=None):
        batch_size = len(sentences)
        seq_length = 8
        input_ids = torch.randint(0, 100, (batch_size, seq_length))
        attention_mask = torch.ones((batch_size, seq_length))
        
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask
        }

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(100, 4)
        self.linear = nn.Linear(4, 100)
    
    def forward(self, input_ids, attention_mask=None, labels=None):
        embedded = self.embedding(input_ids)
        logits = self.linear(embedded)
        
        class Output:
            pass
        
        output = Output()
        
        if labels is not None:
            loss_fn = nn.CrossEntropyLoss()
            shift_logits = logits[..., :-1, :].contiguous()
            shift_labels = labels[..., 1:].contiguous()
            loss = loss_fn(
                shift_logits.view(-1, shift_logits.size(-1)),
                shift_labels.view(-1)
            )
            output.loss = loss
        else:
            output.loss = torch.tensor(0.0)
        
        return output

model = MockModel()
tokenizer = MockTokenizer()
questions = ["What is 2+2?", "What is the capital of France?"]
answers = ["4", "Paris"]
max_length = 128

ARGS = {
    "model": model,
    "tokenizer": tokenizer,
    "questions": questions,
    "answers": answers,
    "max_length": max_length
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () 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
build_model Not yet run
unverified (harvested, no recorded run)
rubickkcibur/IWSI/src/model/trainLM.py
code served (permissive licence) · get_code("54bb152639bca9fe")
How it ran

no invocation recorded.

qa_preprocess Not yet run
unverified (harvested, no recorded run)
rubickkcibur/IWSI/src/model/trainLM.py
code served (permissive licence) · get_code("90be5ce7647bff49")
How it ran

no invocation recorded.

test_loss Not yet run
unverified (harvested, no recorded run)
rubickkcibur/IWSI/src/utils/evaluation.py
code served (permissive licence) · get_code("e144e5c5b9801622")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 6 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.

FunctionAlso present inEarliest-datedOthers named
qa_preprocess 1 other paper
1 later
2505.19715 (2025-05)
Graceful Forgetting in Generative Language Models

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-22.

Repositories linked to this paper

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

Abstract

Large language models (LLMs) have shown remarkable capability in numerous tasks and applications. However, fine-tuning LLMs using high-quality datasets under external supervision remains prohibitively expensive. In response, LLM self-improvement approaches have been vibrantly developed recently. The typical paradigm of LLM self-improvement involves training LLM on self-generated data, part of which may be detrimental and should be filtered out due to the unstable data quality. While current works primarily employs filtering strategies based on answer correctness, in this paper, we demonstrate that filtering out correct but with high distribution shift extent (DSE) samples could also benefit the results of self-improvement. Given that the actual sample distribution is usually inaccessible, we propose a new metric called DS weight to approximate DSE, inspired by the Importance Weighting methods. Consequently, we integrate DS weight with self-consistency to comprehensively filter the self-generated samples and fine-tune the language model. Experiments show that with only a tiny valid set (up to 5\% size of the training set) to compute DS weight, our approach can notably promote the reasoning ability of current LLM self-improvement methods. The resulting performance is on par with methods that rely on external supervision from pre-trained reward models.

For agents

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

get_harvested_code_for_paper("2408.09849")
get_code_for_paper("2408.09849")
have("2408.09849")

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

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

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

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

Connect an agent — have() is free.