-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support subclasses of chains for langchain flavor #8453
Conversation
Signed-off-by: Liang Zhang <liang.zhang@databricks.com>
6a05f2c
to
faa958e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Documentation preview for fc7920d will be available here when this CircleCI job completes successfully. More info
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth trying
@minkin-koantek could you help test ? You can install this branch of the PR via:
|
I will test it in the next 12 hr thx! |
@WeichenXu123 Thanks for linking the issue. |
665d6f5
to
7cb777d
Compare
Signed-off-by: Liang Zhang <liang.zhang@databricks.com>
Signed-off-by: Liang Zhang <liang.zhang@databricks.com>
Signed-off-by: Liang Zhang <liang.zhang@databricks.com>
Signed-off-by: Liang Zhang <liang.zhang@databricks.com>
Signed-off-by: Liang Zhang <liang.zhang@databricks.com>
The setup is based on a Databricks Dolly script from dbdemos. If I am unsuccessful in getting the model to register I will isolate it so you can try it |
The type of my model tested is langchain.chains.combine_documents.stuff.StuffDocumentsChain Code used to deploy:
Resulting message after fixing promotion code:
|
We're not out of the woods yet. I tried using the standard batch inference usage of the model having installed the MLFlow 2.3.3..dev0 using this code:
This was the error:
|
Signed-off-by: Liang Zhang <liang.zhang@databricks.com>
Signed-off-by: Liang Zhang <liang.zhang@databricks.com>
def test_langchain_native_log_and_load_qa_with_sources_chain(): | ||
# StuffDocumentsChain is a subclass of Chain | ||
model = create_qa_with_sources_chain() | ||
with mlflow.start_run(): | ||
logged_model = mlflow.langchain.log_model(model, "langchain_model") | ||
|
||
loaded_model = mlflow.langchain.load_model(logged_model.model_uri) | ||
assert model == loaded_model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add at test case for pyfunc predict / spark UDF too (I know we're tracking these internally)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once predict()
and spark_udf()
coverage is added :)
Thanks @liangz1 ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Related Issues/PRs
#xxxWhat changes are proposed in this pull request?
This PR extends the mlflow langchain flavor to support saving and loading all subclasses of Chain.
Before:
& load
(langchain
& pyfunc)
type in model
metadata
predict
spark_udf
After:
& load
(langchain
& pyfunc)
info in model
metadata
predict
spark_udf
LLMChain
AgentExecutor
of Chain
(see known
exceptions
below)
exists in
model.yaml)
containing
memory
* Given all the Chains have some bugs in SerDe, we cannot test any concrete Chains. It should work and we can add tests after langchain fixed the bugs.
Here is a list of Chains that langchain supports loading.
https://github.com/hwchase17/langchain/blob/0c3de0a0b32fadb8caf3e6d803287229409f9da9/langchain/chains/loading.py#L409
Among them, MLflow cannot support the following number of chains and reasons:
kwargs
during mlflow.pyfunc.load_model: 6 chains are blocked. mlflow plans to have a follow-up PR to support it.Known exceptions
Examples of Chain classes that are known to be not supported as of
langchain==0.0.176
:class ConversationChain(LLMChain): Chain to have a conversation and load context from memory.
Reason: (fromlangchain
) Saving of memory is not yet supported.How is this patch tested?
Does this PR change the documentation?
Release Notes
Is this a user-facing change?
mlflow langchain flavor allows logging and loading all subclasses of Chain, as long as their serialization / deserialization methods are implemented by langchain.
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/artifacts
: Artifact stores and artifact loggingarea/build
: Build and test infrastructure for MLflowarea/docs
: MLflow documentation pagesarea/examples
: Example codearea/model-registry
: Model Registry service, APIs, and the fluent client calls for Model Registryarea/models
: MLmodel format, model serialization/deserialization, flavorsarea/recipes
: Recipes, Recipe APIs, Recipe configs, Recipe Templatesarea/projects
: MLproject format, project running backendsarea/scoring
: MLflow Model server, model deployment tools, Spark UDFsarea/server-infra
: MLflow Tracking server backendarea/tracking
: Tracking Service, tracking client APIs, autologgingInterface
area/uiux
: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/docker
: Docker use across MLflow's components, such as MLflow Projects and MLflow Modelsarea/sqlalchemy
: Use of SQLAlchemy in the Tracking Service or Model Registryarea/windows
: Windows supportLanguage
language/r
: R APIs and clientslanguage/java
: Java APIs and clientslanguage/new
: Proposals for new client languagesIntegrations
integrations/azure
: Azure and Azure ML integrationsintegrations/sagemaker
: SageMaker integrationsintegrations/databricks
: Databricks integrationsHow should the PR be classified in the release notes? Choose one:
rn/breaking-change
- The PR will be mentioned in the "Breaking Changes" sectionrn/none
- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/feature
- A new user-facing feature worth mentioning in the release notesrn/bug-fix
- A user-facing bug fix worth mentioning in the release notesrn/documentation
- A user-facing documentation change worth mentioning in the release notes