# AI in e-commerce

E-commerce uses AI for product search, recommendations, pricing, fraud prevention, content generation and customer support. Learn the most valuable use cases.

## Overview

Online retail is one of the most data-rich industries. Every search, click, scroll, basket addition, purchase, return and review is recorded. A medium-sized shop may have hundreds of thousands of products and millions of visits a month. AI turns that data into a better experience for shoppers and better decisions for the business.

On the shopper's side, AI helps people find what they want: search that understands intent, recommendations that suggest relevant items, and assistants that answer questions. On the business side, it forecasts demand, sets prices and promotions, detects fraud, writes and checks product content, and routes customer service. Most of these systems are invisible to shoppers, but together they shape almost every page they see.

An everyday picture is a good shopkeeper in a small neighbourhood store. They know regular customers, suggest something that goes well with what you picked up, keep popular items in stock and notice when someone suspicious is lingering at the till. E-commerce AI tries to provide that attentiveness to millions of shoppers at once, while respecting their privacy.

## What it is

| Use case | Question | Typical technique |
|---|---|---|
| Product search | Which products match this query? | [BM25](/tools/bm25), [embeddings](/tools/embeddings), [hybrid search](/tools/hybrid-search), [learning to rank](/tools/learning-to-rank) |
| Recommendations | What else might this shopper want? | Collaborative filtering, sequence models, [recommendation](/tools/recommendation) systems |
| Personalisation | What should this page show this person? | Ranking models, bandits |
| Pricing and promotions | What price or discount maximises the goal? | Demand models, optimisation, experiments |
| Demand forecasting | How much stock do we need? | Time-series and boosting models |
| Fraud prevention | Is this order or account genuine? | [Gradient boosting](/tools/gradient-boosting), anomaly and graph models |
| Product content | Are titles, descriptions and attributes complete and correct? | Language and vision models |
| Customer service | Where is my order, and can I return it? | Language models with retrieval and tools |
| Returns prediction | Is this order likely to be returned? | Classification models |

The core loop of most of these systems is ranking: from many candidates, choose and order the few that will be shown. Search ranks products for a query, recommendations rank products for a person and context, and email campaigns rank offers for each customer.

## Where it came from

Recommendation was one of the earliest large-scale applications of machine learning on the web. Research systems in the 1990s used collaborative filtering, recommending items liked by similar users. In 2003, engineers at a large online retailer described item-to-item collaborative filtering, which scaled by comparing products rather than customers, and the approach became widely copied. The Netflix Prize competition, which ran from 2006 to 2009, drew wide attention to matrix factorisation and ensemble methods for recommendation.

Search moved from keyword matching towards learning to rank in the late 2000s and 2010s, using click and purchase data to train ranking models. Deep learning brought sequence-aware recommenders and embedding-based retrieval in the late 2010s. Fraud detection and demand forecasting followed paths similar to those in finance and logistics.

Since the early 2020s, large language models have opened new uses: generating and checking product descriptions, extracting attributes from text and images, understanding complex queries, and shopping assistants that can compare products and answer questions. Privacy regulation, such as the [GDPR](/tools/gdpr) and cookie consent rules, has reshaped how personal data may be used for personalisation.

## How it works

### Step 1: capture events and catalogue data

Log page views, searches, clicks, basket events, orders and returns, with timestamps and session identifiers, through an event pipeline. Keep the product catalogue clean: titles, categories, attributes, images, prices and stock.

### Step 2: retrieve candidates

For search, combine keyword retrieval, which handles exact product codes and brand names, with vector retrieval over embeddings, which handles meaning and synonyms. For recommendations, generate candidates from co-purchase patterns, similar items and the shopper's recent history. Vector databases such as [Elasticsearch](/tools/elasticsearch) or [Qdrant](/tools/qdrant) often serve this step.

### Step 3: rank the candidates

A ranking model scores each candidate using features of the product, the shopper, the query and the context, such as device and time. Training labels come from clicks, purchases and returns. Business rules then apply, for example removing out-of-stock items or adding diversity.

### Step 4: decide prices and promotions

Demand models estimate how sales respond to price, promotions and competitors' prices. Optimisation then chooses prices within rules, such as minimum margins and legal constraints. Because observational data mix cause and effect, controlled experiments and [causal inference](/tools/causal-inference) methods are important.

### Step 5: protect the business

Fraud models score orders, accounts and payments in real time. Other models detect fake reviews, bots and promotion abuse.

### Step 6: measure with experiments

Changes are tested with A/B tests that compare conversion, revenue per visitor, return rates and longer-term retention. Offline metrics, such as ranking accuracy, guide development but do not replace live tests.

## Key concepts and terms

| Term | Meaning |
|---|---|
| Conversion rate | Share of visits or sessions that end in a purchase |
| Collaborative filtering | Recommending based on patterns across many users and items |
| Cold start | Lack of data for new users or new products |
| Learning to rank | Training models to order items by relevance |
| Embedding retrieval | Finding items by vector similarity |
| A/B test | A randomised experiment comparing two versions |
| Price elasticity | How demand changes in response to price |
| Basket analysis | Finding items often bought together |
| Click-through rate | Share of impressions that are clicked |
| Popularity bias | Recommenders favouring already popular items |
| Attribute extraction | Turning unstructured text or images into structured product fields |

