tahamajs commited on
Commit
c79c066
·
verified ·
1 Parent(s): 704efe6

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +45 -22
README.md CHANGED
@@ -3,7 +3,6 @@ license: apache-2.0
3
  tags:
4
  - diffusion
5
  - flow-matching
6
- - rectified-flow
7
  - text-generation
8
  - reasoning
9
  - qwen2.5
@@ -13,47 +12,71 @@ language:
13
  - en
14
  ---
15
 
16
- # BlockDiffuse: Parallel Multi-Block Reasoning Generation in Latent Space
17
 
18
- **BlockDiffuse** is a non-autoregressive / block-autoregressive diffusion framework that generates entire blocks of 100 tokens simultaneously in continuous latent space using Rectified Flow Matching.
 
 
 
19
 
20
- By coupling a Diffusion Transformer (DiT) with a frozen decoder-only Base LLM (`Qwen/Qwen2.5-0.5B-Instruct`), BlockDiffuse bypasses token-by-token sequential decoding, achieving parallel multi-token throughput.
21
 
22
- ## Model Summary
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- - **Base LLM**: `Qwen/Qwen2.5-0.5B-Instruct`
25
- - **DiT Architecture**: 8 Transformer Blocks with 14 Attention Heads ($d_\text{model}=896$, head dim 64)
26
- - **Latent Space**: Mid-layer representations (layer 12) for prompt conditioning; target 100-token blocks supervised via Flow Matching.
27
- - **Initialization**: Transfer learning from layers 6–11 of Qwen2.5-0.5B.
28
- - **Projection Head**: Deep 3-layer MLP residual adapter before RMSNorm and discrete token decoding.
29
- - **Training Objectives**: Flow Matching Velocity MSE ($\mathcal{L}_\text{FM}$) + Dispersive Loss + Teacher KL Distillation + Discrete Token Cross-Entropy ($\mathcal{L}_\text{CE}$) + Contrastive InfoNCE Nearest-Neighbor Loss ($\mathcal{L}_\text{NN}$).
30
 
31
- ## Benchmark Results on RTX 4070 Laptop GPU
 
 
 
 
32
 
33
- | Mode | Tokens | Diffusion Steps | Latency | Throughput |
34
  | :--- | :--- | :--- | :--- | :--- |
35
- | **Single-Block Parallel** | 100 tokens | 8 ODE steps (DPM-Solver + TFE) | **1,730.60 ms** | **57.78 tokens/sec** |
36
- | **Multi-Block Autoregressive** | 200 tokens (2 blocks) | 8 ODE steps per block | **1,279.20 ms** | **156.35 tokens/sec** |
 
 
 
 
37
 
38
- ## Quickstart & Inference
39
 
