Created
January 23, 2022 12:11
-
-
Save davidmezzetti/93d0f95c59856db18344ecf997709ee5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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": text, "length": len(text)}, None) for uid, text in enumerate(data)]) | |
# Filter by score | |
print(embeddings.search("select text, score from txtai where similar('hiking danger') and score >= 0.15")) | |
# Filter by metadata field 'length' | |
print(embeddings.search("select text, length, score from txtai where similar('feel good story') and score >= 0.05 and length >= 40")) | |
# Run aggregate queries | |
print(embeddings.search("select count(*), min(length), max(length), sum(length) from txtai")) | |
print() | |
for x in embeddings.search("select count(*), min(length), max(length), sum(length), text, score from txtai group by text limit 10"): | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment