Text Generation
Transformers
recurrent_qwen
recurrent-depth
latent-reasoning
qwen2.5
research
custom_code
Instructions to use mshapiro123/recurrent-qwen2.5-0.5b-full-block with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mshapiro123/recurrent-qwen2.5-0.5b-full-block with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mshapiro123/recurrent-qwen2.5-0.5b-full-block", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("mshapiro123/recurrent-qwen2.5-0.5b-full-block", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mshapiro123/recurrent-qwen2.5-0.5b-full-block with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mshapiro123/recurrent-qwen2.5-0.5b-full-block" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mshapiro123/recurrent-qwen2.5-0.5b-full-block", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mshapiro123/recurrent-qwen2.5-0.5b-full-block
- SGLang
How to use mshapiro123/recurrent-qwen2.5-0.5b-full-block with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mshapiro123/recurrent-qwen2.5-0.5b-full-block" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mshapiro123/recurrent-qwen2.5-0.5b-full-block", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mshapiro123/recurrent-qwen2.5-0.5b-full-block" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mshapiro123/recurrent-qwen2.5-0.5b-full-block", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mshapiro123/recurrent-qwen2.5-0.5b-full-block with Docker Model Runner:
docker model run hf.co/mshapiro123/recurrent-qwen2.5-0.5b-full-block
File size: 17,178 Bytes
5795c01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | <?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 1280 900" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Paper One architecture comparison diagram">
<defs>
<marker id="arr" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M0,0 L10,5 L0,10 z" fill="#4B5563"/>
</marker>
<marker id="arrB" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M0,0 L10,5 L0,10 z" fill="#2563EB"/>
</marker>
<marker id="arrA" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M0,0 L10,5 L0,10 z" fill="#B45309"/>
</marker>
</defs>
<!-- ===================== HEADER ===================== -->
<text x="30" y="34" font-size="19" font-weight="700" fill="#111827">The base model and its recurrent retrofits</text>
<text x="30" y="56" font-size="12" fill="#6B7280">Qwen2.5-0.5B-Instruct · split at layers 6 and 18 · forced depth: loops = task depth (no learned halting)</text>
<!-- legend -->
<rect x="880" y="24" width="14" height="10" fill="#E8E8E6" stroke="#7A7A75"/>
<text x="900" y="33" font-size="9.5" fill="#4B5563">pretrained, unchanged</text>
<rect x="880" y="40" width="14" height="10" fill="#EFF4FF" stroke="#2563EB"/>
<text x="900" y="49" font-size="9.5" fill="#4B5563">trained — full-block budget (180.6M)</text>
<rect x="880" y="56" width="14" height="10" fill="#FEF3E2" stroke="#B45309"/>
<text x="900" y="65" font-size="9.5" fill="#4B5563">trained — adapter budget (6.01M, base frozen)</text>
<!-- ===================== PANEL 1: BASE MODEL ===================== -->
<rect x="20" y="80" width="400" height="540" rx="10" fill="#F6F6F3" stroke="#E2E2DE"/>
<text x="36" y="108" font-size="13.5" font-weight="700" fill="#111827">Base model — dense</text>
<rect x="70" y="130" width="300" height="36" rx="6" fill="#FFFFFF" stroke="#9CA3AF"/>
<text x="220" y="152" font-size="10.5" fill="#1F2937" text-anchor="middle">tokens</text>
<line x1="220" y1="166" x2="220" y2="188" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<rect x="70" y="190" width="300" height="248" rx="6" fill="#E8E8E6" stroke="#7A7A75" stroke-width="1.5"/>
<text x="220" y="288" font-size="11" fill="#333" text-anchor="middle" font-weight="600">24 decoder layers — 0 to 23</text>
<text x="220" y="306" font-size="9.5" fill="#6B7280" text-anchor="middle">executed once, in order</text>
<text x="220" y="322" font-size="9.5" fill="#6B7280" text-anchor="middle">depth fixed by the architecture</text>
<text x="220" y="352" font-size="8.5" fill="#6B7280" text-anchor="middle">24 × 14.91M = 357.9M layer parameters</text>
<text x="220" y="366" font-size="8.5" fill="#6B7280" text-anchor="middle">tied embedding, LM head, and norms: 136.1M</text>
<text x="220" y="380" font-size="8.5" fill="#6B7280" text-anchor="middle">494.0M unique parameters</text>
<line x1="220" y1="438" x2="220" y2="452" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<rect x="70" y="454" width="300" height="40" rx="6" fill="#FFFFFF" stroke="#9CA3AF"/>
<text x="220" y="478" font-size="10.5" fill="#1F2937" text-anchor="middle">LM head — token logits</text>
<text x="220" y="530" font-size="10" fill="#374151" text-anchor="middle" font-weight="600">more computation requires more tokens</text>
<text x="220" y="548" font-size="9.5" fill="#6B7280" text-anchor="middle">(the scratchpad recipe serializes its reasoning here)</text>
<!-- ===================== PANEL 2: FULL-BLOCK RETROFIT ===================== -->
<rect x="440" y="80" width="400" height="540" rx="10" fill="#F6F6F3" stroke="#E2E2DE"/>
<text x="456" y="108" font-size="13.5" font-weight="700" fill="#111827">Full-block retrofit</text>
<rect x="470" y="130" width="230" height="36" rx="6" fill="#FFFFFF" stroke="#9CA3AF"/>
<text x="585" y="152" font-size="10.5" fill="#1F2937" text-anchor="middle">tokens</text>
<line x1="585" y1="166" x2="585" y2="188" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<rect x="470" y="190" width="230" height="52" rx="6" fill="#E8E8E6" stroke="#7A7A75"/>
<text x="585" y="207" font-size="10.5" fill="#333" text-anchor="middle" font-weight="600">Prelude — layers 0–5</text>
<text x="585" y="221" font-size="8.5" fill="#6B7280" text-anchor="middle">pretrained, unchanged → output p</text>
<text x="585" y="235" font-size="8.5" fill="#6B7280" text-anchor="middle">6 layers · 89.5M</text>
<line x1="585" y1="242" x2="585" y2="250" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<!-- p re-injection path into bridge -->
<path d="M700,212 L770,212 L770,254" fill="none" stroke="#2563EB" stroke-width="1.3" marker-end="url(#arrB)"/>
<text x="736" y="205" font-size="8.5" fill="#1E40AF" text-anchor="middle">p, re-injected</text>
<rect x="470" y="252" width="230" height="116" rx="6" fill="#EFF4FF" stroke="#2563EB" stroke-width="1.5"/>
<text x="585" y="274" font-size="10.5" fill="#1E40AF" text-anchor="middle" font-weight="600">Recurrent Block — layers 6–17</text>
<text x="585" y="293" font-size="9" fill="#1E40AF" text-anchor="middle">12 layers, weight-tied · 12 × 14.91M = 178.9M</text>
<text x="585" y="310" font-size="9" fill="#1E40AF" text-anchor="middle">every block weight trained</text>
<text x="585" y="340" font-size="8.5" fill="#2563EB" text-anchor="middle">loop 1 input is p · later loops input u from the bridge</text>
<!-- feedback loop through the bridge -->
<line x1="700" y1="330" x2="714" y2="330" stroke="#2563EB" stroke-width="1.4" marker-end="url(#arrB)"/>
<text x="707" y="324" font-size="8" fill="#1E40AF" text-anchor="middle">h</text>
<rect x="716" y="256" width="108" height="100" rx="6" fill="#EFF4FF" stroke="#2563EB" stroke-width="1.5"/>
<text x="770" y="274" font-size="8.5" fill="#1E40AF" text-anchor="middle" font-weight="700">split re-entry bridge</text>
<text x="770" y="292" font-size="8.5" fill="#1E40AF" text-anchor="middle">W<tspan dy="2" font-size="6.5">p</tspan><tspan dy="-2">·p + W</tspan><tspan dy="2" font-size="6.5">s</tspan><tspan dy="-2">·h</tspan></text>
<text x="770" y="308" font-size="8.5" fill="#1E40AF" text-anchor="middle">identity-biased gate</text>
<text x="770" y="324" font-size="8" fill="#2563EB" text-anchor="middle">→ u, the next loop's input</text>
<text x="770" y="344" font-size="8.5" fill="#1E40AF" text-anchor="middle" font-weight="600">1.61M trained</text>
<line x1="716" y1="272" x2="702" y2="272" stroke="#2563EB" stroke-width="1.4" marker-end="url(#arrB)"/>
<text x="709" y="264" font-size="8" fill="#1E40AF" text-anchor="middle">u</text>
<text x="770" y="370" font-size="8.5" fill="#6B7280" text-anchor="middle">loops 2…T</text>
<line x1="585" y1="368" x2="585" y2="382" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<rect x="470" y="384" width="230" height="52" rx="6" fill="#E8E8E6" stroke="#7A7A75"/>
<text x="585" y="401" font-size="10.5" fill="#333" text-anchor="middle" font-weight="600">Coda — layers 18–23</text>
<text x="585" y="415" font-size="8.5" fill="#6B7280" text-anchor="middle">pretrained, unchanged</text>
<text x="585" y="429" font-size="8.5" fill="#6B7280" text-anchor="middle">6 layers · 89.5M</text>
<line x1="585" y1="436" x2="585" y2="450" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<rect x="470" y="452" width="230" height="40" rx="6" fill="#EFF4FF" stroke="#2563EB" stroke-width="1.5"/>
<text x="585" y="476" font-size="10" fill="#1E40AF" text-anchor="middle" font-weight="600">decoded state at loop T — the answer</text>
<text x="640" y="530" font-size="10" fill="#374151" text-anchor="middle" font-weight="600">trained: block 178.9M + bridge 1.61M = 180.6M forward-active</text>
<text x="640" y="548" font-size="9.5" fill="#6B7280" text-anchor="middle">T = 1 bypasses the bridge and recurrent additions entirely,</text>
<text x="640" y="562" font-size="9.5" fill="#6B7280" text-anchor="middle">reproducing the base computation exactly</text>
<!-- ===================== PANEL 3: ADAPTER RETROFIT ===================== -->
<rect x="860" y="80" width="400" height="540" rx="10" fill="#F6F6F3" stroke="#E2E2DE"/>
<text x="876" y="108" font-size="13.5" font-weight="700" fill="#111827">Adapter retrofit — same surgery</text>
<rect x="890" y="130" width="230" height="36" rx="6" fill="#FFFFFF" stroke="#9CA3AF"/>
<text x="1005" y="152" font-size="10.5" fill="#1F2937" text-anchor="middle">tokens</text>
<line x1="1005" y1="166" x2="1005" y2="188" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<rect x="890" y="190" width="230" height="52" rx="6" fill="#E8E8E6" stroke="#7A7A75"/>
<text x="1005" y="207" font-size="10.5" fill="#333" text-anchor="middle" font-weight="600">Prelude — layers 0–5</text>
<text x="1005" y="221" font-size="8.5" fill="#6B7280" text-anchor="middle">frozen → output p</text>
<text x="1005" y="235" font-size="8.5" fill="#6B7280" text-anchor="middle">6 layers · 89.5M</text>
<line x1="1005" y1="242" x2="1005" y2="250" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<!-- p re-injection path into bridge -->
<path d="M1120,212 L1190,212 L1190,254" fill="none" stroke="#B45309" stroke-width="1.3" marker-end="url(#arrA)"/>
<text x="1156" y="205" font-size="8.5" fill="#7C3E06" text-anchor="middle">p, re-injected</text>
<rect x="890" y="252" width="230" height="116" rx="6" fill="#E8E8E6" stroke="#7A7A75" stroke-width="1.5"/>
<text x="1005" y="270" font-size="10.5" fill="#333" text-anchor="middle" font-weight="600">Recurrent Block — layers 6–17</text>
<text x="1005" y="285" font-size="8.5" fill="#6B7280" text-anchor="middle">12 layers, weight-tied, frozen — 178.9M</text>
<!-- LoRA composition mini-diagram -->
<rect x="906" y="294" width="88" height="18" rx="3" fill="#FFFFFF" stroke="#7A7A75"/>
<text x="950" y="307" font-size="8" fill="#4B5563" text-anchor="middle">W — frozen</text>
<rect x="906" y="318" width="112" height="18" rx="3" fill="#FEF3E2" stroke="#B45309"/>
<text x="962" y="331" font-size="8" fill="#7C3E06" text-anchor="middle">ΔW = A·B — rank 16, trained</text>
<line x1="994" y1="303" x2="1043" y2="312" stroke="#4B5563" stroke-width="1.1" marker-end="url(#arr)"/>
<line x1="1018" y1="327" x2="1043" y2="320" stroke="#B45309" stroke-width="1.1" marker-end="url(#arrA)"/>
<circle cx="1052" cy="316" r="9" fill="#FFFFFF" stroke="#374151"/>
<text x="1052" y="320" font-size="10" fill="#111827" text-anchor="middle" font-weight="700">+</text>
<line x1="1061" y1="316" x2="1078" y2="316" stroke="#4B5563" stroke-width="1.1" marker-end="url(#arr)"/>
<text x="1096" y="313" font-size="8" fill="#374151" text-anchor="middle">every block</text>
<text x="1096" y="323" font-size="8" fill="#374151" text-anchor="middle">projection</text>
<text x="1005" y="354" font-size="8.5" fill="#7C3E06" text-anchor="middle">ΔW ≈ 4.40M over 84 projections — applied at every loop</text>
<!-- feedback loop through the bridge -->
<line x1="1120" y1="330" x2="1134" y2="330" stroke="#B45309" stroke-width="1.4" marker-end="url(#arrA)"/>
<text x="1127" y="324" font-size="8" fill="#7C3E06" text-anchor="middle">h</text>
<rect x="1136" y="256" width="108" height="100" rx="6" fill="#FEF3E2" stroke="#B45309" stroke-width="1.5"/>
<text x="1190" y="274" font-size="8.5" fill="#7C3E06" text-anchor="middle" font-weight="700">split re-entry bridge</text>
<text x="1190" y="292" font-size="8.5" fill="#7C3E06" text-anchor="middle">W<tspan dy="2" font-size="6.5">p</tspan><tspan dy="-2">·p + W</tspan><tspan dy="2" font-size="6.5">s</tspan><tspan dy="-2">·h</tspan></text>
<text x="1190" y="308" font-size="8.5" fill="#7C3E06" text-anchor="middle">identity-biased gate</text>
<text x="1190" y="324" font-size="8" fill="#B45309" text-anchor="middle">→ u, the next loop's input</text>
<text x="1190" y="344" font-size="8.5" fill="#7C3E06" text-anchor="middle" font-weight="600">1.61M trained</text>
<line x1="1136" y1="272" x2="1122" y2="272" stroke="#B45309" stroke-width="1.4" marker-end="url(#arrA)"/>
<text x="1129" y="264" font-size="8" fill="#7C3E06" text-anchor="middle">u</text>
<text x="1190" y="370" font-size="8.5" fill="#6B7280" text-anchor="middle">loops 2…T</text>
<line x1="1005" y1="368" x2="1005" y2="382" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<rect x="890" y="384" width="230" height="52" rx="6" fill="#E8E8E6" stroke="#7A7A75"/>
<text x="1005" y="401" font-size="10.5" fill="#333" text-anchor="middle" font-weight="600">Coda — layers 18–23</text>
<text x="1005" y="415" font-size="8.5" fill="#6B7280" text-anchor="middle">frozen</text>
<text x="1005" y="429" font-size="8.5" fill="#6B7280" text-anchor="middle">6 layers · 89.5M</text>
<line x1="1005" y1="436" x2="1005" y2="450" stroke="#4B5563" stroke-width="1.4" marker-end="url(#arr)"/>
<rect x="890" y="452" width="230" height="40" rx="6" fill="#FEF3E2" stroke="#B45309" stroke-width="1.5"/>
<text x="1005" y="476" font-size="10" fill="#7C3E06" text-anchor="middle" font-weight="600">decoded state at loop T — the answer</text>
<text x="1060" y="530" font-size="10" fill="#374151" text-anchor="middle" font-weight="600">trained: LoRA ≈ 4.40M + bridge 1.61M = 6.01M forward-active (3.3%)</text>
<text x="1060" y="548" font-size="9.5" fill="#6B7280" text-anchor="middle">base weights untouched — the adapter is detachable</text>
<text x="1060" y="562" font-size="9.5" fill="#6B7280" text-anchor="middle">and recovery of the base model is guaranteed</text>
<!-- ===================== BOTTOM STRIP: THE FIVE ARMS ===================== -->
<text x="30" y="666" font-size="13.5" font-weight="700" fill="#111827">The five registered comparison arms (Section 9)</text>
<rect x="20" y="682" width="232" height="140" rx="10" fill="#EFF4FF" stroke="#2563EB" stroke-width="1.3"/>
<text x="36" y="706" font-size="11" font-weight="700" fill="#1E40AF">Arm A — recurrent 0.5B</text>
<text x="36" y="726" font-size="9.5" fill="#1F2937">Full-block budget</text>
<text x="36" y="742" font-size="9.5" fill="#1F2937">Latent loops at forced depth</text>
<text x="36" y="758" font-size="9.5" fill="#1F2937">One decoded state, no generation</text>
<text x="36" y="806" font-size="9" fill="#6B7280" font-style="italic">primary registered system</text>
<rect x="268" y="682" width="232" height="140" rx="10" fill="#FEF3E2" stroke="#B45309" stroke-width="1.3"/>
<text x="284" y="706" font-size="11" font-weight="700" fill="#7C3E06">Arm E — recurrent 0.5B</text>
<text x="284" y="726" font-size="9.5" fill="#1F2937">Adapter budget, base frozen</text>
<text x="284" y="742" font-size="9.5" fill="#1F2937">Identical surgery and protocol</text>
<text x="284" y="758" font-size="9.5" fill="#1F2937">Tests whether 180M is required</text>
<text x="284" y="806" font-size="9" fill="#6B7280" font-style="italic">parameter-efficiency control</text>
<rect x="516" y="682" width="232" height="140" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="1.3"/>
<text x="532" y="706" font-size="11" font-weight="700" fill="#374151">Arm B — dense 0.5B</text>
<text x="532" y="726" font-size="9.5" fill="#1F2937">Direct-answer SFT</text>
<text x="532" y="742" font-size="9.5" fill="#1F2937">No sequential computation</text>
<text x="532" y="806" font-size="9" fill="#6B7280" font-style="italic">primary preregistered control</text>
<rect x="764" y="682" width="232" height="140" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="1.3"/>
<text x="780" y="706" font-size="11" font-weight="700" fill="#374151">Arm C — dense 0.5B</text>
<text x="780" y="726" font-size="9.5" fill="#1F2937">Serialized-scratchpad SFT</text>
<text x="780" y="742" font-size="9.5" fill="#1F2937">Writes its reasoning in tokens</text>
<text x="780" y="758" font-size="9.5" fill="#1F2937">Token axis instead of depth axis</text>
<text x="780" y="806" font-size="9" fill="#6B7280" font-style="italic">strongest dense control</text>
<rect x="1012" y="682" width="232" height="140" rx="10" fill="#FFFFFF" stroke="#9CA3AF" stroke-width="1.3"/>
<text x="1028" y="706" font-size="11" font-weight="700" fill="#374151">Arm D — dense 1.5B</text>
<text x="1028" y="726" font-size="9.5" fill="#1F2937">Direct-answer SFT</text>
<text x="1028" y="742" font-size="9.5" fill="#1F2937">3× the parameters, one pass</text>
<text x="1028" y="758" font-size="9.5" fill="#1F2937">Tests scale as a substitute for depth</text>
<text x="1028" y="806" font-size="9" fill="#6B7280" font-style="italic">scale control</text>
<text x="640" y="850" font-size="9.5" fill="#6B7280" text-anchor="middle">All arms evaluated on identical frozen rows under the same reader (Section 4.2).</text>
<text x="640" y="878" font-size="9.5" fill="#9CA3AF" text-anchor="middle">Latent Space Reasoning program · Paper One · architecture comparison · 2026-07-27</text>
</svg>
|