<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mun Chong Soo on Medium]]></title>
        <description><![CDATA[Stories by Mun Chong Soo on Medium]]></description>
        <link>https://medium.com/@mcsoo915?source=rss-c3163f3d15ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qSGEnkut1N98vFr-J7ArdA.jpeg</url>
            <title>Stories by Mun Chong Soo on Medium</title>
            <link>https://medium.com/@mcsoo915?source=rss-c3163f3d15ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 10:32:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mcsoo915/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond Hugging Face: Exploring Faster LLM Fine-Tuning with Llama Factory and Unsloth ]]></title>
            <link>https://medium.com/@mcsoo915/mastering-llm-fine-tuning-a-battle-of-speed-and-efficiency-between-modern-libraries-179f017ed1c1?source=rss-c3163f3d15ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/179f017ed1c1</guid>
            <category><![CDATA[supervised-fine-tuning]]></category>
            <category><![CDATA[unsloth]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[llama-factory]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Mun Chong Soo]]></dc:creator>
            <pubDate>Sun, 01 Dec 2024 08:15:06 GMT</pubDate>
            <atom:updated>2025-03-11T11:46:44.751Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A comprehensive performance analysis of Llama Factory, Unsloth, and Hugging Face for fine-tuning large language models</em></p><h3><strong>1. Introduction </strong>🌟</h3><p>The landscape of Large Language Models (LLMs) has evolved dramatically, with fine-tuning becoming a crucial step in deploying these models for specific applications. While pre-training builds a model’s foundational knowledge through self-supervised learning on vast text corpora, supervised fine-tuning (SFT) adapts these pre-trained models for specific tasks using labeled data.</p><p>Think of pre-training as giving a model general knowledge about the world, while SFT is like teaching it a specific profession. This specialization process is crucial because it:</p><ul><li>🎯 Aligns the model with specific use cases</li><li>📈 Improves performance on domain-specific tasks</li></ul><h3>2. The Science Behind Fine-tuning: A Literature Review 📚</h3><p>Modern SFT approaches leverage several key techniques, each backed by groundbreaking research:</p><h4><strong><em>i. Parameter-Efficient Fine-Tuning (PEFT)</em></strong></h4><ul><li><strong><em>LoRA (Low-Rank Adaptation)</em></strong><em> </em>— <a href="https://arxiv.org/abs/2106.09685">https://arxiv.org/abs/2106.09685</a> <br>- <em>Reduces training parameters by decomposing weight updates into lower-rank matrices</em></li><li><strong><em>QLoRA (Quantized LoRA) </em></strong>— <a href="https://arxiv.org/abs/2305.14314">“QLoRA: Efficient Finetuning of Quantized LLMs”</a><br>- <em>Combines quantization with LoRA for even more memory efficiency</em></li></ul><h4><strong><em>ii. Optimization Techniques</em></strong></h4><ul><li><strong><em>Mixed precision training</em></strong><em> </em>—<a href="https://arxiv.org/abs/1710.03740"> “Mixed Precision Training”</a><br>- <em>Uses both 16-bit and 32-bit floating-point operations</em></li><li><strong><em>Flash Attention</em></strong> — <a href="https://arxiv.org/pdf/2205.14135">“FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness”</a><br>- <em>Optimizes attention computation for better memory efficiency</em></li><li><strong><em>Flash Attention 2 </em></strong>— <a href="https://arxiv.org/abs/2307.08691">“Flash Attention-2: Faster Attention with Better Parallelism”</a><br><em>- Further improves attention computation speed and efficiency</em></li></ul><h3>The Contenders: Modern Fine-tuning Libraries 🏆</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*RKJ_faplJFfj3uGhLOOj4w.png" /><figcaption>Huggingface</figcaption></figure><ol><li><strong>Hugging Face Transformers </strong>🤗</li></ol><ul><li>🌟 Industry standard for ML models</li><li>📚 Comprehensive documentation and community support</li><li>🌐 Extensive ecosystem and model hub</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*VgVny-xNCD6XeCHUusrGow.png" /><figcaption>Llama Factory</figcaption></figure><p>2.<strong> Llama Factory</strong></p><ul><li>🚀 Efficient multi-GPU support</li><li>⚙️ Simplified configuration (yaml files or UI interface)</li><li>Repository: <a href="http://github.com/hiyouga/LLaMA-Factory">github.com/hiyouga/LLaMA-Factory</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/174/1*KQVru-RGXz502sd8IPwrzQ.png" /><figcaption>Unsloth</figcaption></figure><p>3.<strong> Unsloth</strong></p><ul><li>⚡ Newer entrant focused on speed optimization</li><li>💪 Single GPU optimization</li><li>🧠 Advanced memory management</li><li>Repository: <a href="http://github.com/unslothai/unsloth">github.com/unslothai/unsloth</a></li></ul><h3>Experimental Setup 🧪</h3><p>To provide a fair comparison, we conducted extensive testing using:</p><h3>- Hardware Configuration 🖥️</h3><blockquote>🏭 Llama Factory: 2 NVIDIA A100 80GB GPUs</blockquote><blockquote>🚀 Unsloth: 1 NVIDIA A100 80GB GPU</blockquote><blockquote>🤗 Hugging Face: 1 NVIDIA A100 80GB GPU</blockquote><h3>- Dataset Specifications 📊</h3><blockquote>💬 Approximately 94,000 conversations</blockquote><blockquote>📝 35 million tokens in total</blockquote><h3>- Model and Training Parameters ⚙️</h3><blockquote>Base Model: 🦙 Llama 3.1 8B Instruct</blockquote><blockquote>LoRA Configuration:</blockquote><blockquote>🎯 Rank: 42</blockquote><blockquote>🎮 Alpha: 72</blockquote><blockquote>💧 Dropout: 0.1</blockquote><blockquote>Different Hyperparameters:</blockquote><blockquote>📏 Max sequence lengths: 256, 512, 1024, 2048</blockquote><blockquote>📦 Batch sizes: 4, 8, 16, 32, 64</blockquote><blockquote>🔄 Epochs: 15</blockquote><h3>Results and Analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t8rZsvSgj3gECQPDR9mvuw.png" /><figcaption>Image 1: Training Time Duration using HuggingFace, Unsloth &amp; Llama Factory</figcaption></figure><h3>Training Time Analysis 📊</h3><ul><li><strong>Sequence Length Impact ⚡</strong></li></ul><blockquote>The upward trend in all curves demonstrates the significant impact of sequence length on training time. This is primarily due to the quadratic complexity (n²) of the attention mechanism — as sequence length doubles, the computational cost quadruples. This explains why we see steeper increases in training time as we move from 256 to 2048 tokens.🔄</blockquote><h3>Relative Performance 📈</h3><p>Llama Factory with dual GPUs demonstrates:</p><blockquote>⚡ 33% faster than Unsloth</blockquote><blockquote>🔥 54% faster than Hugging Face</blockquote><blockquote>💪 Better scaling with larger batch sizes</blockquote><h3><strong>Memory Management 🧠</strong></h3><p>Unsloth shows particularly impressive memory efficiency:</p><blockquote>💪 Maintains stability up to batch size 32 with 2048 sequence length</blockquote><blockquote>🚀 Only reaches OOM at batch 64 with 1024+ sequence length</blockquote><blockquote>⭐ Outperforms HF which hits OOM earlier at batch 32, sequence length 1024</blockquote><h3>Conclusion 🎯</h3><p>Our comprehensive analysis leads to a straightforward recommendation for practitioners:</p><blockquote>Single GPU Setup: 💪 Choose Unsloth for its superior memory efficiency and competitive performance</blockquote><blockquote>Multi-GPU Setup: 🚀 Opt for Llama Factory to leverage its excellent distributed training capabilities</blockquote><h3>What’s Next? 🚀</h3><p>Coming soon: We’ll walk through the complete setup process!</p><ul><li>🐳 “Dockerizing Unsloth: From Zero to Fine-tuning in 15 Minutes”</li><li>🏭 “Llama Factory: Fine-tuning LLMs in 5 Minutes with Llama Factory”</li></ul><p>Because everyone deserves a smooth setup experience! 😉</p><p>Until then, may your VRAM be plentiful and your OOM errors few! 🙏</p><p><em>P.S. Already tinkering with the setup? Bookmark these guides — they might save you some debug time!</em> 😅</p><h3>About the Author ✍️</h3><p>LLM Engineer with 2+ years of hands-on experience in the AI industry. Specialized in fine-tuning large language models, building RAG systems, and optimizing LLM deployments. Passionate about making AI more accessible and efficient.</p><h3>Connect With Me! 🤝</h3><p>👋 Want to discuss more about LLM fine-tuning? Follow me on:</p><ul><li>Say hi to me on <a href="https://www.linkedin.com/in/mun-chong-soo-a14813193/">LinkedIn</a> !</li></ul><p>Let’s connect and build better AI together! 🤝</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=179f017ed1c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>