SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2607.16431 · 2026

RIMS: Preference Optimization via Smoothed Multi-pair Aggregation for Small-Scale LLM Retrieval-Augmented Generation

Tianci Liu, Linjun Zhang, Haoyu Wang, Zihan Dong, Pei Tian

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; 0 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 4 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/2607.16431.json · badge: /api/ran/2607.16431.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
tptrix29/RIMS canonical (classifier label)
classifier basis: census
5 ran · 0 no recorded run
FunctionStatusWhere it lives
exact_match Ran
ran, violated the contract we drafted
tptrix29/RIMS/baseline/baseline_instructrag.py
code served (permissive licence) · get_code("693e3eb42781f873")
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 bool, 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 re
import string

def normalize_answer(s):

    def remove_articles(text):
        return re.sub('\\b(a|an|the)\\b', ' ', text)

    def white_space_fix(text):
        return ' '.join(text.split())

    def remove_punc(text):
        exclude = set(string.punctuation)
        return ''.join((ch for ch in text if ch not in exclude))

    def lower(text):
        return text.lower()
    return white_space_fix(remove_articles(remove_punc(lower(s))))

def exact_match(prediction, ground_truth):
    return normalize_answer(prediction) == normalize_answer(ground_truth)

# Setup code
ARGS = {
    "prediction": "The quick brown fox jumps over the lazy dog.",
    "ground_truth": "the quick brown fox jumps over the lazy dog"
}
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 bool, 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
normalize_answer Ran
ran; our contract draft was wrong, not the code
tptrix29/RIMS/baseline/baseline_instructrag.py
pointer only (licence: MIT); the stored copy get_code serves, from shmsw25/GraphRetriever, is pointer only (licence: NONE) · get_code("dae7ab386661a4f4")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from shmsw25/GraphRetriever, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

normalize_question Ran
ran; our contract draft was wrong, not the code
tptrix29/RIMS/baseline/baseline_instructrag.py
code served (permissive licence) · get_code("55d1f049e88b9924")
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

def normalize_question(question):
    if not question.endswith('?'):
        question = question + '?'
    return question[0].lower() + question[1:]

ARGS = {
    'question': 'What is this'
}
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
restore Ran
ran; our contract draft was wrong, not the code
tptrix29/RIMS/training/data_vllm.py
code served (permissive licence) · get_code("1ab38c8517a7a5ef")
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. 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 pickle
import json
import tempfile
import os
from collections import defaultdict

# Create temporary directory for test files
tmpdir = tempfile.mkdtemp()
prefix = os.path.join(tmpdir, "test_data")

# Create mock cache data structures
q_chosen_cache = {
    0: [
        [{"role": "user", "content": "hello"}, {"role": "assistant", "content": "response1"}],
        [{"role": "user", "content": "hi"}, {"role": "assistant", "content": "response2"}],
    ],
    1: [
        [{"role": "user", "content": "question"}, {"role": "assistant", "content": "answer1"}],
    ]
}

q_rejected_cache = {
    0: [
        [{"role": "user", "content": "hello"}, {"role": "assistant", "content": "bad_response1"}],
        [{"role": "user", "content": "hi"}, {"role": "assistant", "content": "bad_response2"}],
    ],
    1: [
        [{"role": "user", "content": "question"}, {"role": "assistant", "content": "bad_answer1"}],
    ]
}

q_logp_chosen_cache = {
    0: [1.5, 2.3],
    1: [1.2]
}

q_logp_rejected_cache = {
    0: [0.8, 1.1],
    1: [0.9]
}

# Create preference data
preference_data = {
    "0": {"chosen": "response1", "rejected": "bad_response1"},
    "1": {"chosen": "answer1", "rejected": "bad_answer1"}
}

# Create idx_list
idx_list = [0, 1]

# Save all files
with open(f'{prefix}_chosen_cache.pkl', 'wb') as f:
    pickle.dump(q_chosen_cache, f)

with open(f'{prefix}_rejected_cache.pkl', 'wb') as f:
    pickle.dump(q_rejected_cache, f)

with open(f'{prefix}_logp_chosen_cache.pkl', 'wb') as f:
    pickle.dump(q_logp_chosen_cache, f)

with open(f'{prefix}_logp_rejected_cache.pkl', 'wb') as f:
    pickle.dump(q_logp_rejected_cache, f)

