Downloads · 30 days
0
xahidxr7/NanoVLM
NanoVLM is a machine learning model from xahidxr7. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
NanoVLM is a robust, PyTorch-based implementation of a Vision-Language Model (VLM) inspired by OpenAI's CLIP architecture. While "Nano" in scale, it utilizes professional-grade techniques including pre-trained backbon…
Downloads · 30 days
0
Access
Public
Updated Apr 30, 2026
Repo size
43.2 MB
Likes
0
Public
Click a slice to open those files.
.pth43.2 MB · 100%
From the Hugging Face model README
NanoVLM is a robust, PyTorch-based implementation of a Vision-Language Model (VLM) inspired by OpenAI's CLIP architecture. While "Nano" in scale, it utilizes professional-grade techniques including pre-trained backbones, EMA weighting, and gradient accumulation to achieve state-of-the-art alignment quality on a single consumer GPU.
This project demonstrates how to bridge visual and linguistic semantics by aligning representations in a shared 256-dimensional latent space, trained natively on the massive 591k-pair MS-COCO dataset.
torch.amp for accelerated training.After an extended training run on the full MS-COCO dataset (using Spatial Attention), the model achieved the following state-of-the-art metrics for its size class:
| Metric | Result |
|---|---|
| Best Val Loss | 2.6436 |
| Image→Text Recall@1 | 19.2% |
| Image→Text Recall@5 | 68.7% |
| Image→Text Recall@10 | 84.8% |
Note: Recall@10 of 84.8% indicates the correct matching caption is found in the top 10 results for nearly 85% of all images in the complex COCO validation set.
pip install torch torchvision matplotlib pillow gradio
best_img_enc.pth, best_txt_enc.pth, and tokenizer_vocab.pth are in the root directory.
python app.py
model.py: Core architecture, including tokenizer and dual-encoder definitions.nanoVLM.ipynb: Full training pipeline, including data ingestion, contrastive loop, and evaluation.app.py: Gradio-based web interface for real-time image-caption similarity matching.save_tokenizer.py: Utility script to serialize the training vocabulary for inference.