40
- To run inference using the official repository [Hooshaai/BlockDiffuse](https://github.com/Hooshaai/BlockDiffuse):
41
 
42
  ```bash
 
43
  git clone https://github.com/Hooshaai/BlockDiffuse.git
44
  cd BlockDiffuse
45
 
 
46
  python inference.py \
47
  --model Qwen/Qwen2.5-0.5B-Instruct \
48
- --checkpoint ./blockdiffuse_final.pt \
49
- --prompt "<|im_start|>system\nYou are a helpful assistant that solves problems step by step.<|im_end|>\n<|im_start|>user\nA bookstore has 140 books on Monday. On Tuesday, they sell 45 books. On Wednesday, they receive 80 books. How many remain?<|im_end|>\n<|im_start|>assistant\n" \
 
50
  --steps 8 \
51
  --solver dpm_solver \
52
- --use_tfe \
53
- --tfe_seeds 3
54
  ```
55
 
56
- ## Citation
57
 
58
  ```bibtex
59
  @software{blockdiffuse2026,
 
3
  tags:
4
  - diffusion
5
  - flow-matching
 
6
  - text-generation
7
  - reasoning
8
  - qwen2.5
 
12
  - en
13
  ---
14
 
15
+ # 🚀 BlockDiffuse: Fully Parallel Latent Space Reasoning Generation
16
 
17
+ <div align="center">
18
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/text-generation.png" alt="Text Generation" width="400"/>
19
+ </div>
20
+ <br/>
21
 
22
+ > **TL;DR:** BlockDiffuse is a novel generative framework that bypasses the autoregressive token-by-token bottleneck of LLMs. By combining a **Diffusion Transformer (DiT)** with **Rectified Flow Matching** and a frozen Qwen2.5-0.5B-Instruct, it generates **100-token blocks in parallel** in continuous latent space, achieving over **150 tokens/sec** on a laptop GPU!
23
 
24
+ ---
25
+
26
+ ## 📖 The Problem: The Autoregressive Bottleneck
27
+
28
+ Traditional Large Language Models (LLMs) generate text autoregressively—one token at a time. While highly effective, this creates a severe latency bottleneck, especially for complex reasoning tasks (like math or coding) that require long "chain-of-thought" sequences before arriving at an answer. Because the model must perform a full forward pass for *every single token*, latency scales linearly with the sequence length.
29
+
30
+ ## 💡 The Solution: BlockDiffuse
31
+
32
+ What if we could generate an entire paragraph of thoughts at once?
33
+
34
+ **BlockDiffuse** shifts text generation from discrete token classification to **continuous continuous latent space trajectory modeling**.
35
+ We map sequences of 100 discrete tokens into a continuous embedding space using the deep layers of a pre-trained LLM. Then, a DiT learns to denoise pure Gaussian noise into these 100-token latent representations simultaneously.
36
 
37
+ ### 🏗️ Architecture Deep Dive
38
+ 1. **Base LLM:** `Qwen/Qwen2.5-0.5B-Instruct` (Frozen). We use the first 12 layers for processing the prompt and the final language modeling head for decoding latents back to text.
39
+ 2. **Diffusion Transformer (DiT):** An 8-layer, 14-head ($d_\text{model}=896$) transformer initialized via transfer learning from Qwen's intermediate layers.
40
+ 3. **Deep Projection Head:** A 3-layer MLP residual adapter that perfectly bridges the gap between the diffusion output space and the discrete token space.
41
+ 4. **Flow Matching:** Instead of standard DDPM, we use **Rectified Flow Matching** with an ODE solver (DPM-Solver) allowing for ultra-fast generation in just 8 steps.
42
+ 5. **Loss Objectives:** A sophisticated multi-objective setup combining Velocity MSE ($\mathcal{L}_\text{FM}$), Teacher KL Distillation, Discrete Token Cross-Entropy ($\mathcal{L}_\text{CE}$), and Contrastive InfoNCE ($\mathcal{L}_\text{NN}$).
43
 
44
+ ---
45
+
46
+ ## ⚡ Benchmark Results (RTX 4070 Laptop 8GB)
47
+
48
+ BlockDiffuse achieves remarkable throughput by solving the ODE block-by-block instead of token-by-token.
49
 
50
+ | Mode | Generation Size | Diffusion Steps | Latency | Throughput |
51
  | :--- | :--- | :--- | :--- | :--- |
52
+ | **Single-Block Parallel** | 100 tokens | 8 ODE steps | **1.73 seconds** | **57.78 tokens/sec** |
53
+ | **Multi-Block Reasoning** | 200 tokens (2 blocks) | 8 ODE steps / block | **1.27 seconds** | **156.35 tokens/sec** |
54
+
55
+ *(Using DPM-Solver with Training-Free Ensemble (TFE) k=3 seeds)*
56
+
57
+ ---
58
 
59
+ ## 💻 Quickstart & Inference
60
 
61
+ Want to run this yourself? Clone the official repository and use our inference script!
62
 
63
  ```bash
64
+ # 1. Clone the repository
65
  git clone https://github.com/Hooshaai/BlockDiffuse.git
66
  cd BlockDiffuse
67
 
68
+ # 2. Run parallel multi-block reasoning
69
  python inference.py \
70
  --model Qwen/Qwen2.5-0.5B-Instruct \
71
+ --checkpoint ./checkpoints_improved/blockdiffuse_final.pt \
72
+ --prompt "<|im_start|>system\nYou are a helpful assistant that solves problems step by step.<|im_end|>\n<|im_start|>user\nJanet has 3 bags of 10 apples. She gives 5 apples to her friend and eats 2. How many apples does she have left?<|im_end|>\n<|im_start|>assistant\n" \
73
+ --max_blocks 2 \
74
  --steps 8 \
75
  --solver dpm_solver \
76
+ --use_tfe
 
77
  ```
78
 
79
+ ## 📝 Citation
80
 
81
  ```bibtex
82
  @software{blockdiffuse2026,