场景:
我曾经使用过fine-tune LLM并使用model.save(model_path)保存它。当我使用ludwig.load(model_path)加载模型时,它完美地加载了,我能够预测测试示例。
描述用例
现在的问题是,我想在Azure Databricks中使用mlflow注册模型,但是它无法找到MLmodel文件。这是因为实际上loaded_model是一个ludwig对象。
代码:
import mlflow
# Start an MLflow run
with mlflow.start_run():
# Log the model
mlflow.log_artifact(local_path="/dbfs/FileStore/shared_uploads/..../....._Finetuned_V1.0", artifact_path="model")
run_id = mlflow.active_run().info.run_id
model_uri = f"runs:/{run_id}/model"
model_name = "...._Finetuned_V1"
result = mlflow.register_model(model_uri=model_uri, name=model_name)
错误:
Registered model '___Finetuned_V1' already exists. Creating a new version of this model...
2023/11/08 21:02:04 INFO mlflow.tracking._model_registry.client: Waiting up to 300 seconds for model version to finish creation. Model name: ____Finetuned_V1, version 18
MlflowException: Model version creation failed for model name: ____Finetuned_V1 version: 18 with status: FAILED_REGISTRATION and message: Failed registration. The source model path must point to a directory containing an MLflow MLmodel, but received: `dbfs:/databricks/mlflow-tracking/64426...../dc14..../artifacts/model/____Finetuned_V1.0`.
请帮助我使用ludwig的方式在mlflow中注册模型,以便我可以继续提供模型服务。如果这个功能不可用,还有什么替代方案吗?
1条答案
按热度按时间az31mfrm1#
我对MLflow有一些了解,但我不清楚你是否可以将对象记录为artifact,并稍后将其作为模型加载。
无论如何,你为什么要手动记录模型而不是使用Ludwig内置的MLflow支持呢?
https://ludwig.ai/0.8/user_guide/integrations/#mlflow
如果你确实需要手动记录模型,请注意MLflow有一个模型口味的概念。由于Ludwig不是一个内置的口味,你需要像这里一样使用
pyfunc
:https://github.com/ludwig-ai/ludwig/blob/master/ludwig/contribs/mlflow/model.py