feat(dx): add human-readable loss-mask explainer (#221) - #426
Open
3367337929 wants to merge 2 commits into
Open
Conversation
added 2 commits
July 30, 2026 17:58
Add a human-readable loss-mask explainer that consumes packer output (token ids + loss mask) and maps it back to conversational structure: roles, turns, text previews, and per-span trainable token counts. New files: - areno/api/loss_mask_explainer.py: MaskSpan, LossMaskReport, LossMaskExplainer.explain() — consumes packer output, does not reimplement mask rules - areno/cli/inspect.py: CLI entry with chat-template (inclusionAI#220) and loss-mask (inclusionAI#221) sub-commands - tests/test_loss_mask_explainer_cpu.py: 20 CPU tests covering SFT, agentic, all-masked, truncated, malformed input, CLI integration, and backward compatibility - docs/troubleshooting/loss-mask-explainer.rst: user documentation Closes inclusionAI#221
The loss-mask explainer CLI (inspect.py) imports ChatTemplateInspector from the chat-template module. Include inclusionAI#220 files so the branch is self-contained and testable on Kaggle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #221
This PR adds a human-readable loss-mask explainer that consumes packer output (token ids + loss mask) and maps it back to conversational structure — roles, turns, text previews, and per-span trainable token counts.
What it does
The explainer takes the packer's actual output and maps each contiguous masked/unmasked region back to its conversational role, turn index, and text preview. It does not reimplement mask rules — it reads the packer output directly to ensure the explanation always matches training behaviour.
Key features:
--show-full-textLossMaskPolicyNew files
areno/api/loss_mask_explainer.py—MaskSpan,LossMaskReport,LossMaskExplainer.explain()tests/test_loss_mask_explainer_cpu.py— 20 CPU testsdocs/troubleshooting/loss-mask-explainer.rst— user documentationModified files
areno/cli/inspect.py— addloss-masksub-command to existing inspect groupKey design decisions
--show-full-textpassedapply_chat_template_with_options,normalize_messages,resolve_model_ref,load_tokenizer@dataclass(slots=True), docstrings, comments followdata.py/rewards.py/openai_chat.pypatternsTesting
All 20 CPU tests pass:
Covers: SFT mask (assistant-only), agentic mask (tool-result suppressed), all-masked, none-masked, truncated sample, malformed input (empty messages, mismatched lengths, unknown role), CLI integration (text/json/full-text), backward compatibility.
Verified on real model (Qwen/Qwen3-0.6B) on Kaggle — 31 tokens, 10 trainable (32.3%), system/user 0%, assistant 100%.

Acceptance criteria checklist