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

Function main

visualization/visualization_paper.py:128–191  ·  view source on GitHub ↗

Main function supporting target step specification

(target_step: int = 64)

Source from the content-addressed store, hash-verified

126 return '\n'.join(html)
127
128def main(target_step: int = 64):
129 """Main function supporting target step specification"""
130 file_path = "sample_process.txt"
131 final_step = 64
132
133 history = parse_generation_history(file_path)
134 if target_step not in history:
135 raise ValueError(f"Invalid target step: {target_step}")
136
137 token_steps = track_token_positions(history)
138 current_tokens = history[target_step]
139
140 html_content = generate_step_visualization(
141 target_step, current_tokens, token_steps, final_step
142 )
143
144 example_steps = [0, 16, 32, 48, 64]
145 example_colors = [generate_background_color(s, final_step) for s in example_steps]
146 legend_html = ''.join(
147 f'<div style="background-color: {color}; color: black;">Step {s}</div>'
148 for s, color in zip(example_steps, example_colors)
149 )
150
151 target_dir = "html/sample_process_paper"
152 if not os.path.exists(target_dir):
153 os.makedirs(target_dir)
154
155 with open(f"{target_dir}/visualization_step_{target_step}.html", "w", encoding="utf-8") as f:
156 f.write(f"""<html>
157<head>
158 <title>Step {target_step} Visualization</title>
159 <style>
160 body {{
161 padding: 40px;
162 background: #f8fafc;
163 font-family: 'Segoe UI', sans-serif;
164 }}
165 .legend {{
166 display: flex;
167 gap: 15px;
168 margin: 20px 0;
169 }}
170 .legend div {{
171 padding: 10px;
172 border-radius: 5px;
173 color: white;
174 min-width: 80px;
175 text-align: center;
176 }}
177 .token:hover {{
178 transform: translateY(-2px);
179 }}
180 </style>
181</head>
182<body>
183 <div style="max-width: 1000px; margin: auto;">
184 <h2>Generation Step {target_step}</h2>
185 <div>{html_content}</div>

Callers 1

Calls 5

openFunction · 0.85
parse_generation_historyFunction · 0.70
track_token_positionsFunction · 0.70

Tested by

no test coverage detected