prob-phoc
PyTorch functions to compute meaningful probabilistic relevance scores from PHOC (Pyramid of Histograms of Characters) embeddings. Although they are called Pyramid of Histograms of Characters, in practice they are a Pyramid of Bag of Characters. At the end, each word is represented by a high-dimensional binary vector.
See the wiki for additional details.
Usage
The library provides two functions: cphoc and pphoc, which are
similar to SciPy's cdist and pdist:
Both functions can operate with PHOC embeddings in the probability space (where each dimension is a real number in the range [0, 1]), or in the log-probability space (where each dimension is the logarithm of a probability). These are also sometimes refered to as the Real and Log semirings.
import torch
from prob_phoc import cphoc, pphoc
x = torch.Tensor(...)
y = torch.Tensor(...)
# Compute the log-relevance scores between all pairs of rows in x, y.
# Note: x and y must have the PHOC log-probabilities.
logprob = cphoc(x, y)
# This is equivalent to:
logprob = cphoc(x, y, method="sum_prod_log")
# If your matrices have probabilities instead of log-probabilities, use:
prob = cphoc(x, y, method="sum_prob_real")
# Compute the log-relevance scores between all pairs of distinct rows in x.
# Note: The output is a vector with N * (N - 1) / 2 elements.
logprob = pphoc(x)
Installation
The easiest way is to install the package from PyPI:
pip install prob-phoc
If you want to install the latest version from the repository, clone it and use the setup.py script to compile and install the library.
python setup.py install
You will need a C++11 compiler (tested with GCC 4.9). If you want to compile with CUDA support, you will also need to install the CUDA Toolkit (tested with versions 8.0, 9.0 and 10.0)
Tests and benchmarks
After the installation, you can run the tests to ensure that everything is working fine.
python -m prob_phoc.test
I have also some benchmarks to compare CPU vs. CUDA, for different matrix sizes and float precision. These take quite a long to run, so don't hold your breath.
python -m prob_phoc.benchmark
Metadata
Release files for prob-phoc 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prob_phoc-0.2.0.tar.gz | 10.2 kB | Without provenance | Details for prob_phoc-0.2.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| prob_phoc-0.2.0-cp37-cp37m-manylinux1_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | Linux glibc 2.5+ x86-64 | Details for prob_phoc-0.2.0-cp37-cp37m-manylinux1_x86_64.whl |
| prob_phoc-0.2.0-cp36-cp36m-manylinux1_x86_64.whl | CPython 3.6 | CPython 3.6 pymalloc | Linux glibc 2.5+ x86-64 | Details for prob_phoc-0.2.0-cp36-cp36m-manylinux1_x86_64.whl |
| prob_phoc-0.2.0-cp35-cp35m-manylinux1_x86_64.whl | CPython 3.5 | CPython 3.5 pymalloc | Linux glibc 2.5+ x86-64 | Details for prob_phoc-0.2.0-cp35-cp35m-manylinux1_x86_64.whl |
| prob_phoc-0.2.0-cp27-cp27mu-manylinux1_x86_64.whl | CPython 2.7 | CPython 2.7 pymalloc wide-unicode | Linux glibc 2.5+ x86-64 | Details for prob_phoc-0.2.0-cp27-cp27mu-manylinux1_x86_64.whl |
Total release size: 5.2 MB
Release files / prob_phoc-0.2.0.tar.gz
| Download URL | prob_phoc-0.2.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a6143f9cfdbbd94d53b97a88bd506b1c917dfce6b1bc9b45291931cf8253c22
|
|
BLAKE2b-256 checksum How to use checksums |
b630b218c6e430b7b22e368bd6fa67b7a8e74f993e9b3ac08b3f2acf1ee99145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.8
|
Release files / prob_phoc-0.2.0-cp37-cp37m-manylinux1_x86_64.whl
| Download URL | prob_phoc-0.2.0-cp37-cp37m-manylinux1_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
494d378ac352935af226a0ffcf680b38cd30b97381a0339806261b0615314f21
|
|
BLAKE2b-256 checksum How to use checksums |
e3e7c57b0e33e3f2acb7ea312a1a82ecf127f51fd69eefcf9cd536727cd91f44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.8
|
Release files / prob_phoc-0.2.0-cp36-cp36m-manylinux1_x86_64.whl
| Download URL | prob_phoc-0.2.0-cp36-cp36m-manylinux1_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
9dd89673b63d2c52e2eab302b720041b47ff364ff99dfbab5ed8bcacdeaec48d
|
|
BLAKE2b-256 checksum How to use checksums |
7a95d110c5a7af200e28d6850f5251abed6d07dc93090271958ad3b5a458b045
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.8
|
Release files / prob_phoc-0.2.0-cp35-cp35m-manylinux1_x86_64.whl
| Download URL | prob_phoc-0.2.0-cp35-cp35m-manylinux1_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
525c8a7393e1ca25974bb559bb0f5f961ed4a549711237bbd7529ebb3a5dd419
|
|
BLAKE2b-256 checksum How to use checksums |
fbbd3535d1c23a7e9d42b980ddf1d4f03f38203f1dd4ccb1a6f5aded89de8f5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.8
|
Release files / prob_phoc-0.2.0-cp27-cp27mu-manylinux1_x86_64.whl
| Download URL | prob_phoc-0.2.0-cp27-cp27mu-manylinux1_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
7b0cc8f200064f9172eddcaeb63f3bfa57e91da739eab4355419dea56ea3311d
|
|
BLAKE2b-256 checksum How to use checksums |
218897a1b244175b124423b2a96bfbbc34cf3a267a81beda2b2523bc5ef14656
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.8
|
Security for prob-phoc 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.