Install the python client

First, install the Python client.

$ pip install basilica

Embed some sentences

Let’s embed some sentences to make sure the client is working.

import basilica
sentences = [
    "This is a sentence!",
    "This is a similar sentence!",
    "I don't think this sentence is very similar at all...",
with basilica.Connection('SLOW_DEMO_KEY') as c:
    embeddings = list(c.embed_sentences(sentences))
[[0.8556405305862427, ...], ...]

Let’s also make sure these embeddings make sense, by checking that the cosine distance between the two similar sentences is smaller:

from scipy import spatial
print(spatial.distance.cosine(embeddings[0], embeddings[1]))
print(spatial.distance.cosine(embeddings[0], embeddings[2]))


Get an API key

The example above uses the slow demo key. You can get an API key of your own by signing up at https://www.basilica.ai/accounts/register . (If you already have an account, you can view your API keys at https://www.basilica.ai/api-keys .)

What next?