Skip to content

feat: 支持可配置的 Embedding 模型 - #672

Open
1400621504-lang wants to merge 4 commits into
netease-youdao:qanything-v2from
1400621504-lang:qanything-v2
Open

feat: 支持可配置的 Embedding 模型#672
1400621504-lang wants to merge 4 commits into
netease-youdao:qanything-v2from
1400621504-lang:qanything-v2

Conversation

@1400621504-lang

Copy link
Copy Markdown

描述

为 QAnything 添加了可配置的 Embedding 模型支持,解决 Issue #399

改动

  1. 新增 config/embedding.yaml 配置文件
  2. 新增 EmbeddingFactory 工厂类
  3. 新增 APIEmbeddings 客户端,支持 OpenAI、DashScope、Ollama
  4. 修改 vectorstore.py 使用工厂类

优势

  • ✅ 支持多种 Embedding 模型(本地 ONNX、PyTorch、API)
  • ✅ 通过配置文件切换,无需修改代码
  • ✅ 向后兼容,不影响现有用户
  • ✅ 符合开闭原则,易于扩展

使用示例

使用本地 ONNX 模型(默认)

embedding:
  type: "local_onnx"
  local:
    model_name: "bge-base-zh-v1.5"
使用 API(OpenAI)

embedding:
  type: "api"
  api:
    provider: "openai"
    model_name: "text-embedding-3-small"
    api_key: "${EMBEDDING_API_KEY}"
相关 Issue
Closes #399

This module provides a unified interface to create different types of Embedding instances, supporting local ONNX models, local PyTorch models, and API calls.
This module provides functionality to obtain text embeddings via API calls. It supports multiple API providers, including OpenAI, DashScope, and local Ollama.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant