Skip to main content

A Generic Sentence Embedding Library

In natural language processing, we need to vectorize or encode text data to let machine proocess it. In the past, we mostly use encoders such as one-hot, term frequency, and TF-IDF (normalized term frequency). There are many challenges with these techniques that you can read here. In the recent years, the deep learning advancements give us opportunity to encode sentences or words in more meaningful format. The word2vec library was one of the major advancement in this field. Or, the BERT language model provides us a powerful sentence encoders that can be used in many projects.

The sentence embedding or encoding is an important step of many NLP projects. Plus, we believe that a flexible sent2vec library is needed to build a prototype fast. That is why we have initiated this project. In the early releases, you will have access to the standard encoders. We will add more curated techniques in the later releases. Hope you can use this library in your exciting NLP projects.

Library

The library requires the following libraries:

  • transformers
  • pandas
  • numpy
  • torch

Install

It can be installed using pip:

pip install sent2vec

Usage

This is how to initialize the library and provide the data.

from sent2vec.vectorizer import Vectorizer

sentences = [
    "This is an awesome book to learn NLP.",
    "DistilBERT is an amazing NLP library.",
    "We can interchangeably use embedding, encoding, or vectorizing.",
]
vectorizer = Vectorizer(sentences)

If you want to use the pre-trained DistilBertModel, you should use the code below.

vectors = vectorizer.sent2vec_bert()

And, that's pretty much it!

Metadata

Release files for sent2vec 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sent2vec 0.0.1
File Size Uploaded
sent2vec-0.0.1.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sent2vec 0.0.1
File Interpreter ABI Platform
sent2vec-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / sent2vec-0.0.1.tar.gz

Download URL sent2vec-0.0.1.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
71b1db244d807b3e2094bae0343ed8324b7d8b5e842a3e80fd21e79ff6755cd1
BLAKE2b-256 checksum
How to use checksums
0d00d9ac521a8bd8a7aec25e90bc7ddda35f22fe0716362cc348d6f611e69c4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.3

Release files / sent2vec-0.0.1-py3-none-any.whl

Download URL sent2vec-0.0.1-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a781e91c4b2a289db2143ca5bc6cfca7c102bb9207253e98d1bbcfe5eb97b71
BLAKE2b-256 checksum
How to use checksums
41f61e1a5ffc473aa849577d615b2e4bdac791f1504ef2e9c2cbbd93ceccef7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.3

Release history Release notifications | RSS feed

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page