Skip to main content

supportr

Project description

Supportr

Intro

supportr is a package used to predict the value of support of texts.

It is based on a fine tuned BERT model.

Install

Use pip

If pip is installed, supportr could be installed directly from it:

pip install supportr

Dependencies

python>=3.6.0
torch>=0.4.1
numpy
pandas
unidecode
pytorch-pretrained-bert
pytorch-transformers

Usage and Example

Notes: During your first usage, the package will download a model file automatically, which is about 400MB.

predict

predict is the core method of this package, which takes a single text of a list of texts, and returns a list of raw values in [1,5] (higher means more support, while lower means less).

Simplest usage

You may directly import supportr and use the default predict method, e.g.:

>>> import supportr
>>> supportr.predict(["I am totally agree with you"])
[3.8364935]

Construct from class

Alternatively, you may also construct the object from class, where you could customize the model path and device:

>>> from supportr import Supportr
>>> sr = Supportr()

# Predict a single text
>>> sr.predict(["I am totally agree with you"])
[3.8364935]

# Predict a list of texts
>>> preds = sr.predict(['I am totally agree with you','I hate you'])
>>> f"Raw values are {preds}"
[3.836493  1.7458204]

More detail on how to construct the object is available in docstrings.

Model using multiprocessing when preprocessing a large dataset into BERT input features

If you want to use several cpu cores via multiprocessing while preprocessing a large dataset, you may construct the object via

>>> pr = Supportr(CPU_COUNT=cpu_cpunt, CHUNKSIZE=chunksize)

If you want to faster the code through multi gpus, you may construct the object via

>>> pr = Supportr(is_paralleled=True, BATCH_SIZE = batch_size)

Contact

Junjie Wu (wujj38@mail2.sysu.edu.cn)

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

supportr-1.2.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

supportr-1.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file supportr-1.2.tar.gz.

File metadata

  • Download URL: supportr-1.2.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.5

File hashes

Hashes for supportr-1.2.tar.gz
Algorithm Hash digest
SHA256 4f8b01cc213de8ebb32886d854a1be1073f43e8779026902d272b7d58452be9b
MD5 468b2f917b8a630ae6ef2a4cc3b796aa
BLAKE2b-256 9b9836f0d00866c3b354a98bf4fd8ea670e21a866025e35fbd698f43cfc3c640

See more details on using hashes here.

File details

Details for the file supportr-1.2-py3-none-any.whl.

File metadata

  • Download URL: supportr-1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.5

File hashes

Hashes for supportr-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc42d947050763b4ff436cec744567ca900a1edb616f0610d555a46d381f23e6
MD5 8fa57894f41de93cae3e857861b84587
BLAKE2b-256 2da29c6065d15fe79edde4a14a47f53716a806978dc8b59a69230678e3e05d1d

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