<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kamel</title>
    <description>The latest articles on DEV Community by Kamel (@kamelak).</description>
    <link>https://dev.to/kamelak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1164109%2Fb9bae4bb-5938-44b9-a4ed-30c7e877e10c.png</url>
      <title>DEV Community: Kamel</title>
      <link>https://dev.to/kamelak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kamelak"/>
    <language>en</language>
    <item>
      <title>🚀 Mixture-of-Recursions: How Recursive Transformers Are Getting Smarter AND Cheaper</title>
      <dc:creator>Kamel</dc:creator>
      <pubDate>Fri, 25 Jul 2025 06:42:38 +0000</pubDate>
      <link>https://dev.to/kamelak/mixture-of-recursions-how-recursive-transformers-are-getting-smarter-and-cheaper-5bcd</link>
      <guid>https://dev.to/kamelak/mixture-of-recursions-how-recursive-transformers-are-getting-smarter-and-cheaper-5bcd</guid>
      <description>&lt;p&gt;&lt;em&gt;What if your language model could “think harder” only when needed—without blowing up your GPU bill? Meet Mixture-of-Recursions (MoR), Google DeepMind has released a new Transformers architecture  that combines the best of adaptive compute and parameter sharing. Here’s what you need to know.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Transformer Dilemma: Power vs. Price
&lt;/h2&gt;

&lt;p&gt;We all love what massive Transformers can do—stunning few-shot learning, tricky reasoning, code completion, etc. But let’s be real: scaling up to billions of parameters means you need serious hardware and cash, whether you’re training or deploying.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two Popular Paths to Efficiency (But Both Are Halfway Solutions)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Parameter Sharing:&lt;/strong&gt; Reuse the same weights across layers (think: Universal Transformers, recurrent models). Saves memory, but doesn’t solve compute waste.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptive Computation:&lt;/strong&gt; Use early-exit or routing, so “easy” tokens don’t go through all layers. Saves computation, but still requires lots of unique parameters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;But what if you could get the best of both worlds?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter Mixture-of-Recursions (MoR): Deep, Smart, and Lean
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0ofgbtvvjrjt7xwvc1p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0ofgbtvvjrjt7xwvc1p.png" alt=" " width="800" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MoR, introduced by Sangmin Bae and collaborators, is a new Transformer architecture that &lt;strong&gt;dynamically decides how many “thinking steps” each token deserves&lt;/strong&gt;, while reusing the same set of layers again and again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Picture this:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All tokens start together, but as the model processes, a “router” decides which tokens need another pass through the shared block of layers.&lt;/li&gt;
&lt;li&gt;“Simple” tokens exit early, “hard” tokens get more recursive attention.&lt;/li&gt;
&lt;li&gt;At every step, only the “active” tokens are part of the expensive attention computation.&lt;/li&gt;
&lt;li&gt;Key-Value (KV) caching is optimized: only store the states you’ll actually need, further saving memory!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;It’s like a Transformer with a built-in “focus engine”—more brainpower where it’s needed, less wasted everywhere else.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does It Work? (Spoiler: It’s Actually Elegant)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fae6c2nccjp6616ew4r57.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fae6c2nccjp6616ew4r57.png" alt=" " width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Recursive Layer Block:&lt;/strong&gt; Instead of stacking dozens of unique layers, MoR reuses a small stack (e.g., 3 layers) recursively. This slashes parameter count.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Token-Level Routing:&lt;/strong&gt; A lightweight router is trained to assign recursion depths per token. Some tokens take 1 pass, others 2, others 3+, depending on their “difficulty.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficient KV Caching:&lt;/strong&gt; Only the active tokens at each recursion depth contribute to the key-value cache, reducing memory and compute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Routing Variants:&lt;/strong&gt; The authors explore “expert-choice” (layers pick which tokens to keep) and “token-choice” (each token picks its own path). Both have trade-offs, but “expert-choice” with an auxiliary loss works best.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why Should You Care?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Smaller Models, Same or Better Results:&lt;/strong&gt; MoR models with half or a third the parameter count &lt;strong&gt;match—or sometimes beat—vanilla Transformers&lt;/strong&gt; on validation loss and few-shot tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cheaper Training:&lt;/strong&gt; For a fixed compute budget, MoR trains on more tokens and achieves better scores.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faster Inference:&lt;/strong&gt; Thanks to dynamic depth and efficient batching, MoR can &lt;strong&gt;double throughput&lt;/strong&gt; compared to regular Transformers on the same hardware.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Footprint:&lt;/strong&gt; Parameter and KV cache sharing means more room for longer contexts or bigger batch sizes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Real-World Impact
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploy Large-Language-Model Power Without LLM Costs:&lt;/strong&gt; For startups, researchers, and tinkerers, MoR means you can do more with less.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexible Computation:&lt;/strong&gt; You can “turn up” the thinking depth for more difficult tasks at inference, without retraining.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open Source:&lt;/strong&gt; The code is available! &lt;a href="https://github.com/raymin0223/mixture_of_recursions" rel="noopener noreferrer"&gt;Check it out on GitHub.&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Curious to dive in?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Read the &lt;a href="https://arxiv.org/abs/2507.10524" rel="noopener noreferrer"&gt;full paper here&lt;/a&gt; or check out the &lt;a href="https://github.com/raymin0223/mixture_of_recursions" rel="noopener noreferrer"&gt;official GitHub repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#transformers #machinelearning #deeplearning #llm #nlp #ai #research #devjournal&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatgpt</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>From Backend to Frontend: How I Merged Laravel with React Using Inertia.js</title>
      <dc:creator>Kamel</dc:creator>
      <pubDate>Wed, 07 May 2025 08:25:30 +0000</pubDate>
      <link>https://dev.to/kamelak/from-backend-to-frontend-how-i-merged-laravel-with-react-using-inertiajs-c6f</link>
      <guid>https://dev.to/kamelak/from-backend-to-frontend-how-i-merged-laravel-with-react-using-inertiajs-c6f</guid>
      <description>&lt;p&gt;Ever wished your backend and frontend could &lt;em&gt;just get along?&lt;/em&gt; I faced this head-on while building a dental clinic management system—and discovered a workflow that’s both powerful and refreshingly simple. Here’s how marrying Laravel and React with Inertia.js turned my app into a seamless, single-page powerhouse.&lt;/p&gt;

