---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

1.  [](/)
2.  [Code examples](/recipes)
3.  Semantic Drift Detection

Back to code examples

DriftThemes

# Semantic Drift Detection

Monitor distribution shifts between baseline and current data using cluster comparison. Detect when new content diverges from training data or when content mix changes unexpectedly.

video

image

text

Production

[Run in Builder](/build?recipe=semantic-drift)

"Detect distribution drift in training data between Q1 baseline and current dataset"

### Why This Matters

Data drift is silent model degradation. By comparing cluster distributions over time, you catch drift before it impacts production systems.

Python

cURL

import time

import requests

from mixpeek import Mixpeek

client \= Mixpeek(api\_key\="YOUR\_API\_KEY", namespace\="drift-monitor")

API \= "https://api.mixpeek.com/v1"

HEADERS \= {"Authorization": "Bearer YOUR\_API\_KEY", "X-Namespace": "drift-monitor"}

\# 1. The training images, embedded

bucket \= client.buckets.create(

    bucket\_name\="training-data",

    bucket\_schema\={"properties": {"image": {"type": "image"}}},

)

collection \= client.collections.create(

    collection\_name\="training-data",

    source\={"type": "bucket", "bucket\_ids": \[bucket\["bucket\_id"\]\]},

    feature\_extractor\={

        "feature\_extractor\_name": "multimodal\_extractor",

        "version": "v1",

    },

)

client.buckets.upload(

    bucket\["bucket\_id"\],

    blobs\=\[{"property": "image", "type": "image", "data": "s3://your-bucket/training/batch-01/img-0001.jpg"}\],

)

client.collections.trigger(collection\["collection\_id"\])

\# 2. One cluster definition, run whenever you want a snapshot of the embedding space.

\#    The SDK has no clusters resource, so this part is REST.

cluster \= requests.post(API + "/clusters", headers\=HEADERS, json\={

    "cluster\_name": "training-drift",

    "collection\_ids": \[collection\["collection\_id"\]\],

    "cluster\_type": "vector",

    "vector\_config": {

        "feature\_uris": \["mixpeek://multimodal\_extractor@v1/vertex\_multimodal\_embedding"\],

        "clustering\_method": "hdbscan",

        "algorithm\_params": {"min\_cluster\_size": 20},

    },

}).json()

def snapshot():

    task \= requests.post(API + "/clusters/" + cluster\["cluster\_id"\] + "/execute", headers\=HEADERS, json\={}).json()

    while client.tasks.get(task\["task\_id"\])\["status"\] not in ("COMPLETED", "COMPLETED\_WITH\_ERRORS", "FAILED"):

        time.sleep(15)

    return requests.get(API + "/clusters/" + cluster\["cluster\_id"\] + "/executions", headers\=HEADERS).json()

baseline \= snapshot()

\# 3. After new data lands and is processed, snapshot again and compare the runs

client.buckets.upload(

    bucket\["bucket\_id"\],

    blobs\=\[{"property": "image", "type": "image", "data": "s3://your-bucket/training/batch-02/img-0001.jpg"}\],

)

client.collections.trigger(collection\["collection\_id"\])

current \= snapshot()

for name in ("noise\_ratio", "silhouette\_score", "mean\_cosine\_to\_centroid"):

    before \= (baseline.get("metrics") or {}).get(name)

    after \= (current.get("metrics") or {}).get(name)

    print(name, before, "->", after)

print("clusters:", baseline\["num\_clusters"\], "->", current\["num\_clusters"\])

\# Every run stays in the history

history \= requests.post(API + "/clusters/" + cluster\["cluster\_id"\] + "/executions/list", headers\=HEADERS, json\={}).json()

for run in history\["results"\]:

    print(run\["run\_id"\], run\["num\_clusters"\], (run.get("metrics") or {}).get("noise\_ratio"))

### Feature Extractors

Multimodal Extractor

Unified embeddings for video, audio, image, and text: scene/silence chunking, Whisper transcription, thumbnails, and Gemini vision.

### Retriever Stages

### Resources Used

Clustering

[

Baseline Clusters

Baseline distribution snapshot for comparison

Baseline distribution snapshot



](https://mixpeek.com/docs/enrichment/clusters)

Analytics

[

Drift Metrics

Distribution shift and novelty scores

Distribution shift and novelty scores



](https://mixpeek.com/docs/enrichment/clusters)

### Documentation

[Clusters](https://mixpeek.com/docs/enrichment/clusters)

## Use Cases Using This Recipe

Advanced

Coming Soon

8 min

### Creative Lineage & Storyboard Intelligence

Track creative evolution from concept to final cut

85% concept retention

Brief-to-final alignment

[

advertising

](/solutions/advertising)

Who It's For

Creative directors, brand managers, and production teams managing multi-version creative workflows

[View Details](/use-cases/creative-lineage-storyboard)

## Related code examples and resources

Pages on the same stages, extractors and patterns.

[

Extractor

### Multimodal Extractor

Unified embeddings for video, audio, image, and text: scene/silence chunking, Whisper transcription, thumbnails, and Gemini vision.

Learn more





](/extractors/multimodal)[

Recipe

### Dataset Versioning

Treat versioned object storage as your dataset's source of truth. Capture complete snapshots-raw assets, embeddings, and cluster assignments-for deterministic reconstruction at any point in time.

Learn more





](/recipes/dataset-versioning)[

Recipe

### Clustering & Theme Discovery

Unsupervised clustering that groups content into semantic themes using HDBSCAN. Surfaces hidden patterns, content variants, and outliers without requiring predefined labels.

Learn more





](/recipes/clustering-theme-discovery)[

Recipe

### Hierarchical Classification

Assign content to multi-level category hierarchies using embedding-based classification. Define your taxonomy once, then classify new content automatically with confidence scores.

Learn more





](/recipes/hierarchical-classification)[

Recipe

### Brand Safety & Ad Verification Pipeline

Brand safety pipeline for ad networks. Scores video and image creatives against the GARM brand safety floor and suitability categories, which vendors still use after GARM wound down in 2024, before an ad is served.

Learn more





](/recipes/brand-safety-pipeline)[

Recipe

### Automated Video Tagging

Automatically generate descriptive tags for video content using scene analysis, object detection, and taxonomy classification. Each video receives structured labels for scenes, objects, actions, and custom business categories without manual annotation.

Learn more





](/recipes/automated-video-tagging)