SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.07981 · 2024

Manipulating Large Language Models to Increase Product Visibility

arXiv · PDF · Open in the Atlas

Code that ran

7 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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 0 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/2404.07981.json · badge: /api/ran/2404.07981.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
aounon/llm-rank-optimizer canonical (classifier label)
classifier basis: census
7 ran · 0 no recorded run
FunctionStatusWhere it lives
create_rank_list Ran
ran, honoured the contract we drafted
aounon/llm-rank-optimizer/plot/plot_dist.py
code served (permissive licence) · get_code("3f47190c670db8f7")
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 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
import numpy as np

torch.manual_seed(0)

# Analyzing the function:
# - rank_dist: a dict where keys are ranks (int) and values are percentages (float/int)
# - num_prod: an integer used to create a default rank value (num_prod + 1)
# - total_values: an integer with default 20, controls the target length of rank_list

# The function iterates over rank_dist.items(), so it needs to be a dict
# with integer keys (ranks) and numeric values (percentages)

rank_dist = {
    1: 40,
    2: 30,
    3: 20,
    4: 10
}

num_prod = 5

total_values = 20

ARGS = {
    "rank_dist": rank_dist,
    "num_prod": num_prod,
    "total_values": total_values
}
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 list, ndim 1, dtype family int — 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
decode_adv_prompt Ran
ran; our contract draft was wrong, not the code
aounon/llm-rank-optimizer/tools.py
code served (permissive licence) · get_code("3ff68c023b8c0dff")
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
import numpy as np
from transformers import AutoTokenizer

class MockTokenizer:
    """Minimal tokenizer mock that implements the decode method."""
    def __init__(self):
        self.vocab = {
            0: "<pad>",
            1: "Hello",
            2: " world",
            3: " this",
            4: " is",
            5: " test"
        }
        self.id_to_token = self.vocab
    
    def decode(self, token_ids):
        """Decode token IDs to string."""
        if isinstance(token_ids, torch.Tensor):
            token_ids = token_ids.tolist()
        elif not isinstance(token_ids, list):
            token_ids = list(token_ids)
        
        result = ""
        for tid in token_ids:
            if tid in self.vocab:
                result += self.vocab[tid]
        return result

torch.manual_seed(0)

# Create mock tokenizer
tokenizer = MockTokenizer()

# Adversarial prompt token IDs
adv_prompt_ids = [1, 2, 3, 4, 5]

# Indices of adversarial tokens (e.g., tokens at positions 1 and 3 are adversarial)
adv_idxs = [1, 3]

