For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

import AI from '@aibrow/web'

// Create the session
const session = await AI.AIBrow.Embedding.create()

// Generate embeddings for known data
const data = {
  '1': 'data1',
  '2': 'data2',
  ...
}
const dataIds = Object.keys(data)
const vectors = await session.get(dataIds.map((id) => data[id]))
const embeddings = dataIds.map((id, index) => ({ id, vector: vectors[index] })

// 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