Skip to main content

This lets you find sentence embedding using word embedding from XLNet and Bert

Project description


Documentation


This is the repository of the xl_bert package. This library helps you find sentence embedding for your sentence using SOTA language models such as Bert and XLNET.

This library takes in an input seven paramters :

**sentence_list,model_name,model_dir,token_model_dir,n_layers,strategy,max_len**. Each parameter has been explained below.

**sentence_list** : List of sentences you want to get embedding of. 

**model_name** : Name of model which you want to use, currently can be 'bert' or 'xlnet'.

**model_dir** : Directory path of pretrained/finetuned Bert/XLNet language model. Default is 'xlnet-base-cased'. Pretrained language models can be seen from here:


<http://huggingface.co/transformers/pretrained_models.html>`_


**token_model_dir** : Directory path of tokenizer. Default is 'xlnet-base-cased'


**n_layers** :  Number of layers you want to use to get sentence embedding.Default is 1

**Strategy** : This is where it gets interesting. Strategy is categorised in four choices.

    'avg': We average each layer individually and then average n_layers.
    'cat': We concatenate each layer individually, then we concatenate n_layers
    'avgcat': We average each layer individually and then concat n_layers
    'catavg': We concat each individual layer and then average n_layers. 

**max_len** : Maximum length of sentence you want. Default 50

================ Installation

pip install xl_bert

Usage with Bert as well as XLNet

get_sentence_embedding(['I am playing','let me dance'],model_name='xlnet',model_dir='xlnet- 
large-cased',token_model_dir='xlnet-large-cased',n_layers=2,strategy='avg',max_len=50) 

Contribution

Package author and current maintainer is Shivam Panwar (panwar.shivam199@gmail.com); You are more than welcome to approach him for help. Contributions are very welcomed, especially since this package is very much in its infancy.

Created by Shivam Panwar (panwar.shivam199@gmail.com)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

xl_bert-0.0.4-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file xl_bert-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: xl_bert-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for xl_bert-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 13494f92f9fc4a82ae5b1c4eea19f8079210e4aa81a7116c214978c8afbbe199
MD5 5144d85396fb308fe960dc32e106ad05
BLAKE2b-256 f5d835f3965114305023b243fedc2a74558169b23a67d601c22c34ce78dcdbf7

See more details on using hashes here.

Supported by

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