# MLflow

**MLflow** 是一个开源平台，用于管理机器学习和生成式 AI 的生命周期，涵盖实验跟踪、模型打包、模型注册表、评估、追踪和部署。它由 [Databricks](https://www.edgepedia.org/zh/databricks)（Databricks）于 2018 年 6 月作为开源项目推出，旨在简化机器学习开发流程，采用 Apache 2.0 许可证。<sup>[1](https://www.databricks.com/sites/default/files/2023-08/accelerating-the-machine-learning-lifecycle-with-mlflow.pdf)</sup><sup> • </sup><sup>[2](https://github.com/mlflow/mlflow)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 由 Databricks 于 2018 年 6 月推出的开源平台，旨在解决实验、可复现性和模型部署问题<sup>[1](https://www.databricks.com/sites/default/files/2023-08/accelerating-the-machine-learning-lifecycle-with-mlflow.pdf)</sup> |
| 核心组件 | 跟踪、项目、模型和模型注册表<sup>[3](https://www.mlflow.org/docs/2.1.1/concepts.html)</sup> |
| 跟踪服务器 | 一个 FastAPI 服务器，为后端和工件存储提供 REST API，并托管 MLflow 界面<sup>[4](https://mlflow.org/docs/latest/self-hosting/architecture/overview/)</sup> |
| 后端存储 | 通过 SQLAlchemy 支持 PostgreSQL、MySQL、SQLite 和 MSSQL；本地使用时默认采用 SQLite<sup>[4](https://mlflow.org/docs/latest/self-hosting/architecture/overview/)</sup><sup> • </sup><sup>[5](https://www.mlflow.org/docs/latest/self-hosting/architecture/tracking-server/)</sup> |
| SDK | Python、TypeScript、Java 和 R 的客户端库<sup>[4](https://mlflow.org/docs/latest/self-hosting/architecture/overview/)</sup> |
| 生成式 AI 能力 | 基于 OpenTelemetry 构建的追踪、LLM 评判器、提示注册表和 AI 网关<sup>[6](https://www.databricks.com/blog/introducing-enhanced-agent-evaluation)</sup><sup> • </sup><sup>[7](https://mlflow.github.io/mlflow-website/docs/latest/genai/)</sup> |
| 托管服务 | Databricks 上的托管 MLflow 和 Amazon SageMaker AI<sup>[8](https://docs.aws.amazon.com/sagemaker/latest/dg/mlflow.html)</sup> |

## 目的与组件

MLflow 解决的是标准软件开发工具无法覆盖的问题：机器学习开发围绕反复实验展开，团队需要记录数据版本、代码和调参参数，复现结果，并部署模型。<sup>[1](https://www.databricks.com/sites/default/files/2023-08/accelerating-the-machine-learning-lifecycle-with-mlflow.pdf)</sup> 该平台由四个组件构成：**跟踪**，一个用于记录参数、代码版本、指标和输出文件的 API 与界面；**项目**，用于组织可复用的代码；**模型**，一种打包格式；以及**模型注册表**，负责管理模型版本、血缘关系、别名、标签和注释，覆盖暂存和生产等阶段。<sup>[3](https://www.mlflow.org/docs/2.1.1/concepts.html)</sup><sup> • </sup><sup>[9](https://www.tavro.ai/wp-content/uploads/2025/11/AI_Governance_Comprehensive_Sept_2024.pdf)</sup>

单个数据科学家可以在本地使用 MLflow 跟踪功能，无需服务器，因为跟踪默认读写本地文件系统；由此产出的模型随后可由生产工程师使用 MLflow 的部署工具进行部署。<sup>[3](https://www.mlflow.org/docs/2.1.1/concepts.html)</sup>

## 架构

自托管部署包含三个主要部分：跟踪服务器、后端存储和工件存储。<sup>[8](https://docs.aws.amazon.com/sagemaker/latest/dg/mlflow.html)</sup> MLflow 跟踪服务器是一个 FastAPI 服务器，为访问后端和工件存储提供 REST API，并托管 MLflow 界面。本地开发时它是可选的，SDK 可以直接与本地数据库和文件系统交互，但对于团队开发而言它必不可少，并提供访问控制等功能。<sup>[4](https://mlflow.org/docs/latest/self-hosting/architecture/overview/)</sup>

**后端存储**是一个数据库，或模拟数据库的文件系统，保存实验、运行和追踪的元数据。MLflow 通过 SQLAlchemy 支持数据库，包括 [PostgreSQL](https://www.edgepedia.org/zh/postgresql)、MySQL、SQLite 和 MSSQL。<sup>[4](https://mlflow.org/docs/latest/self-hosting/architecture/overview/)</sup> 服务器默认使用 SQLite 数据库（`sqlite:///mlflow.db`）；SQLite 在大多数用例中性能与可靠性良好，而对于高并发的生产部署，推荐使用 PostgreSQL 或 MySQL。<sup>[5](https://www.mlflow.org/docs/latest/self-hosting/architecture/tracking-server/)</sup> 后端存储持久化每次运行的元数据，如运行 ID、起止时间、参数和指标。<sup>[8](https://docs.aws.amazon.com/sagemaker/latest/dg/mlflow.html)</sup>

**工件存储**持久化每次运行的文件，这些文件通常较大，如模型权重、图像和 Parquet（面向大数据的列式数据文件格式）数据文件。这些文件对跟踪后端来说过大，且访问频率较低，因此 [Amazon S3](https://www.edgepedia.org/zh/amazon-s3) 这类廉价对象存储成为常见选择。<sup>[4](https://mlflow.org/docs/latest/self-hosting/architecture/overview/)</sup> 工件处理可通过两种方式配置：使用 `--artifacts-destination` 时，服务器代理上传并管理存储凭据，客户端无需持有存储凭据；使用 `--default-artifact-root` 和 `--no-serve-artifacts` 时，客户端直接写入存储，必须自行持有凭据。<sup>[5](https://www.mlflow.org/docs/latest/self-hosting/architecture/tracking-server/)</sup> 当请求量大到引发性能问题时，可以让一个服务器以 `--artifacts-only` 模式与一个 `--no-serve-artifacts` 实例并行运行，将工件处理与其他跟踪事件隔离；在此模式下，任何非工件任务（如列出实验）都会返回 HTTPError。<sup>[5](https://www.mlflow.org/docs/latest/self-hosting/architecture/tracking-server/)</sup>

## 评估与生成式 AI 功能

MLflow 的评估框架为分类和回归任务提供自动化模型评估，通过统一 API 生成指标、可视化和诊断，并可选提供基于 SHAP 的解释。<sup>[10](https://mlflow.org/docs/latest/ml/evaluation)</sup> 基于指标阈值的模型验证在 MLflow 2.18.0 中从 `mlflow.models.evaluate()` 迁移到了 `mlflow.validate_evaluation_results()`。<sup>[10](https://mlflow.org/docs/latest/ml/evaluation)</sup>

对于生成式 AI，MLflow 提供了一套独立的评估系统，围绕 `mlflow.genai.evaluate()` 和带有内置 LLM 评判器的 `Scorer` 对象构建；两套系统互不兼容，因为 `EvaluationMetric` 对象不能用于 `mlflow.genai.evaluate()`，而 `Scorer` 对象也不能用于 `mlflow.models.evaluate()`。<sup>[10](https://mlflow.org/docs/latest/ml/evaluation)</sup> MLflow 追踪基于可观测性行业标准 [OpenTelemetry](https://www.edgepedia.org/zh/opentelemetry) 构建，可以从任何生成式 AI 应用收集追踪数据，包括在 Databricks 之外部署的应用。<sup>[6](https://www.databricks.com/blog/introducing-enhanced-agent-evaluation)</sup> 生成式 AI 平台还包括一个提示注册表，用于维护提示及其评估分数和相关元数据，以及一个用于治理的 AI 网关。<sup>[7](https://mlflow.github.io/mlflow-website/docs/latest/genai/)</sup>

## 版本与近期变化

MLflow 3.0 引入了新的跟踪与版本管理架构，MLflow 在其中充当横向元数据枢纽，将每个模型或应用版本与其代码、模型权重、数据集、配置、指标、追踪和可视化关联起来。它为生成式 AI 应用新增了生产级追踪、LLM 评判器和在线监控，既可在开源版中使用，也可作为 Databricks 上的托管服务使用，现有托管 MLflow 用户无需迁移。<sup>[11](https://www.databricks.com/blog/mlflow-30-unified-ai-experimentation-observability-and-governance)</sup>

MLflow 3.10.0 新增了多工作区支持，让用户可以在单个跟踪服务器内逻辑隔离实验、模型和提示，通过 `--enable-workspaces` 标志或 `MLFLOW_ENABLE_WORKSPACES` 环境变量启用。该版本还新增了聊天机器人对话的评估与模拟、追踪的成本跟踪，以及 AI 网关端点的用量跟踪。<sup>[12](https://mlflow.org/releases)</sup>

## 托管服务与生态系统

托管 MLflow 可在 Databricks 上使用，其中 MLflow 3.0 作为 MLOps 和 AI 可观测性的基础，并使用 Unity Catalog 治理模型、生成式 AI 应用、提示和数据集。<sup>[11](https://www.databricks.com/blog/mlflow-30-unified-ai-experimentation-observability-and-governance)</sup> Amazon SageMaker AI 也提供托管 MLflow：托管跟踪服务器的计算资源和后端元数据存储运行在 SageMaker 服务账户中，而工件存储是客户自己 AWS 账户中的 Amazon S3 存储桶。<sup>[8](https://docs.aws.amazon.com/sagemaker/latest/dg/mlflow.html)</sup>

MLflow 被广泛用作实验跟踪工具；在一项关于机器学习实验管理工具的混合方法研究中，它被列为支持基于 API 的资产跟踪的流行工具之一，与 TensorBoard、[Weights & Biases](https://www.edgepedia.org/zh/weights-and-biases)、Neptune 和 Comet.ml 并列。<sup>[13](https://www.danielstrueber.de/publications/IOSB24.pdf)</sup> 在 2024 年一项关于服务成本的实验研究中，它也出现在所评估的广泛使用的模型服务框架之列，与 TensorFlow Serving、TorchServe、MLServer 和 BentoML 并列。<sup>[14](https://arxiv.org/abs/2411.10337)</sup> 替代产品各有侧重：[ClearML](https://www.edgepedia.org/zh/clearml) 将跟踪、任务调度、数据版本管理和流水线编排整合进更广泛的 MLOps 栈，而 Weights & Biases 和 Comet/Opik 则是专注于跟踪、LLM 可观测性和协作的 SaaS 产品。<sup>[15](https://futurepicker.com/en/mlflow-alternatives-experiment-tracking-2026-en/)</sup><sup> • </sup><sup>[16](https://www.zenml.io/blog/mlflow-alternatives)</sup>

## References

1. [Accelerating the Machine Learning Lifecycle with MLflow, Databricks](https://www.databricks.com/sites/default/files/2023-08/accelerating-the-machine-learning-lifecycle-with-mlflow.pdf)
2. [mlflow/mlflow on GitHub](https://github.com/mlflow/mlflow)
3. [MLflow Concepts (2.1.1 documentation)](https://www.mlflow.org/docs/2.1.1/concepts.html)
4. [Architecture Overview, MLflow documentation](https://mlflow.org/docs/latest/self-hosting/architecture/overview/)
5. [MLflow Tracking Server, MLflow documentation](https://www.mlflow.org/docs/latest/self-hosting/architecture/tracking-server/)
6. [Introducing Enhanced Agent Evaluation, Databricks Blog](https://www.databricks.com/blog/introducing-enhanced-agent-evaluation)
7. [MLflow GenAI documentation](https://mlflow.github.io/mlflow-website/docs/latest/genai/)
8. [Accelerate generative AI development using managed MLflow on Amazon SageMaker AI, AWS documentation](https://docs.aws.amazon.com/sagemaker/latest/dg/mlflow.html)
9. [AI Governance Comprehensive reference, Tavro](https://www.tavro.ai/wp-content/uploads/2025/11/AI_Governance_Comprehensive_Sept_2024.pdf)
10. [ML Model Evaluation, MLflow documentation](https://mlflow.org/docs/latest/ml/evaluation)
11. [MLflow 3.0: Build, Evaluate, and Deploy Generative AI with Confidence, Databricks Blog](https://www.databricks.com/blog/mlflow-30-unified-ai-experimentation-observability-and-governance)
12. [MLflow releases](https://mlflow.org/releases)
13. [Machine Learning Experiment Management Tools: A Mixed-Methods Empirical Study, Strüber](https://www.danielstrueber.de/publications/IOSB24.pdf)
14. [On the Cost of Model-Serving Frameworks: An Experimental Evaluation, arXiv](https://arxiv.org/abs/2411.10337)
15. [MLflow Alternatives: ML Experiment Tracking Tools Compared 2026, FuturePicker](https://futurepicker.com/en/mlflow-alternatives-experiment-tracking-2026-en/)
16. [We Tested 9 MLflow Alternatives for MLOps, ZenML Blog](https://www.zenml.io/blog/mlflow-alternatives)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › AI companies, people, and products

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/mlflow

English original: https://www.edgepedia.org/mlflow
