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:
https://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@gmai.

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.3-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xl_bert-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7439839549b39fd5ff521bb1870b2c42afc5113dba92ba0cff2eb78521cc914f
MD5 04badf60cf03f4a9a81675d122a3ff82
BLAKE2b-256 0dd0f98451a37bff35be93c228daa75e5d248db21221dd0dba93fecf408a88df

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