In the world of Natural Language Processing (NLP), machines can understand and generate text by learning from vast amounts of data. Word embeddings, which represent words as numerical vectors, are essential for this purpose. You've probably heard of Word2Vec and Count vectorization - two popular algorithms for creating word embeddings. This project provides a basic introduction to Word2Vec and one-hot encoding.
The aim of this project is to understand the continuous skip-gram algorithm and build a model for generating word embeddings from a set of documents.
The dataset used for this project contains more than two million customer complaints about consumer financial products. It includes various columns, with one containing the actual text of the complaint and another indicating the product for which the customer is raising the complaint.
Note: The project uses the first 100 complaints for testing purposes, but you can train the model on the entire dataset.
- Language:
Python
- Libraries:
pandas
,torch
,collections
,nltk
,numpy
,pickle
,os
,re
- Introduction to the continuous skip-gram algorithm
- Data Description
- Data Preprocessing
- Handling missing values
- Conversion to lowercase
- Punctuation removal
- Digits removal
- Removing extra spaces
- Tokenization
- Building a Data Loader
- Creating the Skip-Gram Model using the PyTorch framework
- Model training
- Generating Word Embeddings
-
Input: Contains the data for analysis, in this case,
complaints.xlsx
. -
Output: Contains pre-trained models and vectorizers for future use.
-
Source: Contains modularized code for various project steps, including:
model.py
data.py
utils.py
These Python files contain useful functions used in
Engine.py
. -
config.py: Contains project configurations.
-
Engine.py: The main file to run the entire project, including model training and saving.
-
skip_gram.ipynb: The original Jupyter notebook.
-
processing.py: Used for data processing.
-
README.md: Contains comprehensive instructions and information on running specific files.
-
requirements.txt: Lists required libraries with respective versions. Install them using
pip install -r requirements.txt
.
Note: The project uses the first 100 complaints for testing purposes, but you can train the model on the entire dataset.