SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2502.14815 · 2025

Optimizing Model Selection for Compound AI Systems

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; 0 honoured the contract we drafted, 0 violated it and 9 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-23; 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/2502.14815.json · badge: /api/ran/2502.14815.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
LLMSELECTOR/LLMSELECTOR canonical (classifier label)
classifier basis not recorded on the link
10 ran · 0 no recorded run
FunctionStatusWhere it lives
Get_Generate Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/llm.py
code served (permissive licence) · get_code("96362ca151f15497")
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 time

# Create a mock provider class that implements the get_response method
class MockProvider:
    def get_response(self, text, model, stop=None, max_tokens=1000, temperature=0.1, query_images=None):
        # Return a simple string response
        return "This is a generated response from the mock provider."

# Initialize the global variables as they would be in the actual code
sleep_time = 10
MyAPI_OpenAI = MockProvider()
model_provider_mapper = {
    "gpt-4": MockProvider(),
    "claude": MockProvider()
}

# Define the ARGS dictionary with all required parameters
ARGS = {
    "prompt": "What is the capital of France?",
    "model_gen": "gpt-3.5-turbo",
    "stop": None,
    "max_tokens": 500,
    "temperature": 0.7,
    "query_images": None
}
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
compute_score Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/metric.py
code served (permissive licence) · get_code("075a2a4962fab858")
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 DataFrame. 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 pandas as pd
import torch
from unittest.mock import Mock

torch.manual_seed(0)

# Create a mock AI system that has a generate method
class MockAISystem:
    def __init__(self, name):
        self.name = name
    
    def generate(self, query, metric, true_answer):
        # Return a mock answer string
        return f"Generated answer for {query}"

# Create a mock metric that has a get_score method
class MockMetric:
    def get_score(self, answer, true_answer):
        # Return a mock score between 0 and 1
        return 0.85

# Create sample dataframe
data_df = pd.DataFrame({
    'query': ['What is 2+2?', 'What is the capital of France?'],
    'true_answer': ['4', 'Paris']
})

# Create compound AI systems dictionary
compoundaisystems = {
    'system_a': MockAISystem('system_a'),
    'system_b': MockAISystem('system_b')
}

# Create metric
metric = MockMetric()

# Define answer_convert function (optional converter)
def answer_convert(x):
    return str(x).lower().strip()

