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.4.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for spacyrerank-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ef717c97655712f4553994e80816c1972bb2f22f6ab21caa3e4c19faecd871a |
|
MD5 | 14442ca3d722963b315ddba4c7fe79f7 |
|
BLAKE2b-256 | 1fcc60174d9e3f37b2a5109628fddf8b34c96643d095cdbb61b67523e1eacb27 |