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

Uploaded Source

Built Distribution

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

WordEmbed-0.0.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: WordEmbed-0.0.1.tar.gz
  • Upload date:
  • Size: 3.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.0.1.tar.gz
Algorithm Hash digest
SHA256 41d17b9bd987cc9a753b476ccc799138269ec9e8930899df48eb2aeb5bc6e6a5
MD5 f598cd6160a6daa3ce02dda44635c708
BLAKE2b-256 e77d323c4eabfd2c5043951d2a3187c2a181d1e382fda58d2aaaf0653b8f4ca2

See more details on using hashes here.

File details

Details for the file WordEmbed-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: WordEmbed-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5cca50b713789adb46d646b37adc545c0eb16a669a237af2e2b296e3332678a9
MD5 c57769778508f657716b58440e634ffb
BLAKE2b-256 834bce7acb8d223f7d519893c963357ae7f510ebb999c208bf405dd78e8bc020

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