浏览代码

Fix error of changing embedding model (#4184)

### What problem does this PR solve?

1. Change embedding model of knowledge base won't change the default
embedding model.
2. Retrieval test bug

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Signed-off-by: jinhai <haijin.chn@gmail.com>
tags/v0.15.1
Jin Hai 10 个月前
父节点
当前提交
4abc144d3d
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3
    3
      rag/llm/embedding_model.py

+ 3
- 3
rag/llm/embedding_model.py 查看文件

@@ -61,11 +61,11 @@ class DefaultEmbedding(Base):
^_-

"""
if not settings.LIGHTEN and not DefaultEmbedding._model:
if not settings.LIGHTEN:
with DefaultEmbedding._model_lock:
from FlagEmbedding import FlagModel
import torch
if not DefaultEmbedding._model:
if not DefaultEmbedding._model or model_name != DefaultEmbedding._model_name:
try:
DefaultEmbedding._model = FlagModel(os.path.join(get_home_cache_dir(), re.sub(r"^[a-zA-Z0-9]+/", "", model_name)),
query_instruction_for_retrieval="为这个句子生成表示以用于检索相关文章:",
@@ -261,7 +261,7 @@ class FastEmbed(DefaultEmbedding):
threads: int | None = None,
**kwargs,
):
if not settings.LIGHTEN and not FastEmbed._model:
if not settings.LIGHTEN:
with FastEmbed._model_lock:
from fastembed import TextEmbedding
if not DefaultEmbedding._model or model_name != DefaultEmbedding._model_name:

正在加载...
取消
保存