Rank phrases and text based on query by leveraging hugging-face models.
Project description
spacy-rerank
Rank phrases and text based on query by leveraging hugging-face models. Currently, we are only leveraging tiny-bert model.
Installation and Implementation
- Install the package using the below
pip install spacyrerank
- Code for simple implementation
from spacyrerank.rerank import Reranker
query = "done effort is wasted"
texts = ["work done", "valuable man", "effort wasted", "Great work", "great work mate"]
reranker = Reranker(query, texts=texts)
reranker()
[{'rank': 2, 'text': 'effort wasted', 'similarity-score': 0.877},
{'rank': 0, 'text': 'work done', 'similarity-score': 0.86},
{'rank': 3, 'text': 'Great work', 'similarity-score': 0.773},
{'rank': 4, 'text': 'great work mate', 'similarity-score': 0.757},
{'rank': 1, 'text': 'valuable man', 'similarity-score': 0.719}]
CPU times: user 331 ms, sys: 76 ms, total: 407 ms
Wall time: 564 ms
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
spacyrerank-0.0.3.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file spacyrerank-0.0.3.tar.gz
.
File metadata
- Download URL: spacyrerank-0.0.3.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd23812c006a588ec3ed4c7f2001a15c88059e4c06d6c0ebddbcf26e7e7cee00 |
|
MD5 | b8c6af14475f07eb4f35737f8cfab4b5 |
|
BLAKE2b-256 | 23e30802fa2a200a5b3d0433a035b7a743e8d528730cc6d542a39ff6a1d724d0 |
Provenance
File details
Details for the file spacyrerank-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: spacyrerank-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd3b79b8a0fa5a8dc8685e7f556b22825aff2fd3eecc8bf2f7ebe70dd93dc53a |
|
MD5 | f7db1e86526abdcab069da39947dcb1f |
|
BLAKE2b-256 | 40768e4e4aa4152e33bf483215123a791a1ea0da505f2635caf8a272f1634c28 |