Abstract: Large language models (LLMs) are increasingly used as rerankers in information retrieval, yet their ranking behavior can be steered by small, natural-sounding prompts. To expose this vulnerability, we present Rank Anything First (RAF), a two-stage token optimization method that crafts concise textual perturbations to consistently promote a target item in LLM-generated rankings while remaining hard to detect. Stage 1 uses Greedy Coordinate Gradient to shortlist candidate tokens at the current position by combining the gradient of the rank-target with a readability score; Stage 2 evaluates those candidates under exact ranking and readability losses using an entropy-based dynamic weighting scheme, and selects a token via temperature-controlled sampling. RAF generates ranking-promoting prompts token-by-token, guided by dual objectives: maximizing ranking effectiveness and preserving linguistic naturalness. Experiments across multiple LLMs show that RAF significantly boosts the rank of target items using naturalistic language, with greater robustness than existing methods in both promoting target items and maintaining naturalness. These findings underscore a critical security implication: LLM-based reranking is inherently susceptible to adversarial manipulation, raising new challenges for the trustworthiness and robustness of modern retrieval systems.
TL;DR
Researchers have developed Rank Anything First (RAF), a two-stage optimization method that crafts short, natural-sounding text snippets to manipulate LLM-based search and recommendation rankings. By balancing ranking effectiveness with linguistic fluency through a novel dynamic weighting scheme, RAF consistently elevates target items to the top of search results while remaining nearly invisible to both automated detectors and human eyes.
What Problem Does This Paper Address?
Large Language Models (LLMs) are increasingly replacing traditional algorithms as "rerankers" in information retrieval (IR) and recommendation systems. While LLMs excel at understanding context, they introduce a massive security vulnerability: rank manipulation.
An attacker (like a malicious vendor) might want their product to appear first, regardless of its actual relevance. Previous adversarial attacks on LLMs usually relied on "gibberish" strings or explicit instruction overrides, which are easily flagged by safety filters. The challenge addressed here is creating an attack that is both effective (it actually moves the item to the top) and stealthy (it looks like a normal, helpful product description).
Methods
The authors introduce Rank Anything First (RAF), which optimizes an adversarial prompt token-by-token using a two-stage approach:
- Stage 1: Gradient-Based Shortlisting: Using Greedy Coordinate Gradient (GCG), the system identifies a shortlist of tokens from the full vocabulary that are likely to improve the target item's rank while maintaining readability.
- Stage 2: Objective-Based Search & Dynamic Weighting: The system evaluates candidates using exact loss functions for ranking and readability. RAF employs an entropy-based dynamic weighting scheme: if the LLM is confident about the next token (low entropy), it prioritizes readability; if uncertain, it prioritizes the ranking objective.
- Temperature-Controlled Sampling: Instead of greedy search, RAF samples from a distribution to ensure the resulting text is diverse and natural.
Datasets and Evaluation
The study utilizes STSData, a benchmark containing product categories like Books, Cameras, and Coffee Machines. To ensure robustness, the authors improved the evaluation pipeline by randomly shuffling the input order of products, preventing success from being a byproduct of positional bias.
Key Insights and Ideas
- Readability as a Regularizer: Adding a readability constraint doesn't just make the attack stealthier; it makes the optimization more stable. Without it, the search space is often too chaotic for convergence.
- The Transferability Trap: Prompts optimized for one model (e.g., Llama-3.1) often work effectively on entirely different models like Mistral or DeepSeek, suggesting shared underlying vulnerabilities in LLM rankers.
- Efficiency over Length: RAF is highly efficient. A 10-token RAF prompt often outperforms 30-token prompts generated by older methods, proving that content quality outweighs quantity in manipulation.
Key Results
Testing across Llama-3.1-8B, Mistral-7B, DeepSeek-7B, and Vicuna-7B revealed several critical findings:
- Ranking Power: RAF consistently achieved the lowest average rank for target items. On the "Books" category with Llama-3.1, RAF pushed target items to an average rank of 4.43, compared to 6.70 for the next best baseline.
- Stealth (Perplexity): RAF achieved perplexity scores significantly lower than baselines (e.g., 15.90 vs. 76.02 for STS), meaning the injected text sounds like legitimate marketing copy.
- Robustness: Unlike previous methods that fail when list order changes, RAF remained effective across multiple random shuffles of candidate items.
Limitations and Future Work
The paper focuses on "listwise" reranking where the LLM sees all items at once; real-world multi-stage pipelines might mitigate some effects. Furthermore, standard "bad word" filters are insufficient for defense because RAF uses natural language. The authors suggest that future work should explore adversarial training to teach rerankers to ignore such manipulated prompts.
Summary updated