--- title: Plugin Embeddings description: Generate embeddings for your documents offline and use them for vector search. --- To perform vector and hybrid search, you need to convert your text data into embeddings. While this [is managed for you with Orama Cloud](/cloud/orama-ai/automatic-embeddings-generation#automatic-embeddings-generation), when using Orama open-source, you need to generate embeddings for your documents on your own. This plugin generates embeddings for your documents at insert and search time, allowing you to perform vector and hybrid searches on your documents. ## Installation You can install the plugin using any major Node.js package manager. ```bash npm install @orama/plugin-embeddings ``` Important note: to use this plugin, you'll also need to install one of the following TensorflowJS backend: - `@tensorflow/tfjs` - `@tensorflow/tfjs-node` - `@tensorflow/tfjs-backend-webgl` - `@tensorflow/tfjs-backend-cpu` - `@tensorflow/tfjs-node-gpu` - `@tensorflow/tfjs-backend-wasm` For example, if you're running Orama on the browser, we highly recommend using `@tensorflow/tfjs-backend-webgl`: ```bash npm install @tensorflow/tfjs-backend-webgl ``` If you're using Orama in Node.js, we recommend using `@tensorflow/tfjs-node`: ```bash npm install @tensorflow/tfjs-node ``` ## Usage Since this plugin will need to generate embeddings for your documents, the search and insert methods are now async. Make sure to use `await` when calling them. This plugin will generate text embeddings for you at insert and search time, allowing you to perform vector and hybrid searches on your documents. ```js import { create, insert, search } from '@orama/orama' import { pluginEmbeddings } from '@orama/plugin-embeddings' import '@tensorflow/tfjs-node' // Or any other appropriate TensorflowJS backend const plugin = await pluginEmbeddings({ embeddings: { // Property used to store generated embeddings. Must be defined in the schema. defaultProperty: 'embeddings', onInsert: { // Generate embeddings at insert-time. // Turn off if you're inserting documents with embeddings already generated. generate: true, // Properties to use for generating embeddings at insert time. // These properties will be concatenated and used to generate embeddings. properties: ['description'], verbose: true, } } }) const db = create({ schema: { description: 'string', // Orama generates 512-dimensions vectors. // When using this plugin, use `vector[512]` as a type. embeddings: 'vector[512]' }, plugins: [plugin] }) // When using this plugin, document insertion becomes async await insert(db, { description: 'The quick brown fox jumps over the lazy dog' }) await insert(db, { description: "I've seen a lazy dog dreaming of jumping over a quick brown fox" }) // When using this plugin, search becomes async const results = await search(db, { term: 'Dreaming of a quick brown fox', mode: 'vector' }) ```