Embedding API

AiBrow allows you to create embeddings from any piece of text. These can then be stored and searched over to find similar text to a new input

// Create the session
const session = await window.aibrow.embedding.create()

// Generate embeddings for known data
const data = {
  '1': 'data1',
  '2': 'data2',
  ...
}
const embeddings = await Promise.all(Object.entries(data).map(async ([id, data]) => {
  const vector = await session.get(data)
  return { id, vector }
})

// Sort the list of embeddings by the most similar
const search = await session.get('search data')
const results = session.findSimilar(embeddings, search)
console.log(data[results[0].id])

Last updated