LLMs suffer from recency bias, where they pay more attention to the last few-shot example in the prompt.
To prevent this, examples should be sorted by complexity or similarity to the query, or rotated/randomized to prevent bias and ensure uniform prediction accuracy.
import random examples = [ex1, ex2, ex3] random.shuffle(examples)
prompt = """ Classify reviews: """ + "\n".join(examples) + f"\nReview: {user_review}\nSentiment:"
Claude is robust against recency bias, though placing the most complex examples first helps build reasoning context.