&lt;h2&gt;
  
  
  🏗️ The Blueprint: My Stack’s Secret Sauce
&lt;/h2&gt;

&lt;p&gt;Forget clunky API calls and duplicated validation logic this architecture lets each layer shine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Laravel (Backend): Handles the heavy lifting—routing, data, and validation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;React (Frontend): Crafts stunning, interactive user experiences.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inertia.js (The Bridge): Magically connects them, letting you build SPAs without building an API.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🦷 Real-World Example: Managing Patients with Style
&lt;/h2&gt;

&lt;p&gt;When developing a dental clinic management system, my top priorities were delivering an exceptional user experience and ensuring blazing-fast performance. After evaluating various options, Laravel emerged as the clear winner for the backend—its elegant syntax, robust ecosystem, and proven scalability made it the perfect foundation.&lt;/p&gt;

&lt;p&gt;But I didn't stop there. Recognizing the need for a dynamic, responsive frontend that could match Laravel's capabilities, I leveraged my React expertise to create interactive user interfaces. The challenge? Bridging these two powerful technologies seamlessly.&lt;/p&gt;

&lt;p&gt;Enter Inertia.js—the game-changing solution that eliminated the traditional API overhead while maintaining the strengths of both frameworks. This elegant bridge allowed me to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Preserve Laravel's backend efficiency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Utilize React's component-based architecture&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Maintain a single codebase without compromising on performance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deliver smooth, app-like interactions&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result? A clinic management system that combines Laravel's backend prowess with React's frontend dynamism through Inertia's streamlined integration—proving that sometimes the best solutions come from combining the right technologies in innovative ways.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. PatientController: Data, Ready for React&lt;/strong&gt;&lt;br&gt;
Here’s a slice of PHP that looks like it belongs in the future:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9np75x17wz3ld7c1q8lq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9np75x17wz3ld7c1q8lq.png" alt="Image description" width="800" height="810"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function show(Patient $patient)
{
    return inertia('Patient/Show', [
        'patient' =&amp;gt; new PatientResource($patient),
        'appointments' =&amp;gt; $patient-&amp;gt;appointments()-&amp;gt;with(['treatments.payments'])-&amp;gt;get(),
        'treatments' =&amp;gt; $patient-&amp;gt;treatmentRecords()-&amp;gt;with(['payments'])-&amp;gt;latest()-&amp;gt;take(5)-&amp;gt;get(),
    ]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Translation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fetches a patient and all their details (including nested relationships).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Returns everything straight to a React component—no manual API wrangling.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2.React Magic: Interactive Patient Details&lt;/strong&gt;&lt;br&gt;
And on the frontend? React takes over:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Show({ auth, patient, appointments, treatments }) {
    const [expanded, setExpanded] = useState([]);
    const toggle = id =&amp;gt; setExpanded(exp =&amp;gt; exp.includes(id) ? exp.filter(i =&amp;gt; i !== id) : [...exp, id]);

    return (
        &amp;lt;AuthenticatedLayout user={auth.user}&amp;gt;
            &amp;lt;div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"&amp;gt;
                &amp;lt;DetailItem label="Contact Information" value={patient.contact_info} /&amp;gt;
                &amp;lt;DetailItem label="Address" value={patient.address} /&amp;gt;
                {/* More fields... */}
            &amp;lt;/div&amp;gt;

            {/* Appointments Table */}
            {appointments.map(a =&amp;gt; (
                &amp;lt;React.Fragment key={a.id}&amp;gt;
                    &amp;lt;tr onClick={() =&amp;gt; toggle(a.id)}&amp;gt;
                        {/* Appointment details */}
                    &amp;lt;/tr&amp;gt;
                    {expanded.includes(a.id) &amp;amp;&amp;amp; (
                        &amp;lt;tr&amp;gt;
                            &amp;lt;td colSpan="5"&amp;gt;{/* Nested treatments here */}&amp;lt;/td&amp;gt;
                        &amp;lt;/tr&amp;gt;
                    )}
                &amp;lt;/React.Fragment&amp;gt;
            ))}
        &amp;lt;/AuthenticatedLayout&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What’s cool:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clicking an appointment row expands details—no reloads, instant UX.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📅 Real-Time Calendar: See Your Day at a Glance
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl1mz0v7um5wwpwnap7vz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl1mz0v7um5wwpwnap7vz.png" alt="Image description" width="800" height="631"&gt;&lt;/a&gt;&lt;br&gt;
Appointments load in real-time, grouped by date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function index()
{
    $appointments = Appointment::with('patient')
        -&amp;gt;whereMonth('date', now()-&amp;gt;month)
        -&amp;gt;orderBy('date')
        -&amp;gt;orderBy('time')
        -&amp;gt;paginate(100);

    return Inertia::render('Appointments/Index', ['appointments' =&amp;gt; $appointments]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in React:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Index({ auth, appointments }) {
    const [currentDate, setCurrentDate] = useState(new Date());
    const byDate = appointments.data.reduce((acc, a) =&amp;gt; {
        const day = format(parseISO(a.date), 'yyyy-MM-dd');
        (acc[day] = acc[day] || []).push(a);
        return acc;
    }, {});

    return (
        &amp;lt;div className="grid grid-cols-7 gap-2"&amp;gt;
            {daysInMonth.map(day =&amp;gt; (
                &amp;lt;motion.div key={day.toString()} onClick={() =&amp;gt; setCurrentDate(day)}&amp;gt;
                    {format(day, 'd')}
                    {byDate[format(day, 'yyyy-MM-dd')]?.map(a =&amp;gt; (
                        &amp;lt;div key={a.id}&amp;gt;{a.patient.name}&amp;lt;/div&amp;gt;
                    ))}
                &amp;lt;/motion.div&amp;gt;
            ))}
        &amp;lt;/div&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  💡 Why This Approach Rocks
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;No API Hassle: Laravel passes data straight to React—no extra endpoints.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Best of Both Worlds: Use Laravel’s validation, ORM, and auth and React’s component magic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Performance: Inertia can pre-render pages for lightning-fast loads.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Simple State: No Redux headaches—let Laravel handle sessions and shared data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reusable Components: Clean, snappy UI that’s easy to maintain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📚 Lessons from the Trenches
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Resource Formatting: Laravel’s API Resources (like PatientResource) keep data clean and predictable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Component-First Thinking: Breaking big pages into bite-sized React pieces (like DetailItem) saves time and sanity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Error Handling: Laravel’s validation errors flow straight into your React forms—no extra code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;State Management: For complex UIs, blend React’s state with Inertia’s shared data for the best results.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  💬 Your Turn!
&lt;/h2&gt;

&lt;p&gt;Have you tried the Laravel + React + Inertia combo? What worked, what didn’t, and what would you do differently?&lt;br&gt;
Drop your experience below—let’s learn from each other!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>laravel</category>
      <category>php</category>
    </item>
  </channel>
</rss>