ARGS = {
    'compoundaisystems': compoundaisystems,
    'data_df': data_df,
    'metric': metric,
    'true_answer_name': 'true_answer',
    'save_answer_prefix': 'answer',
    'answer_convert': answer_convert
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
compute_tag Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/metric.py
code served (permissive licence) · get_code("1a27128efa695483")
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 DataFrame. 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
import pandas as pd
import numpy as np

# Stand-in AI System class that has the generate method
class MockAISystem:
    def generate(self, query, metric, true_answer):
        """
        Mock generate method that returns a dict with 'iter' key
        """
        return {
            'iter': np.random.randint(0, 100),
            'score': np.random.rand(),
            'response': f"Generated response for: {query}"
        }

# Create sample data
data_df = pd.DataFrame({
    'query': ['What is 2+2?', 'What is the capital of France?'],
    'true_answer': ['4', 'Paris']
})

# Create compound AI systems dict
compoundaisystems = {
    'system_a': MockAISystem(),
    'system_b': MockAISystem(),
}

# Define metric
metric = 'accuracy'

# Define tag
tag = 'iter'

# Construct ARGS dictionary
ARGS = {
    'compoundaisystems': compoundaisystems,
    'data_df': data_df,
    'metric': metric,
    'tag': tag
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
extract_ans Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/module/debate.py
code served (permissive licence) · get_code("ae7782a357cf3a90")
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 extract_ans(text, regex='\\([a-h][1-8]\\)', remove_left=1, remove_right=1):
    matches = re.findall(regex, text)
    if not matches:
        return '()'
    len1 = len(matches[-1])
    return f'{matches[-1][remove_left:len1 - remove_right]}'
    return f'{matches[-1][remove_left:remove_right]}' if matches else '()'

ARGS = {
    'text': 'The answer is (c5) and (g2) for sure.',
    'regex': r'\([a-h][1-8]\)',
    'remove_left': 1,
    'remove_right': 1
}
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
extract_ans Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/module/majorityvote.py
code served (permissive licence) · get_code("4ec0ffdf43c1c1c5")
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 extract_ans(text, regex='\\([a-h][1-8]\\)', remove_left=1, remove_right=1):
    matches = re.findall(regex, text, re.IGNORECASE)
    if not matches:
        return '()'
    len1 = len(matches[-1])
    return f'{matches[-1][remove_left:len1 - remove_right]}'


# Set up arguments for extract_ans
text = "The answer is (c5) and (d3) in the grid."
regex = r'\([a-h][1-8]\)'
remove_left = 1
remove_right = 1

ARGS = {
    'text': text,
    'regex': regex,
    'remove_left': remove_left,
    'remove_right': remove_right
}
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
extract_final_answer Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/diagnoser.py
code served (permissive licence) · get_code("5672cff2de3b190b")
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 int, ndim 0, dtype family int, 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

def extract_final_answer(text):
    cleaned_text = re.sub('[^\\w]', '', text)
    cleaned_text = cleaned_text.lower()
    if 'finalansweryes' in cleaned_text:
        return 1
    elif 'finalanswerno' in cleaned_text:
        return 0
    elif 'correctanswer' in cleaned_text:
        return 0
    else:
        return 0.5

ARGS = {
    'text': 'Final Answer: Yes!'
}
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 int, ndim 0, dtype family int, 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
my_decode Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/llm.py
code served (permissive licence) · get_code("05b617dbf3b25a2a")
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 zlib
import pickle
import torch

# Create a simple test object to encode/decode
test_data = {
    "key1": "value1",
    "key2": [1, 2, 3],
    "key3": torch.randn(2, 4)
}

# Compress and encode the test data
compressed_obj = zlib.compress(pickle.dumps(test_data))

# Convert to bytes for the function
obj_input = compressed_obj

ARGS = {
    "obj": obj_input
}
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 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
my_encode Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/llm.py
code served (permissive licence) · get_code("f2fc23dea676ed77")
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 memoryview. 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 zlib
import pickle
import sqlite3

# The function my_encode takes a single parameter 'obj' of any type
# and serializes it using pickle, compresses it with zlib, and wraps it in sqlite3.Binary
# We need to provide a valid object that can be pickled and compressed

# Create a test object - a simple dictionary with various data types
test_obj = {
    "name": "test",
    "values": [1, 2, 3, 4, 5],
    "nested": {
        "key1": "value1",
        "key2": [10, 20, 30]
    },
    "number": 42,
    "float": 3.14
}

ARGS = {
    "obj": test_obj
}
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 memoryview — a memoryview output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a memoryview output the recorded ndim 1 and dtype family int 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
resize_to_max_pixels Ran
ran on a synthesized input
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/module/directgen.py
code served (permissive licence) · get_code("d957a2e9f35bc763")
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 math
from PIL import Image

# Create a small test image
test_image = Image.new('RGB', (100, 200))

# Construct the image dict that the function expects
image = {
    'raw': test_image,
    'hash': 'test_hash_123'
}

# Define arguments for the function
ARGS = {
    'image': image,
    'max_pixels': 10000
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL — 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
strip_latex Ran
ran; our contract draft was wrong, not the code
LLMSELECTOR/LLMSELECTOR/llmselector/llmselector/compoundai/metric.py
code served (permissive licence) · get_code("0892f960b112ef52")
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.

ARGS = {
    'response': '$x^2 + y^2$'
}
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

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, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 1 the same month, 0 later) and 9 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
strip_latex 1 other paper
1 the same month
2502.19187 (2025-02)
BIG-Bench Extra Hard

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

Compound AI systems that combine multiple LLM calls, such as self-refine and multi-agent-debate, achieve strong performance on many AI tasks. We address a core question in optimizing compound systems: for each LLM call or module in the system, how should one decide which LLM to use? We show that these LLM choices have a large effect on quality, but the search space is exponential. We propose LLMSelector, an efficient framework for model selection in compound systems, which leverages two key empirical insights: (i) end-to-end performance is often monotonic in how well each module performs, with all other modules held fixed, and (ii) per-module performance can be estimated accurately by an LLM. Building upon these insights, LLMSelector iteratively selects one module and allocates to it the model with the highest module-wise performance, as estimated by an LLM, until no further gain is possible. LLMSelector is applicable to any compound system with a bounded number of modules, and its number of API calls scales linearly with the number of modules, achieving high-quality model allocation both empirically and theoretically. Experiments with popular compound systems such as multi-agent debate and self-refine using LLMs such as GPT-4o, Claude 3.5 Sonnet and Gemini 1.5 show that LLMSelector confers 5%-70% accuracy gains compared to using the same LLM for all modules.

For agents

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

get_harvested_code_for_paper("2502.14815")
get_code_for_paper("2502.14815")
have("2502.14815")

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

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

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

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

Connect an agent — have() is free.