MCPcopy Create free account
hub / github.com/ML-GSAI/LLaDA / generate_step_visualization

Function generate_step_visualization

visualization/visualization_zhihu.py:90–138  ·  view source on GitHub ↗

Final visualization version (completely borderless)

(current_step: int, current_tokens: List[str],
                               token_steps: List[int], max_step: int)

Source from the content-addressed store, hash-verified

88 return f"#{r:02x}{g:02x}{b:02x}"
89
90def generate_step_visualization(current_step: int, current_tokens: List[str],
91 token_steps: List[int], max_step: int) -> str:
92 """Final visualization version (completely borderless)"""
93 html = []
94
95 for idx, token in enumerate(current_tokens):
96 style = [
97 "padding: 6px 8px",
98 "margin: 2px",
99 "border-radius: 6px",
100 "display: inline-block",
101 "font-weight: 600",
102 "font-size: 16px",
103 "font-family: 'Segoe UI', sans-serif",
104 "transition: all 0.2s ease",
105 "width: 120px",
106 "min-width: 120px",
107 "text-align: center",
108 "white-space: nowrap",
109 "overflow: hidden",
110 "text-overflow: ellipsis",
111 "box-sizing: border-box",
112 "vertical-align: middle",
113 "border: 0 !important",
114 "outline: 0 !important",
115 "box-shadow: none !important",
116 "position: relative",
117 "z-index: 1"
118 ]
119
120 if token == '<|mdm_mask|>':
121 style.extend([
122 "color: transparent",
123 "background: #f8fafc",
124 "text-shadow: none"
125 ])
126 display_text = "&#8203;"
127 else:
128 text_color = generate_background_color(token_steps[idx], max_step)
129 style.append(f"color: {text_color}")
130 display_text = token if token != " " else "␣"
131
132 html.append(f''&#x27;
133 <div style="display: inline-block; border: none !important; margin: 0 !important; padding: 0 !important;">
134 <span style="{"; ".join(style)}">{display_text}</span>
135 </div>
136 ''&#x27;)
137
138 return '\n'.join(html)
139
140def main(target_step: int = 64):
141 """Main function supporting target step specification"""

Callers 1

mainFunction · 0.70

Calls 1

Tested by

no test coverage detected