Install the R client

First, install the R client.

  "https://storage.googleapis.com/basilica-r-client/latest.tar.gz", repos=NULL

Embed some sentences

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


conn <- connect("SLOW_DEMO_KEY")

sentences = c(
    "This is a sentence!",
    "This is a similar sentence!",
    "I don't think this sentence is very similar at all..."
embeddings <- embed_sentences(sentences, conn=conn)

[[0.8556405305862427, ...], ...]

Let's also make sure these embeddings make sense, by checking that the correlation between the two similar sentences is larger:

print(cor(embeddings[1,], embeddings[2,]))
print(cor(embeddings[1,], embeddings[3,]))


Great! You can see that the two very similar strings are much closer in this feature space. This same feature extraction can be use in a lot of different ways, including training regressions, classifiers, and clustering.