Repository navigation
Basal viz - #2
Conversation
Reviewer's GuideAdds the Sequence diagram for the basal decision visualizer requestsequenceDiagram
participant User
participant Viz as basal-viz
participant Explainer
participant SharedBackend
participant Model
User->>Viz: POST /api/explain
Viz->>Explainer: explain(body)
Explainer->>Explainer: explain_question(q)
Explainer->>Model: lens(ids, letter_ids)
Model-->>Explainer: per-layer letter probabilities
Explainer->>SharedBackend: run_shared(groups)
SharedBackend->>Model: _forward_masked(packed inputs)
Model-->>SharedBackend: packed probabilities
SharedBackend-->>Explainer: option-order probabilities
Explainer-->>Viz: calibrated answer and explanation data
Viz-->>User: Render prompts, packing, charts, readout, thresholds
Flow diagram for the visualized calibrated decisionflowchart TD
Input["State and typed questions"] --> Prompt["Render both option orders"]
Prompt --> Pack["Pack shared prefix and option tails"]
Pack --> Lens["Run model and record per-layer logit lens"]
Lens --> Readout["Read option-letter probabilities"]
Readout --> Average["Map letters to options and average orders"]
Average --> Calibrate["Apply temperature calibration"]
Calibrate --> Threshold["Compare confidence with thresholds"]
Threshold --> Decision["Answer, auto-accept, or route to a person"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="basal/viz.html" line_range="341" />
<code_context>
+// ---- decide -----------------------------------------------------------------------------------------------------
+let currentGold = null;
+async function decide(gold) {
+ currentGold = gold === undefined ? currentGold : gold;
+ const req = readRequest();
+ if (!Object.keys(req.questions).length) return;
</code_context>
<issue_to_address>
**issue (bug_risk):** After loading a bundled example, editing its state, question text, or options leaves `currentGold` pointing to the example's original answer. The next decision therefore displays a stale “matches the expected answer” or “expected” badge for the modified request.
**Triggers:** When a user loads an example and changes any input before pressing Decide.
**Suggested fix:** Clear `currentGold` whenever the state or question editors change, or only retain it when the request still matches the loaded example.
```suggestion
currentGold = gold === undefined ? null : gold;
```
</issue_to_address>| // ---- decide ----------------------------------------------------------------------------------------------------- | ||
| let currentGold = null; | ||
| async function decide(gold) { | ||
| currentGold = gold === undefined ? currentGold : gold; |
There was a problem hiding this comment.
issue (bug_risk): After loading a bundled example, editing its state, question text, or options leaves currentGold pointing to the example's original answer. The next decision therefore displays a stale “matches the expected answer” or “expected” badge for the modified request.
Triggers: When a user loads an example and changes any input before pressing Decide.
Suggested fix: Clear currentGold whenever the state or question editors change, or only retain it when the request still matches the loaded example.
| currentGold = gold === undefined ? currentGold : gold; | |
| currentGold = gold === undefined ? null : gold; |
Screen.Recording.2026-09-29.at.16.17.14.mov |
feat: GGUF backend (llama.cpp) + Apple Silicon engine comparison
|
basal-viz is a great idea and we'd like to merge it. Two things first: (1) MPS is already in main via #4, so please rebase onto v2.0.0 without the MPS commit and use the existing backends; (2) basal-2.0 uses prompt format 2 (up to 255 options; render and letter_ids take fmt from the model's basal.json) and one option order by default. Could you port viz to that and check it with basal-2.0-mini? Then we'll merge it as the optional basal-viz command. |
|
Thanks again for basal-viz. main has moved on (2.1, and 2.2 on Mon 19 Oct). When you have time, please rebase onto v2.2.0 without the MPS commit and port to prompt format 2; once it runs with basal-2.0-mini we'll merge. If it doesn't fit your schedule, no problem: we'll close this in two weeks and you can reopen anytime. |
docs(strix): --mode strix benchmarks, HARDWARE.md and SERVING.md (stacked on #2)
… option orders, calibration and answer Port of #2 to the current engine without its MPS backend (main has MPS since #4): the page runs a basal-serve Server in process (--mode mps on Apple Silicon, eager elsewhere) and reads its PyTorch model for the per-layer readout. Prompts, option codes (up to 255, format 2 from basal.json) and option orders (one by default for format-2 models; --orders 1|2) come from Server.jobs_for; temperatures per type and option-count bucket and the per-type certified thresholds from the calibration file basal-serve loads; multi questions are explained per label, act and tool by their base type. The code logits are read in fp32 as the engines read them. Each request is also answered by Server.decide and the page shows the difference. The page handles one or two orders and types without a certified threshold; question types the form does not edit (act, tool, tasks) are sent as JSON. Llama-architecture models only (refused otherwise). Docs: SERVING.md, "See how a decision is made". Checked with basal-2.0-mini on MPS and CPU, bundled examples and a multi / act / 30-option request: equal to the served answer for single questions (0 on MPS), within 0.006 for requests with several questions (one packed row over the state, bf16).
|
Thank you for basal-viz! It is merged and ships in basal v2.2.0 Since main had moved a long way, we did the port ourselves, as discussed in the review:
If you'd like, we'd be glad to list you in CODEOWNERS for |
merge after #1 is merged
a simple local page that shows every step of a decision with many examples
Summary by Sourcery
Add Apple Silicon support and a local visualizer for inspecting basal decision-making end to end.
New Features:
basal-vizlocal web interface for exploring model decisions step by step, including prompts, option-order packing, layer-wise probabilities, calibration, and confidence thresholds.Enhancements:
Build:
basal-vizcommand and package its web assets.Documentation:
Tests: