LanceDB Node.js 向量搜索
使用 LanceDB 和 Ollama 的嵌入模型进行向量搜索的 Node.js 实现。
概述
该项目演示了如何:
连接到 LanceDB 数据库
使用 Ollama 创建自定义嵌入函数
对存储的文档执行向量相似性搜索
处理并显示搜索结果
先决条件
Node.js(v14 或更高版本)
Ollama 使用
nomic-embed-text
模型在本地运行具有读/写权限的 LanceDB 存储位置
安装
克隆存储库
安装依赖项:
依赖项
@lancedb/lancedb
:Node.js 的 LanceDB 客户端apache-arrow
:用于处理列式数据node-fetch
:用于向 Ollama 发出 API 调用
用法
运行向量搜索测试脚本:
或者直接执行:
配置
该脚本连接到:
LanceDB 在配置的路径下
Ollama API 位于
http://localhost:11434/api/embeddings
MCP 配置
要与 Claude Desktop 作为 MCP 服务集成,请将以下内容添加到您的 MCP 配置 JSON 中:
用您的实际安装路径替换路径:
/path/to/lancedb-node/dist/index.js
- 已编译 index.js 文件的路径/path/to/your/lancedb/storage
- 您的 LanceDB 存储目录的路径
自定义嵌入函数
该项目包括一个自定义的OllamaEmbeddingFunction
,它:
向 Ollama API 发送文本
接收 768 维的嵌入
格式化它们以便与 LanceDB 一起使用
向量搜索示例
该示例在“ai-rag”表中搜索“如何定义成功标准”,并显示其相似度分数的结果。
执照
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
Related MCP Servers
- -securityFlicense-qualityEnables efficient vector database operations for embedding storage and similarity search through a Model Context Protocol interface.Last updated -6
- -securityFlicense-qualityA Python-based local indexing server that creates semantic search capabilities for codebases using ChromaDB, allowing Cursor IDE to perform vector searches on your code without sending data to external services.Last updated -24
Lindorm MCP Serverofficial
-securityAlicense-qualityAn example server that enables interaction with Alibaba Cloud's Lindorm multi-model NoSQL database, allowing applications to perform vector searches, full-text searches, and SQL operations through a unified interface.Last updated -2Apache 2.0- -securityAlicense-qualityA vector search system that enables semantic retrieval of document chunks using MongoDB Atlas Vector Search and Voyage AI embeddings, allowing users to search documents by meaning rather than just keywords.Last updated -2MIT License