You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{ VectorDB }=require('ruvector');const{ encode }=require('your-embedding-model');asyncfunctionsemanticSearch(){constdb=newVectorDB({dimensions: 384});awaitdb.initialize();// Index documentsconstdocuments=['Machine learning is a subset of AI','Neural networks power modern AI','Deep learning uses multiple layers'];for(constdocofdocuments){constembedding=awaitencode(doc);awaitdb.insert({id: doc.slice(0,20),vector: embedding,metadata: {text: doc}});}// Search by meaningconstquery='How does artificial intelligence work?';constqueryVec=awaitencode(query);constresults=awaitdb.search({vector: queryVec,topK: 5});results.forEach(r=>{console.log(`${r.score.toFixed(3)}: ${r.metadata.text}`);});}