Skip to content

Repository files navigation

DYSON RAG Assistant

Multimodal & Cross-Lingual RAG System for Amazon UK Strategy Optimization

License Python Docker LangChain ChromaDB


Executive Summary

⚠️ BEFORE WE START: This system is not a standard conversational RAG. It is conceived as a Decision Support System (DSS) for business, oriented toward giving detailed, reasoned responses backed by data. This implies a higher latency than that of a generic RAG (acceptable up to ~18 s in generation, ~35 s in p90), and that standard industry metrics (RAGAS, etc.) do not apply directly, having been adapted to the context of the project. Responses are cached in the pilot to improve times with regular use (below 10 seconds), and the model runs against a cloud LLM such as Gemini (which would improve real production response times by 1-2 seconds).

This Master's Thesis (TFM) in Data Science presents a complete Retrieval-Augmented Generation (RAG) system for e-commerce business intelligence. The system combines multimodal data processing (text + PDFs + HTML + market data), cross-lingual capabilities (English/Spanish/French/German/Italian), and hybrid retrieval (BM25 + Vector Search + Re-ranking) to deliver actionable strategic insights for Amazon marketplace optimization.

Unlike traditional chatbots, this project delivers a production-ready Decision Support System (DSS) that enables business users to:

  • Query consolidated market intelligence from multiple data sources (Amazon reviews, Helium 10, technical documentation)
  • Receive AI-powered strategic recommendations grounded in real data
  • Quantify lost revenue opportunities and identify recovery levers
  • Access insights in 5 languages without language barriers
  • Use a web interface requiring zero technical knowledge

Key Achievement (v5.4): The system identified £30,000–£50,000 in monthly lost revenue for Dyson on Amazon UK by detecting catalog gaps (13+ missing products), visibility issues (flagship V15 not indexed despite ~10,160 monthly searches), and competitive displacement by Shark.

Latest performance metrics:

  • Source Consistency (faithfulness): ~0.88–0.93 average (High in 97% of responses)
  • Hallucination rate: <3%
  • Latency (pilot with cache): ~10 s average (<1.5 s for deterministic bypasses)
  • LLM-as-a-Judge: 4.0–4.5/5 average
  • Retrieval precision: 85–95%
  • Human evaluation: 42/50 responses rated Excellent

Quick Start

Two ways to run the pilot: Docker (recommended, one command) or local Python.

Option A — Docker (recommended)

# 1. Clone repository
git clone https://github.com/albertosvallejo/dyson-rag-assistant.git
cd dyson-rag-assistant

# 2. Configure environment
cp .env.example .env
# Edit .env and add your Google Gemini API key: GOOGLE_API_KEY=your_key_here

# 3. Build and start
docker compose up --build

# 4. Open browser
# http://localhost        → Pilot interface
# http://localhost/health → API health check
# http://localhost/docs   → Swagger UI

Option B — Local Python

# 1. Clone and install dependencies
git clone https://github.com/albertosvallejo/dyson-rag-assistant.git
cd dyson-rag-assistant
pip install -r requirements.txt

# 2. Configure environment
cp .env.example .env
# Edit .env and add your Google Gemini API key

# 3. Run the API server (Terminal 1)
python -m uvicorn api:app --reload --port 8000

# 4. Open browser
# http://localhost:8000/docs  → API docs / Swagger UI

Prerequisites (Docker):

Prerequisites (Local Python):

  • Python 3.9+
  • Google Cloud API key for Gemini (set in .env file)
  • 8GB+ RAM recommended
  • Vector index files in data/vectorstore/ directory (generated by Notebook 02)

Business & Presentation Materials

The docs/ folder includes ready-to-use presentation decks for stakeholder communication:

Document Description
dyson_rag_business_deck.pdf Business-oriented deck — value proposition, use cases, and revenue impact framing for clients and decision-makers
dyson_rag_enablement_deck.pdf Enablement deck — onboarding guide and feature walkthrough for end users and internal teams
dyson_style_guide.pdf Visual style guide — colour palette, typography, and component library used across all project materials

All three documents are in PDF format and can be shared directly with non-technical stakeholders without requiring access to the codebase.


Table of Contents


Project Context

