ManimGL animation source code for explaining how CLIP maps images and text into a shared embedding space.
This repo is a visual explainer for the core CLIP idea: image patches and text tokens are encoded separately, projected into the same vector space, normalized, compared with cosine similarity, and then used for retrieval or classification-like decisions.
- How image and text encoders produce vectors.
- Why a shared embedding space makes image-text matching possible.
- How L2 normalization and cosine similarity shape CLIP comparisons.
- How similarity matrices, UMAP-style projections, and decision boundaries can make embedding behavior easier to see.
clip_encoding.py- main CLIP encoding overview scene.clip_encoding_scene_1.py- shared embedding space.clip_encoding_scene_2.py- CLIP similarity matrix.clip_encoding_scene_3.py- L2 normalization and cosine similarity.clip_encoding_scene_4.py- UMAP-style embedding visualization.clip_encoding_scene_5.py- MLP decision boundary scene.clip_encoding_scene_6.py- bad sinks and cluster behavior.example_photos/- small reference images used by the scenes.requirements.txt- pinned ManimGL-related dependencies.
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtIf the PyPI manimgl package has import issues on your Python version, install ManimGL from source instead:
pip install /path/to/manimglInteractive mode with live preview:
manimgl clip_encoding.py CLIPEncoding -i --autoreloadRender the main scene to video:
manimgl clip_encoding.py CLIPEncoding -w --hdRender a specific scene:
manimgl clip_encoding_scene_3.py L2NormalizationCosineSimilarity -w --hdRendered output is written under videos/.
CLIP is often introduced with a single diagram, but the intuition lives in the geometry: normalization, similarity, clusters, and boundaries. This repo keeps the animation source public so the explanation is inspectable and reusable.