File tree Expand file tree Collapse file tree
src/vectorcode/subcommands/query/reranker Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import logging
2+ import sys
23
34from vectorcode .cli_utils import Config
45
1213
1314
1415def get_reranker (configs : Config ) -> RerankerBase :
15- if configs .reranker == "NaiveReranker" or not configs .reranker :
16+ if configs .reranker and hasattr (sys .modules [__name__ ], configs .reranker ):
17+ # dynamic dispatch
18+ return getattr (sys .modules [__name__ ], configs .reranker )(configs )
19+
20+ # TODO: replace the following with an Exception before the release of 0.6.0.
21+ logger .warning (
22+ f""""reranker" option should be set to one of the following: { list (i for i in __all__ if i != "RerankerBase" )} .
23+ To choose a CrossEncoderReranker model, you can set the "model_name_or_path" key in the "reranker_params" option to the name/path of the model.
24+ To use NaiveReranker, set the "reranker" option to "NaiveReranker".
25+ The old configuration syntax will be DEPRECATED in v0.6.0
26+ """
27+ )
28+ if not configs .reranker :
1629 return NaiveReranker (configs )
17- elif configs .reranker == "CrossEncoderReranker" :
18- return CrossEncoderReranker (configs )
1930 else :
20- logger .warning (
21- f"""
22- "reranker" option should be set to one of the following: { list (i for i in __all__ if i != "RerankerBase" )} .
23- To choose a custom reranker model, you can set the "model_name_or_path" key in the "reranker_params" option to the name/path of the model.
24- The old configuration syntax will be deprecated in v0.6.0
25- """
26- )
2731 configs .reranker_params .update ({"model_name_or_path" : configs .reranker })
2832 configs .reranker = "CrossEncoderReranker"
2933 return CrossEncoderReranker (
You can’t perform that action at this time.
0 commit comments