Refactor embedding configuration to remove local model support, transitioning to a unified remote API approach. Update environment variables and documentation accordingly. Enhance error handling in the orchestrator and related modules to reflect these changes. This update simplifies the embedding process and improves overall system reliability.
This commit is contained in:
@@ -162,3 +162,47 @@
|
||||
| 配置项 | 含义 | 默认 |
|
||||
|--------|------|------|
|
||||
| `DIALOG_INTENT_CLASSIFIER` | `hybrid`:规则快速路径 + LLM;`rules`:仅规则 | `hybrid`(未设置时按 hybrid 处理) |
|
||||
|
||||
---
|
||||
|
||||
# Impact Analysis — 移除本地 Embedding(仅远程 API)
|
||||
|
||||
## 1. 改动概览
|
||||
|
||||
- **背景与目标**:不再维护本地 HuggingFace / PyTorch 推理路径;Embedding 统一为 OpenAI 兼容远程 `/v1/embeddings`。
|
||||
- **涉及模块**:`backend/utils/embedding.py`、`backend/main.py`、`backend/agents/orchestrator.py`、`backend/utils/fewshot_selector.py`、`backend/config/settings.py`、`api_server.py`、`scripts/build_fewshot_chroma_index.py`、`pyproject.toml`、`requirements.txt`、`main.spec`、`README.md`、`.env` 注释。
|
||||
- **改动类型**:功能删减 / 依赖精简。
|
||||
|
||||
## 2. 方法级改动
|
||||
|
||||
| 位置 | 变更 |
|
||||
|------|------|
|
||||
| `Qwen3Embedding`(原) | **删除**;本地 `transformers`+`torch` 编码路径移除。 |
|
||||
| `get_embedder` | 仅构造 `OpenAICompatibleRemoteEmbedding`;前两个位置参数废弃保留以兼容旧调用。 |
|
||||
| `clear_embedder` | 仅 `gc.collect()`,不再触碰 CUDA。 |
|
||||
| `Text2SQLOrchestrator.__init__` | 移除 `embedding_model_path`;`FewShotSelector` 不再传模型路径。 |
|
||||
| `FewShotSelector.__init__` | 移除 `embedding_model_path`。 |
|
||||
| `setup_environment` | 删除 `USE_LOCAL_EMBEDDING` / `EMBEDDING_MODEL_PATH` 分支。 |
|
||||
|
||||
## 3. 调用方与影响范围
|
||||
|
||||
- **调用方**:所有原 `get_embedder(path)` 仍可运行(路径被忽略);`Text2SQLOrchestrator(..., embedding_model_path=...)` 需改为不传该参数(已改仓库内引用)。
|
||||
- **破坏性变更**:**是**——不再支持 `USE_LOCAL_EMBEDDING=true` 与本地模型目录;`pyproject.toml` / `requirements.txt` 不再声明 `torch`/`transformers`/`sentencepiece`/`accelerate`/`safetensors`(若 `camel-ai[all]` 等仍带入部分传递依赖,以实际 lock 为准)。
|
||||
|
||||
## 4. 风险与回滚
|
||||
|
||||
- **风险级别**:中(仅使用本地 Embedding 的部署将失效;需改为远程 Key 与模型名)。
|
||||
- **回滚**:回退提交并恢复依赖与 `embedding.py` 历史版本。
|
||||
|
||||
**回滚方式是否简单**:是(单提交回退)。
|
||||
|
||||
## 5. 验证与测试
|
||||
|
||||
- 建议:`python -m py_compile` 对改动 `.py`;在已配置 `OPENAI_*` 或 `MODELSCOPE_*` 的环境下跑一次 Schema 向量构建或 Few-shot 检索。
|
||||
|
||||
## 6. 配置变更
|
||||
|
||||
| 移除/失效项 | 说明 |
|
||||
|-------------|------|
|
||||
| `USE_LOCAL_EMBEDDING`、`EMBEDDING_MODEL_PATH` | 代码不再读取;`.env` 中可删去以免误解。 |
|
||||
| CLI `--embedding-model` | 已删除。 |
|
||||
|
||||
Reference in New Issue
Block a user