Skip to content
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

mlflow.langchain.log_model : AttributeError: module 'langchain' has no attribute '__version__' #8419

Open
Abonia1 opened this issue May 11, 2023 · 9 comments

Comments

@Abonia1
Copy link

Abonia1 commented May 11, 2023

Having issue while using mlflow.langchain.log_model in databricks:
Langchain version = 0.0.125

mlflow.langchain.log_model(
    lc_model=llm_chain,
    artifact_path="model",
    registered_model_name="flan-t5"
)

WARNING mlflow: MLflow does not guarantee support for LLMChains outside of HuggingFaceHub and OpenAI, found <class 'langchain.llms.huggingface_pipeline.HuggingFacePipeline'>
AttributeError: module 'langchain' has no attribute 'version'

Capture d’écran 2023-05-11 à 15 21 35

thanks in advance.

@WeichenXu123
Copy link
Collaborator

Hi @Abonia1 Could you provide your langchain package version and the complete reproducing code ? Thank you!

@Abonia1
Copy link
Author

Abonia1 commented May 15, 2023

Hello @WeichenXu123 ,thanks for taking a lead on this topic.
As I got the error with latest version of langchain I have repoted the issue here and using langchain==0.0.125.

Complete code :

from langchain import PromptTemplate, HuggingFaceHub, LLMChain
from langchain.llms import HuggingFacePipeline
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, AutoModelForSeq2SeqLM


import torch
import mlflow

tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")
pipe = pipeline(
    "text2text-generation",
    model=model, 
    tokenizer=tokenizer, 
    max_length=100
)

local_llm = HuggingFacePipeline(pipeline=pipe)
template = """Translate everything you see after this into French:{input}"""
prompt = PromptTemplate(template=template, input_variables=["input"])

llm_chain = LLMChain(prompt=prompt, 
                     llm=local_llm
                     )
question = "What is the capital of England?"
print(llm_chain.run(question))

mlflow.langchain.log_model(
    lc_model=llm_chain,
    artifact_path="model",
    registered_model_name="flan-t5"
)

@WeichenXu123
Copy link
Collaborator

I thin you are using an out-of-date langchain package , the latest version is 0.0.170 now. And I tested in 0.0.170 version we don't have the issue.

@Abonia1
Copy link
Author

Abonia1 commented May 17, 2023

But with recent version I can't import Langchain in databricks. I have reported the issue and its still open here .

As old version is supported by databricks now, there is any work around to make mlflow work with langchain==0.0.125 ?

Any help would be appreciated.

@WeichenXu123 WeichenXu123 reopened this May 18, 2023
@WeichenXu123
Copy link
Collaborator

WeichenXu123 commented May 18, 2023

Got it. Let me check. I think we need to address the langchain issue on databricks

@WeichenXu123
Copy link
Collaborator

@Abonia1 Could you try this ? langchain-ai/langchain#4401 (comment)

@mlflow-automation
Copy link
Collaborator

@BenWilson2 @dbczumar @harupy @WeichenXu123 Please assign a maintainer and start triaging this issue.

@Abonia1
Copy link
Author

Abonia1 commented May 19, 2023

@WeichenXu123 Even I have tried

%pip install langchain typing_extensions==4.1.0

I got this error as we don'thave access to model in community version of databricks:
Capture d’écran 2023-05-19 à 20 35 45

For info: As mentionned here, there are certain limitations with the community edition and we do not have this feature there. To use this we need to go with the commercial version of Databricks.

So consider we can't use the feature of mlfow+langchain in community version of databricks. Thanks for all the help.

@WeichenXu123
Copy link
Collaborator

WeichenXu123 commented May 22, 2023

@Abonia1

Sorry my previous comment is wrong, I updated my comment, langchain-ai/langchain#4401 (comment)
you need to install typing-extensions>=4.2.0 to address the issue.

For info: As mentionned here, there are certain limitations with the community edition and we do not have this feature there. To use this we need to go with the commercial version of Databricks.

Yes this is an limitation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants