---
type: concept
x-llmwiki:
  schemaVersion: "0.1"
  contentHash: 6aea416915d8cb7252f955c0906aab0312a5ee79ab0999fade6621dc55f3fb80
  pageDirectory: concepts
  sources:
    - collect-user-feedback-databricks-on-aws.md
  confidence: 0.98
  provenanceState: extracted
  freshnessStatus: unverified
  aliases:
    - mlflow-log_feedback-api
    - MLA
    - MLflow Feedback APIs
    - Log User Feedback
    - MLflow Feedback
    - log_feedback API
  citations:
    - file: collect-user-feedback-databricks-on-aws.md
title: MLflow log_feedback API
description: The API for programmatically logging user feedback against traces, supporting boolean, numeric, text, and structured feedback values.
tags:
  - mlflow
  - api
  - feedback
  - tracing
timestamp: "2026-06-18T14:39:03.201Z"
---

# MLflow log_feedback API

The **MLflow log_feedback API** provides a structured way to capture and log user feedback on [GenAI](/concepts/mlflow-genai-evaluate-api.md) application traces within [MLflow 3](/concepts/mlflow-3.md). It enables persistent storage of assessments on traces, allowing organizations to track quality over time, identify areas for improvement, and build evaluation datasets from production data. ^[collect-user-feedback-databricks-on-aws.md]

## Overview

The `log_feedback` API is available in both the `mlflow-tracing` package (for production deployments) and the standard MLflow package (for development environments). ^[collect-user-feedback-databricks-on-aws.md]

```python
pip install --upgrade mlflow-tracing
```

Regardless of which installation method you choose, the `log_feedback` API is available for collecting user feedback. MLflow 3 is required for this functionality; MLflow 2.x is not supported due to performance limitations and missing features essential for production use. ^[collect-user-feedback-databricks-on-aws.md]

## Why Collect User Feedback

User feedback provides ground truth about an application's performance:

- **Real-world quality signals** – Understand how actual users perceive your application's outputs
- **Continuous improvement** – Identify patterns in negative feedback to guide development
- **Training data creation** – Use feedback to build high-quality evaluation datasets
- **Quality monitoring** – Track satisfaction metrics over time and across different user segments
- **Model fine-tuning** – Leverage feedback data to improve underlying models

^[collect-user-feedback-databricks-on-aws.md]

## Feedback Data Model

In MLflow, user feedback is captured using the **Feedback** entity, which is a type of [Assessment](/concepts/assessments.md) that can be attached to traces or specific spans. The Feedback entity provides a structured way to store: ^[collect-user-feedback-databricks-on-aws.md]

- **Value**: The actual feedback (boolean, numeric, text, or structured data)
- **Source**: Information about who or what provided the feedback (human user, LLM judge, or code)
- **Rationale**: Optional explanation for the feedback
- **Metadata**: Additional context like timestamps or custom attributes

## Feedback Collection Approaches

When implementing feedback collection in production, you need to link user feedback to specific traces. There are two approaches: ^[collect-user-feedback-databricks-on-aws.md]

1. **Using client request IDs** – Generate your own unique IDs when processing requests and reference them later for feedback
2. **Using MLflow trace IDs** – Use the trace ID automatically generated by MLflow

### Understanding the Feedback Collection Flow

Both approaches follow a similar pattern: ^[collect-user-feedback-databricks-on-aws.md]

1. **During the initial request**: Your application either generates a unique client request ID or retrieves the MLflow-generated trace ID
2. **After receiving the response**: The user can provide feedback by referencing either ID
3. **Feedback is logged**: MLflow's `log_feedback` API creates an assessment attached to the original trace
4. **Analysis and monitoring**: You can query and analyze feedback across all traces

## API Reference

### Basic Usage

```python
import mlflow
from mlflow.entities import AssessmentSource

mlflow.log_feedback(
    trace_id="<trace-id>",
    name="user_feedback",
    value=<boolean_or_numeric_value>,
    source=AssessmentSource(
        source_type="HUMAN",
        source_id="<user-id>"
    ),
    rationale="<optional-comment>"
)
```

