修复embedding的bug

This commit is contained in:
Wenjie Zhang 2025-02-28 02:41:45 +08:00
parent 0023107c48
commit bb88a696d8
4 changed files with 4 additions and 4 deletions

View File

@ -67,7 +67,7 @@ class KnowledgeBase:
logger.error(f"Collection {collection_name} not found, create it")
# self.add_collection(collection_name)
vectors = self.embed_model.encode(docs)
vectors = self.embed_model.batch_encode(docs)
data = [{
"id": int(random.random() * 1e12),

View File

@ -63,8 +63,8 @@ class Retriever:
def query_classification(self, query):
"""判断是否需要查询
- 对于完全基于用户给定信息的任务称之为足够sufficient不需要检索
- 否则称之为不足insufficient可能需要检索
- 对于完全基于用户给定信息的任务称之为"足够""sufficient"不需要检索
- 否则称之为"不足""insufficient"可能需要检索
"""
raise NotImplementedError

View File

@ -28,6 +28,7 @@ class RemoteEmbeddingModel:
embed_state = {}
def batch_encode(self, messages, batch_size=20):
logger.info(f"Batch encoding {len(messages)} messages")
data = []
if len(messages) > batch_size:

View File

@ -99,7 +99,6 @@ async def get_graph_info():
@data.get("/graph/node")
async def get_graph_node(entity_name: str):
logger.debug(f"Get graph node {entity_name}")
result = startup.dbm.graph_base.query_node(entity_name=entity_name)
return {"result": startup.retriever.format_query_results(result), "message": "success"}