Academic Framework

  • Program: Master's in Data Science
  • Institution: BIG School — https://thebigschool.com/master-data-science-con-ia/
  • Duration: May 2025 – March 2026
  • Discipline: Natural Language Processing, Information Retrieval, Business Analytics
  • License: Academic Use Only

Business Context

E-commerce marketplace management requires synthesizing intelligence from multiple fragmented sources: customer reviews, competitive data, technical specifications, search trends. This project addresses the critical need for:

  1. Data Consolidation: Unified access to Amazon reviews, Helium 10 market data, and technical documentation
  2. Multimodal Understanding: Processing text, PDFs, HTML tables, and image metadata together
  3. Cross-Lingual Access: Querying in Spanish, English, French, German or Italian regardless of source data language
  4. Business Translation: Converting raw data into strategic recommendations with quantified impact

Target User: Amazon Key Account Manager for Dyson UK, responsible for catalog optimization and market share recovery.


Research Problem

Challenge Statement

Dyson, despite being the premium leader in cordless vacuum cleaners, faces a critical visibility problem on Amazon UK:

  • Flagship product (V15) ranks on page 3 for main keyword "cordless vacuum cleaner" (~10,160 monthly searches)
  • 13+ official models are not indexed on Amazon UK despite being available on Dyson.co.uk
  • Competitors like Shark dominate page 1, capturing conversions that should go to Dyson
  • Current analysis is manual and fragmented, taking 2–4 hours per session with incomplete data coverage (~30–40%)

The Core Problem: How can we enable the Amazon UK team to systematically quantify lost revenue and prescribe recovery actions by cross-referencing external demand data, customer sentiment, and competitive positioning?

Research Questions

  1. Can a RAG system effectively integrate multimodal data (text + PDFs + market data) for business intelligence?
  2. How can we ensure cross-lingual functionality (Spanish queries → English retrieval → Spanish responses)?
  3. What hybrid retrieval architecture (BM25 + Vector + Re-ranking) optimizes precision for technical business queries?
  4. Can we quantify business impact (lost revenue, recovery opportunities) through automated data analysis?
  5. How do we validate RAG system quality beyond technical metrics to include business utility?

Success Criteria

Technical Metrics:

  • Retrieval precision ≥80% (relevant documents in top-K results)
  • Answer relevance ≥85% (LLM responses address user query)
  • Response time <5 seconds for 90th percentile (pilot with cache)
  • Cross-lingual accuracy ≥85%
  • No context fragmentation (structured data stays atomic)

Business Metrics:

  • Quantified lost revenue opportunity (in £)
  • Prioritized action plan with estimated ROI
  • Time savings: 60–80% reduction vs manual analysis (from 2–4 hours to <30 minutes)
  • User adoption by non-technical stakeholders
  • Successful deployment as pilot interface

Methodology

Data Collection & Sources

The system integrates four complementary data sources, each contributing a distinct intelligence layer:

Source Records Type Intelligence Layer
Amazon UK Reviews 298 reviews Text Customer sentiment, pain points, NPS proxy
Helium 10 Market Data 38 products Structured Rankings, pricing, BSR, competitor presence
Dyson Product PDFs 81 documents PDF/HTML Specs, features, catalog coverage
SEO Keywords 39 keywords Structured Search volume, CTR, visibility gaps

Key Design Principle: Structured data (reviews, market records, keywords) is stored as atomic records — NOT chunked. This prevents context fragmentation and improves retrieval precision by ~10–15% vs naive chunking approaches.

Hybrid Retrieval Architecture

The system implements a 3-stage pipeline combining complementary retrieval methods:

Stage 1 — Hybrid Search

  • BM25 (lexical): Optimized for exact technical terms, model names, specific keywords
  • Vector Search (multilingual-e5-large, 384 dims): Semantic similarity for conceptual queries
  • Dynamic α weighting: Query-type detection automatically adjusts BM25/Vector balance

Stage 2 — Re-ranking

  • CrossEncoder (ms-marco-MiniLM-L-6-v2): Full query-document relevance scoring
  • Reranks top-20 candidates to top-5 for generation context
  • +15–20% precision improvement vs single-stage retrieval

