Vocabulary for this course

The terms the chapters assume, in plain words. You can open this from any chapter.

attribute
A named value attached to a span or trace, such as a model name or token count, that you can filter and group by.
cardinality
The number of distinct values a field can take. User ids make a field expensive to store and chart; a status code does not.
cost
The money a request spends, usually worked out from token counts and the price per token.
error taxonomy
A short, named list of failure classes, each with an owner and a rule for whether it can be retried.
feedback label
A defined judgement attached to a request after the fact, such as helpful, wrong or unsafe, with a rubric two people can apply alike.
latency
The time a request spends waiting and working, reported for each stage and for the whole.
p95
The cutoff that 95 out of 100 requests finish under, so a few very slow calls stay visible.
redaction
Removing or masking sensitive values before a record is stored, while keeping enough context to debug.
retention
How long stored records are kept before deletion, set by policy rather than by disk space.
sampling
Keeping only a chosen share of records, ideally with every failure kept and the totals corrected.
self time
The part of a span's duration spent in that step alone, after subtracting the time its children took.
span
One timed step inside a request, with a start, an end and the values it carried.
trace
One request's whole journey, with every step nested under the step that caused it.
trace id
A value shared by every record of one request, so pieces written by different services can be joined.

Observability for AI systems

Feedback loops and labels

A thumbs-down is an event, not a metric. Turn feedback into defined labels and regression cases, or the dashboard grows while the product does not.

Part 7 of 10

Intermediate16 min readBack to Courses

Feedback is an event, not a column

A thumbs-down is not a field on a request; it is an event that arrives later, sometimes from a different service, and it should be appended rather than overwriting the original record. Link it by trace id, timestamp it, and record the source: explicit rating, correction, accepted edit, retry or abandonment. The same request can collect several signals over time, and they can disagree. A rating from an agent and a rating from a user are different evidence, even when the number is the same. Recording the source is also the only way to compare feedback across channels.

Appending keeps the history. A trace that was marked helpful and then corrected a week later tells a different story from one that was never rated. The event log also lets you change the label schema without rewriting the traces. When the definition of a failure changes, the old events still say what the user did, which is the part that does not change. A correction is often more informative than a rating: it says what the right answer was.

Explicit feedback is biased

People who respond are angry or delighted; silence is not satisfaction. A helpful rate computed from thumbs is a rate among the people who chose to press a button, not among users. Implicit signals are noisier but broader: did they copy the answer, edit it, retry the same question, or leave? Each is a hint, none is a verdict. A user who leaves without rating may be satisfied, confused or gone; the absence is not a zero. Treat silence as unknown, not as approval.

Use both, and state the denominator. If the helpful rate is 70 percent of 40 ratings, the number is not the same as 70 percent of 4,000 requests. The first is a signal to investigate; the second is a product metric. A dashboard that shows the percentage without the count invites a decision the data cannot support. Segment the rate before comparing versions, or a change in the mix of users looks like a change in quality.

Attach a score to a trace

from langfuse import Langfuse

langfuse = Langfuse()
langfuse.create_score(
    trace_id="8f2c1a",
    name="helpful",
    value=0,
    comment="said thirty days; the policy says five",
)

Join feedback to the trace

Join the ratings to their traces and compute a helpful rate per prompt version. Then add a third version with two ratings and see how the count changes your confidence.

Output
Click "Run" to execute your code

Labels need a definition

A label without a definition is an opinion with a database column. Write a rubric: failure mode, severity, expected answer, and examples of each. Two labelers should agree on a sample before you trust the labels; if they do not, the rubric is the thing to fix. Agreement is not bureaucracy, it is the difference between a dataset and a collection of moods. The rubric should include a catch-all class, so a labeler is not forced to choose between two wrong categories.

Keep the label schema small enough to remember. Five failure modes that people apply consistently beat twenty that nobody can distinguish. Version the rubric, because a label from last quarter may mean something different from the same label today. The version belongs on every labeled case, next to the trace id. A label that requires a paragraph of explanation is usually two labels that have been merged.

Do not train or tune on the same feedback you report. Keep a holdout of labeled cases that never enters the prompt or the training set, or the next evaluation measures memorisation.

Close the loop

Negative feedback becomes useful only when it changes something. Deduplicate, redact, and turn the case into an eval item with the question, the context and the expected answer. Then fix the prompt or the retriever and rerun the set. The loop is complete when the case is in the regression set, not when the ticket is closed. The expected answer is the part most teams skip, and the part that makes the case runnable.

A feedback dashboard that nobody acts on is a museum. The weekly question is not how many thumbs-down arrived; it is which case was added and which change made it pass. That is the difference between listening and measuring, and it is the only part of the loop that compounds. The review should end with a named change and a date, not a general intention to improve.

Turn complaints into cases

Deduplicate the negative feedback by normalised question and print the eval cases. Then add a case with an email address and confirm the redaction keeps it out of the dataset.

Output
Click "Run" to execute your code

Check what you learned

One question at a time. A wrong answer explains itself — take another go.

Part 1 of 5

Why should feedback be appended rather than written onto the trace?