AnnDB
Search…
Question Answering
Question answering datasets provide an out-of-the-box solution for a machine learning powered search engine. AnnDB uses state-of-the-art machine learning models to provide highly relevant search results. Using the API, you can build a dataset of facts that you can later query using natural language queries.

Create a Dataset

Create a dataset with Question Answering type which tells AnnDB to encode your facts and queries to vectors.
In order to manage data in your dataset, create a corresponding dataset instance using the client.
Python
Ruby
1
dataset = client.text('<DATASET_NAME>')
Copied!
1
dataset = client.text("<DATASET_NAME>")
Copied!
Python
Ruby
1
result = dataset.search('query', 10)
2
3
for item in result:
4
print(item.id, item.metadata)
Copied!
1
result = dataset.search("query", 10)
2
3
result.each do |item|
4
puts item.id, item.metadata
5
end
Copied!

Insert

Python
Ruby
1
# Single item
2
id = dataset.insert(
3
'London has 8.9 million inhabitants.',
4
metadata={'key': 'value'}
5
)
Copied!
1
# Batch
2
result = dataset.insert_batch([
3
anndb_api.TextItem(
4
None,
5
'London has 8.9 million inhabitants.',
6
{'key': 'value'}
7
),
8
...
9
])
10
11
for r in result:
12
print(r.id, r.error)
Copied!
1
id = dataset.insert(
2
"London has 8.9 million inhabitants.",
3
metadata={ "key": "value" }
4
)
Copied!
1
result = dataset.insert_batch([
2
{
3
text: "London has 8.9 million inhabitants.",
4
metadata: { "key": "value" }
5
},
6
...
7
])
8
9
result.each { |r|
10
puts r[:id], r[:error]
11
}
Copied!

Update

Python
Ruby
1
# Single item
2
id = dataset.update(
3
id,
4
'London has 9 million inhabitants.',
5
metadata={'key': 'value'}
6
)
Copied!
1
# Batch
2
result = dataset.update_batch([
3
anndb_api.TextItem(
4
id,
5
'London has 9 million inhabitants.',
6
{'key': 'value'}
7
),
8
...
9
])
10
11
for r in result:
12
print(r.id, r.error)
Copied!
1
id = dataset.update(
2
id,
3
"London has 9 million inhabitants.",
4
metadata={ "key": "value" }
5
)
Copied!
1
result = dataset.update_batch([
2
{
3
id: id,
4
text: "London has 9 million inhabitants.",
5
metadata: { "key": "value" }
6
},
7
...
8
])
9
10
result.each { |r|
11
puts r[:id], r[:error]
12
}
Copied!

Delete

Python
Ruby
1
# Single item
2
dataset.delete(id)
Copied!
1
# Batch
2
result = dataset.delete_batch([id, ...])
3
4
for r in result:
5
print(r.id, r.error)
Copied!
1
dataset.delete(id)
Copied!
1
result = dataset.delete_batch([id, ...])
2
3
result.each { |r|
4
puts r[:id], r[:error]
5
}
Copied!
Last modified 7mo ago