Stage 3 — Generation

  • Google Gemini 1.5 Flash (Temperature: 0.1 for factual consistency)
  • 3 response modes: Direct (3–5 lines) / Extended (full analysis) / In Depth (multi-section report)
  • Market context injection: Revenue impact, competitive displacement, catalog gaps
  • Async hallucination checking against retrieved sources

Performance Optimization

Deterministic Bypasses: 8 high-frequency patterns (system capabilities, latency explanations, data sources, etc.) answered without LLM call — <1.5 s response, 0% hallucination rate.

Semantic Cache: Cosine similarity threshold 0.87. Queries semantically equivalent to previous ones return cached responses in <10 s, eliminating redundant LLM calls.

Prompt Injection System: Role-based context injection (Strategic / Technical / Customer analysis modes) with automated market_context assembly from structured data.

Cross-Lingual Architecture

Query language detection → English retrieval (all source data) → LLM response in detected query language. No translation overhead, no separate models per language. Achieves ~88% accuracy across EN/ES/FR/DE/IT.


Project Evolution

Phase Period Version Milestone
Foundation Jan 2026 v1–v3 Multimodal extraction, BM25 + Vector setup, ChromaDB, retrieval recall 70–80%
Business Alignment Feb 2026 v4 Specialized prompts, cross-lingual testing, FastAPI + pilot interface, LLM-as-a-Judge 4.0–4.5/5
Optimization Mar 2026 v5.0–5.3 8 deterministic bypasses, semantic cache, async hallucination check
Production Mar 2026 v5.4 Source Consistency bug fix, adapted latency thresholds, Docker deployment

Results & Performance

Quality Metrics

Metric Score Benchmark Signal
Source Consistency 0.88–0.93 ≥0.80 target PASS
Hallucination Rate <3% <5% target PASS
LLM-as-a-Judge 4.3/5 ≥4.0 target PASS
Human Excellent 42/50 ≥40 target PASS
Hit@1 72% ≥60% target PASS
Hit@5 95% ≥80% target PASS
MRR 0.83 High quality PASS
NDCG 0.88 Above threshold PASS

Latency Profile

Mode Response Time Condition Notes
FAST <1.5 s Deterministic bypass 8 patterns, 0% hallucination, no LLM call
CACHED <10 s Semantic cache hit (≥0.87) Most common queries after first run
PIPELINE 10–18 s Full RAG (normal query) Acceptable for a DSS — not a chatbot
p90 ~35 s Complex / cold start Documented upper bound, rare in practice

Business Impact

Total Monthly Opportunity: £160,000–£225,000 (Timeline: 3–6 months · Confidence: High–Medium)

Revenue Lever Monthly Impact Recovery Mechanism
V15 visibility gap £40K–£50K/mo Indexing + SEO fix unlocks ~10K monthly searches at £499 avg price
Missing catalog (13+ SKUs) £80K–£120K/mo Models exist but are invisible on Amazon UK — highest single lever
Competitive displacement £25K–£35K/mo Shark dominates page 1; Buy Box and sponsored placement recovery

Operational Efficiency:

  • Analysis time: 2–4 hours → <30 min (–75%)
  • Data coverage: 30–40% → 100% (+150%)
  • Decision speed: Days → Minutes (–95%)

System Architecture

┌─────────────────────────────────────────────────────────────┐
│                     PILOT INTERFACE                          │
│              pilot.html + frontend.js                        │
│         Language selector · 3 response modes                 │
└─────────────────────┬───────────────────────────────────────┘
                      │ HTTP / SSE
┌─────────────────────▼───────────────────────────────────────┐
│                    NGINX REVERSE PROXY                        │
│              Static serving + SSE proxy                       │
└─────────────────────┬───────────────────────────────────────┘
                      │
┌─────────────────────▼───────────────────────────────────────┐
│                    FASTAPI + UVICORN                          │
│    /query  /health  /history  /dashboard  /docs (Swagger)    │
│                    api.py                                     │
└─────────────────────┬───────────────────────────────────────┘
                      │
