Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building an AI Vision Search Engine with MySQL ...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Building an AI Vision Search Engine with MySQL HeatWave GenAI

Modern AI systems increasingly rely on multimodal data: text, images, documents, audio, and video. Among these modalities, image understanding has become one of the most important capabilities for AI-powered applications. Traditionally, implementing these capabilities required specialized computer vision infrastructure, external vector databases, custom ML pipelines, and multiple frameworks.
With MySQL HeatWave GenAI, many of these capabilities can now be implemented directly inside SQL workflows using built-in AI routines. In this article, we will build the foundations of a Vision Model Evaluation Assistant using MySQL HeatWave GenAI.

Avatar for Olivier DASINI

Olivier DASINI

May 14, 2026

More Decks by Olivier DASINI

Other Decks in Technology

Transcript

  1. Building an AI Vision Search Engine with MySQL HeatWave GenAI

    Lower Cost, Simpler Architecture, Faster AI Innovation May 20, 2026 Olivier Dasini MySQL AI & Analytics Solutions Architect @ Oracle [email protected] Blogs : www.dasini.net/blog/en : www.dasini.net/blog/fr Linkedin : www.linkedin.com/in/olivier-dasini Slides : https://speakerdeck.com/freshdaz
  2. Safe harbor statement The following is intended to outline our

    general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. 2 Copyright © 2026, Oracle and/or its affiliates. All rights reserved.
  3. 3 Me, Myself & I Olivier DASINI Copyright © 2026,

    Oracle and/or its affiliates. All rights reserved. 3  Data Geek  Addicted to MySQL for 20+ years  Playing with databases for 25+ years  Writer, Blogger and Speaker  Also former : DBA, Consultant, Architect, Trainer, ...  MySQL HeatWave AI & Analytics Solution Architect, at Oracle  Stay up to date!  Blog: www.dasini.net/blog/en  Linkedin: www.linkedin.com/in/olivier-dasini/  Slides: https://speakerdeck.com/freshdaz
  4. 4 Resources & Slides • Read the Deep Dive Article:

    This presentation is based on the deeper implementation details found here (Highly Recommended): Building an AI Vision Search Engine with MySQL HeatWave GenAI • Download the Deck: Grab a copy of these slides anytime on my Speaker Deck: https://speakerdeck.com/freshdaz/building-an-ai-vision-search-engine-with-mysql-heatwave-genai 4 https://dasini.net/blog/2026/05/14/building-an-ai-vision-search-engine-with-mysql-heatwave-genai/
  5. 5 Agenda 1. Landscape of Vision-to-Embedding Approaches 2. Overview of

    MySQL HeatWave GenAI 3. Generating Image Understanding with sys.ML_GENERATE 4. Text-to-Image Search (Semantic Retrieval) 5. Reverse Image Search (Image-to-Image via Semantics) 6. Architectural Trade-offs & Design Considerations 7. Conclusion 5
  6. Modern AI applications are multimodal • Modern AI systems increasingly

    rely on multimodal data: • text, images, documents, audio, and video • Some of the requirements: • Search images using natural language • Compare visually similar assets • Validate AI-generated descriptions • Build semantic retrieval pipelines 6 Copyright © 2026, Oracle and/or its affiliates Why Semantic Image Understanding?
  7. Operationally Heavy and Fragmented • Specialized computer vision infrastructure •

    External vector databases • Custom ML pipelines • Multiple orchestration frameworks • Operational complexity 8 Copyright © 2026, Oracle and/or its affiliates Traditional AI Image Pipelines
  8. Three main paradigms 1. Direct Image Embeddings 2. Semantic Metadata

    Embeddings 3. Multimodal Fusion Models 9 Copyright © 2026, Oracle and/or its affiliates Vision-to-Embedding Approaches
  9. Powerful, Yet Hard to Explain • Image → Neural Network

    → Vector • Popular architectures include: • CLIP, ResNet, Vision Transformers (ViT) • Convert raw image pixels directly into vectors ✔ Fast similarity search ✔ Excellent for image-to-image matching ✗ Black-box behavior ie, No human-readable explanation ✗ Harder to debug and refine 10 Copyright © 2026, Oracle and/or its affiliates 1. Direct Image Embeddings
  10. Human-Readable and SQL-Native • Image → Text → Embedding •

    Generate text (descriptions and/or keywords) ✔ Human-readable and explainable ✔ Useful for debug ✔ SQL-native workflow ✔ Ideal for MySQL HeatWave GenAI ✗ Less precise for purely visual similarity ✗ Depends on generated metadata quality 11 Copyright © 2026, Oracle and/or its affiliates 2. Semantic Metadata Embeddings
  11. Create unified multimodal embeddings • Multimodal architectures capable of jointly

    processing: • Images, Text, Audio, Video, Structured data, … • These systems use: • {Early | Intermediate | Late | Hybrid} fusion architectures ✔ Very powerful semantic understanding ✔ Strong cross-modal reasoning ✗ More complex, Harder to operationalize ✗ Less transparent ✗ Difficult to integrate into SQL-centric architectures 12 Copyright © 2026, Oracle and/or its affiliates 3. Multimodal Fusion Models
  12. The Semantic Metadata Embeddings pipeline • ML_GENERATE handles image-to-text generation

    • ML_EMBED_ROW handles text-to-vector conversion • Human-readable semantic audit trail • Explainability is critical for evaluation systems 13 Copyright © 2026, Oracle and/or its affiliates Why Choose Image → Text → Embedding?
  13. Generative AI Integrated and Automated, at no additional cost •

    HeatWave GenAI lets you communicate with unstructured data in HeatWave using natural- language queries • Using HeatWave GenAI, you can perform natural-language searches in a single step using either in- database or external large language models (LLMs) • It uses a familiar SQL interface which makes it is easy to use for content generation, summarization, sentiment analysis, retrieval-augmented generation (RAG), … • All the elements that are necessary to use HeatWave GenAI with proprietary data are integrated and optimized to work with each other • HeatWave GenAI lets you integrate generative AI into the applications, providing an integrated end- to-end pipeline including vector store generation, vector search using RAG, and an inbuilt chatbot 16 Copyright © 2026, Oracle and/or its affiliates MySQL HeatWave GenAI https://dev.mysql.com/doc/heatwave/en/mys-hw-genai.html
  14. Copyright © 2026, Oracle and/or its affiliates. All rights reserved.

    17 MySQL HeatWave GenAI  Provides integrated and automated generative AI with in-database large language models (LLMs)  An automated, in-database vector store & scale-out vector processing  The ability to have contextual conversations in natural language Letting you take advantage of generative AI without AI expertise, data movement, or additional cost https://www.oracle.com/heatwave/genai/
  15. A cost effective unified platform • Unified OLTP + OLAP

    + ML + GenAI platform • AI workflows directly inside SQL • Built-in vector store capabilities • Key elements: ML_GENERATE, ML_EMBED_ROW, DISTANCE, VECTOR 18 Copyright © 2026, Oracle and/or its affiliates MySQL HeatWave GenAI
  16. From Images to Semantic Metadata with sys.ML_GENERATE • The sys.ML_GENERATE

    routine supports multimodal prompts combining: • Text • Images • This enables: • Caption generation • Object detection prompts • Context extraction • Semantic interpretation • https://dev.mysql.com/doc/heatwave/en/mys-hwgenai-ml-generate.html 22 Copyright © 2026, Oracle and/or its affiliates What sys.ML_GENERATE Enables
  17. From Images to Semantic Metadata with sys.ML_GENERATE • The supported

    vision models can be queried directly from MySQL HeatWave (9.6.1): 23 Copyright © 2026, Oracle and/or its affiliates Supported Vision Models SELECT * FROM sys.ML_SUPPORTED_LLMS WHERE model_id LIKE 'google.gemini%'; +---------------------------+--------------------------------+-------------------+---------------------+---------------+ | provider | model_id | availability_date | capabilities | default_model | +---------------------------+--------------------------------+-------------------+---------------------+---------------+ | OCI Generative AI Service | google.gemini-2.5-flash | 2026-01-22 | ["GENERATION"] | 0 | | OCI Generative AI Service | google.gemini-2.5-pro | 2026-01-22 | ["GENERATION"] | 0 | | OCI Generative AI Service | google.gemini-2.5-flash-lite | 2026-01-22 | ["GENERATION"] | 0 | +---------------------------+--------------------------------+-------------------+---------------------+---------------+
  18. • This table stores: • The original image (in base

    64) • Semantic metadata (Image description and keywords) • Vector embeddings (of the description and the keywords) 24 Copyright © 2026, Oracle and/or its affiliates Table Definition CREATE TABLE image_details ( id_image int unsigned NOT NULL AUTO_INCREMENT, image_name varchar(255) NOT NULL, image_base64 longtext NOT NULL, image_description json NOT NULL, image_description_embedding vector(2048) NOT NULL COMMENT 'GENAI_OPTIONS=EMBED_MODEL_ID=cohere.embed-english-v3.0', image_keywords json NOT NULL, image_keywords_embedding vector(2048) NOT NULL COMMENT 'GENAI_OPTIONS=EMBED_MODEL_ID=cohere.embed-english-v3.0', created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id_image) ) ENGINE=InnoDB; Stored inside MySQL HeatWave
  19. SQL Example 25 Copyright © 2026, Oracle and/or its affiliates

    Object Detection Prompt SELECT image_base64 FROM image_details WHERE id_image = 1 INTO @image_base64; SET @prompt_desc_key_json = 'What objects are present?'; SELECT JSON_UNQUOTE( JSON_EXTRACT( sys.ML_GENERATE(@prompt_desc_key_json, JSON_OBJECT("model_id", "google.gemini-2.5-pro", "image", @image_base64)), '$.text' ) ) AS description;
  20. SQL Example 26 Copyright © 2026, Oracle and/or its affiliates

    Scene Context Prompt SET @prompt_desc_key_json = 'What is the context of this scene?'; SELECT JSON_UNQUOTE( JSON_EXTRACT( sys.ML_GENERATE(@prompt_desc_key_json, JSON_OBJECT("model_id", "google.gemini-2.5-pro", "image", @image_base64)), '$.text' ) ) AS description;
  21. Query in Words, Retrieve by Meaning • Input: Text •

    Output: Relevant Images • Convert text query into embedding • Similarity search against image embeddings • Search by meaning, not pixels • This is semantic retrieval 28 Copyright © 2026, Oracle and/or its affiliates Text-to-Image Search
  22. Query in Words, Retrieve by Meaning • An embedding model

    is a machine learning model that transforms complex, high-dimensional data (words, sentences, images, …) into compact, fixed-size lists of numbers called vectors (or embeddings) • The supported embedding models can be queried directly from MySQL HeatWave (9.6.1): 29 Copyright © 2026, Oracle and/or its affiliates Supported Embedding Models SELECT * FROM sys.ML_SUPPORTED_LLMS WHERE capabilities LIKE '["TEXT_EMBEDDINGS"]'; +---------------------------+--------------------------------+-------------------+---------------------+---------------+ | provider | model_id | availability_date | capabilities | default_model | +---------------------------+--------------------------------+-------------------+---------------------+---------------+ | HeatWave | all_minilm_l12_v2 | 2024-07-01 | ["TEXT_EMBEDDINGS"] | 0 | | HeatWave | multilingual-e5-small | 2024-07-24 | ["TEXT_EMBEDDINGS"] | 1 | | OCI Generative AI Service | cohere.embed-english-v3.0 | 2024-02-17 | ["TEXT_EMBEDDINGS"] | 0 | | OCI Generative AI Service | cohere.embed-multilingual-v3.0 | 2024-02-17 | ["TEXT_EMBEDDINGS"] | 0 | +---------------------------+--------------------------------+-------------------+---------------------+---------------+
  23. 2 steps • The workflow contains two phases: 1) Preprocessing

    • Each image must first be semantically enriched. 2)Query execution • The user enters a text description • The text becomes an embedding • Similarity search retrieves matching images 30 Copyright © 2026, Oracle and/or its affiliates Workflow Overview
  24. SQL Example 31 Copyright © 2026, Oracle and/or its affiliates

    Preprocessing - Generating Semantic Metadata SET @prompt_desc_key_json = ' Analyze the image and return a minified JSON object. The JSON must contain two fields: "description" (a concise, single-paragraph description of visible content with no speculation) and "keywords" (a JSON array of relevant lowercase visual keywords). Output ONLY the raw JSON on a single line without any markdown formatting, backticks, or preamble ';
  25. SQL Example 32 Copyright © 2026, Oracle and/or its affiliates

    Preprocessing - Generate Description and Keywords SELECT JSON_UNQUOTE( JSON_EXTRACT( sys.ML_GENERATE(@prompt_desc_key_json, JSON_OBJECT("model_id", "google.gemini-2.5-pro", "image", @image_base64)), '$.text' ) ) AS description;
  26. SQL Example 33 Copyright © 2026, Oracle and/or its affiliates

    Preprocessing - Generate Embeddings and Store Data INSERT INTO image_details ( image_name, image_base64, image_description, image_description_embedding, image_keywords, image_keywords_embedding ) VALUES ( image_name, image_base64, image_description, sys.ML_EMBED_ROW( @source_image_descriptions, '{"model_id": "cohere.embed-english-v3.0"}' ), image_keywords, sys.ML_EMBED_ROW( @source_image_keywords, '{"model_id": "cohere.embed-english-v3.0"}' ));
  27. Query in Words, Retrieve by Meaning • At query time:

    • The user enters a text description • The text becomes an embedding • Similarity search retrieves matching images 34 Copyright © 2026, Oracle and/or its affiliates Text-to-Image Search
  28. SQL Example 35 Copyright © 2026, Oracle and/or its affiliates

    Query time - Generate Query Embedding SET @embeddOptions = '{"model_id": "cohere.embed-english-v3.0"}'; SET @searchImage = 'street motorcycle'; SELECT sys.ML_EMBED_ROW( @searchImage, @embeddOptions ) INTO @searchImageEmbedding;
  29. SQL Example 36 Copyright © 2026, Oracle and/or its affiliates

    Query time - Similarity Search Using Descriptions SELECT image_name, DISTANCE( image_description_embedding, @searchImageEmbedding, 'COSINE' ) AS min_distance FROM image_details ORDER BY min_distance LIMIT 3;
  30. SQL Example 37 Copyright © 2026, Oracle and/or its affiliates

    Query time - Similarity Search Using Description + Keywords WITH distances AS ( SELECT image_name, ( DISTANCE( image_keywords_embedding, @searchImageEmbedding, 'COSINE' ) + DISTANCE( image_description_embedding, @searchImageEmbedding, 'COSINE' ) ) / 2 AS avg_distance FROM image_details ) SELECT * FROM distances ORDER BY avg_distance ASC LIMIT 3;
  31. SQL Example 38 Copyright © 2026, Oracle and/or its affiliates

    Query time - Similarity Search with a simple reranking strategy WITH initial_results AS ( SELECT image_name, DISTANCE(image_keywords_embedding, @searchImageEmbedding, 'COSINE' ) AS keywords_distance, DISTANCE(image_description_embedding, @searchImageEmbedding, 'COSINE' ) AS description_distance FROM image_details ORDER BY keywords_distance + description_distance LIMIT 15 ), reranked_results AS ( SELECT image_name, ( 0.3 * keywords_distance + 0.7 * description_distance ) AS combined_distance FROM initial_results ) SELECT * FROM reranked_results ORDER BY combined_distance ASC LIMIT 3;
  32. Similarity of meaning • Input: Image • Output: Relevant Images

    • Semantic image-to-image search • Similarity of meaning, not appearance • No complex computer vision frameworks required • This is: • Similarity of meaning • Not similarity of pixels 40 Copyright © 2026, Oracle and/or its affiliates Reverse Image Search
  33. Why This Is Interesting • 2 images may be visually

    different while still being semantically related • For example: • Different motorcycles • Different lighting conditions • Different camera angles • Yet both images may describe: « A motorcycle parked on an urban street » • Semantic retrieval captures this meaning 41 Copyright © 2026, Oracle and/or its affiliates Reverse Image Search
  34. Key benefits • Simpler Architecture • Eliminates the need for

    complex computer vision frameworks, GPU-heavy pipelines, and specialized external vector databases • Complete Explainability • Audit retrieval results directly through generated metadata; refine descriptions and improve LLM prompts based on clear text logic • SQL-Native Workflow • Keep metadata, embeddings, similarity search, and ranking logic unified within the MySQL HeatWave engine 42 Copyright © 2026, Oracle and/or its affiliates Advantages of the Semantic Approach
  35. • Building AI-powered semantic image systems involves several important architectural

    decisions 1. Descriptions vs Keywords 2. Database vs Object Storage 3. Prompt engineering quality 44 Copyright © 2026, Oracle and/or its affiliates Architectural Trade-offs
  36. 45 Copyright © 2026, Oracle and/or its affiliates Description vs

    Keywords Descriptions • Descriptions provide: • Rich contextual understanding • Better semantic reasoning • Natural language flexibility • However: • They may introduce noise • Longer text may dilute embeddings Keywords • Keywords provide: • Focused semantic signals • Better precision • Faster matching • However: • They lose contextual richness Both representations serve different purposes
  37. Hybrid approach Strategy implemented here • A hybrid approach: •

    Used descriptions for semantic context • Used keywords for precision • Combined both during re-ranking • However • I’m storing two embeddings doubles vector storage (2 × 2048 dimensions per image) • For very large libraries, consider using only one – either concatenated or choose the one that performs better on your validation set 46 Copyright © 2026, Oracle and/or its affiliates Description vs Keywords
  38. Storing Images in MySQL • Advantages: • Simpler architecture •

    Centralized governance • Easier transactional consistency • Disadvantages: • Larger database size increases buffer pool pressure • Backup overhead • Potentially performance impact (queries, replication, …) 47 Copyright © 2026, Oracle and/or its affiliates Storing Images in the Database vs Object Storage Storing Images in Object Storage • Advantages: • Better scalability • Lower storage costs • Better CDN integration • Disadvantages: • More complex architecture • Additional security management
  39. Recommended Hybrid Strategy • A practical enterprise approach is often:

    • Store thumbnails (small, e.g., 512×512) as base64 in MySQL (should be sufficient for vision model analysis) • Store full-resolution images in object storage for later retrieval or user download • This enables: • Fast previews • Efficient semantic retrieval • Scalable storage architecture 48 Copyright © 2026, Oracle and/or its affiliates Storing Images in the Database vs Object Storage
  40. Semantic quality heavily depends on prompts • Poor prompts generate:

    • Vague descriptions • Weak keywords • Low-quality embeddings • Well-designed prompts improve: • Retrieval quality • Explainability • Evaluation consistency Prompt engineering becomes a critical part of semantic architecture design! 49 Copyright © 2026, Oracle and/or its affiliates Prompt Engineering Matters
  41. • MySQL HeatWave GenAI significantly simplifies the implementation of semantic

    image understanding systems • By combining: • Vision-language models • Text embeddings • Vector search • SQL-native AI routines • By consolidating multimodal AI directly within MySQL HeatWave, organizations can deploy sophisticated vision systems while substantially lowering their Total Cost of Ownership. 51 Copyright © 2026, Oracle and/or its affiliates Wrap-up MySQL HeatWave enables architects & developers to build AI systems that remain understandable, debuggable, & governable
  42. Copyright © 2026, Oracle and/or its affiliates. All rights reserved.

    52 Merci! Q&R Olivier Dasini MySQL AI & Analytics Solutions Architect @ Oracle [email protected] Blogs : www.dasini.net/blog/en : www.dasini.net/blog/fr Linkedin : www.linkedin.com/in/olivier-dasini Slides : https://speakerdeck.com/freshdaz
  43. Copyright © 2026, Oracle and/or its affiliates. All rights reserved.

    55 Discovering MySQL Database Service • Discovering MySQL Database Service – Episode 1 – Introduction – http://dasini.net/blog/2021/08/03/discovering-mysql-database-service-episode-1-introduction/ • Discovering MySQL Database Service – Episode 2 – Create a compartment – http://dasini.net/blog/2021/08/10/discovering-mysql-database-service-episode-2-create-a-compartment/ • Discovering MySQL Database Service – Episode 3 – Create a Virtual Cloud Network – http://dasini.net/blog/2021/08/17/discovering-mysql-database-service-episode-3-create-a-virtual-cloud-network/ • Discovering MySQL Database Service – Episode 4 – Dump your MySQL data into an Object Storage bucket – http://dasini.net/blog/2021/08/24/discovering-mysql-database-service-episode-4-dump-your-mysql-data-into-an-object-storage-bucket/ • Discovering MySQL Database Service – Episode 5 – Create a MySQL DB system from a MySQL Shell dump – http://dasini.net/blog/2021/08/31/discovering-mysql-database-service-episode-5-create-a-mysql-db-system-from-a-mysql-shell-dump/ • Discovering MySQL Database Service – Episode 6 – Update the Private Subnet Security List – http://dasini.net/blog/2021/09/07/discovering-mysql-database-service-episode-6-update-the-private-subnet-security-list/ • Discovering MySQL Database Service – Episode 7 – Use a Bastion SSH port forwarding session – http://dasini.net/blog/2021/09/14/discovering-mysql-database-service-episode-7-use-a-bastion-ssh-port-forwarding-session/ • Discovering MySQL Database Service – Episode 8 – Connect to MySQL Database Service Using MySQL Shell – http://dasini.net/blog/2021/09/21/discovering-mysql-database-service-episode-8-connect-to-mysql-database-service-using-mysql-shell/ • Discovering MySQL Database Service – Episode 9 – Connect to MySQL Database Service Using MySQL Workbench – http://dasini.net/blog/2021/09/28/discovering-mysql-database-service-episode-9-connect-to-mysql-database-service-using-mysql-workbench/ • Discovering MySQL Database Service – Episode 10 – Connect to MySQL Database Service Using OCI Cloud Shell – http://dasini.net/blog/2021/10/05/discovering-mysql-database-service-episode-10-connect-to-mysql-database-service-using-oci-cloud-shell/ • ... Tutorials where I show you, step by step, how to use MDS and some other OCI services Tutorials where I show you, step by step, how to use MDS and some other OCI services http://dasini.net/blog/en
  44. Copyright © 2026, Oracle and/or its affiliates Oracle Live Labs

    Self-paced learning MySQL HeatWave Live Labs 56