Semantic Search
Semantic textual similarity datasets allow you to go beyond traditional keyword and exact-match search. AnnDB uses state-of-the-art machine learning models to provide accurate and semantically relevant results. Using the API, you can build a dataset of sentences which you can then query using natural language queries to find semantically similar information.
Create a dataset with
Semantic Similarity
type which tells AnnDB to encode your sentences to vectors.
In order to manage data in your dataset, create a corresponding dataset instance using the client.
Python
Ruby
dataset = client.text('<DATASET_NAME>')
dataset = client.text("<DATASET_NAME>")
Python
Ruby
result = dataset.search('query', 10)
for item in result:
print(item.id, item.metadata)
result = dataset.search("query", 10)
result.each do |item|
puts item.id, item.metadata
end
Python
Ruby
# Single item
id = dataset.insert('my sentence', metadata={'key': 'value'})
# Batch
result = dataset.insert_batch([
anndb_api.TextItem(None, 'my sentence', {'key': 'value'}),
...
])
for r in result:
print(r.id, r.error)
id = dataset.insert("my sentence", metadata={ "key": "value" })
result = dataset.insert_batch([
{
text: "my sentence",
metadata: { "key": "value" }
},
...
])
result.each { |r|
puts r[:id], r[:error]
}
Python
Ruby
# Single item
id = dataset.update(id, 'my updated sentence', metadata={'key': 'value'})
# Batch
result = dataset.update_batch([
anndb_api.TextItem(id, 'my updated sentence', {'key': 'value'}),
...
])
for r in result:
print(r.id, r.error)
id = dataset.update(id, "my updated sentence", metadata={ "key": "value" })
result = dataset.update_batch([
{
id: id,
text: "my updated sentence",
metadata: { "key": "value" }
},
...
])
result.each { |r|
puts r[:id], r[:error]
}
Python
Ruby
# Single item
dataset.delete(id)
# Batch
result = dataset.delete_batch([id, ...])
for r in result:
print(r.id, r.error)
dataset.delete(id)
result = dataset.delete_batch([id, ...])
result.each { |r|
puts r[:id], r[:error]
}
Last modified 2yr ago