Downloads · 30 days
18
17% of all-time downloads
jaweed123/small-embedding-model-10K-vocab
small-embedding-model-10K-vocab is a machine learning model from jaweed123. 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 apache-2.0.
This is a custom word embedding model trained on a Wikipedia dataset. The model learns vector representations of words using a neural network-based embedding layer.
Downloads · 30 days
18
17% of all-time downloads
All-time downloads
106
Public
Parameters
3M
24 MB on disk
Likes
0
Public
Click a slice to open those files.
.bin12 MB · 50%
From the Hugging Face model README
This is a custom word embedding model trained on a Wikipedia dataset. The model learns vector representations of words using a neural network-based embedding layer.
The model was trained on a subset of 5,000 samples from the Wikipedia dataset using the following hardware specifications:
You can manually download the model or use one of the following commands:
## Create a Python virtual environment
python -m venv ./env
## Activate the virtual environment
# (for bash terminal)
source ./env/Scripts/activate
## Install dependencies
pip install -r requirements.txt
## Clone the HuggingFace Repo
git clone https://huggingface.co/jaweed123/small-embedding-model-10K-vocab && cd small-embedding-model-10K-vocab/
import torch
from embedding_model import WordEmbeddingModel
from dataset_loader import WikipediaDataset
# Load dataset to get the vocabulary
dataset = WikipediaDataset()
vocab = dataset.build_vocab()
word_to_index = vocab
index_to_word = {idx: word for word, idx in vocab.items()} # Reverse mapping
# Load trained model
VOCAB_SIZE = len(vocab)
model = WordEmbeddingModel(vocab_size=VOCAB_SIZE)
# Load trained weights (Handling key mismatches)
MODEL_FILE = "word_embeddings_final.pth"
state_dict = torch.load(MODEL_FILE)
# Fix key mismatch if needed
if "embeddings.weight" in state_dict:
state_dict["embedding.weight"] = state_dict.pop("embeddings.weight")
# Load the state dictionary
model.load_state_dict(state_dict, strict=False)
model.eval() # Set model to evaluation mode
# Function to get word embedding
def get_embedding(word):
if word not in word_to_index:
print(f"❌ Word '{word}' not in vocabulary!")
return None
word_idx = torch.tensor([word_to_index[word]], dtype=torch.long)
with torch.no_grad():
embedding = model(word_idx)
return embedding.numpy()
# Test words
test_words = ["king", "queen", "apple", "unknownword"]
for word in test_words:
embedding = get_embedding(word)
if embedding is not None:
print(f"🔹 Word: {word} → Embedding: {embedding[:5]} ...") # Show first 5 values
This model is designed for NLP applications requiring word embeddings, such as:
If you use this model in research, please cite:
@misc{small-embedding-model-10K-vocab,
title={Custom Word Embedding Model},
author={Abdul Jaweed},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/jaweed123/small-embedding-model-10K-vocab}
}