Skip to content

Commit

Permalink
Warm up reranker on model switch (onyx-dot-app#2408)
Browse files Browse the repository at this point in the history
* warm up reranker on model switch

* properly type

* fix issue

* Update search_settings.py
  • Loading branch information
pablonyx authored and rajiv chodisetti committed Oct 2, 2024
1 parent 774f678 commit a8af95e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions backend/danswer/db/search_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from danswer.db.models import SearchSettings
from danswer.indexing.models import IndexingSetting
from danswer.natural_language_processing.search_nlp_models import clean_model_name
from danswer.natural_language_processing.search_nlp_models import warm_up_cross_encoder
from danswer.search.models import SavedSearchSettings
from danswer.server.manage.embedding.models import (
CloudEmbeddingProvider as ServerCloudEmbeddingProvider,
Expand Down Expand Up @@ -180,6 +181,14 @@ def update_current_search_settings(
logger.warning("No current search settings found to update")
return

# Whenever we update the current search settings, we should ensure that the local reranking model is warmed up.
if (
current_settings.provider_type is None
and search_settings.rerank_model_name is not None
and current_settings.rerank_model_name != search_settings.rerank_model_name
):
warm_up_cross_encoder(search_settings.rerank_model_name)

update_search_settings(current_settings, search_settings, preserved_fields)
db_session.commit()
logger.info("Current search settings updated successfully")
Expand Down
4 changes: 3 additions & 1 deletion web/src/app/admin/embeddings/RerankingFormPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const RerankingDetailsForm = forwardRef<
>
{({ values, setFieldValue, resetForm }) => {
const resetRerankingValues = () => {
setRerankingDetails(originalRerankingDetails);
resetForm();
};

Expand Down Expand Up @@ -191,7 +192,8 @@ const RerankingDetailsForm = forwardRef<
{card.rerank_provider_type ===
RerankerProvider.LITELLM ? (
<LiteLLMIcon size={24} className="mr-2" />
) : RerankerProvider.COHERE ? (
) : card.rerank_provider_type ===
RerankerProvider.COHERE ? (
<CohereIcon size={24} className="mr-2" />
) : (
<MixedBreadIcon size={24} className="mr-2" />
Expand Down

0 comments on commit a8af95e

Please sign in to comment.