ARGS = {
    "adv_prompt_ids": adv_prompt_ids,
    "adv_idxs": adv_idxs,
    "tokenizer": tokenizer
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, termcolor, torch, transformers — 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_nonascii_toks Ran
ran, honoured the contract we drafted
aounon/llm-rank-optimizer/tools.py
code served (permissive licence) · get_code("917ac97cb67e17b3")
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 1, dtype family int, shape (7,) 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

class MockTokenizer:
    def __init__(self):
        self.vocab_size = 10
        self.bos_token_id = 0
        self.eos_token_id = 1
        self.pad_token_id = 2
        self.unk_token_id = 3
        # Create a mapping of token ids to strings
        # Mix ascii and non-ascii tokens
        self.token_map = {
            0: "<bos>",
            1: "</s>",
            2: "<pad>",
            3: "<unk>",
            4: "hello",
            5: "world",
            6: "🔥",  # non-ascii emoji
            7: "你好",  # non-ascii Chinese
            8: "café",  # mixed ascii and non-ascii
            9: "test"
        }
    
    def decode(self, token_ids):
        """Decode a list of token ids to a string."""
        if isinstance(token_ids, (list, torch.Tensor)):
            if len(token_ids) == 1:
                return self.token_map.get(int(token_ids[0]), "")
            return "".join([self.token_map.get(int(t), "") for t in token_ids])
        return self.token_map.get(int(token_ids), "")

ARGS = {
    'tokenizer': MockTokenizer(),
    'device': 'cpu'
}
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 1, dtype family int, shape (7,) — shape (7,) 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
prompt_generator_llama Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
aounon/llm-rank-optimizer/rank_opt.py
code served (permissive licence) · get_code("aa46ad7086cd0ba0")
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 torch
import json

torch.manual_seed(0)

class SimpleTokenizer:
    """Stand-in tokenizer that mimics HuggingFace tokenizer behavior."""
    def __call__(self, text, return_tensors=None, add_special_tokens=True):
        # Simple mock: return a tensor of token IDs based on text length
        token_ids = torch.tensor([[i % 100 for i in range(len(text) // 10 + 1)]], dtype=torch.long)
        if return_tensors == 'pt':
            return {'input_ids': token_ids}
        return {'input_ids': token_ids}

# Create sample arguments
target_product_idx = 1

product_list = [
    {"id": 1, "name": "Product A", "price": 10.0},
    {"id": 2, "name": "Product B", "price": 20.0},
    {"id": 3, "name": "Product C", "price": 30.0},
]

user_msg = "Please recommend the best product for me."

tokenizer = SimpleTokenizer()

device = torch.device('cpu')

# Create sts_tokens: shape (1, 4) - batch size 1, sequence length 4
sts_tokens = torch.randint(0, 100, (1, 4), dtype=torch.long)

ARGS = {
    'target_product_idx': target_product_idx,
    'product_list': product_list,
    'user_msg': user_msg,
    'tokenizer': tokenizer,
    'device': device,
    'sts_tokens': sts_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 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
prompt_generator_vicuna Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
aounon/llm-rank-optimizer/rank_opt.py
code served (permissive licence) · get_code("f31668c61a9bbb09")
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 torch
import json

torch.manual_seed(0)

# Stand-in tokenizer that mimics HuggingFace tokenizer behavior
class StandInTokenizer:
    def __call__(self, text, return_tensors=None, add_special_tokens=True):
        # Simple mock: convert text length to token count
        token_count = len(text.split()) + 2  # rough approximation
        token_ids = torch.randint(100, 1000, (1, token_count))
        
        if return_tensors == 'pt':
            return {'input_ids': token_ids}
        return {'input_ids': token_ids}

# Create sample data
target_product_idx = 1
product_list = [
    {"name": "Product A", "price": 10},
    {"name": "Product B", "price": 20},
    {"name": "Product C", "price": 30},
]
user_msg = "I want the best product"
tokenizer = StandInTokenizer()
device = "cpu"
sts_tokens = torch.randint(100, 1000, (1, 4))  # Small tensor for STS tokens

ARGS = {
    "target_product_idx": target_product_idx,
    "product_list": product_list,
    "user_msg": user_msg,
    "tokenizer": tokenizer,
    "device": device,
    "sts_tokens": sts_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 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
rank_products Ran
ran; our contract draft was wrong, not the code
aounon/llm-rank-optimizer/rank_opt.py
code served (permissive licence) · get_code("3f1ad7b766b2b495")
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 torch

torch.manual_seed(0)

# Construct arguments for rank_products function
text = "I recommend the laptop for work. The keyboard is great. Consider the mouse for productivity. The monitor is excellent."
product_names = ["laptop", "keyboard", "mouse", "monitor", "headphones"]

ARGS = {
    "text": text,
    "product_names": product_names
}
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
target_loss Ran
ran; our contract draft was wrong, not the code
aounon/llm-rank-optimizer/tools.py
code served (permissive licence) · get_code("9ecf44a5744c0c2a")
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 1, dtype family float, shape (2,) 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)

class SimpleTokenizer:
    def __init__(self):
        self.vocab_size = 100
    
    def __call__(self, text, return_tensors=None, add_special_tokens=False):
        # Return a simple dict with input_ids
        # For the target sequence, we'll return a small tensor
        input_ids = torch.tensor([[5, 6, 7]], dtype=torch.long)
        return {'input_ids': input_ids}

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(100, 4)
        self.lm_head = nn.Linear(4, 100)
        self.device_attr = torch.device('cpu')
    
    @property
    def device(self):
        return self.device_attr
    
    def get_input_embeddings(self):
        return self.embedding
    
    def forward(self, inputs_embeds):
        # inputs_embeds shape: (batch_size, seq_len, embedding_dim)
        # Return logits of shape (batch_size, seq_len, vocab_size)
        logits = self.lm_head(inputs_embeds)
        return type('Output', (), {'logits': logits})()

# Construct arguments
model = SimpleModel()
tokenizer = SimpleTokenizer()

# embeddings: (batch_size=2, sequence_length=5, embedding_dim=4)
embeddings = torch.randn(2, 5, 4)

# target_sequence: a string
target_sequence = "Sure, here is"

ARGS = {
    'embeddings': embeddings,
    'model': model,
    'tokenizer': tokenizer,
    'target_sequence': target_sequence
}
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 1, dtype family float, shape (2,) — shape (2,) 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 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
get_nonascii_toks 1 other paper
1 later
2410.05451 (2024-10)
SecAlign: Defending Against Prompt Injection with Preference Optimization

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) are increasingly being integrated into search engines to provide natural language responses tailored to user queries. Customers and end-users are also becoming more dependent on these models for quick and easy purchase decisions. In this work, we investigate whether recommendations from LLMs can be manipulated to enhance a product's visibility. We demonstrate that adding a strategic text sequence (STS) -- a carefully crafted message -- to a product's information page can significantly increase its likelihood of being listed as the LLM's top recommendation. To understand the impact of STS, we use a catalog of fictitious coffee machines and analyze its effect on two target products: one that seldom appears in the LLM's recommendations and another that usually ranks second. We observe that the strategic text sequence significantly enhances the visibility of both products by increasing their chances of appearing as the top recommendation. This ability to manipulate LLM-generated search responses provides vendors with a considerable competitive advantage and has the potential to disrupt fair market competition. Just as search engine optimization (SEO) revolutionized how webpages are customized to rank higher in search engine results, influencing LLM recommendations could profoundly impact content optimization for AI-driven search services. Code for our experiments is available at https://github.com/aounon/llm-rank-optimizer.

For agents

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

get_harvested_code_for_paper("2404.07981")
get_code_for_paper("2404.07981")
have("2404.07981")

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

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

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

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

Connect an agent — have() is free.