Closed rhlarora84 closed 21 hours ago
The following code is used to create a Ranker object which downloads the model into a custom directory and then FlashrankRerank is initialized.
def create_ms_marco_mini_llm(): logger.info("Download model ms_marco_mini_llm") model_name = "ms-marco-MiniLM-L-12-v2" ranker = Ranker(model_name=model_name, max_length=1024, cache_dir=model_dir) return FlashrankRerank(client=ranker, model=model_name)
The validate_environment method in FlashrankRerank goes to create another Ranker object causing it to download model into a different directory
@root_validator(pre=True) def validate_environment(cls, values: Dict) -> Dict: """Validate that api key and python package exists in environment.""" try: from flashrank import Ranker except ImportError: raise ImportError( "Could not import flashrank python package. " "Please install it with `pip install flashrank`." ) values["model"] = values.get("model", DEFAULT_MODEL_NAME) values["client"] = Ranker(model_name=values["model"]) return values
No response
FlashrankRerank should check if the client is already initialized before creating a ranker.
langchain==0.2.5 langchain-anthropic==0.1.15 langchain-aws==0.1.6 langchain-community==0.2.5 langchain-core==0.2.7 langchain-experimental==0.0.61 langchain-openai==0.1.8 langchain-text-splitters==0.2.1 openinference-instrumentation-langchain==0.1.19
pr #23350
Checked other resources
Example Code
The following code is used to create a Ranker object which downloads the model into a custom directory and then FlashrankRerank is initialized.
The validate_environment method in FlashrankRerank goes to create another Ranker object causing it to download model into a different directory
Error Message and Stack Trace (if applicable)
No response
Description
FlashrankRerank should check if the client is already initialized before creating a ranker.
System Info
langchain==0.2.5 langchain-anthropic==0.1.15 langchain-aws==0.1.6 langchain-community==0.2.5 langchain-core==0.2.7 langchain-experimental==0.0.61 langchain-openai==0.1.8 langchain-text-splitters==0.2.1 openinference-instrumentation-langchain==0.1.19