Skip to content

roll back rerank topn setting #11297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,3 @@ RESET_PASSWORD_TOKEN_EXPIRY_MINUTES=5

CREATE_TIDB_SERVICE_JOB_ENABLED=false

RETRIEVAL_TOP_N=0
2 changes: 0 additions & 2 deletions api/configs/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,6 @@ class DataSetConfig(BaseSettings):
default=30,
)

RETRIEVAL_TOP_N: int = Field(description="number of retrieval top_n", default=0)


class WorkspaceConfig(BaseSettings):
"""
Expand Down
7 changes: 3 additions & 4 deletions api/core/rag/datasource/retrieval_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from flask import Flask, current_app

from configs import DifyConfig
from core.rag.data_post_processor.data_post_processor import DataPostProcessor
from core.rag.datasource.keyword.keyword_factory import Keyword
from core.rag.datasource.vdb.vector_factory import Vector
Expand Down Expand Up @@ -114,7 +113,7 @@ def retrieve(
query=query,
documents=all_documents,
score_threshold=score_threshold,
top_n=DifyConfig.RETRIEVAL_TOP_N or top_k,
top_n=top_k,
)

return all_documents
Expand Down Expand Up @@ -186,7 +185,7 @@ def embedding_search(
query=query,
documents=documents,
score_threshold=score_threshold,
top_n=DifyConfig.RETRIEVAL_TOP_N or len(documents),
top_n=len(documents),
)
)
else:
Expand Down Expand Up @@ -231,7 +230,7 @@ def full_text_index_search(
query=query,
documents=documents,
score_threshold=score_threshold,
top_n=DifyConfig.RETRIEVAL_TOP_N or len(documents),
top_n=len(documents),
)
)
else:
Expand Down
Loading