┌─────────────────────▼───────────────────────────────────────┐
│                  DYSON RAG PIPELINE                           │
│              pipeline_wrapper.py + rag_core.py               │
│                                                               │
│  ┌──────────┐   ┌──────────┐   ┌──────────┐   ┌──────────┐ │
│  │ Bypass   │   │ Semantic │   │ Hybrid   │   │  Cross   │ │
│  │ Router   │   │  Cache   │   │ Search   │   │ Encoder  │ │
│  │ <1.5s    │   │  <10s    │   │BM25+Vec  │   │ Rerank   │ │
│  └──────────┘   └──────────┘   └──────────┘   └──────────┘ │
│                                                               │
│  ┌─────────────────────────────────────────────────────────┐ │
│  │              GEMINI 1.5 FLASH                            │ │
│  │   Context injection · Market analysis · 5-lang output   │ │
│  └─────────────────────────────────────────────────────────┘ │
└─────────────────────┬───────────────────────────────────────┘
                      │
┌─────────────────────▼───────────────────────────────────────┐
│                   CHROMADB INDEX                              │
│         ~1,500 chunks · 50MB · multilingual-e5-large         │
│    298 reviews · 38 market records · 81 PDFs · 39 keywords   │
└─────────────────────────────────────────────────────────────┘

Pipeline Routing Reference

User Query
    │
    ├─► Deterministic bypass match? ──YES──► Direct response <1.5 s (0% hallucination)
    │
    ├─► Semantic cache hit ≥0.87? ───YES──► Cached response <10 s
    │
    └─► Full RAG pipeline
            │
            ├── Language detection
            ├── Query type classification (lexical / semantic / mixed)
            ├── Hybrid search (BM25 α + Vector 1-α, dynamic weighting)
            ├── CrossEncoder re-ranking (top-20 → top-5)
            ├── Market context injection
            ├── Gemini generation (temp 0.1)
            ├── Async hallucination check
            └── Response in query language (10–18 s)

Key Features (v5.4)

Multimodal Data Integration

  • 298 Amazon UK reviews: Sentiment analysis, pain point extraction, NPS proxy scoring
  • 38 market records: Real-time ranking data, pricing, BSR, competitor presence per keyword
  • 81 product PDFs/HTML: Technical specs, catalog coverage, availability mapping
  • 39 SEO keywords: Search volume, CTR estimates, visibility gap quantification

Revenue Quantification Engine

Automated detection and financial impact estimation for three revenue leak categories:

  1. Catalog gaps: Products on dyson.co.uk but missing from Amazon UK
  2. Visibility issues: Products indexed but ranking beyond page 1–2
  3. Competitive displacement: Keywords where competitors dominate despite inferior Dyson specs

Cross-Lingual Capability

  • Query in: EN / ES / FR / DE / IT
  • Retrieval always in English (source data language)
  • Response in detected query language
  • No translation API calls, no separate models per language

Three Response Modes

  • Direct: Concise, 3–5 lines — for quick factual lookups
  • Extended: Full analysis with cited sources — standard operating mode
  • In Depth: Multi-section structured report — for strategic planning sessions

Pilot Demo

The pilot interface runs at http://localhost after Docker deployment.

Interface features:

  • Language selector (EN / ES / FR / DE / IT)
  • Response mode toggle (Direct / Extended / In Depth)
  • Source citations displayed per response
  • Query history panel
  • Latency indicator (FAST / CACHED / PIPELINE badge)
  • Dashboard tab with system health metrics

Example queries to try:

"What is the estimated monthly revenue loss from the V15 visibility gap?"
"Which Dyson models are available on dyson.co.uk but not indexed on Amazon UK?"
"Why is Shark winning on 'cordless vacuum cleaner' against us?"
"What do V15 customers complain about that Gen5 users don't?"
"¿Cuáles son las principales quejas sobre la duración de la batería?"

Notebook Features

Notebook Purpose Key Outputs
01_data_extraction.ipynb Scraping, PDF extraction, data cleaning Raw → processed data in data/processed/
02_indexing.ipynb ChromaDB index creation, embedding generation Vector index in data/vectorstore/
03_retrieval_generation.ipynb Pipeline development, prompt engineering Pipeline configuration
04_evaluation.ipynb LLM-as-a-Judge, retrieval metrics, human eval Evaluation reports in outputs/evaluation/
05_demo_production.ipynb End-to-end demo, query examples Demonstration notebook

Installation & Usage

Environment Setup

