MCPcopy
hub / github.com/bbycroft/llm-viz / renderOutputAtBottom

Function renderOutputAtBottom

src/llm/components/ModelCard.ts:325–364  ·  view source on GitHub ↗
(state: IProgramState)

Source from the content-addressed store, hash-verified

323}
324
325function renderOutputAtBottom(state: IProgramState) {
326 let layout = state.layout;
327
328 let softmax = layout.logitsSoftmax;
329
330
331 let topMid = new Vec3(softmax.x + softmax.dx/2, softmax.y + softmax.dy + layout.margin);
332
333 let outCellH = 10;
334 let outCellW = 6;
335
336 let nCells = layout.shape.T;
337 let tl = new Vec3(topMid.x - outCellW * nCells / 2, topMid.y);
338 let br = new Vec3(topMid.x + outCellW * nCells / 2, topMid.y + outCellH);
339
340 let lineOpts = makeLineOpts({ color: Vec4.fromHexColor("#000000", 0.2), mtx: new Mat4f(), thick: 1.5 });
341
342 renderOutputBoxes(state, layout, tl, br, outCellW, 4, lineOpts, { boldLast: true, tokMixes: state.display.tokenOutputColors });
343
344 for (let i = 0; i < nCells; i++) {
345 let tx = cellPosition(layout, softmax, Dim.X, i) + 0.5 * layout.cell;
346 let ty = softmax.y + softmax.dy + 0.5 * layout.cell;
347 let bx = tl.x + (i + 0.5) * outCellW;
348 let by = tl.y - layout.cell;
349
350 let midY1 = lerp(ty, by, 1/6);
351 let midY2 = lerp(ty, by, 3/4);
352
353 drawLine(state.render.lineRender, new Vec3(tx, ty), new Vec3(tx, midY1), lineOpts);
354 drawLine(state.render.lineRender, new Vec3(tx, midY1), new Vec3(bx, midY2), lineOpts);
355 drawLine(state.render.lineRender, new Vec3(bx, midY2), new Vec3(bx, by), lineOpts);
356
357 let arrLen = 0.6;
358 let arrowLeft = new Vec3(bx - arrLen, by - arrLen);
359 let arrowRight = new Vec3(bx + arrLen, by - arrLen);
360 drawLine(state.render.lineRender, arrowLeft, new Vec3(bx, by), lineOpts);
361 drawLine(state.render.lineRender, arrowRight, new Vec3(bx, by), lineOpts);
362 }
363
364}

Callers 1

drawModelCardFunction · 0.85

Calls 5

makeLineOptsFunction · 0.90
cellPositionFunction · 0.90
lerpFunction · 0.90
renderOutputBoxesFunction · 0.85
fromHexColorMethod · 0.80

Tested by

no test coverage detected