How the mood of a mention gets read
A mention comes off the queue: a review, a post, a comment. The reader has one job — turn that bit of text into a number that says how positive or negative it is, plus a one-line reason. That single step is the only place in the whole system a model is used. Everything after it — the trend, the alerts, the weekly pulse — is plain Python on top of the stored scores. The model labels the mood; it never decides what to do about it.
Key takeaways
- One Bedrock Haiku 4.5 call per mention returns a mood score and a one-line reason.
- The score is on a fixed scale, so every mention is measured the same way.
- Scores are stored in DynamoDB; the rolling trend is computed from them in plain Python.
- A short, blank or junk mention is skipped before the model call, to save cost.
- The model only labels mood. It never decides whether to alert and never writes a reply.
The read flow, per mention
The mood score: one scale for everything
The model is asked for a single number on a fixed scale — say, −2 for furious, −1 for unhappy, 0 for neutral, +1 for pleased, +2 for delighted — plus a one-line reason in plain words. The fixed scale is the whole point. A five-star review and an off-hand comment are wildly different in shape, but once each becomes a number on the same scale, they can be averaged, compared, and trended together. A review platform’s own star rating doesn’t help here, because half your sources don’t have stars at all — the comment under a post has no stars, just words. Reading every mention into the same scale is what lets the monitor treat them as one stream.
The prompt is short and strict: “Read this mention. Return JSON only: a mood score from −2 to +2 and a one-line reason. Do not guess at facts you can’t see. If the text is unclear, score it 0 and say so.” Asking for JSON only, with a tight range, keeps the output something plain Python can check and store without surprises.
A cheap model, and only when it’s worth it
Reading mood is exactly the kind of small, well-defined job a fast, inexpensive model does well, so the reader uses Claude Haiku 4.5 — the cheap path. There’s no need for heavier reasoning here; the task is “how does this feel,” not “reason through a contract.” Each call is a few hundred tokens in and a few tokens out, so it costs a fraction of a cent.
Before any call, Step 2 checks whether the call is worth making. A blank comment, a one-word “ok,” a mention that’s already been scored, or obvious junk gets skipped with no model call at all. Most mentions are worth reading; the pre-check just stops the system from paying for the ones that aren’t. It’s a small saving per mention that adds up across a busy month, and it keeps the model focused on text that actually carries a mood.
Store the score, then compute the trend
A valid score is written to the sm-scores table in DynamoDB against the mention’s id, with the source, the posted-at time, the score, and the reason. That stored row is the system’s memory. Everything else reads from it.
The trend is plain Python on top of those rows. After each batch, the reader recomputes a rolling average over the trailing window (default 14 days) — one number that says how the mood has felt lately — and compares it to the same number from before this batch. The difference is the slope: rising, flat, or falling. No model touches this step. The trend is just arithmetic over the stored scores, which means it’s fast, free, and gives the same answer every time for the same data. Part 4 uses the slope and the individual scores to decide when a human needs to hear about it.
Why the model is used only here
The model earns its place reading mood, because reading tone from free text is genuinely hard to do with rules — sarcasm, slang, and context defeat keyword lists. But the moment the mood is a number, rules win. Deciding whether a score is below the floor, whether the average dropped too fast, what to put in the weekly email — all of that is clearer, cheaper, and more predictable as plain Python. Keeping the model to one job also means the part of the system you can’t fully predict is small and contained: one labeled number per mention, validated before it’s trusted, and never allowed to decide an action on its own.
Next post: how an angry mention — a single furious score, or a sharp drop in the trend — reaches a human, worst item first, with the original a click away.
All posts