/$$ /$$ /$$ /$$ /$$ /$$
| $$ | $$ | $$ | $$ | $$|__/
| $$ | $$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ | $$ | $$ /$$ /$$$$$$ /$$ /$$ /$$
| $$ / $$//$$__ $$ /$$_____/|_ $$_/ /$$__ $$ /$$__ $$| $$ / $$/| $$ /$$__ $$| $$ | $$ | $$
\ $$ $$/| $$$$$$$$| $$ | $$ | $$ \ $$| $$ \__/ \ $$ $$/ | $$| $$$$$$$$| $$ | $$ | $$
\ $$$/ | $$_____/| $$ | $$ /$$| $$ | $$| $$ \ $$$/ | $$| $$_____/| $$ | $$ | $$
\ $/ | $$$$$$$| $$$$$$$ | $$$$/| $$$$$$/| $$ \ $/ | $$| $$$$$$$| $$$$$/$$$$/
\_/ \_______/ \_______/ \___/ \______/ |__/ \_/ |__/ \_______/ \_____/\___/
Multi-modal vector search engine β image similarity, zero-shot KNN classification, and text-to-image retrieval powered by CLIP embeddings.
VectorView is a multi-modal vector search system that converts raw images and natural language into high-dimensional embeddings using OpenAI's CLIP model β then stores, indexes, and retrieves them via Pinecone and MongoDB Atlas Vector Search.
No supervised training. No labeled pipelines. Just embeddings and geometry.
You give it: "A Running Dog"
It returns: πΆπβ the closest matching images in the dataset
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β VectorView Pipeline β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π Animal Dataset (cats / dogs / wolves) β
β β β
β βΌ β
β βββββββββββββββ CLIP Model (ViT-B/32) β
β β Image β βββββββββββββββββββββββββββΊ [512-d vector] β
β β Encoder β β β
β βββββββββββββββ β β
β βΌ β
β βββββββββββββββ ββββββββββββββββββββ β
β β Text β βββΊ [512-d vector] βββββΊβ Vector Database β β
β β Encoder β β β β
β βββββββββββββββ β ββββββββββββββ β β
β β β Pinecone β β β
β ββββββββββββββββββββββββββββββββββββ β ββββββββββββββ β β
β β Query β β ββββββββββββββ β β
β β "cute Kitty" / query_image.jpg β β β MongoDB β β β
β ββββββββββββββββββββββββββββββββββββ β ββββββββββββββ β β
β β ββββββββββββββββββββ β
β βΌ β β
β Cosine Similarity βββββββββββ Top-K Results (k=5) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
**Goal:** Given a query image, retrieve the most visually similar images from the dataset.
How it works:
- Embed the query image with CLIP into a 512-d vector
- Send the vector to Pinecone
- Pinecone computes cosine similarity and returns the top-K nearest neighbors
- Display the results alongside similarity scores
**Goal:** Classify an unknown image without ever training a classifier.
How it works:
- Embed the query image with CLIP
- Retrieve the top-K nearest neighbors from Pinecone
- Run a majority vote on neighbor labels
- The predicted class is the most common label among neighbors β zero training required
**Goal:** Search the image dataset using natural language queries.
How it works:
- Encode a text prompt (e.g.
"wolf in snow") with CLIP's text encoder - The text vector lands in the same embedding space as the images
- MongoDB Atlas
$vectorSearchfinds the nearest image vectors - Return and display the top matching images
| Component | Tool | Role |
|---|---|---|
| Embedding Model | openai/clip-vit-base-patch32 |
Image + Text β 512-d Vector |
| Vector DB (Primary) | Pinecone (Serverless) | Hosted ANN search, Tasks 1 & 2 |
| Vector DB (Comparison) | MongoDB Atlas | Vector search via $vectorSearch, Task 3 |
| Runtime | Python 3.10+, Google Colab | Development environment |
| Visualization | Matplotlib | Display query + result images |
git clone https://github.com/your-username/vector-view.git
cd vector-viewpip install torch torchvision transformers pinecone pymongo[srv] Pillow matplotlib tqdmOrganize your images like this:
vector-view/
βββ animal_dataset/
βββ cats/
β βββ cat_001.jpg
β βββ ...
βββ dogs/
β βββ dog_001.jpg
β βββ ...
βββ wolves/
βββ wolf_001.jpg
βββ ...
In Colab: upload
animal_dataset.zipvia Files β Upload, then run the extraction cell.
Open the Configuration cell in the notebook and fill in your keys:
PINECONE_API_KEY = "your_pinecone_key" # app.pinecone.io
PINECONE_ENV = "us-east-1" # your Pinecone region
PINECONE_INDEX = "animal-embeddings" # auto-created
MONGO_URI = "mongodb+srv://..." # MongoDB Atlas URI
MONGO_DB = "your_database"
MONGO_COLLECTION = "animal_images"Execute cells top-to-bottom in Colab or Jupyter. Each task is self-contained after setup.
Why CLIP?
CLIP (Contrastive LanguageβImage Pretraining) was trained to align image and text representations in a shared vector space. This means encode("a dog") and encode(dog_image.jpg) produce geometrically close vectors β enabling cross-modal retrieval with zero task-specific training.
Why Vector Databases?
Traditional SQL WHERE clauses can't find similar things. Vector DBs use Approximate Nearest Neighbor (ANN) algorithms β like HNSW or IVFFlat β to find the closest vectors in milliseconds, even across millions of entries.
Cosine Similarity:
similarity(A, B) = (A Β· B) / (βAβ Γ βBβ)
Range [-1, 1] β closer to 1 = more similar.
| Feature | Pinecone | MongoDB Atlas |
|---|---|---|
| Type | Purpose-built vector DB | Multi-model DB + vector search |
| Setup | Fully managed, API-first | Atlas cluster + index config |
| Query Speed | Extremely fast (dedicated ANN) | Fast, but secondary to document ops |
| Metadata Filtering | β Native | β
via $match pipeline |
| Best For | Pure vector workloads | Apps needing vectors + documents |
- CLIP embeddings are surprisingly robust β text queries like
"running dog"retrieve contextually correct images with no fine-tuning - KNN classification via vector search matches simple CNN accuracy on clean datasets with zero training overhead
- Pinecone offers faster cold-start indexing; MongoDB is preferable when your app already stores structured documents
- Cross-modal search degrades on ambiguous text β
"animal"returns scattered results across all classes
VectorView/
βββ VectorView.ipynb # Main notebook
βββ animal_dataset/ # Image dataset (not tracked in git)
βββ screenshots/ # Output screenshots for README
βββ README.md









