360 Secure SkillHub
360 安全技能中心

Local Vector Store

轻量级语义搜索模块:用本地向量嵌入建立文档索引,支持批量索引、余弦相似度检索、嵌入维度与相似度阈值配置,结果以结构化 JSON 返回;声明不依赖外部 API,向量数据存于本地目录。

jackfeng0614-prog
jackfeng0614-prog
热度 52.90
最近更新 2026-05-11 17:44:17
分类:搜索依赖:代码执行 / 读写文件应用场景:研究 / 数据处理 / 笔记整理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add local-vector-store
Metadata
name
local-vector-store
description
Implements semantic search using local vector embeddings for knowledge base indexing and similarity matching. Use when you need to search documents by meaning rather than keywords, or build a searchable knowledge base.

Local Vector Store

A lightweight semantic search engine that indexes documents as vectors and enables similarity-based retrieval without external APIs.

Features

  • Document indexing with vector embeddings
  • Semantic similarity search
  • Local storage (no external dependencies)
  • Batch indexing support
  • Configurable embedding dimensions
  • Cosine similarity matching

Usage

const vectorStore = require('./local-vector-store');

// Initialize store
const store = await vectorStore.create({
  dimension: 384,
  storePath: '/tmp/vector-store'
});

// Index documents
await store.index({
  id: 'doc1',
  content: 'Machine learning is a subset of artificial intelligence',
  metadata: { source: 'wiki' }
});

// Search by semantic similarity
const results = await store.search({
  query: 'AI and deep learning',
  topK: 5,
  threshold: 0.7
});

// Batch operations
await store.indexBatch([
  { id: 'doc2', content: 'Neural networks process data' },
  { id: 'doc3', content: 'Algorithms solve computational problems' }
]);

Configuration

Set environment variables:

  • VECTOR_DIMENSION: Embedding dimension (default: 384)
  • STORE_PATH: Local storage directory (default: /tmp/vector-store)
  • SIMILARITY_THRESHOLD: Minimum similarity score (default: 0.5)

Output Format

{
  "query": "semantic search",
  "results": [
    {
      "id": "doc1",
      "content": "...",
      "similarity": 0.92,
      "metadata": {}
    }
  ],
  "searchTime": 45
}