DEV Community

shashank ms
shashank ms

Posted on

LLMs for Personalized Marketing and Recommender Systems in E-commerce

Traditional recommender systems in e-commerce rely on collaborative filtering and matrix factorization. These methods struggle with cold-start users, sparse catalogs, and semantic nuance. Large language models offer an alternative: they can reason over unstructured product descriptions, browse histories, and natural language preferences inside a single context window. The result is a new inference layer that unifies retrieval, ranking, and response generation.

Why LLMs Are Changing E-commerce Personalization

Matrix factorization and two-tower models encode behavior, but they ignore text. An LLM can read a product description, infer that "breathable merino wool base layer" matches a user's stated preference for "temperature regulating hiking clothes," and generate an explanation in the same forward pass. This collapses retrieval, ranking, and copy generation into one step.

The shift becomes practical when inference cost is predictable. Oxlo.ai provides fully OpenAI-compatible endpoints with flat per-request pricing, so feeding long user histories or large catalog snippets does not inflate cost the way token-based metering does.

Architecture: RAG, Agents, and Structured Output

Production systems usually combine three primitives:

  • Retrieval with embeddings. Use Oxlo.ai's BGE-Large or E5-Large endpoints to encode product descriptions and user queries. Retrieve a candidate set with vector search before the LLM sees any text.
  • Reasoning with structured output. Feed the candidate set, user profile, and business rules into an LLM. Constrain the output with JSON mode so the model returns a machine-readable array of recommendations.
  • Agentic tool use. For dynamic inventory, enable function calling. The model can invoke price checks, stock queries, or promotion filters before finalizing its recommendation list.

Oxlo.ai supports all three out of the box: embeddings, chat completions with JSON mode, and function calling. No cold starts on popular models means latency stays consistent during traffic spikes.

Implementation: Building a Recommendation Agent with Oxlo.ai

The following example uses the OpenAI Python SDK pointed at Oxlo.ai. It passes a long user history and a retrieved catalog snippet, then asks for structured recommendations.

import openai
import json

client = openai.OpenAI(
    base_url="https://api.oxlo.ai/v1",
    api_key="YOUR_OXLO_API_KEY"
)

user_context = """
User ID: 48192
Preferences: sustainable materials, neutral colors, size M
Recent sessions: viewed organic cotton tees, read a review about recycled polyester, asked about carbon-neutral shipping
Catalog candidates:
1. Eco-Tee Organic Cotton (ID: SKU-9912) ... [description]
2. GreenShell Jacket Recycled Nylon (ID: SKU-4451) ... [description]
... (20 more items)
"""

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[
        {"role": "system", "content": "You are a personalized shopping assistant. Return only valid JSON."},
        {"role": "user", "content": f"Recommend 3 items and explain why they fit this user.\n\n{user_context}"}
    ],
    response_format={"type": "json_object"},
    temperature=0.2
)

recommendations = json.loads(response.choices[0].message.content)

Because Oxlo.ai charges per request rather than per token, expanding the user context with full session logs or larger candidate sets does not change the price of the inference call.

For retrieval, generate query embeddings against the same infrastructure:

embedding = client.embeddings.create(
    model="bge-large",
    input="waterproof breathable hiking jacket under 200 dollars"
)

# Use the resulting vector with your Pinecone, Weaviate, or pgvector index.

The Cost Argument: Per-Request vs Token-Based Pricing

Personalization workloads are inherently long-context. A single recommendation request can include thousands of tokens of user history, product metadata, and few-shot examples. On token-based platforms, this input length directly multiplies cost. Oxlo.ai uses flat per-request pricing, which means the cost of a recommendation query is the same whether the context is 500 tokens or 50,000 tokens.

For agentic flows that require multiple tool calls and reasoning steps, the savings compound. Each round trip is one request, not a growing token bill. See https://oxlo.ai/pricing for plan details.

Model Selection for Marketing Workloads

Oxlo.ai hosts more than 45 models across seven categories. For e-commerce personalization, these are particularly relevant:

  • Llama 3.3 70B. A reliable default for general recommendation reasoning and JSON mode output.
  • Qwen 3 32B. Strong multilingual performance for global catalogs and agent workflows that traverse language boundaries.
  • DeepSeek R1 671B MoE. Use when the task requires deep reasoning, such as cross-category bundle suggestions or interpreting complex user constraints.
  • DeepSeek V4 Flash. 1M context window lets you inject massive catalog sections or extended user timelines in a single request.
  • Kimi K2.6. Advanced reasoning, agentic coding, and vision support for multimodal catalogs that include product images.
  • BGE-Large / E5-Large. Embedding endpoints for semantic retrieval and candidate generation.

All models are accessible through the same OpenAI-compatible endpoint, so switching from a fast baseline to a heavy reasoning model is a one-line configuration change.

Conclusion

LLMs are moving e-commerce personalization from static lookup tables to dynamic, context-aware reasoning. The main operational barrier has been inference cost, especially when long user histories and large catalogs inflate token counts. Oxlo.ai removes that barrier with flat per-request pricing, OpenAI SDK compatibility, and a broad model catalog that covers embeddings, fast inference, and deep reasoning. If you are building the next generation of recommender systems, Oxlo.ai is a backend worth evaluating.

Top comments (0)