^[collect-user-feedback-databricks-on-aws.md]

### AssessmentSource Object

The `AssessmentSource` object identifies who or what provided the feedback: ^[collect-user-feedback-databricks-on-aws.md]

- `source_type`: Can be "HUMAN" for user feedback or "LLM_JUDGE" for automated evaluation
- `source_id`: Identifies the specific user or system providing feedback

### Multi-dimensional Feedback

You can log multiple dimensions of feedback as separate assessments for granular analysis: ^[collect-user-feedback-databricks-on-aws.md]

```python
# Log each dimension as a separate assessment
dimensions = {
    "accuracy": accuracy,
    "helpfulness": helpfulness,
    "relevance": relevance
}
for dimension, score in dimensions.items():
    mlflow.log_feedback(
        trace_id=trace_id,
        name=f"user_{dimension}",
        value=score / 5.0,
        source=AssessmentSource(
            source_type="HUMAN",
            source_id=user_id
        ),
        rationale=comment if dimension == "accuracy" else None
    )
```

## Feedback Storage and Access

Feedback is stored as assessments on the trace, which means: ^[collect-user-feedback-databricks-on-aws.md]

- It's permanently associated with the specific interaction
- It can be queried alongside the trace data
- It's visible in the MLflow UI when viewing the trace

### Retrieving Traces with Feedback

```python
from mlflow.client import MlflowClient
from datetime import datetime, timedelta

client = MlflowClient()

# Get traces from the last 24 hours
cutoff_time = datetime.now() - timedelta(hours=24)
cutoff_timestamp_ms = int(cutoff_time.timestamp() * 1000)

traces = client.search_traces(
    experiment_names=["/Shared/production-genai-app"],
    filter_string=f"trace.timestamp_ms > {cutoff_timestamp_ms}"
)
```

^[collect-user-feedback-databricks-on-aws.md]

### Analyzing Feedback

```python
def analyze_user_feedback(traces):
    """Analyze feedback patterns from traces."""
    client = MlflowClient()
    # ... trace processing logic ...
    return {
        "total_traces": len(traces),
        "traces_with_feedback": traces_with_feedback,
        "feedback_rate": (traces_with_feedback / total_traces) * 100,
        "positive_rate": (positive_count / traces_with_feedback) * 100,
        "positive_count": positive_count,
        "negative_count": negative_count
    }
```

^[collect-user-feedback-databricks-on-aws.md]

## Streaming Considerations

When using streaming responses (Server-Sent Events or WebSockets), the trace ID isn't available until the stream completes. Key considerations include: ^[collect-user-feedback-databricks-on-aws.md]

- **Trace ID timing**: Design your UI to handle this gracefully by disabling feedback controls until the trace ID is received
- **Event structure**: Use a consistent event format with a `type` field to distinguish between content tokens, completion events, and errors
- **State management**: Track both the streaming content and trace ID separately
- **Error handling**: Include error events in the stream to gracefully handle failures
- **Buffer management**: Implement proper line buffering and consider `X-Accel-Buffering: no` headers
- **Performance optimization**: Add small delays between tokens to prevent overwhelming clients

## Related Concepts

- [Assessment](/concepts/assessments.md) – The entity type for capturing feedback on traces
- [MLflow 3](/concepts/mlflow-3.md) – The version requirement for user feedback collection
- [GenAI Tracing](/concepts/mlflow-genai-tracing.md) – The tracing infrastructure that supports feedback collection
- [Production Monitoring for GenAI](/concepts/production-quality-monitoring-mlflow-genai.md) – Using feedback for quality monitoring in production
- Human Feedback Alignment – Improving feedback quality with expert annotations

## Sources

- collect-user-feedback-databricks-on-aws.md

# Citations

1. [collect-user-feedback-databricks-on-aws.md](/references/collect-user-feedback-databricks-on-aws-0b0ba83c.md)
