Views
No views yet
| Metric | Value |
|---|---|
| Mean Reciprocal Rank (MRR) | 86.9% |
| Perfect-clustering words | 93 / 100 |
| Contaminated words | 6 / 100 |
| Excellent superclasses (MRR ≥ 0.8) | 16 / 20 |
| ImageNet transfer accuracy | 77.71% |
1import torch
2import torch.nn as nn
3import torch.nn.functional as F
4from huggingface_hub import hf_hub_download
5
6# --- Minimal model class ---
7class SkipGramModel(nn.Module):
8 def __init__(self, vocab_size, embedding_dim, dropout=0.3):
9 super().__init__()
10 self.center_embeddings = nn.Embedding(vocab_size, embedding_dim)
11 self.context_embeddings = nn.Embedding(vocab_size, embedding_dim)
12 self.dropout = nn.Dropout(dropout)
13
14# --- Download and load checkpoint ---
15path = hf_hub_download(repo_id="haripra1112001/visual-skipgram-cifar100",
16 filename="best_skipgram_523words.pth")
17checkpoint = torch.load(path, map_location='cpu', weights_only=False)
18
19vocab = checkpoint['word_to_idx'] # dict: word -> int index
20idx_to_word = {v: k for k, v in vocab.items()}
21vocab_size = len(vocab) # 523
22embedding_dim = 128
23
24model = SkipGramModel(vocab_size, embedding_dim)
25model.load_state_dict(checkpoint['model_state_dict'])
26model.eval()
27
28embeddings = model.center_embeddings.weight.data # shape (523, 128)
29
30# --- Lookup a word vector ---
31def get_vector(word):
32 return embeddings[vocab[word]]
33
34# --- Find nearest neighbours by cosine similarity ---
35def nearest_neighbours(word, top_k=5):
36 vec = get_vector(word).unsqueeze(0) # (1, 128)
37 sims = F.normalize(embeddings, dim=1) @ F.normalize(vec, dim=1).T
38 sims = sims.squeeze()
39 sims[vocab[word]] = -1 # exclude self
40 top = sims.topk(top_k)
41 return [(idx_to_word[i.item()], round(s.item(), 3))
42 for i, s in zip(top.indices, top.values)]
43
44print(nearest_neighbours('dolphin'))
45# e.g. [('whale', 0.94), ('seal', 0.91), ('otter', 0.89), ...]1checkpoint.keys()
2# ['model_state_dict', 'word_to_idx', 'config']
3
4checkpoint['config']
5# {
6# 'embedding_dim': 128,
7# 'context_size': 5,
8# 'num_negative': 10,
9# 'lr': 0.10,
10# 'dropout': 0.35,
11# 'label_smoothing': 0.10,
12# 'epochs': 50,
13# 'batch_size': 2048,
14# 'patience': 6,
15# 'rare_threshold': 0.00015
16# }| File | Description |
|---|---|
best_skipgram_523words.pth | Model weights + vocabulary + config |
report.md | Full technical report — training details, ablation study, baseline comparisons |
1@misc{prajapati2026visual,
2 title = {Visual-Grounded Skip-Gram for CIFAR-100: Corpus Augmentation and
3 Evolutionary Refinement Outperform Transformer Sentence Encoders
4 on Visual Clustering},
5 author = {Prajapati, Harishkumar Kishorkumar},
6 year = {2026}
7}can, orange, mouse)
score below their linguistic baselines.