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.

Installation

LINUX:
python -m pip install WordEmbed

WINDOWS:
py -m pip install WordEmbed

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

image

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.2.0.tar.gz (9.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: WordEmbed-0.2.0.tar.gz
  • Upload date:
  • Size: 9.3 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.2.0.tar.gz
Algorithm Hash digest
SHA256 d480d590d23a0e60abab5641d27c799d2636cc8d4d2a8056052a47c27a46e15d
MD5 fce18b903256a4c5b2ebaa0c94788241
BLAKE2b-256 14c2bfc89bb349959f0e3a8534bab5fd0db4a024e3192dc03db35656fc92c2a7

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