Skip to main content

Train and use word embeddings specific to your data

Project description

WordEmbed

About

This project allows you to train word embedding on your own data set. It incorporates embedding methods such as 'Glove','Skip-gram' or 'CBOW' and train word embeddings specific to dataset. Morever, this word embeddings can be used as tensorflow layer API too.

If you want to build a NLP model, word embeddings are the building blocks for most of the NLP model. Current trend give us two option:

  1. Train word embedding along with your final NLP model from the scratch. It is generally used in small and simple models. In this case, as model stacks huge no of layers, vanishing gradients become significant and cause poor training of word embedding. Example- Tensorflow's Embedding API
  2. Use pre-trained embedding, trained on different dataset. Most of the industrial and real world soltions use this option. It has minor drawback. i.e when our dataset contains words which aren't present in pre-trained embeddings, embedding quality degrades. Example FastText,GloVe,Word2vec.

This work addresses this issue by allowing us to train word embedding on specific data and then use this trained embedding as tensorflow layer API and train along with model.

image source: https://projector.tensorflow.org/

Installation

LINUX:
py -m pip install Embed

WINDOWS:
py -m pip install Embed

Usage

class Embed(data,embidding_dim,embedding='glove',sampling_window=2, negative_samples=4,Trainable=True)

Parameters:
data= string, path to raw data file.
embedding_dim= integer, Vector dimension e.g 512
embeding=string,{'glove','skipgram','cbow'} embedding method to be used default to 'glove'
sampling_window= integer, {1<sampling_window<10} Size of sampling window default = 2
negative_samples= integer, {2<negative_samples<15} Size of negative samples default=4
Trainable= bool, if TRUE, Tensorflow layer API is trainable else Freezed if False. Default=True

Returns Embed object

Methods

  1. train():
    Preprocess the raw data and trains the embedding

Attributes

  1. score:
    Returns a float value, spearmen correlation w.r.t simlex999. It can be used to compare embeddings from different method.

  2. TfAPI:
    Returns tensorflow's layer object. It can be used in tensorflow model building, just like teensorflow's Embedding layer API.

  3. embeddings:
    Returns a dictonary with word-embedding pair.

  4. tokenizer:
    Returns tensorflow's tokenizer object.

Example

Project details


Download files

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

Source Distribution

WordEmbed-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: WordEmbed-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.0

File hashes

Hashes for WordEmbed-0.1.0.tar.gz
Algorithm Hash digest
SHA256 adc101d60b195ff0b282f678a7ba4fff62402bb4080f56e798c7229fb1bfe45d
MD5 13f954188a7a3b39e9b8ab145a15d57d
BLAKE2b-256 4be4714693c9a8dc3c8fc63ba913238fdb5012058986e540f57bc16823ca2755

See more details on using hashes here.

Supported by

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