# Clone repository
git clone https://github.com/albertosvallejo/dyson-rag-assistant.git
cd dyson-rag-assistant

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env: add GOOGLE_API_KEY=your_gemini_key_here

Generate Vector Index

Before running the API, generate the ChromaDB index by running Notebook 02:

jupyter notebook notebooks/02_indexing.ipynb
# Run all cells — generates data/vectorstore/dyson_rag_2025_11/

Run API Server

python -m uvicorn api:app --reload --port 8000
# API available at http://localhost:8000
# Swagger UI at http://localhost:8000/docs

API Endpoints

Endpoint Method Description
/query POST Main RAG query endpoint
/health GET System health check
/history GET Query history retrieval
/dashboard GET System metrics dashboard
/docs GET Swagger UI

Docker Deployment

# Build and start all services
docker compose up --build

# Services started:
# - FastAPI + Uvicorn (port 8000, internal)
# - Nginx reverse proxy (port 80, public)

# Access:
# http://localhost        → Pilot interface
# http://localhost/health → API health
# http://localhost/docs   → Swagger UI

# Stop services
docker compose down

# Rebuild after code changes
docker compose up --build --force-recreate

Docker services (docker-compose.yml):

  • api: FastAPI application with ChromaDB index mounted
  • nginx: Reverse proxy serving pilot.html and forwarding API calls

File Structure

dyson-rag-assistant/
│
├── notebooks/
│   ├── 01_data_extraction.ipynb
│   ├── 02_indexing.ipynb
│   ├── 03_retrieval_generation.ipynb
│   ├── 04_evaluation.ipynb
│   └── 05_demo_production.ipynb
│
├── data/
│   ├── raw/                         # Raw source files
│   ├── processed/                   # Cleaned data (parquet, json)
│   ├── vectorstore/
│   │   └── dyson_rag_2025_11/       # ChromaDB persistent index
│   └── evaluation_dataset_testing.xlsx
│
├── docs/                            # Presentation and brand materials
│   ├── dyson_rag_business_deck.pdf  # Business deck for stakeholders
│   ├── dyson_rag_enablement_deck.pdf # Enablement deck for end users
│   └── dyson_style_guide.pdf        # Visual style guide
│
├── outputs/
│   ├── query_history.json
│   ├── query_history_v50.xlsx
│   ├── rag_pipeline_config.json
│   └── evaluation/
│       ├── evaluation_report_YYYYMMDD.json
│       ├── faithfulness_report_YYYYMMDD.xlsx
│       ├── complete_evaluation_YYYYMMDD.xlsx
│       └── human_evaluation_template_YYYYMMDD.xlsx
│
├── assets/
│   └── images/
│       ├── 01_pilot_basic.gif
│       ├── 02_pilot_advanced.gif
│       ├── logo.png, favicon.ico
│       └── lang_*.png (en, es, fr, de, it)
│
├── pipeline_wrapper.py              # RAG pipeline (HybridRetriever + DysonRAGPipeline)
├── api.py                           # FastAPI backend
├── pilot.html                       # Frontend HTML interface
├── frontend.js                      # Frontend JavaScript (SPA)
├── rag_core.py                      # Core RAG logic
├── Dockerfile                       # Backend Docker image
├── docker-compose.yml               # Service orchestration
├── nginx.conf                       # Reverse proxy + static serving
├── .env.example                     # Environment template
├── .dockerignore                    # Docker build exclusions
├── .gitignore
├── .gitattributes
├── requirements.txt
└── README.md

Technical Stack

Category Technology Version Purpose
Language Python 3.11 Core development
RAG Framework LangChain 1.2+ Document processing, prompts, chains
Vector Database ChromaDB 1.4+ Persistent vector storage
Embeddings intfloat/multilingual-e5-large 384 dims, cross-lingual
LLM Google Gemini Flash / Pro Generation
Data Processing Pandas 2.2+ Data manipulation
PDF Processing PyMuPDF PDF text extraction
HTML Processing BeautifulSoup 4 Web scraping, table parsing
Lexical Search rank-bm25 BM25 algorithm
Re-ranking Sentence Transformers CrossEncoder (ms-marco-MiniLM)
API Framework FastAPI REST API endpoints
Web Server Uvicorn ASGI server
Reverse Proxy Nginx 1.27-alpine Static serving + SSE proxy
Containerization Docker / Docker Compose Reproducible deployment
Frontend HTML/Vanilla JS Bootstrap + custom CSS