## A worked example

This scenario is illustrative. An online home-goods shop has 80,000 products. Many searches return poor results: a query for "small sofa for studio flat" matches products containing "small" or "sofa" but misses items listed as "two-seater loveseat". About 14 per cent of searches end with no click.

The team adds hybrid search. Keyword retrieval stays for brand names and product codes, and embedding retrieval adds products that match the meaning of the query. A language model extracts missing attributes, such as width, seat count and material, from product descriptions, which are checked by sampling. A learning-to-rank model, trained on six months of clicks and purchases, combines text relevance, attributes, price, ratings and stock.

In a four-week A/B test with half of traffic, searches ending with no click fall from 14 to 10 per cent, and revenue per search visitor rises by about 6 per cent. Return rates for search-driven orders do not rise, which suggests shoppers are finding genuinely suitable products rather than being nudged into poor matches. The team rolls out the change and adds the zero-click rate to its weekly dashboard.

## Strengths and limitations

**Strengths:**

- Helps shoppers find relevant products faster.
- Increases conversion and order value when done well.
- Scales personalisation to millions of visitors.
- Improves stock and pricing decisions with demand models.
- Automates content quality and routine customer service.

**Limitations:**

- Personalisation can feel intrusive and must respect consent and privacy law.
- Recommenders can narrow choice and amplify popularity bias.
- Pricing algorithms raise fairness and competition concerns.
- Offline metrics often disagree with live results.
- Generated content can contain errors that mislead customers.

## How it compares with alternatives

| Approach | Strength | Weakness |
|---|---|---|
| Machine-learned ranking and recommendations | Relevant, personalised, scalable | Needs data, experiments and monitoring |
| Manual merchandising | Brand control, curated stories | Does not scale, not personal |
| Rule-based recommendations ("top sellers") | Simple, transparent | Same for everyone, popularity bias |
| Keyword-only search | Precise for exact terms | Misses synonyms and intent |
| Conversational shopping assistant | Handles complex needs | Costly, must be grounded to avoid errors |

## Practical guidance and best practices

1. Clean and enrich the product catalogue before tuning ranking models.
2. Combine keyword and embedding retrieval for search.
3. Train on purchases and returns, not only clicks, to avoid optimising for curiosity.
4. Validate every important change with an A/B test and guard metrics.
5. Handle cold start with content features for new products and users.
6. Add diversity and business rules on top of pure relevance.
7. Respect consent: personalise only with permitted data, and offer non-personalised options.
8. Review generated product content for accuracy before publishing.

## Common mistakes

- Optimising click-through rate and increasing returns and dissatisfaction.
- Evaluating recommenders only offline and skipping live experiments.
- Ignoring stock, so top recommendations are often unavailable.
- Letting a pricing model produce prices that look unfair or break rules.
- Publishing language-model descriptions without checking facts such as dimensions.
- Assuming all traffic is human when bots distort the data.

## Frequently asked questions

### What is the difference between search and recommendation?

Search starts from an explicit query and ranks products that match it. Recommendation starts from context, such as a product page or a shopper's history, and suggests items the person did not ask for. Both are ranking problems and often share models and features.

### How do shops handle new products with no sales?

They use content features, such as category, attributes, text and image embeddings, to place new products near similar items, and give them some controlled exposure to collect data. This is known as handling the cold-start problem.

### Is dynamic pricing legal?

Changing prices over time is generally lawful, but rules vary by country and sector. Price discrimination on protected characteristics, misleading reference prices and algorithmic coordination with competitors can be unlawful. Businesses should get legal advice for their markets.

### Can language models replace product search?

Not entirely. Shopping assistants are useful for complex, open-ended needs, but most shoppers still search with short queries and want fast, precise results. The common pattern is to use language models to improve search, attributes and content, and offer an assistant alongside.

### How do I measure whether personalisation works?

Run randomised experiments comparing personalised and non-personalised experiences on revenue per visitor, conversion, return rates and repeat purchases. Watch longer-term metrics too, because short-term gains can hide declining satisfaction.

## Glossary

- Conversion: a visit that ends in a purchase.
- Catalogue: the structured list of products and their attributes.
- Ranking model: a model that orders candidates by predicted relevance.
- Cold start: the problem of having little data for new items or users.
- A/B test: a randomised controlled experiment.
- Embedding: a vector that represents meaning for similarity search.
- Basket: the set of items a shopper intends to buy.
- Merchandising: deciding which products are promoted and how.

## Summary

E-commerce uses AI to rank search results, recommend products, personalise pages, set prices, forecast demand, prevent fraud, improve product content and support customers. It builds on collaborative filtering and learning to rank, now extended by embeddings and language models. Success depends on a clean catalogue, combined keyword and semantic retrieval, training on purchases and returns, careful experiments and respect for consent and fairness.
