Created
January 23, 2022 12:16
-
-
Save davidmezzetti/e7d8621c4cd6f08a1b7f94f13c9e5990 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
import urllib | |
from IPython.display import Image | |
# Get an image | |
request = urllib.request.urlopen("https://raw.githubusercontent.com/neuml/txtai/master/demo.gif") | |
# Upsert new record having both text and an object | |
embeddings.upsert([("txtai", {"text": "txtai executes machine-learning workflows to transform data and build AI-powered semantic search applications.", "object": request.read()}, None)]) | |
# Query txtai for the most similar result to "machine learning" and get associated object | |
result = embeddings.search("select object from txtai where similar('machine learning') limit 1")[0]["object"] | |
# Display image | |
Image(result.getvalue(), width=600) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment