HOME

/

Learn for AI

/

The Math Behind AI Search

LEARN FOR AI

The Math Behind AI Search

Kishan Panpalia

Kishan Panpalia

Founding Team, Pepper

Updated:  

Published:  

28/10/2025

5

min read

TLDR

  • AI answer engines retrieve source passages and then generate answers from them, a process called retrieval-augmented generation that marketers can influence.
  • Cosine similarity, hybrid keyword and vector retrieval through Reciprocal Rank Fusion, and reranking decide which pages get pulled into AI answers.
  • Write focused single-topic pages, cover both keywords and topics, lead with a crisp answer and use question-style headings, bullets and FAQs.
A collage of torn paper pieces layered on top of each other, featuring a large lavender piece with a rough edge on top, a beige piece behind it, a dark brown piece below, and a cream piece with lavender polka dots at the bottom right.

IN THIS ARTICLE

Reading progres

10%

SHARE

https://www.pepper.inc/blog/ai-native-the-math-behind-ai-search

The Bottom Line

AI Search runs on measurable math: embedding similarity, hybrid retrieval and reranking. Pages that answer one question clearly, with matching keywords and scannable structure, are the ones these systems retrieve and cite.

As Pepper’s resident Generative Engine Optimization (GEO) nerd, I get asked a lot about how large language models and AI answer engines like Google’s AI Overviews work behind the scenes. That’s not surprising — just look at the rise in interest in AI Search Optimization over the last year.

Google Trends chart of interest over time in AI Search Optimization, flat through late 2024 then rising sharply to a peak of 100 in 2025.

Yes, there’s a ton of overlap between GEO and SEO best practices. But GEO still represents a fundamental shift in search, and its importance is growing as Google makes AI Overviews and AI Mode the default search experience.

To influence these AI tools, we need to understand them at their core.

At a high level, these LLM-powered answer engines operate in two phases: Retrieval of source information and Generation of an answer using that information.

Under the hood, that workflow unfolds something like this:

  • First, the system interprets and may expand the user’s query.
  • Then, it retrieves the most relevant passages from a search or vector index.
  • Finally, the LLM composes an answer by combining its existing knowledge with those retrieved snippets, often surfacing citations alongside key claims.

This is often called Retrieval-Augmented Generation (RAG). Mathematically, we can view an LLM’s answer as a function Answer = f(Query, {Docs}), where the document set is chosen to maximize relevance and quality.

LLMs seem mystifying, but we can dissect how they work — and what it means for marketers — in a few key ways.

The core math that powers AI Search

1) Embedding similarity (how “close” your page is to the question)

When an AI answer engine looks for the content most relevant to a user’s query, it first converts both the query and the passages from a potential source into vectors, or long lists of numbers that represent meaning. Each vector is a point in a high-dimensional space. To decide which passages are most relevant, the system compares the angle between these vectors using a metric called cosine similarity.

Vectors that point in the same direction (a small angle) mean the texts are semantically similar; those pointing in very different directions mean they’re about different things.

In plain English, cosine similarity tells the system how close two pieces of text are in meaning, not just in matching keywords.

Cosine similarity formula: sim(q, d) equals the dot product of query and document vectors divided by the product of their magnitudes.

Marketer takeaway: Write clear, focused pages on one topic each. That creates “distinct” vectors that closely match questions. This will increase your chances of getting retrieved and cited.

2) Hybrid retrieval (merging keyword and vector results)

Most AI answer engines combine two kinds of retrieval signals: keyword-based and semantic (vector-based). The keyword side comes from traditional search ranking, i.e., where your content appears in the classic blue-link results. The vector side measures how closely your content’s meaning aligns with the user’s question.

To merge these two perspectives, systems often use a technique called Reciprocal Rank Fusion (RRF), which blends results from both methods into a single ranked list before the LLM chooses which passages to cite.

Reciprocal Rank Fusion formula: fusion score sums 1 divided by k plus the document's rank in each retrieval method, with k commonly 60.

Marketer takeaway: You need both obvious keywords and strong topic coverage. Don’t rely on just one or the other.

3) Reranking (which candidates make the answer)

The LLM uses a “reranker” to assign a relevance score to each possible page it can pull, often modeled like:

Reranker formula combining weighted BM25 keyword score, embedding cosine similarity and a cross-encoder score checking whether a passage answers the question.

Marketer takeaway: Compel AI to pull your content with this simple checklist.

  • Put a crisp answer sentence first.
  • Use headings that echo the questions users are asking.
  • Use bullets, tables, and FAQs.

That’s enough math for this week. In our next newsletter, I’ll dive into three simple yet high-impact KPI formulas you can use to track how well you’re actually optimizing for AI Search — so be sure to stay tuned (and dust off that TI-84, for old times’ sake).