Development environment: Google Colab + Google Drive + Jupyter


Academic Contributions

Methodological Innovations

  1. Selective Chunking Strategy: Structured data (market/reviews/keywords) is NOT chunked, preventing context fragmentation and improving retrieval precision by ~10–15% vs naive chunking.

  2. Cross-Lingual RAG without Translation Overhead: Base data in English + multilingual embeddings + LLM responding in detected query language. Cost-efficient cross-lingual architecture (~88% accuracy across 5 languages).

  3. Business-Aligned Evaluation Framework: Beyond technical metrics (Hit@K, MRR), introduces business metrics (Actionability, Revenue Impact) and adapts faithfulness evaluation to penalize long, argued responses appropriately. Standard RAGAS metrics do not apply to this RAG profile.

  4. Hybrid Retrieval with Dynamic Weighting: BM25 for technical terms + Vector for semantic queries, with automatic query-type detection.

  5. Deterministic Bypass Architecture: 8 high-frequency patterns answered without LLM call (<1.5 s, 0% hallucination), combined with async hallucination checking for full pipeline responses.

  6. Lost Revenue Quantification Engine: Automated detection of catalog gaps, visibility issues, competitive displacement, with financial impact estimation (£/month) and prioritized action plan.


Future Work

Short-Term Enhancements

  1. Model precision and latency refinement: further testing and optimization of bypasses and prompt injections with real usage experience.

  2. Product sheet and keyword positioning optimization: add keyword positioning data per product, titles, descriptions, A+ content, versus competition — available from Helium 10 Platinum (paid version).

  3. Margin optimization by ISO: add data on dimensions, shipping type, competition per ISO — available from Helium 10 Platinum — to complement existing cost and margin estimates for Dyson vs. competitor products.

  4. Deeper sentiment analysis: add competitor product reviews (at least for top-5 brands).

  5. Historical data with MoM/PoP charts: trend evolution and comparative analysis over time.

Medium-Term Goals

  1. Automated data pipeline: automatic scheduled extraction from Helium 10 and official Dyson websites per country (dyson.co.uk, dyson.es, dyson.de, dyson.fr, dyson.it).

  2. More product lines and countries: extend beyond cordless vacuums and Amazon UK.

  3. LLM model updates and comparisons: benchmark against new models as they emerge.

Long-Term Vision

  1. Full e-commerce intelligence platform: multi-marketplace, multi-brand, multi-country, real-time dashboards.

  2. Automated execution: low-risk recommendations auto-executed (price adjustments within bounds), content updates submitted for approval.


License

Academic Use Only

This project is part of a Master's Thesis (TFM) in Data Science.

No Official Affiliation: This project has no official affiliation with Dyson Ltd. and does not represent the company's actual corporate strategy. All recommendations are hypothetical and based on public data analysis for academic purposes.

All data used is from publicly accessible sources: Amazon.co.uk (customer reviews, product listings), Dyson.co.uk (technical documentation), and Helium 10 (market intelligence). No proprietary or confidential information from Dyson Ltd. has been used.

Citation:

Sanchez, Alberto. (2026). DYSON RAG Assistant: Multimodal & Cross-Lingual RAG System
for Amazon UK Strategy Optimization. Master's Thesis in Data Science with AI, 2nd Edition.
BIG School. Available at: https://github.com/albertosvallejo/

Contact & Support

Project Author:

Academic Program:

Technical Support:

Acknowledgments:

  • BIG School — Academic support and resources
  • Open Source Community: LangChain, ChromaDB, HuggingFace, Google (Gemini API), FastAPI
  • Amazon UK and Dyson Ltd. — Publicly available data that enabled this research
  • Helium 10 — Market intelligence tools

Contact for Commercial Licensing: DH Marketing Consultants — alberto.sanchez@gmail.com


Last Updated: March 26, 2026 Version: v5.4 (Production Pilot) Status: Production Ready — Docker Deployed


This README serves dual purposes: technical documentation for users/developers and comprehensive evaluation material for thesis committee members.

Releases

Packages

Contributors

Languages