Last active
August 18, 2021 14:29
-
-
Save davidmezzetti/2c8fd02a58d2c844d3ef427bde26e588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an index for the list of text | |
embeddings.index([(uid, text, None) for uid, text in enumerate(data)]) | |
print("%-20s %s" % ("Query", "Best Match")) | |
print("-" * 50) | |
# Run an embeddings search for each query | |
for query in ("feel good story", "climate change", "public health story", "war", "wildlife", | |
"asia", "lucky", "dishonest junk"): | |
# Extract uid of first result | |
# search result format: (uid, score) | |
uid = embeddings.search(query, 1)[0][0] | |
# Print text | |
print("%-20s %s" % (query, data[uid])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment