Downloads · 30 days
12
3% of all-time downloads
patomp/thai-light-multimodal-distill
thai-light-multimodal-distill is a feature extraction model from patomp. Use it when you need embeddings to search or compare text. It is set up for transformers. The card lists the license as cc-by-4.0.
Downloads · 30 days
12
3% of all-time downloads
All-time downloads
460
Public
Repo size
1.7 MB
Likes
0
Public
Click a slice to open those files.
.bin1.7 MB · 100%
From the Hugging Face model README
pip install pythainlp
pip install gensim=4.3.1
pip install git+https://github.com/openai/CLIP.git
Encode a text by
from transformers import AutoModel
text = 'หมากำลังวิ่งในสนามหญ้า'
model = AutoModel.from_pretrained("patomp/thai-light-multimodal-distill", trust_remote_code=True)
embeddings = model(text)
print("Text features shape:", embeddings.shape)
Encode an image by
import torch
import clip
import requests
from PIL import Image
device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = clip.load("ViT-B/32", device=device)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
image = preprocess(image).unsqueeze(0).to(device)
with torch.no_grad():
image_features = model.encode_image(image)
print("Image features shape:", image_features.shape)
On the test set of Thai MS COCO 2014 dataset
| Model \ Metrics | text-find-image recall@1 | text-find-image recall@10 | image-find-text recall@1 | image-find-text recall@10 | # text samples per second* |
|---|---|---|---|---|---|
| Multilingual Encoder | |||||
| clip-ViT-B-32-multilingual-v1 | 0.075 | 0.242 | 0.096 | 0.286 | 251 |
| XLM-Roberta-Large-Vit-B-32 | 0.226 | 0.565 | 0.265 | 0.596 | 20 |
| Thai Encoder (WangchanBERTa-based) | |||||
| Thai-Cross-CLIP | 0.167 | 0.475 | 0.197 | 0.523 | 48 |
| Thai Encoder (Thai2Fit-based) | |||||
| thai-light-multimodal-clip-and-distill | 0.082 | 0.328 | 0.118 | 0.401 | 450 |
| thai-light-multimodal-distill | 0.084 | 0.319 | 0.122 | 0.401 | 450 |
Some part of this content referenced from https://huggingface.co/M-CLIP/XLM-Roberta-Large-Vit-B-32
For more detail, please visit https://github.com/calzonelover/Lightweight-Multi-modal-Encoder-for-Thai.