{"id":20547219,"url":"https://github.com/jpuigcerver/prob-phoc","last_synced_at":"2026-05-07T01:35:12.050Z","repository":{"id":62578090,"uuid":"133390089","full_name":"jpuigcerver/prob-phoc","owner":"jpuigcerver","description":"Probabilistic relevance scores from PHOC embeddings","archived":false,"fork":false,"pushed_at":"2019-02-08T00:13:38.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-04-17T08:36:37.538Z","etag":null,"topics":["cuda","keyword-spotting","kws","phoc","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpuigcerver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-14T16:22:02.000Z","updated_at":"2019-02-08T00:19:38.000Z","dependencies_parsed_at":"2022-11-03T19:36:09.284Z","dependency_job_id":null,"html_url":"https://github.com/jpuigcerver/prob-phoc","commit_stats":null,"previous_names":["jpuigcerver/prob_phoc"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jpuigcerver/prob-phoc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpuigcerver%2Fprob-phoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpuigcerver%2Fprob-phoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpuigcerver%2Fprob-phoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpuigcerver%2Fprob-phoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpuigcerver","download_url":"https://codeload.github.com/jpuigcerver/prob-phoc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpuigcerver%2Fprob-phoc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32586189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cuda","keyword-spotting","kws","phoc","pytorch"],"created_at":"2024-11-16T02:06:55.062Z","updated_at":"2026-05-07T01:35:12.032Z","avatar_url":"https://github.com/jpuigcerver.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prob-phoc\n\n[![Build Status](https://travis-ci.com/jpuigcerver/prob-phoc.svg?branch=master)](https://travis-ci.com/jpuigcerver/prob-phoc)\n\nPyTorch functions to compute meaningful probabilistic relevance scores from\nPHOC (Pyramid of Histograms of Characters) embeddings.\nAlthough they are called Pyramid of Histograms of Characters, in practice\nthey are a Pyramid of Bag of Characters. At the end, each word is\nrepresented by a high-dimensional binary vector.\n\nSee the [wiki](https://github.com/jpuigcerver/prob-phoc/wiki)\nfor additional details.\n\n## Usage\n\nThe library provides two functions: `cphoc` and `pphoc`, which are\nsimilar to SciPy's `cdist` and `pdist`:\n\nBoth functions can operate with PHOC embeddings in the probability space (where\neach dimension is a real number in the range [0, 1]), or in the log-probability\nspace (where each dimension is the logarithm of a probability). These are also\nsometimes refered to as the Real and Log semirings.\n\n```python\nimport torch\nfrom prob_phoc import cphoc, pphoc\n\nx = torch.Tensor(...)\ny = torch.Tensor(...)\n\n# Compute the log-relevance scores between all pairs of rows in x, y.\n# Note: x and y must have the PHOC log-probabilities.\nlogprob = cphoc(x, y)\n\n# This is equivalent to:\nlogprob = cphoc(x, y, method=\"sum_prod_log\")\n\n# If your matrices have probabilities instead of log-probabilities, use:\nprob = cphoc(x, y, method=\"sum_prob_real\")\n\n# Compute the log-relevance scores between all pairs of distinct rows in x.\n# Note: The output is a vector with N * (N - 1) / 2 elements.\nlogprob = pphoc(x)\n```\n\n## Installation\n\nThe easiest way is to install the package from PyPI:\n\n```bash\npip install prob-phoc\n```\n\nIf you want to install the latest version from the repository, clone it\nand use the setup.py script to compile and install the library.\n\n```bash\npython setup.py install\n```\n\nYou will need a C++11 compiler (tested with GCC 4.9).\nIf you want to compile with CUDA support, you will also need to install\nthe CUDA Toolkit (tested with versions 8.0, 9.0 and 10.0)\n\n## Tests and benchmarks\n\nAfter the installation, you can run the tests to ensure that everything is\nworking fine.\n\n```bash\npython -m prob_phoc.test\n```\n\nI have also some benchmarks to compare CPU vs. CUDA, for different matrix\nsizes and float precision. These take quite a long to run, so don't hold\nyour breath.\n\n```bash\npython -m prob_phoc.benchmark\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpuigcerver%2Fprob-phoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpuigcerver%2Fprob-phoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpuigcerver%2Fprob-phoc/lists"}