This script indexes ~800 poem verses from the huggingface poem_sentiment
dataset, and uses a transformer model to index them,
and performs a KNN search using FAISS module.
Before running, install all the requirements with these 3 commands:
conda create -n jina-2.0 -c conda-forge -c huggingface faiss-cpu datasets
conda activate jina-2.0
pip install jina sentence-transformers --pre
Here's how the output for the search phrase ("a mourning man") looks like:
[0]: sat mournfully guarding their corpses there,
[1]: dearest, why should i mourn, whimper, and whine, i that have yet to live?
[2]: taught by the sorrows that his age had known
[3]: the love that lived through all the stormy past,
[4]: some moment, nailed on sorrow's cross,
[5]: ay, knelt and worshipped on, as love in beauty's bower,
[6]: the crown of sorrow on their heads, their loss
[7]: inexorable death; and claims his right.
[8]: and the words which he utters, are--worship, or die!
[9]: and so i should be loved and mourned to-night.