Skip to main content

Word2Vec Trainer

A PyTorch implementation of Word2Vec built as a learning project to understand how word embeddings are trained.

About

I wanted to understand Word2Vec beyond the API, so I implemented the training pipeline myself and packaged it as a Python library. I built this project while learning about Word2Vec, Skip-gram, negative sampling, and word embeddings.

The goal was to implement the main components myself and understand how they work rather than treating Word2Vec as a black box.

The project includes:

  • Text preprocessing
  • Vocabulary creation
  • Training pair generation
  • Skip-gram model
  • Negative sampling
  • Model training with PyTorch

Project Structure

word2vec_trainer/
│
├── pyproject.toml
├── README.md
├── LICENSE
│
├── src/
│   └── word2vec_trainer/
│       ├── dataset_loader.py
│       ├── word2vec_model.py
│       ├── preprocessing.py
│       └── trainer.py
│
├── tests/
│   ├── test_dataset.py
│   ├── test_preprocessing.py
│   ├── test_model.py
│   └── test_trainer.py
│
└── examples/
    └── basic_training.py

Training Pipeline

Text without commas or special characters
   ↓
Preprocessing
   ↓
Vocabulary
   ↓
Training Pairs
   ↓
Negative Sampling
   ↓
Skip-gram Model
   ↓
Learned Word Embeddings

Installation

Clone the repository:

git clone https://github.com/AbhishekBiswas12/word2vec_trainer.git
cd word2vec_trainer

Install in editable mode:

python -m pip install -e .

Usage

A basic training example is available in:

examples/basic_training.py

The public API is still evolving as the project develops.

Testing

Run the test suite with:

pytest

AI-Assisted Development

This project was built primarily as a learning exercise.

During development, I occasionally used ChatGPT and Google Colab's coding assistant when I got stuck with implementation details, debugging, or understanding concepts.

I used these tools as learning and development assistance while working to understand the underlying implementation.

Status

🚧 Work in progress

Future improvements include:

  • Improve the public API
  • Expand test coverage
  • Add more examples
  • Add embedding evaluation and visualization
  • Benchmark different training configurations
  • Publish the package to PyPI

References

License

MIT License. See LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

word2vec_trainer_pytorch-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

word2vec_trainer_pytorch-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file word2vec_trainer_pytorch-0.1.0.tar.gz.

File metadata

  • Download URL: word2vec_trainer_pytorch-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for word2vec_trainer_pytorch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 404fb81af5e47fb6cd6c2440be4b393d6f6658a860b1c85d382a5722645bce07
MD5 e4597432834b7a42756cea40abb6b33f
BLAKE2b-256 6ec5b55712730eb55d5f0171e66872219c70bea70446e2b7c3545ff799f0201d

See more details on using hashes here.

Provenance

The following attestation bundles were made for word2vec_trainer_pytorch-0.1.0.tar.gz:

Publisher: pypi-publish.yml on AbhishekBiswas12/word2vec_trainer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file word2vec_trainer_pytorch-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for word2vec_trainer_pytorch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b81a4b0f93f64c63bedb0f5415700b7931ab0919189ea02f8cd53e2d59fbcc26
MD5 e1666e1897a47ffa7313b3622360e5f4
BLAKE2b-256 8a08effc14553e836163bc4dfdd5aacb8f90f3fd90ecea30701c9375d7338845

See more details on using hashes here.

Provenance

The following attestation bundles were made for word2vec_trainer_pytorch-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on AbhishekBiswas12/word2vec_trainer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page