SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.15065 · EMNLP · 2023

Inference-Time Policy Adapters (IPA): Tailoring Extreme-Scale LMs without Fine-tuning

Prithviraj Ammanabrolu, Yejin Choi, Xiang Ren, Ximing Lu, Nouha Dziri, Lianhui Qin, Faeze Brahman, Liwei Jiang, Abhilasha Ravichander, Peter West, Skyler Hallinan, Sahana Ramnath, and 5 more

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 4 failures of our instrument; 2 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/2305.15065.json · badge: /api/ran/2305.15065.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
gximinglu/ipa marked official in Papers with Code
Papers with Code archive
9 ran · 2 no recorded run
FunctionStatusWhere it lives
Clause Ran
ran on a synthesized input · constructed an object; no result was computed
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("09533ca3a50beeb9")
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 an instance of its own class, Clause: the run constructed the object and did not call it, so no result was computed. 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 numpy as np
from typing import List, Dict

# Construct arguments for Clause.__init__

# idx parameter: an integer identifier
idx = 0

# phrases parameter: a list of lists of integers (token sequences)
# Each inner list represents a sequence of token IDs that form a phrase/literal
phrases = [
    [1, 2, 3],           # First phrase: tokens [1, 2, 3]
    [4, 5],              # Second phrase: tokens [4, 5]
    [6, 7, 8, 9]         # Third phrase: tokens [6, 7, 8, 9]
]

ARGS = {
    "idx": idx,
    "phrases": phrases
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Clause — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Clause 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
ConstrainedHypothesis Ran
ran on a synthesized input · constructed an object; no result was computed
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("829dc5027203efb2")
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 an instance of its own class, ConstrainedHypothesis: the run constructed the object and did not call it, so no result was computed. 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
from typing import List

# Construct valid arguments for ConstrainedHypothesis

# constraint_list: List[List[List[int]]]
# This represents constraints as clauses containing literals (phrases of token IDs)
constraint_list = [
    [
        [101, 102, 103],  # First clause, first literal (phrase)
        [104, 105]        # First clause, second literal (phrase)
    ],
    [
        [201, 202],       # Second clause, first literal
        [203, 204, 205]   # Second clause, second literal
    ]
]

# eos_tokens: List[int]
# End-of-sequence token IDs to avoid during generation
eos_tokens = [50256, 0]

ARGS = {
    "constraint_list": constraint_list,
    "eos_tokens": eos_tokens
}
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 ConstrainedHypothesis — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ConstrainedHypothesis 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
Literal Ran
ran on a synthesized input · constructed an object; no result was computed
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("26f86b735923a213")
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 an instance of its own class, Literal: the run constructed the object and did not call it, so no result was computed. 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 torch.nn as nn
from typing import List

torch.manual_seed(0)

# The Literal class constructor takes:
# - tokens: List[int]
# 
# The body uses:
# - self.tokens (accessed with indexing)
# - self.pointer (starts at -1, incremented, compared to len(self.tokens) - 1)
# - self.satisfy (set to boolean)
#
# The advance method compares word_id to self.tokens[self.pointer + 1]
# and increments self.pointer, so tokens needs to be a list of integers
# with at least a few elements to test the logic.

tokens = [10, 20, 30, 40, 50]

ARGS = {
    "tokens": tokens
}
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 Literal — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Literal 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
add_control_code Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("bbdcee6294271ede")
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 3, 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 torch

torch.manual_seed(0)

# Create small tensors for input_ids and attention_mask
# input_ids: batch_size=2, seq_length=4
input_ids = torch.tensor([
    [101, 2054, 2003, 102],
    [101, 2054, 2003, 102]
], dtype=torch.long)

# attention_mask: batch_size=2, seq_length=4
attention_mask = torch.tensor([
    [1, 1, 1, 1],
    [1, 1, 1, 0]
], dtype=torch.long)

# control_code: a single integer token
control_code = 103

ARGS = {
    "input_ids": input_ids,
    "attention_mask": attention_mask,
    "control_code": control_code
}
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 3, 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
get_response_logits Ran
ran; our contract draft was wrong, not the code
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("a5b9efe1547f6da6")
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 Tensor, ndim 3, dtype family float, shape (2, 4, 256) 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

torch.manual_seed(0)

# Create a minimal model that satisfies the function's usage
class MinimalModel(nn.Module):
    def __init__(self, vocab_size=256, hidden_size=4):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.linear = nn.Linear(hidden_size, vocab_size)
    
    def prepare_inputs_for_generation(self, input_ids, **kwargs):
        # This method is called by the function
        # Return a dict with the input_ids and any kwargs passed through
        return {"input_ids": input_ids, **kwargs}
    
    def forward(self, input_ids, attention_mask=None, return_dict=True, output_attentions=False, output_hidden_states=False):
        # Generate logits for the model output
        embeddings = self.embedding(input_ids)
        logits = self.linear(embeddings)
        
        # Return an object with logits attribute
        class ModelOutput:
            pass
        
        output = ModelOutput()
        output.logits = logits
        return output

# Set up small tensors
batch_size = 2
query_seq_len = 3
response_seq_len = 4
vocab_size = 256

# Create input tensors
query_input_ids = torch.randint(0, vocab_size, (batch_size, query_seq_len))
response_input_ids = torch.randint(0, vocab_size, (batch_size, response_seq_len))

# Create attention masks (all ones for simplicity, but ensure query_mask sums properly)
query_mask = torch.ones(batch_size, query_seq_len, dtype=torch.long)
response_mask = torch.ones(batch_size, response_seq_len, dtype=torch.long)

# Create model
model = MinimalModel(vocab_size=vocab_size, hidden_size=4)
model.eval()

ARGS = {
    "model": model,
    "query_input_ids": query_input_ids,
    "response_input_ids": response_input_ids,
    "query_mask": query_mask,
    "response_mask": response_mask,
}
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 Tensor, ndim 3, dtype family float, shape (2, 4, 256) — shape (2, 4, 256) 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
init_batch Ran
ran; our contract draft was wrong, not the code
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("17bed87cd7624c0f")
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 torch
import pickle
from typing import List, Optional

# First, let's understand what init_batch expects:
# - raw_constraints: List[List[List[List[int]]]] - a list of constraint sets for each batch item
# - eos_tokens: List[int] - list of end-of-sequence token IDs

# Build small test data
# raw_constraints structure: batch_size items, each containing a list of clauses,
# each clause containing a list of phrases, each phrase being a list of token IDs

raw_constraints = [
    # First batch item: 2 clauses
    [
        [[1, 2, 3]],      # Clause 0: 1 phrase with tokens [1, 2, 3]
        [[4, 5], [6, 7]]  # Clause 1: 2 phrases with tokens [4, 5] and [6, 7]
    ],
    # Second batch item: 1 clause
    [
        [[10, 11, 12, 13]]  # Clause 0: 1 phrase with tokens [10, 11, 12, 13]
    ]
]

eos_tokens = [0, 100]  # Two different EOS token IDs

ARGS = {
    "raw_constraints": raw_constraints,
    "eos_tokens": eos_tokens
}
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 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
mask_pad Ran
ran, honoured the contract we drafted
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("3cb3f78a134bd16d")
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 Tensor, ndim 2, dtype family float, shape (2, 4) 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 numpy as np

torch.manual_seed(0)

# The function mask_pad takes two parameters:
# - value: a tensor that gets multiplied by mask
# - mask: a binary mask tensor (0s and 1s) of same shape as value
# The function applies masking: keeps value where mask=1, replaces with NEGATIVE_INF where mask=0

# Create small test tensors
value = torch.randn(2, 4)  # batch_size=2, dim=4
mask = torch.randint(0, 2, (2, 4)).float()  # binary mask, same shape as value

ARGS = {
    "value": value,
    "mask": mask,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) 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
process_generation Ran
ran; our contract draft was wrong, not the code
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("429406ae7594ed3d")
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)

