SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2605.08333 · 2026

CDS4RAG: Cyclic Dual-Sequential Hyperparameter Optimization for RAG

Tao Chen, Pengzhou Chen

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 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, 2 violated it and 0 have no contract verdict; 7 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/2605.08333.json · badge: /api/ran/2605.08333.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
ideas-labo/cds4rag canonical (classifier label)
classifier basis: census
10 ran · 0 no recorded run
FunctionStatusWhere it lives
calculate_llmaaj_correctness Ran
ran, honoured the contract we drafted
ideas-labo/cds4rag/utils.py
code served (permissive licence) · get_code("40ac0e0232fb29ad")
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

class MockLLM:
    """Mock LLM that streams responses with numeric scores."""
    def __init__(self, score=0.85):
        self.score = score
    
    def stream(self, messages):
        """Simulate streaming response from LLM."""
        class Chunk:
            def __init__(self, content):
                self.content = content
        
        # Yield response chunks that contain a numeric score
        response_text = f"Based on the evaluation, I would give a score of {self.score}"
        yield Chunk(response_text)

# Create test arguments
prediction = "the quick brown fox jumps over the lazy dog"
reference = "the quick brown fox jumps over a lazy dog"
llm = MockLLM(score=0.92)

ARGS = {
    "prediction": prediction,
    "reference": reference,
    "llm": llm
}
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
calculate_retrieval_metrics Ran
ran; our contract draft was wrong, not the code
ideas-labo/cds4rag/utils.py
code served (permissive licence) · get_code("a5b3c7b1c8deb3fb")
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 dict. 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

class MockDocument:
    """Mock document class with page_content attribute"""
    def __init__(self, content):
        self.page_content = content

class MockEmbeddingModel:
    """Mock embedding model - not actually called by the function"""
    def embed(self, text):
        return np.random.rand(4)

# Create test data
retrieved_docs = [
    MockDocument("machine learning is a subset of artificial intelligence"),
    MockDocument("deep learning uses neural networks for pattern recognition"),
    MockDocument("artificial intelligence encompasses machine learning and robotics"),
    MockDocument("data science involves statistics and programming")
]

true_context = "Machine Learning is a subset of Artificial Intelligence"

embedding_model = MockEmbeddingModel()

question = "What is the relationship between machine learning and AI?"