And if you really want to get an edge on AI Search, sign up to get early access to Atlas, our transformative tool for tracking and optimizing AI Search visibility.

Kishan Panpalia is a founding team member at Pepper.

Author byline banner for Kishan Panpalia with headshot and LinkedIn icon.
Pepper ad banner reading Drive more traffic and leads with Pepper, with a Book a Demo button and SEO dashboard screenshot.
Section header: Chart of the Week

SEO budgets get a boost

Smarty Marketing bar chart of SEO budget change due to AI: about 61% will increase, 35% no change, 4% will decrease.

Turns out AI didn’t kill SEO — it gave it a raise. New research shows that more than 61% of companies are increasing their SEO budgets due to AI. About a third (35%) are staying the course with their current budgets, and just 4% plan to scale back.

Even more telling: 86% of businesses are already investing in what they’re calling “AI SEO” (what we usually call AI Search or GEO here at AI Native). In short: Everyone’s competing to stay visible in a world where “ranking” now means appearing in an LLM’s context window, and they’re willing to shell out to show up.

Section header: New and Noteworthy

AI news is moving faster than cosine similarity converges to 1. Here are the top stories to know this week.

  • There’s much ado about OpenAI’s Atlas browser, a search-meets-chat hybrid that cites its sources. Early verdicts are lukewarm, with some reviewers shrugging it off as underwhelming, others calling it just gussied-up Googling, and yet others calling out security risks.
  • Microsoft is close on Atlas’ heels with Edge Copilot Mode, which users can’t help but note behaves a lot like OpenAI’s new toy. Nothing screams “innovation in 2025” like releasing a copycat feature 48 hours after your competitor/frenemy.
  • Reddit’s taking Perplexity to court, the latest salvo in the ongoing fight over who owns the internet’s training data.
  • Amazon’s rolling out a new AI shopping feature that predicts what you’ll buy before you finish scrolling. It reads reviews, compares specs, and lands you on a decision faster than your willpower can object.
  • Layoffs hit Amazon and Meta AI teams. Amazon’s HR division and Meta’s AI unit both announced cuts this month as Big Tech recalibrates around generative investments.
  • Wikipedia joins the “zero-click” club. The internet’s favorite homework helper says traffic is taking a hit as AI summaries and social-video platforms siphon off readers who never click through.
  • Mondelez will embrace generative ads to cut creative production costs by up to50%. AI may be able to write taglines, but it will never know the sweet, sweet satisfaction of a perfectly split Oreo.
  • Microsoft is channeling Clippy’s energy with Copilot’s brains. The brand’s new AI assistant, Mico, is sending nostalgic millennials over the moon.
Section header: Hot Jobs
Section header: Meme of the Week
How it started versus how it's going meme: Clippy offering help with a document, then Microsoft's Mico offering workslop.

Credit: Kayne McGladrey on LinkedIn

ABOUT THE AUTHOR

Kishan Panpalia

Kishan Panpalia

Founding Team, Pepper

42

 Articles published

Kishan Panpalia
Kishan Panpalia
Kishan Panpalia

Focus:  

LLMO Strategy

Content Operations

B2B Growth

See what AI says about you.

Get a report on the answers where ChatGPT, Gemini, Perplexity and Google AI Overviews name you, and the ones where they name someone else.

Run the free check

More from this category

Continue exploring Learn for AI

250+ brands that Pepper got recommended

Case Study

Case Study

Aayush Anand Profile Image

Aayush Anand

Aayush Anand

Applied AI & New Media for Growth, PhonePe

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Deepak Sharma

Deepak Sharma

Chief of Staff & Chief Product Officer, Pepperfry

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Katelyn Watson

Katelyn Watson

CMO, Talkspace

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Elay Cohen

Elay Cohen

CEO & Co-founder, SalesHood

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Himanshu Sirohi

Himanshu Goyal

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Nitin Sethi

Nitin Sethi

Chief Digital Officer

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Tariq Z Khan

Tariq Z. Khan

Director of Content Marketing, Algolia

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Martijn Scheijbeler

Martijn Scheijbeler

SVP Marketing, RVshare

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Kavitha Ganesan

Kavitha Ganesan

Head of Brand marketing, TVS Srichakra Limited (Eurogrip)

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.

Mahesh Kumar

Mahesh Kumar

CMO, Acceldata

Black and white illustrated king chess piece with layered torn paper collage background in pastel colors including teal, purple, beige, and brown.
Small grassy hill with patches of taller grass and some sparse vegetation on top against a black background.

For businesses playing the long game, Pepper turns your earned authority visible to search & AI, making

organic growth winnable again.

A tree formed from colorful particles above a grassy hill

Get a strategy presentation with real projections before you sign up.

i

*the long game is not about waiting.
‍
It is about building something that keeps winning after everyone else's quick win wore off. And you will see it work within a quarter.