with open(f'{prefix}.json', 'w') as f:
    json.dump(preference_data, f)

with open(f'{prefix}_idx_list.txt', 'w') as f:
    for idx in idx_list:
        f.write(f"{idx}\n")

num_data = 3

ARGS = {
    "prefix": prefix,
    "num_data": num_data
}
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 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
run_inference Ran
ran; our contract draft was wrong, not the code
tptrix29/RIMS/training/data_vllm.py
code served (permissive licence) · get_code("ec6550f53d905905")
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 float; 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 torch
import torch.nn as nn

torch.manual_seed(0)

# Stand-in classes for vLLM-like objects
class TokenLogprob:
    def __init__(self, logprob_value):
        self.logprob = logprob_value

class CompletionOutput:
    def __init__(self, text, logprobs=None):
        self.text = text
        self.logprobs = logprobs or []

class RequestOutput:
    def __init__(self, outputs):
        self.outputs = outputs

class SamplingParams:
    def __init__(self, logprobs=False):
        self.logprobs = logprobs

class MockLLM(nn.Module):
    def __init__(self):
        super().__init__()
    
    def chat(self, batch_msgs, sampling_params=None, continue_final_message=False, add_generation_prompt=False):
        # Return a list of RequestOutput objects, one per message batch
        batch_outputs = []
        for msg in batch_msgs:
            if sampling_params.logprobs:
                # Create logprobs structure: list of dicts with token_id -> TokenLogprob
                logprobs = [
                    {0: TokenLogprob(-0.5)},
                    {1: TokenLogprob(-0.3)}
                ]
                completion = CompletionOutput("Generated text.", logprobs=logprobs)
            else:
                completion = CompletionOutput("Generated text.", logprobs=[])
            batch_outputs.append(RequestOutput([completion]))
        return batch_outputs

# Create mock objects
llm = MockLLM()

batch_msgs = [
    [{"role": "user", "content": "Hello"}],
    [{"role": "user", "content": "Hi"}]
]

sampling_params = SamplingParams(logprobs=True)

ARGS = {
    "llm": llm,
    "batch_msgs": batch_msgs,
    "sampling_params": sampling_params
}
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 tuple, ndim 2, dtype family float — 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, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 1 later) and 3 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
normalize_answer 133 other papers
131 dated earlier, 1 later, 1 undated · 1 only as an assembly brick
1508.06615 (2015-08)
Character-Aware Neural Language Models
1606.05250 (2016-06)
SQuAD: 100,000+ Questions for Machine Comprehension of Text
1608.07905 (2016-08)
Machine Comprehension Using Match-LSTM and Answer Pointer
and 130 more not named here
normalize_question 2 other papers
2 dated earlier
2302.00083 (2023-02)
In-Context Retrieval-Augmented Language Models
2602.00723 (2026-02)
Rethinking Hallucinations: Correctness, Consistency, and Prompt Multiplicity

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

Small-scale language models (SLMs) are attractive for retrieval-augmented generation (RAG) in resource-constrained settings, but their limited capacity makes them highly sensitive to noisy or spurious retrieved evidence. Existing preferencebased methods such as RoseRAG select only the hardest single preference pair via hard argmin/argmax, discarding the remaining signal; others treat multiple pairs as independent binary comparisons, resulting in low data utilization. We propose RIMS, a three-stage preference optimization framework comprising (1) synthetic chain-of-thought preference data generation via rejection sampling using the target SLM itself without relying on proprietary models, (2) a differentiable soft aggregation mechanism that replaces hard selection with a smooth operator, preserving gradient signal from all preference pairs while retaining the discriminative structure of margin-aware selection, and (3) preference optimization with the smoothed objective applied to multiple alignment algorithms. We theoretically show that the smoothed approximation admits a controllable error bound and that smooth aggregation yields provably tighter gradient alignment to the oracle objective than hard selection. Experiments on four multi-hop question answering benchmarks show that our approach outperforms state-of-the-art baselines across multiple SLM backbones, achieving consistent gains in Exact Match and F1 under noisy retrieval conditions. Our implementation is available at https://github.com/tptrix29/RIMS.

For agents

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

get_harvested_code_for_paper("2607.16431")
get_code_for_paper("2607.16431")
have("2607.16431")

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

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

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

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

Connect an agent — have() is free.