@leuria/web-embed
v0.1.2
Published
A small embedding model that runs in the page (Transformers.js), as a Leuria provider: search by meaning for visitors without their own model.
Downloads
472
Readme
@leuria/web-embed
A small embedding model that runs in the page, as a Leuria provider: search by meaning for visitors whose own AI can't embed. It uses Transformers.js in a Web Worker, so the page stays responsive.
import { leuria, promptAPI, createAI } from "@leuria/client"
import { pageEmbedder } from "@leuria/web-embed"
const ai = createAI({ providers: [leuria(), promptAPI(), pageEmbedder()] })
// Later, from a click (the visitor agrees to the download):
await ai.connect("page-embed")- Asks first. Until the visitor agrees, the provider is
needs-actionwithaction: "download". The model and its runtime are about 40 MB, downloaded once and kept in the browser's cache.autoLoad: trueskips the question. - Default model:
Xenova/bge-small-en-v1.5(English, made for search), with the query instruction from its model card. Choose another withmodel(andqueryPrefix). - Where files come from: Hugging Face by default; set
remoteHostto serve the model from your own site. Texts never leave the page.
Apache-2.0.
