Skip to main content

Agreementr

Intro

Agreementr is a package used to predict the value of agreement of texts.

It is based on a fine tuned BERT model.

Install

Use pip

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

pip install agreementr

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 agreement, while lower means less).

Simplest usage

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

>>> import agreementr
>>> agreementr.predict(["I am totally agree with you"])
[4.3568916]

Construct from class

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

>>> from agreementr import Agreementr
>>> ar = Agreementr()

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

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

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

>>> ar = Agreementr(CPU_COUNT=cpu_cpunt, CHUNKSIZE=chunksize)

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

>>> ar = Agreementr(is_paralleled=False, BATCH_SIZE = batch_size)

Contact

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

Metadata

Release files for agreementr 1.5

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

Source distribution (sdist)

Source distribution for agreementr 1.5
File Size Uploaded
agreementr-1.5.tar.gz 7.6 kB Details

Built distribution (wheel)

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

Total release size: 17.9 kB

Release files / agreementr-1.5.tar.gz

Download URL agreementr-1.5.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ede97ded28092cf6484c0e06bcf42b5349612abe1500680a348a1456f48bb08f
BLAKE2b-256 checksum
How to use checksums
874ee1bc6e2f0078d82cbdcfc909baafe0a2e0c4c90ff61b009f1b9ac022175d
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / agreementr-1.5-py3-none-any.whl

Download URL agreementr-1.5-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b88f55f3459574bee99519589794d33f03ce69fcfeb420d397f2bf7e3556bc65
BLAKE2b-256 checksum
How to use checksums
ebf296eaa883b4dff3ffaaac42623f3e2273905aec2733b4414dfffe914c0fa5
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.5 This release

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

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