# The function process_generation takes a single parameter 'text' which is a string
# It processes the text by splitting on '.' or '!' and returning the first part with the delimiter
# No complex objects needed, just a simple string

ARGS = {
    "text": "Hello world. This is a test! More text here."
}
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
remove_control_code Ran
ran, honoured the contract we drafted
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("ba8e7009fad31689")
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 3, 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 torch

torch.manual_seed(0)

# Create small tensors for input_ids and attention_mask
# The function slices [:, 1:] so we need at least 2 columns
# Using batch_size=2, sequence_length=4 for clarity
input_ids = torch.randint(0, 100, (2, 4))
attention_mask = torch.ones(2, 4, dtype=torch.long)

ARGS = {
    "input_ids": input_ids,
    "attention_mask": attention_mask,
}
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 3, 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
Policy Not yet run
unverified (harvested, no recorded run)
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("4e0ff675e558ddf8")
How it ran

no invocation recorded.

get_model_output Not yet run
unverified (harvested, no recorded run)
gximinglu/ipa/policy.py
code served (permissive licence) · get_code("967107de3b5957a5")
How it ran

no invocation recorded.

Also present in other papers' code

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

While extreme-scale language models have demonstrated exceptional performance on a variety of language tasks, the degree of control over these language models through pure prompting can often be limited. Directly finetuning such language models can be effective for tailoring them, but it can be either extremely costly (e.g., GPT-3) or not even feasible for the broader community (e.g., GPT-4). We propose Inference-time Policy Adapters (IPA), which efficiently tailors a language model such as GPT-3 without fine-tuning it. IPA guides a large base model during decoding time through a lightweight policy adapter trained to optimize an arbitrary user objective with reinforcement learning. On five challenging text generation tasks, such as toxicity reduction and lexically constrained generation, IPA consistently brings significant improvements over off-the-shelf language models. It outperforms competitive baseline methods, sometimes even including expensive finetuning. In particular, tailoring GPT-2 with IPA can outperform GPT-3, while tailoring GPT-3 with IPA brings a major performance boost over GPT-3 (and sometimes even over GPT-4). Our promising results highlight the potential of IPA as a lightweight alternative to tailoring extreme-scale language models. 1

For agents

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

get_harvested_code_for_paper("2305.15065")
get_code_for_paper("2305.15065")
have("2305.15065")

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

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

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

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

Connect an agent — have() is free.