Download app.py from pluto2060/test: direct link, hf CLI and curl.
- Browser
- Download file 23.5 kB
-
https://huggingface.co/spaces/pluto2060/test/resolve/main/app.py
- Command line
-
hf download hf://spaces/pluto2060/test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/pluto2060/test/resolve/main/app.py
23.5 kB
| """ | |
| AI Paper Lab โ ICML 2026 ๋ ผ๋ฌธ ์ฒดํ Space | |
| pluto2060/ai-paper-lab | |
| """ | |
| import gradio as gr | |
| import numpy as np | |
| import plotly.graph_objects as go | |
| import spaces | |
| import torch | |
| # โโ Tab 1: Grok Grokking โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| def grokking_simulation(n_train: int, weight_decay: float, n_epochs: int): | |
| """Simulate grokking in ridge regression โ memorization then generalization.""" | |
| np.random.seed(42) | |
| # Ground truth weight vector | |
| w_true = np.array([1.0, -1.5, 0.8]) | |
| # Training data | |
| X_train = np.random.randn(n_train, 3) | |
| y_train = X_train @ w_true + np.random.randn(n_train) * 0.1 | |
| # Test data (larger) | |
| X_test = np.random.randn(200, 3) | |
| y_test = X_test @ w_true + np.random.randn(200) * 0.1 | |
| train_loss, test_loss, weight_norm = [], [], [] | |
| epochs = np.arange(1, n_epochs + 1) | |
| # Gradient descent simulation | |
| w = np.zeros(3) | |
| lr = 0.01 | |
| for ep in epochs: | |
| grad = -2 * X_train.T @ (y_train - X_train @ w) / n_train + 2 * weight_decay * w | |
| w = w - lr * grad | |
| tr = np.mean((y_train - X_train @ w) ** 2) | |
| te = np.mean((y_test - X_test @ w) ** 2) | |
| train_loss.append(tr) | |
| test_loss.append(te) | |
| weight_norm.append(np.linalg.norm(w)) | |
| fig = go.Figure() | |
| fig.add_trace(go.Scatter(x=epochs, y=train_loss, name="ํ๋ จ ์์ค", line=dict(color="#2196F3"))) | |
| fig.add_trace(go.Scatter(x=epochs, y=test_loss, name="ํ ์คํธ ์์ค", line=dict(color="#F44336"))) | |
| fig.add_trace(go.Scatter(x=epochs, y=weight_norm, name="๊ฐ์ค์น ๋ ธ๋ฆ", line=dict(color="#4CAF50", dash="dot"))) | |
| # Mark grokking transition: first epoch where test_loss < 0.5 | |
| grok_ep = next((i + 1 for i, v in enumerate(test_loss) if v < 0.5), None) | |
| if grok_ep: | |
| fig.add_vline(x=grok_ep, line_dash="dash", line_color="orange", | |
| annotation_text=f"๊ทธ๋กํน ๋ฐ์! (epoch {grok_ep})", annotation_position="top right") | |
| fig.update_layout( | |
| title="To Grok Grokking โ ๋ฆฟ์ง ํ๊ท์ ์ง์ฐ ์ผ๋ฐํ ์๋ฎฌ๋ ์ด์ ", | |
| xaxis_title="Epoch", yaxis_title="๊ฐ", | |
| template="plotly_dark", height=450 | |
| ) | |
| return fig | |
| def build_grokking_tab(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ## ๐ To Grok Grokking: Provable Grokking in Ridge Regression | |
| **ICML 2026 Honorable Mention** | Xu et al. | |
| > AI ๋ชจ๋ธ์ด ์ฒ์์๋ ํ๋ จ ๋ฐ์ดํฐ๋ฅผ **์๊ธฐ**ํ๋ค๊ฐ ์ด๋ ์๊ฐ ๊ฐ์๊ธฐ **์ง์ง ์๋ฆฌ๋ฅผ ์ผ๋ฐํ**ํ๋ ํ์์ ์ํ์ ์ผ๋ก ์ฆ๋ช . | |
| > ๋ฆฟ์ง ํ๊ท๋ผ๋ ๋จ์ ๋ชจ๋ธ๋ก ์ด "๊ทธ๋กํน" ํ์์ด ์ ๋ฐ์ํ๋์ง ํด์์ ์ผ๋ก ๊ท๋ช . | |
| **์ฒดํ**: ์ฌ๋ผ์ด๋๋ฅผ ์กฐ์ ํด ๊ทธ๋กํน์ด ์ธ์ ๋ฐ์ํ๋์ง ์ง์ ํ์ธํ์ธ์. | |
| - `ํ๋ จ ๋ฐ์ดํฐ ์` โ โ ์๊ธฐ ๊ธฐ๊ฐ ๋ ๊ธธ์ด์ง | |
| - `์ ๊ทํ ๊ฐ๋` โ โ ์ผ๋ฐํ ์ด์ง (๊ทธ๋กํน ๊ฐ์) | |
| """) | |
| with gr.Row(): | |
| n_train = gr.Slider(5, 50, value=15, step=5, label="ํ๋ จ ๋ฐ์ดํฐ ์ (N)") | |
| wd = gr.Slider(0.001, 0.1, value=0.01, step=0.001, label="์ ๊ทํ ๊ฐ๋ (weight_decay)") | |
| n_ep = gr.Slider(100, 2000, value=500, step=100, label="ํ์ต epoch ์") | |
| btn = gr.Button("์๋ฎฌ๋ ์ด์ ์คํ", variant="primary") | |
| plot = gr.Plot() | |
| btn.click(grokking_simulation, inputs=[n_train, wd, n_ep], outputs=plot) | |
| # โโ Tab 2: Quantum vs Classical โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| def quantum_classical_viz(n_max: int): | |
| ns = np.arange(1, n_max + 1) | |
| classical = ns ** 2 # O(nยฒ) โ typical classical linear system solver | |
| quantum_inspired = ns * np.log(ns) ** 2 # quantum-inspired classical (best known) | |
| quantum = np.log(ns) ** 2 # quantum algorithm (polylog) | |
| fig = go.Figure() | |
| fig.add_trace(go.Scatter(x=ns, y=classical, name="๊ณ ์ ์๊ณ ๋ฆฌ์ฆ O(nยฒ)", line=dict(color="#F44336"))) | |
| fig.add_trace(go.Scatter(x=ns, y=quantum_inspired, name="์์์๊ฐ ๊ณ ์ O(nยทlogยฒn)", line=dict(color="#FF9800"))) | |
| fig.add_trace(go.Scatter(x=ns, y=quantum, name="์์ ์๊ณ ๋ฆฌ์ฆ O(logยฒn)", line=dict(color="#4CAF50"))) | |
| fig.update_layout( | |
| title=f"์์ vs ๊ณ ์ ์๊ณ ๋ฆฌ์ฆ ๋ณต์ก๋ ๋น๊ต (N=1~{n_max})", | |
| xaxis_title="๋ฌธ์ ํฌ๊ธฐ N", yaxis_title="๊ณ์ฐ ๋จ๊ณ ์ (์๋์ )", | |
| template="plotly_dark", height=450, | |
| yaxis_type="log" | |
| ) | |
| return fig | |
| def build_quantum_tab(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ## ๐ An Exponential Separation Between Quantum and Classical Algorithms | |
| **ICML 2026 Spotlight** | Grรธnlund & Larsen (Aarhus Univ.) | |
| > ์ ํ ๋ฐฉ์ ์ ํ๊ธฐ์์ ์์ ์๊ณ ๋ฆฌ์ฆ์ด ๊ณ ์ ์๊ณ ๋ฆฌ์ฆ๋ณด๋ค **์ง์ํจ์์ ์ผ๋ก ๋น ๋ฆ**์ ์ํ์ ์ผ๋ก ์ฆ๋ช . | |
| > "์ง์ ๋ถ๋ฆฌ"๋: ๊ณ ์ ์ปดํจํฐ๊ฐ ๋ฐฑ๋ง ๋ ๊ฑธ๋ฆด ๊ณ์ฐ์ ์์ ์ปดํจํฐ๊ฐ ๋จ ๋ช ์ด์ ์ฒ๋ฆฌ. | |
| **์ฒดํ**: N ์ฌ๋ผ์ด๋๋ฅผ ๋๋ฆด์๋ก ์ธ ์๊ณ ๋ฆฌ์ฆ์ ๊ฒฉ์ฐจ๊ฐ ์ผ๋ง๋ ๋ฒ์ด์ง๋์ง ํ์ธํ์ธ์. | |
| """) | |
| n_max = gr.Slider(10, 500, value=100, step=10, label="๋ฌธ์ ํฌ๊ธฐ N (์ต๋)") | |
| btn = gr.Button("๋น๊ต ์ฐจํธ ์์ฑ", variant="primary") | |
| plot = gr.Plot() | |
| btn.click(quantum_classical_viz, inputs=[n_max], outputs=plot) | |
| # โโ Tab 3: M+Adam vs Adam โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| def madam_simulation(lr: float, beta1: float, noise_scale: float, n_steps: int): | |
| np.random.seed(0) | |
| # Simple 2D quadratic loss: f(x,y) = xยฒ + 10yยฒ | |
| def loss_fn(w): return w[0] ** 2 + 10 * w[1] ** 2 | |
| def grad_fn(w): return np.array([2 * w[0], 20 * w[1]]) | |
| def simulate(optimizer="adam"): | |
| w = np.array([3.0, 2.0]) | |
| m, v = np.zeros(2), np.zeros(2) | |
| beta2 = 0.999 | |
| eps = 1e-8 | |
| losses = [] | |
| for t in range(1, n_steps + 1): | |
| g = grad_fn(w) + np.random.randn(2) * noise_scale | |
| if optimizer == "adam": | |
| m = beta1 * m + (1 - beta1) * g | |
| v = beta2 * v + (1 - beta2) * g ** 2 | |
| m_hat = m / (1 - beta1 ** t) | |
| v_hat = v / (1 - beta2 ** t) | |
| w -= lr * m_hat / (np.sqrt(v_hat) + eps) | |
| else: # M+Adam: split mantissa/exponent optimization | |
| # Mantissa part: high-precision momentum | |
| m = beta1 * m + (1 - beta1) * g | |
| # Exponent part: sign-based update (low precision) | |
| exp_update = np.sign(g) | |
| v = beta2 * v + (1 - beta2) * g ** 2 | |
| m_hat = m / (1 - beta1 ** t) | |
| v_hat = v / (1 - beta2 ** t) | |
| # Blend: 70% mantissa, 30% exponent | |
| update = 0.7 * m_hat / (np.sqrt(v_hat) + eps) + 0.3 * lr * exp_update | |
| w -= lr * update | |
| losses.append(loss_fn(w)) | |
| return losses | |
| steps = np.arange(1, n_steps + 1) | |
| adam_losses = simulate("adam") | |
| madam_losses = simulate("madam") | |
| fig = go.Figure() | |
| fig.add_trace(go.Scatter(x=steps, y=adam_losses, name="Adam (ํ์ค)", line=dict(color="#2196F3"))) | |
| fig.add_trace(go.Scatter(x=steps, y=madam_losses, name="M+Adam (๊ฐ์ยท์ง์ ๋ถ๋ฆฌ)", line=dict(color="#FF5722"))) | |
| fig.update_layout( | |
| title="M+Adam vs Adam โ ์์ค ๊ณก์ ๋น๊ต", | |
| xaxis_title="Step", yaxis_title="Loss", | |
| template="plotly_dark", height=450, yaxis_type="log" | |
| ) | |
| return fig | |
| def build_madam_tab(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ## ๐ M+Adam: Low-Precision Training via MantissaโExponent Optimization | |
| **ICML 2026 Spotlight** | Liang, Loeschcke, Anandkumar et al. | |
| > ์ซ์์ **๊ฐ์๋ถ(mantissa)**์ **์ง์๋ถ(exponent)**๋ฅผ ๋ถ๋ฆฌํ์ฌ ๊ฐ๊ฐ ๋ค๋ฅด๊ฒ ์ต์ ํ โ | |
| > ์ ์ ๋ฐ๋(FP8/INT8)์์๋ Adam ์์ค์ ์์ ์ ํ์ต ๋ฌ์ฑ. | |
| > AI ํ๋ จ ๋น์ฉ ๋ํญ ์ ๊ฐ ๊ฐ๋ฅ. | |
| **์ฒดํ**: ํ๋ผ๋ฏธํฐ๋ฅผ ์กฐ์ ํด M+Adam์ด Adam ๋๋น ์ด๋ป๊ฒ ์๋ ดํ๋์ง ๋น๊ตํ์ธ์. | |
| """) | |
| with gr.Row(): | |
| lr = gr.Slider(0.001, 0.1, value=0.01, step=0.001, label="ํ์ต๋ฅ (lr)") | |
| beta1 = gr.Slider(0.5, 0.99, value=0.9, step=0.01, label="๋ชจ๋ฉํ ฮฒโ") | |
| noise = gr.Slider(0.0, 2.0, value=0.5, step=0.1, label="๊ทธ๋๋์ธํธ ๋ ธ์ด์ฆ") | |
| n_steps = gr.Slider(50, 500, value=200, step=50, label="Step ์") | |
| btn = gr.Button("๋น๊ต ์คํ", variant="primary") | |
| plot = gr.Plot() | |
| btn.click(madam_simulation, inputs=[lr, beta1, noise, n_steps], outputs=plot) | |
| # โโ Tab 4: Linear RNN Parallelism โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| def rnn_parallel_viz(seq_len: int, n_layers: int): | |
| seq_lens = np.arange(1, seq_len + 1) | |
| # Standard RNN: O(T) sequential โ each step depends on previous | |
| rnn_latency = seq_lens * n_layers # strictly sequential | |
| # Linear RNN: can use parallel scan (O(log T) depth) | |
| linear_rnn_latency = np.ceil(np.log2(np.maximum(seq_lens, 1))) * n_layers | |
| # Transformer: O(Tยฒ) attention but fully parallel โ single pass | |
| transformer_latency = np.ones_like(seq_lens) * n_layers # parallel, O(1) depth | |
| fig = go.Figure() | |
| fig.add_trace(go.Scatter(x=seq_lens, y=rnn_latency, name="ํ์ค RNN (์์ฐจ, O(T))", line=dict(color="#F44336"))) | |
| fig.add_trace(go.Scatter(x=seq_lens, y=linear_rnn_latency, name="์ ํ RNN (๋ณ๋ ฌ ์ค์บ, O(log T))", line=dict(color="#4CAF50"))) | |
| fig.add_trace(go.Scatter(x=seq_lens, y=transformer_latency, name="Transformer (์์ ๋ณ๋ ฌ, O(1))", line=dict(color="#2196F3", dash="dot"))) | |
| fig.update_layout( | |
| title=f"RNN ์ ํ๋ณ ๋ณ๋ ฌํ ๊น์ด ๋น๊ต (๋ ์ด์ด {n_layers}๊ฐ)", | |
| xaxis_title="์ํ์ค ๊ธธ์ด T", yaxis_title="๋ณ๋ ฌ ์ฒ๋ฆฌ ๊น์ด (๋ฎ์์๋ก ๋น ๋ฆ)", | |
| template="plotly_dark", height=450 | |
| ) | |
| return fig | |
| def build_rnn_tab(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ## ๐ Why Are Linear RNNs More Parallelizable? | |
| **ICML 2026 Poster** | Merrill, Jiang, Li, Lin, Sabharwal | |
| > ํ์ค RNN์ ๊ฐ ์คํ ์ด ์ด์ ์คํ ์ **์์กด** โ ์์ฐจ ์คํ ๊ฐ์ โ ๋ณ๋ ฌํ ๋ถ๊ฐ. | |
| > ์ ํ RNN์ **๋ณ๋ ฌ ์ค์บ(prefix sum)** ์๊ณ ๋ฆฌ์ฆ ์ ์ฉ ๊ฐ๋ฅ โ O(log T) ๊น์ด๋ก ๋จ์ถ. | |
| > ์ด ๋ ผ๋ฌธ์ ์ด๋ฅผ ๋ณต์ก๋ ํด๋์ค ์ด๋ก ์ผ๋ก ํ์ํ. | |
| **์ฒดํ**: ์ํ์ค ๊ธธ์ด๊ฐ ๋์ด๋ ์๋ก ์ธ ๋ชจ๋ธ์ ๋ณ๋ ฌ ์ฒ๋ฆฌ ๊น์ด๊ฐ ์ด๋ป๊ฒ ๋ฌ๋ผ์ง๋์ง ํ์ธํ์ธ์. | |
| """) | |
| with gr.Row(): | |
| seq_len = gr.Slider(10, 512, value=128, step=16, label="์ํ์ค ๊ธธ์ด T") | |
| n_layers = gr.Slider(1, 24, value=6, step=1, label="๋ ์ด์ด ์") | |
| btn = gr.Button("๋น๊ต ์คํ", variant="primary") | |
| plot = gr.Plot() | |
| btn.click(rnn_parallel_viz, inputs=[seq_len, n_layers], outputs=plot) | |
| # โโ Tab 5: Random Matrix Diffusion โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| def diffusion_consistency_viz(n_steps: int, noise_sigma: float, seed: int): | |
| np.random.seed(seed) | |
| img_size = 32 | |
| # Simulate forward diffusion (noise injection) | |
| clean = np.random.randn(img_size, img_size) * 0.3 + 0.5 | |
| clean = np.clip(clean, 0, 1) | |
| alphas = np.linspace(1.0, 0.0, n_steps + 1) # noise schedule | |
| noisy_imgs = [] | |
| for t in range(n_steps + 1): | |
| alpha = alphas[t] | |
| noise = np.random.randn(img_size, img_size) * noise_sigma | |
| noisy = alpha * clean + (1 - alpha) * noise | |
| noisy_imgs.append(noisy) | |
| # Plot selected timesteps | |
| show_steps = [0, n_steps // 4, n_steps // 2, 3 * n_steps // 4, n_steps] | |
| fig, _ = __import__('matplotlib.pyplot', fromlist=['']), None | |
| import matplotlib.pyplot as plt | |
| fig_mpl, axes = plt.subplots(1, len(show_steps), figsize=(14, 3)) | |
| fig_mpl.patch.set_facecolor('#1a1a2e') | |
| for ax, t in zip(axes, show_steps): | |
| ax.imshow(noisy_imgs[t], cmap='viridis', vmin=-1, vmax=2) | |
| ax.set_title(f't={t}', color='white', fontsize=10) | |
| ax.axis('off') | |
| fig_mpl.suptitle("ํ์ฐ ๊ณผ์ ์๊ฐํ โ ๋ ธ์ด์ฆ ์ฃผ์ (t=0: ์๋ณธ โ t=T: ์์ ๋ ธ์ด์ฆ)", color='white') | |
| fig_mpl.tight_layout() | |
| return fig_mpl | |
| def build_diffusion_tab(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ## ๐ A Random Matrix Perspective on the Consistency of Diffusion Models | |
| **ICML 2026 Honorable Mention** | Wang, Zavatone-Veth, Pehlevan (Harvard) | |
| > ํ์ฐ ๋ชจ๋ธ์ด ์ ๋น์ทํ ์ ๋ ฅ์ ๋น์ทํ ๊ฒฐ๊ณผ๋ฅผ ๋ด๋์ง(์ผ๊ด์ฑ) **๋๋ค ํ๋ ฌ ์ด๋ก **์ผ๋ก ์ํ์ ์ค๋ช . | |
| > ๋ฌด์์ ๊ฐ์ค์น ํ๋ ฌ์ ์คํํธ๋ผ ํน์ฑ โ ํ์ฐ ๊ถค์ ์ ์์ธก ๊ฐ๋ฅ์ฑ์ ์ด๋ก ์ ์ผ๋ก ๊ท๋ช . | |
| **์ฒดํ**: ๋ ธ์ด์ฆ ์ฃผ์ ๊ณผ์ ์ ์ง์ ์๊ฐํ. ์๋ณธ ์ด๋ฏธ์ง๊ฐ ๋จ๊ณ์ ์ผ๋ก ๋ ธ์ด์ฆ๋ก ๋ณํ๋จ. | |
| """) | |
| with gr.Row(): | |
| n_steps = gr.Slider(10, 100, value=40, step=10, label="ํ์ฐ ๋จ๊ณ ์ T") | |
| noise_sigma = gr.Slider(0.1, 2.0, value=0.8, step=0.1, label="๋ ธ์ด์ฆ ๊ฐ๋ ฯ") | |
| seed = gr.Slider(0, 99, value=42, step=1, label="๋๋ค ์๋") | |
| btn = gr.Button("์๊ฐํ", variant="primary") | |
| plot = gr.Plot(label="ํ์ฐ ๊ณผ์ ") | |
| btn.click(diffusion_consistency_viz, inputs=[n_steps, noise_sigma, seed], outputs=plot) | |
| # โโ Tab 6: LM Circuits (ZeroGPU) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| def lm_circuits_demo(text: str, layer_idx: int): | |
| from transformers import GPT2Model, GPT2Tokenizer | |
| import torch | |
| tokenizer = GPT2Tokenizer.from_pretrained("gpt2") | |
| model = GPT2Model.from_pretrained("gpt2", output_hidden_states=True) | |
| model.eval() | |
| inputs = tokenizer(text, return_tensors="pt", max_length=32, truncation=True) | |
| with torch.no_grad(): | |
| outputs = model(**inputs) | |
| # hidden state at chosen layer: [1, seq_len, 768] | |
| hidden = outputs.hidden_states[layer_idx][0].cpu().numpy() # [seq_len, 768] | |
| tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0]) | |
| # Sparsity: fraction of near-zero activations (|h| < threshold) | |
| threshold = 0.1 | |
| sparsity_per_neuron = (np.abs(hidden) < threshold).mean(axis=0) # [768] | |
| sparsity_per_token = (np.abs(hidden) < threshold).mean(axis=1) # [seq_len] | |
| fig = go.Figure() | |
| # Heatmap: tokens ร first 64 neurons | |
| n_show = min(64, hidden.shape[1]) | |
| fig = go.Figure(data=go.Heatmap( | |
| z=hidden[:, :n_show], | |
| x=[f"N{i}" for i in range(n_show)], | |
| y=tokens, | |
| colorscale="RdBu", | |
| zmid=0, | |
| )) | |
| fig.update_layout( | |
| title=f"GPT-2 ๋ ์ด์ด {layer_idx} โ ๋ด๋ฐ ํ์ฑํ ํํธ๋งต (์ฒซ 64๊ฐ ๋ด๋ฐ)\n" | |
| f"์ ์ฒด ๋ด๋ฐ ํฌ์์ฑ: {sparsity_per_neuron.mean():.1%}", | |
| xaxis_title="๋ด๋ฐ ์ธ๋ฑ์ค", yaxis_title="ํ ํฐ", | |
| template="plotly_dark", height=max(300, len(tokens) * 30 + 100) | |
| ) | |
| info = f"๋ ์ด์ด {layer_idx} ํฌ์์ฑ: {sparsity_per_neuron.mean():.1%} (|ํ์ฑํ|<{threshold} ๋น์จ)\n" | |
| info += "ํฌ์์ฑ์ด ๋์์๋ก โ ํ๋ก ํด์์ด ์ฌ์ (๋ ผ๋ฌธ ํต์ฌ ์ฃผ์ฅ)" | |
| return fig, info | |
| def build_circuits_tab(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ## ๐ Language Model Circuits Are Sparse in the Neuron Basis | |
| **ICML 2026 Spotlight** | Arora, Wu, Steinhardt, Schwettmann | |
| > LLM ๋ด๋ถ์ "ํ๋ก"(ํน์ ๊ธฐ๋ฅ์ ์ํํ๋ ๋ด๋ฐ ์งํฉ)๊ฐ **๋ด๋ฐ ๊ธฐ์ ์์ ํฌ์**ํจ์ ์ค์ฆ. | |
| > ๋๋ถ๋ถ ๋ด๋ฐ์ ํน์ ์์ ์ ๊ฑฐ์ ํ์ฑํ๋์ง ์์ โ AI ๋ธ๋๋ฐ์ค ํด์ ๊ฐ๋ฅ์ฑ ํฅ์. | |
| **์ฒดํ**: ํ ์คํธ ์ ๋ ฅ โ GPT-2 ๊ฐ ๋ ์ด์ด์ ๋ด๋ฐ ํ์ฑํ ํจํด ์๊ฐํ. ํฌ์ํ ์๋ก ํ๋ก ํด์ ์ฉ์ด. | |
| *ZeroGPU ์ฌ์ฉ โ ์ฒซ ์คํ ์ ๋ชจ๋ธ ๋ก๋ฉ์ 15โ30์ด ์์๋ ์ ์์ต๋๋ค.* | |
| """) | |
| text_in = gr.Textbox(value="The cat sat on the mat", label="๋ถ์ํ ํ ์คํธ (์์ด)") | |
| layer_idx = gr.Slider(0, 11, value=6, step=1, label="GPT-2 ๋ ์ด์ด ์ธ๋ฑ์ค (0~11)") | |
| btn = gr.Button("ํ์ฑํ ๋ถ์ (ZeroGPU)", variant="primary") | |
| plot = gr.Plot() | |
| info_out = gr.Textbox(label="ํฌ์์ฑ ์ ๋ณด", interactive=False) | |
| btn.click(lm_circuits_demo, inputs=[text_in, layer_idx], outputs=[plot, info_out]) | |
| # โโ Tab 7: Any-Diffusion / SDXL Turbo (ZeroGPU) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| def any_diffusion_demo(prompt: str, n_steps: int, seed: int): | |
| from diffusers import AutoPipelineForText2Image | |
| import torch | |
| pipe = AutoPipelineForText2Image.from_pretrained( | |
| "stabilityai/sdxl-turbo", | |
| torch_dtype=torch.float16, | |
| variant="fp16" | |
| ).to("cuda") | |
| generator = torch.Generator("cuda").manual_seed(seed) | |
| image = pipe( | |
| prompt=prompt, | |
| num_inference_steps=n_steps, | |
| guidance_scale=0.0, | |
| generator=generator, | |
| ).images[0] | |
| return image | |
| def build_anydiff_tab(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ## ๐ Any-Diffusion: Unified Multimodal Understanding and Generation | |
| **ICML 2026 Poster** | Li, Long, Shen, Gao, Cao et al. | |
| > ํ ์คํธยท์ด๋ฏธ์งยท์์ฑ์ **any-to-any** ๋ฐฉ์์ผ๋ก ํตํฉ ์ฒ๋ฆฌํ๋ ํ์ฐ ๋ชจ๋ธ. | |
| > ๋ง์คํฌ ๊ธฐ๋ฐ ์ด์ฐ ํ์ฐ์ผ๋ก ๋ชจ๋ฌ๋ฆฌํฐ ๊ฒฝ๊ณ๋ฅผ ์ ๊ฑฐ. | |
| **์ฒดํ**: ํ๋กฌํํธ ์ ๋ ฅ โ ์ด๋ฏธ์ง ์์ฑ (SDXL-Turbo, Any-Diffusion ๊ฐ๋ ๊ตฌํ์ฒด). | |
| SDXL-Turbo๋ ๋จ 1โ4 step์ผ๋ก ๊ณ ํ์ง ์ด๋ฏธ์ง ์์ฑ โ Any-Diffusion์ ํจ์จ์ฑ ๊ฐ๋ ๊ณผ ๋์ผ์ ์. | |
| *ZeroGPU ์ฌ์ฉ โ ์ฒซ ์คํ ์ ๋ชจ๋ธ ๋ก๋ฉ์ 20โ40์ด ์์๋ ์ ์์ต๋๋ค.* | |
| """) | |
| prompt = gr.Textbox(value="a futuristic AI laboratory with neural network visualizations", label="์ด๋ฏธ์ง ํ๋กฌํํธ (์์ด)") | |
| with gr.Row(): | |
| n_steps = gr.Slider(1, 4, value=2, step=1, label="์ถ๋ก ์คํ ์ (1โ4)") | |
| seed = gr.Slider(0, 9999, value=42, step=1, label="์๋") | |
| btn = gr.Button("์ด๋ฏธ์ง ์์ฑ (ZeroGPU)", variant="primary") | |
| img_out = gr.Image(label="์์ฑ ์ด๋ฏธ์ง") | |
| btn.click(any_diffusion_demo, inputs=[prompt, n_steps, seed], outputs=img_out) | |
| # โโ Tab 8: Flexibility Trap (LLM API comparison) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| def flexibility_trap_demo(prompt: str, max_new_tokens: int): | |
| """Compare autoregressive (fixed order) vs masked diffusion LM (random order) generation.""" | |
| from transformers import GPT2LMHeadModel, GPT2Tokenizer | |
| import torch | |
| tokenizer = GPT2Tokenizer.from_pretrained("gpt2") | |
| model = GPT2LMHeadModel.from_pretrained("gpt2").to("cuda") | |
| model.eval() | |
| inputs = tokenizer(prompt, return_tensors="pt").to("cuda") | |
| input_len = inputs["input_ids"].shape[1] | |
| # 1. Standard autoregressive (left-to-right, fixed order) | |
| with torch.no_grad(): | |
| out_ar = model.generate( | |
| **inputs, | |
| max_new_tokens=max_new_tokens, | |
| do_sample=True, | |
| temperature=0.8, | |
| pad_token_id=tokenizer.eos_token_id, | |
| ) | |
| text_ar = tokenizer.decode(out_ar[0][input_len:], skip_special_tokens=True) | |
| # 2. Simulate "arbitrary order" by shuffling generation positions | |
| # (simplified proxy โ actual diffusion LM requires MDLM architecture) | |
| with torch.no_grad(): | |
| out_perm1 = model.generate( | |
| **inputs, | |
| max_new_tokens=max_new_tokens, | |
| do_sample=True, | |
| temperature=1.2, # higher temp = more "random" order effect | |
| pad_token_id=tokenizer.eos_token_id, | |
| ) | |
| text_perm1 = tokenizer.decode(out_perm1[0][input_len:], skip_special_tokens=True) | |
| with torch.no_grad(): | |
| out_perm2 = model.generate( | |
| **inputs, | |
| max_new_tokens=max_new_tokens, | |
| do_sample=True, | |
| temperature=1.2, | |
| pad_token_id=tokenizer.eos_token_id, | |
| ) | |
| text_perm2 = tokenizer.decode(out_perm2[0][input_len:], skip_special_tokens=True) | |
| result = f"""[๊ณ ์ ์์ ์์ฑ (Autoregressive โ ์ผ์ชฝโ์ค๋ฅธ์ชฝ)] | |
| {text_ar} | |
| [์์ ์์ ์๋ฎฌ๋ ์ด์ #1 (higher temperature)] | |
| {text_perm1} | |
| [์์ ์์ ์๋ฎฌ๋ ์ด์ #2] | |
| {text_perm2} | |
| โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| ๋ ผ๋ฌธ ํต์ฌ: ์์ ์์ ์์ฑ์ ํ๋ฉด์ ์ผ๋ก ๋ค์ํด ๋ณด์ด์ง๋ง | |
| ์ค์ ์ถ๋ก ๊ฒฝ๋ก์ ๋ค์์ฑ์ ์คํ๋ ค ๋ฎ์์ง๋๋ค (The Flexibility Trap). | |
| ๊ณ ์ ์์ ์์ฑ #1์ด ๋๋ถ๋ถ์ ๋ฒค์น๋งํฌ์์ ๋ ์ผ๊ด๋ ์ถ๋ก ์ ๋ณด์ ๋๋ค.""" | |
| return result | |
| def build_flexibility_tab(): | |
| with gr.Column(): | |
| gr.Markdown(""" | |
| ## ๐ The Flexibility Trap: Rethinking the Value of Arbitrary Order in Diffusion LMs | |
| **ICML 2026 Outstanding Paper** | Ni, Wang, Yue et al. | |
| > ํ์ฐ ์ธ์ด ๋ชจ๋ธ์ **์์ ์์ ์์ฑ**์ด ์ถ๋ก ๋ค์์ฑ์ ์คํ๋ ค ๋ฎ์ถ๋ค๋ ์ญ์ค์ ๋ฐ๊ฒฌ. | |
| > "์ ์ฐํ ์๋ก ๋ ํ์ผ์ " โ JustGRPO ํ๋ จ์ผ๋ก ๊ฐ์ . | |
| **์ฒดํ**: ๊ฐ์ ํ๋กฌํํธ๋ก ๊ณ ์ ์์ vs ์์ ์์ ์์ฑ ๊ฒฐ๊ณผ๋ฅผ ๋น๊ตํ์ธ์. | |
| (GPT-2๋ก ๊ฐ๋ ์์ฐ โ ์ค์ ํ์ฐ LM ํ๋์ proxy) | |
| *ZeroGPU ์ฌ์ฉ* | |
| """) | |
| prompt = gr.Textbox(value="The future of artificial intelligence will", label="์์ ํ๋กฌํํธ") | |
| max_tokens = gr.Slider(20, 100, value=40, step=10, label="์์ฑ ํ ํฐ ์") | |
| btn = gr.Button("์์ฑ ๋น๊ต (ZeroGPU)", variant="primary") | |
| out = gr.Textbox(label="์์ฑ ๊ฒฐ๊ณผ ๋น๊ต", lines=12) | |
| btn.click(flexibility_trap_demo, inputs=[prompt, max_tokens], outputs=out) | |
| # โโ Main App โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| with gr.Blocks( | |
| title="AI Paper Lab โ ICML 2026", | |
| theme=gr.themes.Base(primary_hue="violet"), | |
| css=""" | |
| .paper-header { background: linear-gradient(135deg, #1a1a2e, #16213e); padding: 20px; border-radius: 10px; margin-bottom: 10px; } | |
| """ | |
| ) as demo: | |
| gr.Markdown(""" | |
| # AI Paper Lab | |
| ### ICML 2026 ์ฃผ์ ๋ ผ๋ฌธ์ ์ง์ ์ฒดํํ์ธ์ | |
| ๊ฐ ํญ์์ ๋ ผ๋ฌธ์ ํต์ฌ ๊ฐ๋ ์ ์ธํฐ๋ํฐ๋ธํ๊ฒ ๊ฒฝํํ ์ ์์ต๋๋ค. | |
| CPU ํญ์ ์ฆ์ ์คํ, ZeroGPU ํญ์ ์ฒซ ์คํ ์ 20โ40์ด ๋๊ธฐ ๋ฐ์. | |
| """) | |
| with gr.Tabs(): | |
| with gr.Tab("1. Grok Grokking (CPU)"): | |
| build_grokking_tab() | |
| with gr.Tab("2. Quantum vs Classical (CPU)"): | |
| build_quantum_tab() | |
| with gr.Tab("3. M+Adam (CPU)"): | |
| build_madam_tab() | |
| with gr.Tab("4. Linear RNN (CPU)"): | |
| build_rnn_tab() | |
| with gr.Tab("5. Diffusion ์๊ฐํ (CPU)"): | |
| build_diffusion_tab() | |
| with gr.Tab("6. LM Circuits (ZeroGPU)"): | |
| build_circuits_tab() | |
| with gr.Tab("7. Any-Diffusion (ZeroGPU)"): | |
| build_anydiff_tab() | |
| with gr.Tab("8. Flexibility Trap (ZeroGPU)"): | |
| build_flexibility_tab() | |
| if __name__ == "__main__": | |
| demo.launch() | |