ARGS = {
    'retrieved_docs': retrieved_docs,
    'true_context': true_context,
    'embedding_model': embedding_model,
    'question': question
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
calculate_retrieval_metrics_embedding Ran
ran; our contract draft was wrong, not the code
ideas-labo/cds4rag/utils.py
code served (permissive licence) · get_code("b9b7237154a24b67")
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 dict. 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

class MockEmbedding:
    """Mock embedding model that returns fixed-size embeddings"""
    def embed_query(self, text):
        # Return a fixed 8-dimensional embedding based on text hash
        np.random.seed(hash(text) % (2**31))
        return np.random.randn(8).tolist()

class MockDocument:
    """Mock document with page_content attribute"""
    def __init__(self, content):
        self.page_content = content

# Create test data
embedding_model = MockEmbedding()

retrieved_docs = [
    MockDocument("The quick brown fox jumps over the lazy dog"),
    MockDocument("Python is a programming language"),
    MockDocument("Machine learning is a subset of artificial intelligence"),
    MockDocument("Natural language processing enables computers to understand text"),
]

true_context = "The quick brown fox jumps over the lazy dog"

question = "What does the fox do?"

ARGS = {
    'retrieved_docs': retrieved_docs,
    'true_context': true_context,
    'embedding_model': embedding_model,
    'question': question,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
clean_json_string Ran
ran; our contract draft was wrong, not the code
ideas-labo/cds4rag/util.py
code served (permissive licence) · get_code("098d9540e2614374")
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 clean_json_string(s):
    s = s.strip().lstrip('\ufeff')
    s = s.replace('\\n', '\n').replace('\\t', '\t')
    s = re.sub('\\\\(?!["\\\\/bfnrt])', '', s)
    return s

ARGS = {
    's': '  \ufeff{"key": "value\\nwith\\ttabs\\\\invalid"}  '
}
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_docs Ran
ran; our contract draft was wrong, not the code
ideas-labo/cds4rag/Run_util.py
code served (permissive licence) · get_code("8c3af9fd98991acd")
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.

class MockDoc:
    def __init__(self, page_content):
        self.page_content = page_content

docs = [
    MockDoc("First document content"),
    MockDoc("Second document content"),
    MockDoc("Third document content")
]

ARGS = {
    "docs": docs
}
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
get_other_corpus Ran
ran; our contract draft was wrong, not the code
ideas-labo/cds4rag/Run_util.py
code served (permissive licence) · get_code("c607ad93e9afd9fa")
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 list, ndim 1, 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 numpy as np

np.random.seed(0)

main_category = 2
corpus_scale = 3
categories = {
    1: 'sports',
    2: 'politics',
    3: 'technology',
    4: 'health',
    5: 'entertainment'
}

ARGS = {
    'main_category': main_category,
    'corpus_scale': corpus_scale,
    'categories': categories
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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 float — 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
load_jsonl Ran
ran; our contract draft was wrong, not the code
ideas-labo/cds4rag/Run_util.py
code served (permissive licence) · get_code("4561fb8f5d531d34")
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 list, ndim 1, 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 json
import tempfile
import os

# Create a temporary JSONL file with sample data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.jsonl")

# Write sample JSONL data
with open(temp_file, 'w', encoding='utf-8') as f:
    f.write(json.dumps({"id": 1, "text": "hello world"}) + "\n")
    f.write(json.dumps({"id": 2, "text": "foo bar"}) + "\n")
    f.write(json.dumps({"id": 3, "name": "test", "value": 42}) + "\n")

ARGS = {
    "file_path": temp_file
}
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 list, ndim 1, dtype family float — 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
recursive_split_text Ran
ran; our contract draft was wrong, not the code
ideas-labo/cds4rag/word_chunker.py
code served (permissive licence) · get_code("f3fbdd2dbdb3b6ee")
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 list, ndim 1, 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 re
from typing import List

def _word_tokens(text: str) -> List[str]:
    return re.findall('\\w+|[\\u4e00-\\u9fff]', text)

def _count_words(text: str) -> int:
    return len(_word_tokens(text))

def recursive_split_text(text: str, chunk_size: int=100, chunk_overlap: int=20, separators: List[str]=('\n\n', '\n', '. ', ' ', '')) -> List[str]:
    """
    Recursively split using natural boundaries (paragraph/line/sentence/space), 
    continue subdivision if length is not met; 
    when further subdivision is not possible, apply token sliding window with overlap.
    """

    def _split(t: str, seps: List[str]) -> List[str]:
        if _count_words(t) <= chunk_size * 1.2:
            return [t]
        if not seps:
            tokens = _word_tokens(t)
            windows = []
            start = 0
            step = max(chunk_size - chunk_overlap, 1)
            while start < len(tokens):
                end = min(start + chunk_size, len(tokens))
                windows.append(' '.join(tokens[start:end]))
                if end == len(tokens):
                    break
                start += step
            return windows
        sep = seps[0]
        parts = t.split(sep) if sep else [t]
        out: List[str] = []
        for p in parts:
            p = p.strip()
            if not p:
                continue
            if _count_words(p) <= chunk_size * 1.2:
                out.append(p)
            else:
                out.extend(_split(p, seps[1:]))
        return out
    raw_chunks = _split(text, list(separators))
    merged: List[str] = []
    buf: List[str] = []
    count = 0
    for piece in raw_chunks:
        pc = _count_words(piece)
        if count + pc <= chunk_size or not buf:
            buf.append(piece)
            count += pc
        else:
            merged.append(' '.join(buf))
            tail_tokens = _word_tokens(merged[-1])
            overlap_tail = ' '.join(tail_tokens[max(0, len(tail_tokens) - chunk_overlap):])
            buf = [overlap_tail, piece] if overlap_tail else [piece]
            count = _count_words(' '.join(buf))
    if buf:
        merged.append(' '.join(buf))
    return merged


ARGS = {
    'text': 'This is a sample text. It contains multiple sentences.\n\nAnd even paragraphs. Here are some more words to make the text longer so that splitting will actually occur.\n\nThis section should trigger the recursive splitting mechanism because it has enough content.',
    'chunk_size': 30,
    'chunk_overlap': 5,
    'separators': ['\n\n', '\n', '. ', ' ', '']
}
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 list, ndim 1, dtype family float — 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
save_vectorstore Ran
ran, violated the contract we drafted
ideas-labo/cds4rag/util.py
code served (permissive licence) · get_code("abbdfd08c0e63fff")
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 pickle
import tempfile
import os

class MockVectorstore:
    """A minimal vectorstore that can be pickled"""
    def __init__(self):
        self.vectors = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
        self.metadata = {"index": 0}

class MockVectorstoreWithSaveLocal:
    """A vectorstore with save_local method"""
    def __init__(self):
        self.vectors = [[1.0, 2.0], [3.0, 4.0]]
    
    def save_local(self, directory):
        """Mock save_local method that creates a directory"""
        os.makedirs(directory, exist_ok=True)
        with open(os.path.join(directory, 'index.pkl'), 'wb') as f:
            pickle.dump(self.vectors, f)

# Create a temporary directory for the filepath
temp_dir = tempfile.gettempdir()
vectorstore_path = os.path.join(temp_dir, 'test_vectorstore.pickle')

# Create a simple picklable vectorstore object
vectorstore = MockVectorstore()

ARGS = {
    'vectorstore': vectorstore,
    'filepath': vectorstore_path
}
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
verify_json_format Ran
ran, violated the contract we drafted
ideas-labo/cds4rag/util.py
code served (permissive licence) · get_code("a82ff54ee2e3ade2")
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 tempfile
import os

# Create a temporary file with valid content for testing
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.json', encoding='utf-8')
temp_file.write('{"valid": "json"}')
temp_file.close()

ARGS = {
    'file_path': temp_file.name
}
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

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 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 10 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

Retrieval-Augmented Generation (RAG) is sensitive to the vast hyperparameters of the retriever and generator, yet optimizing them using given queries is a challenging task due to the complex interactions and expensive evaluation costs. Existing algorithms are ineffective and slow in convergence, since they often treat RAG as a monolithic black box or only optimize partial hyperparameters. In this paper, we propose CDS4RAG, a framework that optimizes the full RAG hyperparameters using given queries via a new cyclic dual-sequential formulation. CDS4RAG is special in the sense that it distinguishes the hyperparameters of the retriever and generator, cyclically optimizing them in turn. Such a paradigm allows us to design fine-grained within-cycle budget provision and expedite the optimization via cross-cycle seeding when optimizing the generator. CDS4RAG is also an algorithm-agnostic framework that can be paired with diverse general algorithms. Through experiments on four common benchmarks and two backbone LLMs, we reveal that CDS4RAG considerably boosts the vanilla algorithms in 21/24 cases while significantly outperforming state-of-the-art algorithms in all cases with up to 1.54× improvements of generation quality and better speedup. * Pengzhou Chen is also supervised in the IDEAS Lab. † Tao Chen is the corresponding author.

For agents

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

get_harvested_code_for_paper("2605.08333")
get_code_for_paper("2605.08333")
have("2605.08333")

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

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

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

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

Connect an agent — have() is free.