<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Paper Reflections - neptune.ai</title>
	<atom:link href="https://neptune.ai/blog/category/paper-reflections/feed" rel="self" type="application/rss+xml" />
	<link>https://neptune.ai/blog/category/paper-reflections</link>
	<description>The experiment tracker for foundation model training.</description>
	<lastBuildDate>Wed, 30 Jul 2025 11:17:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i0.wp.com/neptune.ai/wp-content/uploads/2022/11/cropped-Signet-1.png?fit=32%2C32&#038;ssl=1</url>
	<title>Paper Reflections - neptune.ai</title>
	<link>https://neptune.ai/blog/category/paper-reflections</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">211928962</site>	<item>
		<title>SabiYarn: Advancing Low-Resource Languages With Multitask NLP Pre-Training [Paper Reflections]</title>
		<link>https://neptune.ai/blog/sabiyarn-advancing-low-resource-languages-with-multitask-nlp-pretraining</link>
		
		<dc:creator><![CDATA[Oduguwa Damilola]]></dc:creator>
		<pubDate>Fri, 01 Aug 2025 11:30:00 +0000</pubDate>
				<category><![CDATA[LLMOps]]></category>
		<category><![CDATA[Paper Reflections]]></category>
		<guid isPermaLink="false">https://neptune.ai/?p=47866</guid>

					<description><![CDATA[In recent years, Large Language Models (LLMs) have mostly improved by scaling. This has primarily involved increasing the size of the LLMs and the data they are trained on, resulting in a highly resource-intensive process that can cost up to millions of dollars. While LLMs have become ubiquitous, the resource-intensive pre-training process poses a threat&#8230;]]></description>
										<content:encoded><![CDATA[
<p>In recent years, Large Language Models (LLMs) have mostly improved by scaling. This has primarily involved <a href="/state-of-foundation-model-training-report#h-scaling" target="_blank" rel="noreferrer noopener">increasing the size of the LLMs and the data they are trained on</a>, resulting in a highly resource-intensive process that can cost up to millions of dollars.</p>



<p>While LLMs have become ubiquitous, the resource-intensive pre-training process poses a threat to the inclusion of low-resource languages, where data is scarce. Often, this is accompanied by a lack of funding for compute resources.</p>



<p>In our paper,<a href="https://aclanthology.org/2025.africanlp-1.14/" target="_blank" rel="noreferrer noopener nofollow"> <em><strong>SabiYarn: Advancing Low-Resource Languages with multi-task NLP Pre-Training</strong></em></a>, which was accepted at the <a href="https://sites.google.com/view/africanlp2025/home" target="_blank" rel="noreferrer noopener nofollow">AfricaNLP workshop</a> at the <a href="https://2025.aclweb.org/" target="_blank" rel="noreferrer noopener nofollow">2025 ACL</a>, we propose a series of optimization methods in the LLM pre-training process that made it possible to train a SOTA multilingual foundation model on Nigerian languages on a single 24 GB GPU.</p>



<p>One of these techniques is a mask-based loss computation strategy. This simple idea avoids computing loss on input prompt tokens the model already knows. This allows the loss function to accurately reflect the model’s true performance on the tokens that matter and avoids wasting compute by backpropagating losses that do not contribute to the model’s learning process.</p>



<p>In this article, we’ll explore this approach, how it reflects the broader compute-aware pre-training design and its influence on the model’s performance.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-prompt-tokens-are-too-expensive-in-low-resource-settings">Prompt tokens are (too) expensive in low-resource settings</h2>



<p>During pre-training, LLMs are trained in causal language modeling through a next-token prediction task. This is typically a slow process involving trillions of tokens, whose goal is to reduce the cross-entropy loss between the predicted token and the label through backpropagation. Along the way, the model acquires multiple skills, memorizes facts, and builds a world model.</p>



<p>For state-of-the-art models like Meta’s <a href="https://ai.meta.com/blog/llama-4-multimodal-intelligence/" target="_blank" rel="noreferrer noopener nofollow">Llama 4</a> or OpenAI’s <a href="https://openai.com/index/gpt-4/" target="_blank" rel="noreferrer noopener nofollow">GPT-4</a>, this computationally intensive process typically involves running thousands of GPUs for months, <a href="https://epoch.ai/data-insights/models-over-1e25-flop" target="_blank" rel="noreferrer noopener nofollow">performing over 10<sup>25</sup> floating-point operations (FLOP)</a>.</p>



<p>Let’s look at a concrete example. Given a sequence like <em>“Translate English to Yoruba: I love rice. =&gt; Mo fẹ́ràn ìrẹsì,”</em> the model is trained to predict every token, from the prompt to the actual answer:</p>



<div id="medium-table-block_572dfada8da30393d14061db5e9e390c"
     class="block-medium-table c-table__outer-wrapper  aligncenter l-padding__top--0 l-padding__bottom--standard l-margin__top--0 l-margin__bottom--0">

    <table class="c-table">
                    <thead class="c-table__head">
            <tr>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Step                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Prompt                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Next token                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            &nbsp;                        </div>
                    </td>
                            </tr>
            </thead>
        
        <tbody class="c-table__body">

                    
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>1</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">English</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Static prompt</span></p>
                                                            </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>2</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>to</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Static prompt</span></p>
                                                            </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>3</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English to</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Yoruba:</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Static prompt</span></p>
                                                            </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>4</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English to Yoruba:</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>I</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                                                                                </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>5</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English to Yoruba: I</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>love</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                                                                                </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>6</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English to Yoruba: I love</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">rice.</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                                                                                </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>7</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English to Yoruba: I love rice.</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">-&gt;</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Static prompt</span></p>
                                                            </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>8</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English to Yoruba: I love rice. -&gt;</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Mo</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                                                                                </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>9</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English to Yoruba: I love rice. -&gt; Mo </span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">fẹ́ràn</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                                                                                </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p>10</p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">Translate English to Yoruba: I love rice. -&gt; Mo </span><span style="font-weight: 400;">fẹ́ràn</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">iresi.</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                                                                                </div>
                        </td>

                    
                </tr>

                    
        </tbody>
    </table>

</div>



<p>In this setup, all tokens are treated equally, regardless of whether they are part of the prompt or the answer. On the one hand, this is straightforward to set up. On the other hand, it means spending compute on learning to predict tokens that are already known and static.</p>



<p>While this is fine in settings with virtually unlimited compute, it becomes problematic in resource-constrained training. Every token prediction contributes to the total training FLOPs. If half the sequence is an instruction or prompt that never changes, that’s half your compute spent on learning what the model doesn’t need to.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-making-do-without-instruction-tuning">Making do without instruction-tuning</h2>



<p>Due to severe compute constraints, we could not include a post-training stage where models are typically aligned with user-facing goals using supervised examples and <a href="/blog/reinforcement-learning-from-human-feedback-for-llms" target="_blank" rel="noreferrer noopener">reinforcement learning from human feedback (RLHF)</a>. In such stages, models learn not just to predict the next token but to generate helpful and aligned responses.</p>



<p>For example, a pre-trained base model may reply to <em>“How are you today”</em> with <em>“?”</em>, completing the sequence with the most likely next token. In contrast, an instruction-tuned model would try to provide a response that aligns with the goal of being a useful assistant or chatbot, e.g., <em>“I’m doing good.”</em></p>



<p>Since post-training wasn’t feasible for SabiYarn, we embedded task awareness directly into the pre-training phase. Our goal was to help the model generalize beyond basic next-token prediction and toward solving meaningful tasks like named-entity recognition, sentiment analysis, and translation entirely through prompt-based conditioning.</p>



<p>In our <a href="https://drive.google.com/file/d/1wkWdXucSYE0hwGxowkzO3iJiTDR5qayP/view?usp=sharing">paper</a>, we propose a task-specific training scheme where the model is conditioned on the task it must perform using XML-like prompt tags. Taking inspiration from the <a href="https://arxiv.org/abs/1910.10683" target="_blank" rel="noreferrer noopener nofollow">T5 paper</a>, we used the following template:</p>




<div
	style="opacity: 0;"
	class="block-code-snippet  l-padding__top--0 l-padding__bottom--0 l-margin__top--standard l-margin__bottom--standard block-code-snippet--regular language-py line-numbers block-code-snippet--show-header"
	data-show-header="show"
	data-header-text=""
>
	<pre style="font-size: .875rem;" data-prismjs-copy="Copy the JavaScript snippet!"><code><task_tag> model_input <closing_tag> Model’s output.</code></pre>
</div>




<p>For example, an English-to-Pidgin translation task looks like this:</p>




<div
	style="opacity: 0;"
	class="block-code-snippet  l-padding__top--0 l-padding__bottom--0 l-margin__top--standard l-margin__bottom--standard block-code-snippet--regular language-py line-numbers block-code-snippet--show-header"
	data-show-header="show"
	data-header-text=""
>
	<pre style="font-size: .875rem;" data-prismjs-copy="Copy the JavaScript snippet!"><code><translate> let me call my father <pcm> : Make I go call my Papa</code></pre>
</div>




<p>With this structured format, we were now able to only calculate the cross-entropy loss on just the label tokens (<em>“Make I go call my Papa”</em>).</p>



<p>This is straightforward to implement in PyTorch by masking out the prompt tokens in the label tensor. We use <span class="c-code-snippet">-100</span> as the ignore index, which PyTorch’s <span class="c-code-snippet">cross_entropy</span> loss function skips:</p>




<div
	style="opacity: 0;"
	class="block-code-snippet  l-padding__top--0 l-padding__bottom--0 l-margin__top--standard l-margin__bottom--standard block-code-snippet--regular language-py line-numbers block-code-snippet--show-header"
	data-show-header="show"
	data-header-text=""
>
	<pre style="font-size: .875rem;" data-prismjs-copy="Copy the JavaScript snippet!"><code>labels = input_ids.clone()
labels[:, :prompt_len] = -100</code></pre>
</div>




<p>Since PyTorch’s cross-entropy loss function ignores the -100 token by default, the prompt tokens are ignored when calculating the loss for that sequence.&nbsp;</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-learning-only-what-matters">Learning only what matters</h2>



<p>An unexpected benefit of this approach is improved task focus. Since the model is not backpropagating on the input portion of the sequence, the model’s learning signal comes exclusively from task-relevant tokens.</p>



<p>Consider a pre-training scenario where an LLM is presented with:</p>




<div
	style="opacity: 0;"
	class="block-code-snippet  l-padding__top--0 l-padding__bottom--0 l-margin__top--standard l-margin__bottom--standard block-code-snippet--regular language-py line-numbers block-code-snippet--show-header"
	data-show-header="show"
	data-header-text=""
>
	<pre style="font-size: .875rem;" data-prismjs-copy="Copy the JavaScript snippet!"><code>translate> let me call my father <pcm> : Make I go call my Papa</code></pre>
</div>




<p>When the loss is computed on every token, the model learns to reproduce the prompt structure, memorizes the task tags, and generates the outputs. The learning signal is diluted across the entire sequence.</p>



<p>Using loss masking, the model can still make input-output connections through the self-attention mechanism during the forward pass. However, backpropagation (learning) only occurs when predicting the output tokens:</p>




<div
	style="opacity: 0;"
	class="block-code-snippet  l-padding__top--0 l-padding__bottom--0 l-margin__top--standard l-margin__bottom--standard block-code-snippet--regular language-py line-numbers block-code-snippet--show-header"
	data-show-header="show"
	data-header-text=""
>
	<pre style="font-size: .875rem;" data-prismjs-copy="Copy the JavaScript snippet!"><code>Make I go call my Papa</code></pre>
</div>




<p>We can compare this to how we as humans learn to translate to a new language: We receive the full input as context, but learning occurs when we’re corrected on our translation, not on the input sentence already provided to us.</p>



<p>Masking out the input forces the model to treat prompts as context rather than a prediction target, allowing training to focus on input-output mappings and reducing the tendency to overfit on prompt formatting.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-investigating-the-impact-of-task-focus-on-training-performance">Investigating the impact of task focus on training performance</h2>



<p>To substantiate this finding, we ran an experiment where we trained the model on a non-trivial problem of descrambling sentences using the masked loss scheme and a non-masked loss as a comparison.</p>



<p>The task was to turn grammatically incoherent sentences into their coherent forms using the same words in the input. For example, “<em>The equations expensive. <strong>show is</strong> optimization computationally that.” </em>should be corrected to <em>“The equations<strong> show</strong> that optimization <strong>is</strong> computationally expensive.”</em> This task requires learning complex relationships between input and output sequences.</p>



<p>Here’s what the loss curves looked like:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img data-recalc-dims="1" fetchpriority="high" decoding="async" width="1920" height="1009" src="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=1920%2C1009&#038;ssl=1" alt="Loss curves" class="wp-image-47889" srcset="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=1920%2C1009&amp;ssl=1 1920w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=768%2C404&amp;ssl=1 768w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=200%2C105&amp;ssl=1 200w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=1536%2C808&amp;ssl=1 1536w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=220%2C116&amp;ssl=1 220w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=120%2C63&amp;ssl=1 120w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=160%2C84&amp;ssl=1 160w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=300%2C158&amp;ssl=1 300w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=480%2C252&amp;ssl=1 480w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?resize=1020%2C536&amp;ssl=1 1020w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/07/Advancing-Low-Resource-Languages-with-Multitask-NLP-Pretraining-loss-curves.png?w=1999&amp;ssl=1 1999w" sizes="(max-width: 1000px) 100vw, 1000px" /></figure>
</div>


<p>We can see that the model converged faster on the task when the loss on the input prompt wasn’t calculated. These efficiency gains compound dramatically over the entire training run and lead to faster convergence.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-the-cost-of-masking-what-are-we-losing">The cost of masking: what are we losing?</h2>



<p>While masking the prompt tokens during loss computation helps conserve compute and sharpen focus, it’s not without tradeoffs. Excluding the prompts from the learning signal increases the risk that the model will fail to adapt to tasks where the prompt structure or phrasing changes at inference time.</p>



<p>That said, such tradeoffs must be weighed against the reality of resource constraints. In low-resource training scenarios, approaches that reduce compute while preserving core task performance are often preferable to fully supervised, resource-intensive alternatives.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-the-case-for-native-llms-for-african-languages">The case for native LLMs for African languages</h2>



<p>While the broader African LLM community has focused its efforts on adapting open-source pre-trained models to African languages, pre-training a foundational model from scratch offers the promise of building a model that doesn’t inherit the cultural biases of Euro-American corpora. It also provides invaluable research insights and data about tokenization, transfer learning, linguistic patterns, and training dynamics for African languages.</p>



<p>An often neglected area is the tokenizer. Tokenizers determine how languages are broken into tokens that LLMs can recognize. Training from scratch enables us to train our own language-specific tokenizers, thereby integrating the morphological and phonological structure, such as tonal diacritics in Yoruba, which also carry semantic meaning.</p>



<p>It also helps with efficiency, as we obtain a tokenizer that effectively tokenizes each language into tokens that recognize useful grammatical structures, such as affixes and punctuation, which can be utilized by the model to learn meaningful representations. In contrast, using an existing tokenizer that is not trained on the target languages leads to poor tokenization, with tokens that don’t accurately reflect grammatical structure, inflated sequence lengths, and ultimately degraded performance. This is especially true for small models, which are appealing due to their lower computing demands.</p>



<p>Looking forward, the future work of our research group focuses on exploring modern LLM architectures, introducing reasoning, instruction following, and test-time computing strategies to resource-constrained pre-training. We’re also exploring hardware-specific optimizations in training and inference and expanding our efforts to even more African languages.&nbsp;</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">47866</post-id>	</item>
		<item>
		<title>STUN: Structured-Then-Unstructured Pruning for Scalable MoE Pruning [Paper Reflection]</title>
		<link>https://neptune.ai/blog/stun-structured-then-unstructured-pruning-for-scalable-moe-pruning</link>
		
		<dc:creator><![CDATA[Seung-won Hwang]]></dc:creator>
		<pubDate>Thu, 05 Jun 2025 11:30:00 +0000</pubDate>
				<category><![CDATA[LLMOps]]></category>
		<category><![CDATA[Paper Reflections]]></category>
		<guid isPermaLink="false">https://neptune.ai/?p=47194</guid>

					<description><![CDATA[Mixture-of-Experts (MoEs) architectures offer a promising solution by sparsely activating specific parts of the model, reducing the inference overhead. However, even with MoEs, the sheer number of parameters and experts makes deployment and serving costly. Pruning is an established method to reduce the number of parameters of a trained model while maintaining its task performance.&#8230;]]></description>
										<content:encoded><![CDATA[
<p><a href="/blog/mixture-of-experts-llms" target="_blank" rel="noreferrer noopener">Mixture-of-Experts (MoEs) architectures</a> offer a promising solution by sparsely activating specific parts of the model, reducing the inference overhead. However, even with MoEs, the sheer number of parameters and experts makes deployment and serving costly.</p>



<p>Pruning is an established method to reduce the number of parameters of a trained model while maintaining its task performance. Typically, we distinguish two kinds of approaches. Unstructured pruning removes individual weights, while structured pruning removes entire model components.<br><br>Due to their clear structure, structured pruning seems to be an ideal match for MoEs. By removing redundant experts, we can shrink the total model size. However, current approaches for expert pruning require many forward passes, whose number grows exponentially with the number of experts. Further, structured pruning does not reduce the number of active weights during inference.</p>



<p>In our paper <a href="https://arxiv.org/pdf/2409.06211" target="_blank" rel="noreferrer noopener nofollow"><em>STUN: Structured-Then-Unstructured Pruning for Scalable MoE Pruning</em></a>, which was accepted for a presentation at <a href="https://2025.aclweb.org/">ACL 2</a><a href="https://2025.aclweb.org/" target="_blank" rel="noreferrer noopener nofollow">0</a><a href="https://2025.aclweb.org/">25</a>, we combine the two classes of pruning methods and introduce an approach that works exceptionally well for MoEs with over 100 experts. In a nutshell, STUN first removes redundant experts and then performs unstructured pruning inside individual experts.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-scaling-barriers-for-mixture-of-expert-models">Scaling barriers for Mixture of Expert models</h2>



<p>MoEs are an effective technique to increase the total number of model parameters while keeping computational demands in check. By dividing the model into specialized structures, called experts, and selectively activating them based on the input, MoEs achieve efficiency gains in training and inference.</p>



<p>More experts allow the model to capture a broader range of representations and specializations, improving performance on diverse tasks or complex data. Unsurprisingly, we see a clear trend towards an increased number of experts in MoEs. To illustrate this evolution, Mistral’s <a href="https://mistral.ai/news/mixtral-of-experts" target="_blank" rel="noreferrer noopener nofollow">Mixtral 8x7B</a> (December 2023) builds on eight experts, Databricks’ <a href="https://www.databricks.com/blog/introducing-dbrx-new-state-art-open-llm" target="_blank" rel="noreferrer noopener nofollow">DBRX</a> (March 2024) on 16, and Snowflake’s <a href="https://www.snowflake.com/en/blog/arctic-open-efficient-foundation-language-models-snowflake/" target="_blank" rel="noreferrer noopener nofollow">Arctic</a> (April 2024) uses 128 experts.</p>


    <a
        href="/blog/mixture-of-experts-llms"
        id="cta-box-related-link-block_a3b2268d1dbb411f4a0c9672ea091160"
        class="block-cta-box-related-link  l-margin__top--standard l-margin__bottom--standard"
        target="_blank" rel="nofollow noopener noreferrer"    >

    
    <div class="block-cta-box-related-link__description-wrapper block-cta-box-related-link__description-wrapper--full">

        
            <div class="c-eyebrow">

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-related--article.svg"
                    loading="lazy"
                    decoding="async"
                    width="16"
                    height="16"
                    alt=""
                    class="c-eyebrow__icon">

                <div class="c-eyebrow__text">
                    Related                </div>
            </div>

        
                    <h3 class="c-header" class="c-header" id="h-mixture-of-experts-llms-key-concepts-explained">                Mixture of Experts LLMs: Key Concepts Explained            </h3>        
                    <div class="c-button c-button--tertiary c-button--small">

                <span class="c-button__text">
                    Read more                </span>

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-button-arrow-right.svg"
                    loading="lazy"
                    decoding="async"
                    width="12"
                    height="12"
                    alt=""
                    class="c-button__arrow">

            </div>
            </div>

    </a>



<p>However, as models scale further, the efficiency gains provided by the MoE architecture alone are insufficient. Here, pruning becomes essential, refining the architecture by removing redundant parameters without compromising overall performance. Combining MoEs with pruning techniques can optimize inference speed and memory consumption, making it a promising direction for further scaling models.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-solving-the-exponential-scaling-challenge-in-structured-moe-pruning">Solving the exponential scaling challenge in structured MoE pruning</h2>



<p>Structured pruning removes specific patterns, such as rows or entire weight tensors. In the context of MoEs, as expert structures from training MoEs correspond to such patterns, pruning experts is a natural fit for structured pruning.</p>



<p>While an increase from 8 to 128 experts may seem modest, it renders current pruning methods unviable. Roughly speaking, they take a “combinatorial” approach to determining which structures to remove, requiring the enumeration of all possible subsets of experts to determine the optimal configuration. To illustrate, when the number of experts increases from 8 to 128, the forward passes of combinatorial pruning algorithms grow exponentially, from 70 to 2.4 × 10³⁷.</p>



<p>In contrast, STUN leverages the behavioral similarity between experts to make informed pruning decisions. Specifically, it first identifies clusters of similar experts based on their behavioral similarity. We can determine the similarity at a minimal cost by inspecting the model’s weights. If two rows have similar values, this suggests a high pairwise similarity between the two corresponding experts. Such an expert pair tends to activate on similar inputs and exhibit similar outputs, thus forming a cluster.</p>



<p>By pruning all but one representative expert from each cluster, STUN effectively reduces the model size while preserving its overall functionality. This approach drastically reduces the exponential complexity of exhaustively enumerating combinations to constant O(1), making it highly scalable for massive MoEs.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-exploring-the-potential-of-a-two-phase-approach-to-moe-pruning">Exploring the potential of a two-phase approach to MoE pruning</h2>



<p>A key question in our research was: How much can we gain from an additional unstructured pruning phase? After we remove all redundant experts, there might be less “margin” for further pruning compared to a scenario where we exclusively apply unstructured pruning.</p>



<p>We can quantify this margin as the <a href="https://en.wikipedia.org/wiki/Kurtosis" target="_blank" rel="noreferrer noopener nofollow">kurtosis</a> of the model weights’ distribution, colloquially known as its &#8220;tailedness.&#8221; As unstructured pruning removes near-zero weights, it reduces the weight distribution’s kurtosis.</p>



<p>Unlike unstructured pruning, which selectively targets weights that minimally impact the model&#8217;s output, structured pruning removes groups of parameters (in our case, experts) based on redundancy or low importance. Thus, structured pruning does not significantly decrease kurtosis, leaving plenty of margin for unstructured pruning.&nbsp;</p>



<p>For instance, if two experts in an MoE perform identically, one can be removed without altering the model&#8217;s output. Still, this does not significantly influence the overall weight distribution—it only reduces the model&#8217;s size.</p>



<p>Since structured pruning primarily reduces architectural redundancy rather than reshaping the underlying weight distribution, our two-phase approach—leveraging unstructured pruning after structured pruning—outperforms unstructured-only pruning.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-putting-stun-to-the-test">Putting STUN to the test</h2>



<p>Our evaluations show that STUN achieves high sparsity with no loss in performance on various MoE architectures, including Snowflake’s <a href="https://www.snowflake.com/en/blog/arctic-open-efficient-foundation-language-models-snowflake/" target="_blank" rel="noreferrer noopener nofollow">Arctic</a>, a 480B-sized MoE with 128 experts.</p>



<p>We achieved nearly no loss in performance with 40% sparsity, even on challenging generative tasks like <a href="https://huggingface.co/datasets/openai/gsm8k" target="_blank" rel="noreferrer noopener nofollow">GSM8K</a> (Grade School Math 8K), a widely adopted question answering task testing on mathematical problems that require multi-step reasoning.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img data-recalc-dims="1" decoding="async" width="757" height="431" src="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/05/GSM8K-5-shot-accuracy-for-Snowflake-Arctic.png?resize=757%2C431&#038;ssl=1" alt="GSM8K 5-shot accuracy for Snowflake Arctic, a 480B Mixture-of-Experts model, after applying different pruning strategies to varying degrees. Structured-only pruning exhibits a significant performance loss as more and more experts are removed. (A sparsity of 30% corresponds to just 90 of the original 128 experts left.) Unstructured-only pruning maintains an unchanged performance up to the point where 30% of the weights are removed. With STUN, the combination of both approaches, benchmark performance remains virtually unaffected up to a sparsity of 40%. This demonstrates that the strategic removal of redundant experts, followed by unstructured pruning, outperforms structured-only and unstructured-only pruning." class="wp-image-47198" srcset="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/05/GSM8K-5-shot-accuracy-for-Snowflake-Arctic.png?w=757&amp;ssl=1 757w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/05/GSM8K-5-shot-accuracy-for-Snowflake-Arctic.png?resize=200%2C114&amp;ssl=1 200w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/05/GSM8K-5-shot-accuracy-for-Snowflake-Arctic.png?resize=220%2C125&amp;ssl=1 220w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/05/GSM8K-5-shot-accuracy-for-Snowflake-Arctic.png?resize=120%2C68&amp;ssl=1 120w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/05/GSM8K-5-shot-accuracy-for-Snowflake-Arctic.png?resize=160%2C91&amp;ssl=1 160w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/05/GSM8K-5-shot-accuracy-for-Snowflake-Arctic.png?resize=300%2C171&amp;ssl=1 300w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/05/GSM8K-5-shot-accuracy-for-Snowflake-Arctic.png?resize=480%2C273&amp;ssl=1 480w" sizes="(max-width: 757px) 100vw, 757px" /><figcaption class="wp-element-caption">GSM8K 5-shot accuracy for Snowflake Arctic, a 480B Mixture-of-Experts model, after applying different pruning strategies to varying degrees. Structured-only pruning exhibits a significant performance loss as more and more experts are removed. (A sparsity of 30% corresponds to just 90 of the original 128 experts left.) Unstructured-only pruning maintains an unchanged performance up to the point where 30% of the weights are removed. With STUN, the combination of both approaches, benchmark performance remains virtually unaffected up to a sparsity of 40%. This demonstrates that the strategic removal of redundant experts, followed by unstructured pruning, outperforms structured-only and unstructured-only pruning. | <a href="https://arxiv.org/pdf/2409.06211" target="_blank" rel="noreferrer noopener nofollow">Source</a></figcaption></figure>
</div>


<p>In some cases, STUN performed orders of magnitude better than unstructured pruning methods. Our O(1) expert pruning method also outperformed existing, more computationally expensive methods, such as <a href="https://arxiv.org/abs/2310.05175" target="_blank" rel="noreferrer noopener nofollow">Lu et al. (2024)</a>, highlighting the effectiveness of our approach.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-whats-next-in-moe-pruning">What’s next in MoE pruning?</h2>



<p>Since STUN does not make any assumption about base MoE models, it is generalizable to other MoE families, such as Mixtral. Our code is <a href="https://github.com/thnkinbtfly/STUN" target="_blank" rel="noreferrer noopener nofollow">available on GitHub</a>. We encourage you to read our paper and adapt it to your MoE models.</p>



<p>Beyond applying and evaluating STUN, a crucial next area of optimization is hardware acceleration for unstructuredly pruned models. Unstructured pruning removes individual weights without considering their location or arrangement in the model. Because of this, the resulting model’s sparsity is random and unaligned—some rows, columns, or even small sections may become very sparse, while others remain dense.</p>



<p>This irregularity is challenging because hardware like GPUs or TPUs assumes regular, contiguous memory layouts. While structured pruning yields a predictable sparsity pattern that allows for memory optimization, the irregularly sparse models resulting from unstructured pruning prevent efficient memory access and parallel processing.</p>



<p>Specialized hardware support can reorganize memory access patterns to reduce overheads from irregularity. Such co-evolution of hardware and software support will likely further establish pruning as a cornerstone of scaling and applying MoE models.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">47194</post-id>	</item>
		<item>
		<title>Bayesian Deep Learning is Needed in the Age of Large-Scale AI [Paper Reflection]</title>
		<link>https://neptune.ai/blog/bayesian-deep-learning-needed-in-the-age-of-large-scale-ai</link>
		
		<dc:creator><![CDATA[Vincent Fortuin]]></dc:creator>
		<pubDate>Thu, 13 Mar 2025 11:30:00 +0000</pubDate>
				<category><![CDATA[LLMOps]]></category>
		<category><![CDATA[Paper Reflections]]></category>
		<guid isPermaLink="false">https://neptune.ai/?p=44106</guid>

					<description><![CDATA[In his famous blog post Artificial Intelligence — The Revolution Hasn’t Happened Yet, Michael Jordan (the AI researcher, not the one you probably thought of first) tells a story about how he might have almost lost his unborn daughter due to a faulty AI prediction. He speculates that many children die needlessly each year in&#8230;]]></description>
										<content:encoded><![CDATA[
<p>In his famous blog post <a href="https://medium.com/@mijordan3/artificial-intelligence-the-revolution-hasnt-happened-yet-5e1d5812e1e7" target="_blank" rel="noreferrer noopener nofollow"><em>Artificial Intelligence — The Revolution Hasn’t Happened Yet</em></a>, Michael Jordan (the AI researcher, not the one you probably thought of first) tells a story about how he might have almost lost his unborn daughter due to a faulty AI prediction. He speculates that many children die needlessly each year in the same way. Abstracting away the specifics of his case, this is one example of an application in which an AI algorithm&#8217;s performance looked good on paper during its development but led to bad decisions once deployed.</p>



<p>In our paper <a href="https://proceedings.mlr.press/v235/papamarkou24b.html" target="_blank" rel="noreferrer noopener nofollow"><em>Bayesian Deep Learning is Needed in the Age of Large-Scale AI</em></a>, we argue that the case above is not the exception but rather the rule and a direct consequence of the research community&#8217;s focus on predictive accuracy as a single metric of interest.</p>



<p>Our position paper was born out of the observation that the annual <a href="https://approximateinference.org/" target="_blank" rel="noreferrer noopener nofollow">Symposium on Advances of Approximate Bayesian Inference</a>, despite its immediate relevance to these questions, attracted fewer junior researchers over the years. At the same time, many of our students and younger colleagues seemed unaware of the fundamental problems with current practices in machine learning research—especially when it comes to large-scale efforts like the work on foundation models, which grab most of the attention today but fall short in terms of safety, reliability, and robustness.</p>



<p>We reached out to fellow researchers in Bayesian deep learning and eventually assembled a group of researchers from 29 of the most renowned institutions around the world, working at universities, government labs, and industry. Together, we wrote the paper to make the case that Bayesian deep learning offers promising solutions to core problems in machine learning and is ready for application beyond academic experiments. In particular, we point out that there are many other metrics beyond accuracy, such as uncertainty calibration, which we have to take into account to ensure that better models also translate to better outcomes in downstream applications.</p>



<p>In this commentary, I will expand on the importance of decisions as a goal for machine learning systems, in contrast to singular metrics. Moreover, I will make the case for why Bayesian deep learning can satisfy these desiderata and briefly review recent advances in the field. Finally, I will provide an outlook for the future of this research area and give some advice on how you can already use the power of Bayesian deep learning solutions in your research or practice today.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-machine-learning-for-decisions">Machine learning for decisions</h2>



<p>If you open any machine learning research paper presented at one of the big conferences, chances are that you will find a big table with a lot of numbers. These numbers usually reflect the predictive accuracy of different methods on different datasets, and the line corresponding to the authors&#8217; proposed method probably has a lot of bold numbers, indicating that they are higher than the ones of the other methods.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img data-recalc-dims="1" decoding="async" width="1201" height="745" src="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=1201%2C745&#038;ssl=1" alt="The results table from the ResNet paper is a typical example of how results are presented in machine learning publications. The researchers applied different models and model variants to the same dataset and measured two metrics. The best metric values—usually belonging to the researchers’ newly devised model—are boldened." class="wp-image-44108" style="width:522px;height:auto" srcset="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?w=1201&amp;ssl=1 1201w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=768%2C476&amp;ssl=1 768w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=200%2C124&amp;ssl=1 200w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=220%2C136&amp;ssl=1 220w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=120%2C74&amp;ssl=1 120w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=160%2C99&amp;ssl=1 160w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=300%2C186&amp;ssl=1 300w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=480%2C298&amp;ssl=1 480w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-ResNet-paper.png?resize=1020%2C633&amp;ssl=1 1020w" sizes="(max-width: 1000px) 100vw, 1000px" /><figcaption class="wp-element-caption">The results table from <a href="https://arxiv.org/abs/1512.03385" target="_blank" rel="noreferrer noopener nofollow">the ResNet paper</a> is a typical example of how results are presented in machine learning publications. The researchers applied different models and model variants to the same dataset and measured two metrics. The best metric values—usually belonging to the researchers’ newly devised model—are boldened.</figcaption></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter size-large"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1920" height="587" src="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=1920%2C587&#038;ssl=1" alt="In the results table from the Vision Transformer paper, the authors compare three of their own model variants against the prior state-of-the-art ResNet-152 model. They trained all four models on seven different datasets and measured the accuracy. Their findings indicate that the ViT-H/14 model (first column) outperforms the other models on six of the seven datasets. Crucially, this does not allow any conclusions about how any of the models would perform on a particular downstream task. (The last line of the table, labeled “TPUv3-core-days,” indicates the number of days it took to train the models on TPUs.)" class="wp-image-44110" srcset="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=1920%2C587&amp;ssl=1 1920w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=768%2C235&amp;ssl=1 768w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=200%2C61&amp;ssl=1 200w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=1536%2C469&amp;ssl=1 1536w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=220%2C67&amp;ssl=1 220w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=120%2C37&amp;ssl=1 120w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=160%2C49&amp;ssl=1 160w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=300%2C92&amp;ssl=1 300w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=480%2C147&amp;ssl=1 480w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?resize=1020%2C312&amp;ssl=1 1020w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/The-results-table-from-the-Vision-Transformer-paper.png?w=1999&amp;ssl=1 1999w" sizes="auto, (max-width: 1000px) 100vw, 1000px" /><figcaption class="wp-element-caption">In the results table from the <a href="https://arxiv.org/abs/2010.11929" target="_blank" rel="noreferrer noopener nofollow">Vision Transformer paper</a>, the authors compare three of their own model variants against the prior state-of-the-art ResNet-152 model. They trained all four models on seven different datasets and measured the accuracy. Their findings indicate that the ViT-H/14 model (first column) outperforms the other models on six of the seven datasets. Crucially, this does not allow any conclusions about how any of the models would perform on a particular downstream task. (The last line of the table, labeled “TPUv3-core-days,” indicates the number of days it took to train the models on <a href="https://en.wikipedia.org/wiki/Tensor_Processing_Unit" target="_blank" rel="noreferrer noopener nofollow">TPUs</a>.)</figcaption></figure>
</div>


<p>Based on this observation, one might believe that bold numbers in tables are all that matters in the world. However, I want to strongly argue that this is not the case. What matters in the real world are <em>decisions—</em>or, more precisely, decisions and their associated <em>utilities</em>.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="h-a-motivating-example">A motivating example</h3>



<p>Imagine you overslept and are now running the risk of getting late to work. Moreover, there is a new construction site on your usual route to work, and there is also a parade going on in town today. This makes the traffic situation rather hard to predict. It is 08:30 am, and you have to be at work by 09:00. There are three different routes you can take: through the city, via the highway, or through the forest. How do you choose?</p>



<p>Luckily, some clever AI researchers have built tools that can predict the time each route takes. There are two tools to choose from, Tool A and Tool B, and these are their predictions:</p>



<div id="medium-table-block_4d77ed5f701252e13e2512c123336e34"
     class="block-medium-table c-table__outer-wrapper  l-padding__top--0 l-padding__bottom--0 l-margin__top--standard l-margin__bottom--standard">

    <table class="c-table">
                    <thead class="c-table__head">
            <tr>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            &nbsp;                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            City                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Highway                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Forest                        </div>
                    </td>
                            </tr>
            </thead>
        
        <tbody class="c-table__body">

                    
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><strong>Tool A</strong></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">35 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">25 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">43 min</span></p>
                                                            </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><strong>Tool B</strong></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">28 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">32 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">35 min</span></p>
                                                            </div>
                        </td>

                    
                </tr>

                    
        </tbody>
    </table>

</div>



<p>Annoyingly, Tool A suggests that you should use the highways, but Tool B suggests the city. However, as a tech-savvy user, you actually know that B uses a newer algorithm, and you have read the paper and marveled at the bold numbers. You know that B yields a lower mean-squared error (MSE), a common measure for predictive performance on regression tasks.</p>



<p>Confidently, you choose to trust Tool B and thus take the route through the city—just to arrive at 09:02 and get an annoyed side-glance from your boss for being late.</p>



<p>But how did that happen? You chose the best tool, after all! Let&#8217;s look at the ground-truth travel times:</p>



<div id="medium-table-block_db8f04c93b3209fe1f42365be4064b82"
     class="block-medium-table c-table__outer-wrapper  l-padding__top--0 l-padding__bottom--0 l-margin__top--standard l-margin__bottom--standard">

    <table class="c-table">
                    <thead class="c-table__head">
            <tr>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            &nbsp;                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            City                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Highway                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Forest                        </div>
                    </td>
                            </tr>
            </thead>
        
        <tbody class="c-table__body">

                    
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><strong>True driving time</strong></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">32 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">25 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">35 min</span></p>
                                                            </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                </tr>

                    
        </tbody>
    </table>

</div>



<p>As we can see, the highway was actually the fastest one and, in fact, the only one that would have gotten you to work on time. But how is that possible? This will become clear when we compute the MSE in these times for the two predictive algorithms:</p>



<section id="note-block_1e171f21e960000d699f9585a9229f73"
         class="block-note c-box c-box--default c-box--dark c-box--no-hover c-box--standard ">

    
    <div class="block-note__content">
                    <div class="c-item c-item--wysiwyg_editor">

                
                
                <div class="c-item__content">

                                            <p><span style="font-weight: 400;">MSE(A) = [ (35-32)</span><span style="font-weight: 400;">²</span><span style="font-weight: 400;"> + (25-25)</span><span style="font-weight: 400;">²</span><span style="font-weight: 400;"> + (43-35)</span><span style="font-weight: 400;">²</span><span style="font-weight: 400;">] / 3 = 24.3</span></p>
<p><span style="font-weight: 400;">MSE(B) = [ (28-32)</span><span style="font-weight: 400;">² </span><span style="font-weight: 400;">+ (32-25)</span><span style="font-weight: 400;">²</span><span style="font-weight: 400;"> + (35-35)</span><span style="font-weight: 400;">²</span><span style="font-weight: 400;">] / 3 = </span><b>21.7</b></p>
                                    </div>

            </div>
            </div>


</section>



<p>Indeed, we see that Tool B has the better MSE, as advertised in the paper. But that didn&#8217;t help you now, did it? What you ultimately cared about was not having the most accurate predictions across all possible routes but making <em>the best decision</em> regarding which route to take, namely the decision that gets you to work in time.</p>



<p>While Tool A makes worse predictions on average, its predictions are better for routes with shorter travel times and get worse the longer a route takes. It also never <em>underestimates</em> travel times.</p>



<p>To get to work on time, you don&#8217;t care about the predictions for the slowest routes, only about the fastest ones. You’d also like to have the confidence to arrive on time and not choose a route that then actually ends up taking longer. Thus, while Tool A has a worse MSE, it actually leads to better decisions.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="h-uncertainty-estimation-to-the-rescue">Uncertainty estimation to the rescue</h3>



<p>Of course, if you had known that the prediction could have been so wrong, you might have never trusted it in the first place, right? Let’s add another useful feature to the predictions: uncertainty estimation.</p>



<p>Here are the original two algorithms and a new third one (Tool C) that estimates its own predictive uncertainties:</p>



<div id="medium-table-block_72e1a7bee95cdf45df2f01bf628311ae"
     class="block-medium-table c-table__outer-wrapper  l-padding__top--0 l-padding__bottom--0 l-margin__top--standard l-margin__bottom--standard">

    <table class="c-table">
                    <thead class="c-table__head">
            <tr>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            &nbsp;                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            City                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Highway                        </div>
                    </td>
                                    <td class="c-item"
                        style="">
                        <div class="c-item__inner">
                            Forest                        </div>
                    </td>
                            </tr>
            </thead>
        
        <tbody class="c-table__body">

                    
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><strong>Tool A</strong></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">35 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">25 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">43 min</span></p>
                                                            </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><strong>Tool B</strong></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">28 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">32 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">35 min</span></p>
                                                            </div>
                        </td>

                    
                </tr>

            
                <tr class="c-row">

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><strong>Tool C</strong></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">25 +/- 8 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">27 +/- 2 min</span></p>
                                                            </div>
                        </td>

                    
                        <td class="c-ceil">
                            <div class="c-ceil__inner">
                                                                    <p><span style="font-weight: 400;">37 +/- 4 min</span></p>
                                                            </div>
                        </td>

                    
                </tr>

                    
        </tbody>
    </table>

</div>



<p>The ranking based on mean predictions of Tool C agrees with Tool B. However, you can now assess how much risk there is that you run late to work. Your true utility is not to be at work in the shortest time possible but to be at work on time, i.e., within a maximum of 30 min.</p>



<p>According to Tool C, the drive through the city can take between 17 and 32 min, so while it seems to be the fastest on average, there is a chance that you will be late. In contrast, the highway can take between 25 and 29 min, so you will be on time in any case. Armed with these uncertainty estimates, you’d make the correct choice of choosing the highway.</p>



<p>This was just one example of a scenario in which we are faced with decisions whose utility does not correlate with an algorithm&#8217;s raw predictive accuracy, and uncertainty estimation is crucial to making better decisions.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-the-case-for-bayesian-deep-learning">The case for Bayesian deep learning</h2>



<p><a href="/blog/bayesian-neural-networks-with-jax" target="_blank" rel="noreferrer noopener">Bayesian deep learning</a> uses the foundational statistical principles of <a href="https://en.wikipedia.org/wiki/Bayesian_inference" target="_blank" rel="noreferrer noopener nofollow">Bayesian inference</a> to endow deep learning systems with the ability to make probabilistic predictions. These predictions can then be used to derive uncertainty intervals of the form shown in the previous example (which a Bayesian would call &#8220;credible intervals&#8221;).</p>



<p>Uncertainty intervals can encompass <em>aleatoric uncertainty</em>, that is, the uncertainty inherent in the randomness of the world (e.g., whether your neighbor decided to leave the car park at the same time as you), and <em>epistemic uncertainty</em>, related to our lack of knowledge (e.g., we might not know how fast the parade moves).</p>



<p>Crucially, by applying Bayes&#8217; theorem, we can incorporate prior knowledge into the predictions and uncertainty estimates of our Bayesian deep learning model. For example, we can use our understanding of how traffic flows around a construction site to estimate potential delays.</p>



<p>Frequentist statisticians will often criticize this aspect of Bayesian inference as &#8220;subjective&#8221; and will advocate for &#8220;distribution-free&#8221; approaches, such as <a href="https://en.wikipedia.org/wiki/Conformal_prediction" target="_blank" rel="noreferrer noopener nofollow">conformal prediction</a>, which give you provable guarantees for the coverage of the prediction intervals. However, these guarantees only hold uniformly across all the predictions (in our example, across all the routes), but not necessarily in any given case.</p>



<p>As we have seen in our example, we don&#8217;t care that much about the accuracy (and, in extension, uncertainty estimates) on the slower routes. As long as the predictions and uncertainty estimates for the fast routes are accurate, a tool serves its purpose. Conformal methods cannot provide such a marginal coverage guarantee for each route, limiting their applicability in many scenarios.</p>


    <a
        href="/blog/bayesian-neural-networks-with-jax"
        id="cta-box-related-link-block_2cb95e95d196b5b9f6c717b3a8267df8"
        class="block-cta-box-related-link  l-margin__top--standard l-margin__bottom--standard"
        target="_blank" rel="nofollow noopener noreferrer"    >

    
    <div class="block-cta-box-related-link__description-wrapper block-cta-box-related-link__description-wrapper--full">

        
            <div class="c-eyebrow">

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-related--article.svg"
                    loading="lazy"
                    decoding="async"
                    width="16"
                    height="16"
                    alt=""
                    class="c-eyebrow__icon">

                <div class="c-eyebrow__text">
                    Related                </div>
            </div>

        
                    <h3 class="c-header" class="c-header" id="h-bayesian-neural-networks-implementing-training-inference-with-the-jax-framework">                Bayesian Neural Networks—Implementing, Training, Inference With the JAX Framework            </h3>        
                    <div class="c-button c-button--tertiary c-button--small">

                <span class="c-button__text">
                    Read more                </span>

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-button-arrow-right.svg"
                    loading="lazy"
                    decoding="async"
                    width="12"
                    height="12"
                    alt=""
                    class="c-button__arrow">

            </div>
            </div>

    </a>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-but-bayesian-deep-learning-doesnt-work">“But Bayesian deep learning doesn’t work”</h2>



<p>If you have only superficially followed the field of Bayesian deep learning a few years ago and have then stopped paying attention, distracted by all the buzz around LLMs and generative AI, you would be excused in believing that it has elegant principles and a strong motivation, but does not actually work in practice. Indeed, this truly was the case until only very recently.</p>



<p>However, in the last few years, the field has seen many breakthroughs that allow for this framework to finally deliver on its promises. For instance, performing Bayesian inference on posterior distributions over millions of neural network parameters used to be computationally intractable, but we now have <a href="https://proceedings.neurips.cc/paper_files/paper/2021/hash/a7c9585703d275249f30a088cebba0ad-Abstract.html" target="_blank" rel="noreferrer noopener nofollow">scalable approximate inference methods</a> that are only marginally more costly than standard neural network training.</p>



<p>Moreover, it used to be hard to choose the right model class for a given problem, but we have made great progress in automating this decision away from the user thanks to advances in <a href="https://proceedings.mlr.press/v139/immer21a.html" target="_blank" rel="noreferrer noopener nofollow">Bayesian model selection</a>.</p>



<p>While it is still nearly impossible to design a meaningful prior distribution over neural network parameters, we have found <a href="https://jmlr.org/papers/v23/20-1340.html" target="_blank" rel="noreferrer noopener nofollow">different</a> <a href="https://openreview.net/forum?id=83vxe8alV4" target="_blank" rel="noreferrer noopener nofollow">ways</a> to specify priors directly over functions, which is much more intuitive for most practitioners. Finally, some troubling conundra related to the behavior of the Bayesian neural network posterior, such as the infamous <a href="https://proceedings.mlr.press/v119/wenzel20a.html" target="_blank" rel="noreferrer noopener nofollow">cold posterior effect</a>, are <a href="https://proceedings.neurips.cc/paper_files/paper/2021/hash/6a12d7ebc27cae44623468302c47ad74-Abstract.html" target="_blank" rel="noreferrer noopener nofollow">much better understood now</a>.</p>



<p>Armed with these tools, Bayesian deep learning models have then started to have a beneficial impact in many domains, including healthcare, robotics, and science. For instance, <a href="https://proceedings.mlr.press/v235/bouchiat24a.html" target="_blank" rel="noreferrer noopener nofollow">we have shown</a> that in the context of predicting health outcomes for patients in the intensive care unit based on time series data, a Bayesian deep learning approach can not only yield better predictions and uncertainty estimates but also lead to recommendations that are more interpretable for medical practitioners. <a href="https://proceedings.mlr.press/v235/papamarkou24b.html" target="_blank" rel="noreferrer noopener nofollow">Our position paper</a> contains detailed accounts of this and other noteworthy examples.</p>



<p>However, Bayesian deep learning is unfortunately still not as easy to use as standard deep learning, which you can do these days in a few lines of <a href="https://pytorch.org/" target="_blank" rel="noreferrer noopener nofollow">PyTorch</a> code.</p>



<p>If you want to use a Bayesian deep learning model, first, you have to think about <a href="https://onlinelibrary.wiley.com/doi/full/10.1111/insr.12502" target="_blank" rel="noreferrer noopener nofollow">specifying the prior</a>. This is a crucial component of the Bayesian paradigm and might sound like a chore, but if you actually have prior knowledge about the task at hand, this can really improve your performance.</p>



<p>Then, you are still left with choosing an approximate inference algorithm, depending on how much computational budget you are willing to spend. Some algorithms are very cheap (such as <a href="https://github.com/aleximmer/Laplace" target="_blank" rel="noreferrer noopener nofollow">Laplace inference</a>), but if you want really high-fidelity uncertainty estimates, you might have to opt for a more expensive one (e.g., <a href="https://github.com/TyXe-BDL/TyXe" target="_blank" rel="noreferrer noopener nofollow">Markov Chain Monte Carlo</a>).</p>



<p>Finally, you have to find the right implementation of that algorithm that also works with your model. For instance, some inference algorithms might only work with certain types of normalization operators (e.g., layer norm vs. batch norm) or might not work with <a href="/blog/deep-learning-model-optimization-methods#h-quantization-reducing-the-memory-footprint-by-lowering-computational-precision" target="_blank" rel="noreferrer noopener">low-precision weights</a>.</p>



<p>As a research community, we should make it a priority to make these tools more easily usable for normal practitioners without a background in ML research.</p>


    <a
        href="/blog/logging-pymc-and-arviz-artifacts-on-neptune"
        id="cta-box-related-link-block_3cecdba64ab9f1661b542c9c3ede81c2"
        class="block-cta-box-related-link  l-margin__top--standard l-margin__bottom--standard"
        target="_blank" rel="nofollow noopener noreferrer"    >

    
    <div class="block-cta-box-related-link__description-wrapper block-cta-box-related-link__description-wrapper--full">

        
            <div class="c-eyebrow">

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-related--article.svg"
                    loading="lazy"
                    decoding="async"
                    width="16"
                    height="16"
                    alt=""
                    class="c-eyebrow__icon">

                <div class="c-eyebrow__text">
                    Related                </div>
            </div>

        
                    <h3 class="c-header" class="c-header" id="h-logging-pymc-and-arviz-artifacts-on-neptune">                Logging PyMC and Arviz Artifacts on Neptune             </h3>        
                    <div class="c-button c-button--tertiary c-button--small">

                <span class="c-button__text">
                    Read more                </span>

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-button-arrow-right.svg"
                    loading="lazy"
                    decoding="async"
                    width="12"
                    height="12"
                    alt=""
                    class="c-button__arrow">

            </div>
            </div>

    </a>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-the-road-ahead">The road ahead</h2>



<p>This commentary on our position paper has hopefully convinced you that there is more to machine learning than predictive accuracies on a test set. Indeed, if you use predictions from an AI model to make decisions, in almost all circumstances, you should care about ways to incorporate your prior knowledge into the model and get uncertainty estimates out of it. If this is the case, trying out Bayesian deep learning is likely worth your while.</p>



<p>A good place to start is the <a href="https://arxiv.org/abs/2309.16314" target="_blank" rel="noreferrer noopener nofollow"><em>Primer on Bayesian Neural Networks</em></a> that I wrote together with three colleagues. I’ve also written a <a href="https://onlinelibrary.wiley.com/doi/full/10.1111/insr.12502" target="_blank" rel="noreferrer noopener nofollow"><em>review on priors in Bayesian Deep Learning</em></a> that’s published open access. Once you understand the theoretical foundations and feel ready to get your hands dirty with some actual Bayesian deep learning in PyTorch, check out some popular libraries for inference methods such as <a href="https://github.com/aleximmer/Laplace" target="_blank" rel="noreferrer noopener nofollow">Laplace inference</a>, <a href="https://github.com/aleximmer/Laplace" target="_blank" rel="noreferrer noopener nofollow">variational inference</a>, and <a href="https://github.com/TyXe-BDL/TyXe" target="_blank" rel="noreferrer noopener nofollow">Markov chain Monte Carlo methods</a>.</p>



<p>Finally, if you are a researcher and would like to get involved in the Bayesian deep learning community, especially contributing to the goal of better benchmarking to show the positive impact on real decision outcomes and to the goal of building easy-to-use software tools for practitioners, feel free to <a href="https://fortuin.github.io/" target="_blank" rel="noreferrer noopener nofollow">reach out to me</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">44106</post-id>	</item>
		<item>
		<title>Open LLMs are Necessary For Current Private Adaptations and Outperform Their Closed Alternatives [Paper Reflection]</title>
		<link>https://neptune.ai/blog/open-llms-are-necessary-for-current-private-adaptations-and-outperform-closed-alternatives</link>
		
		<dc:creator><![CDATA[Olatunji Iyiola Emmanuel]]></dc:creator>
		<pubDate>Thu, 20 Feb 2025 11:30:00 +0000</pubDate>
				<category><![CDATA[LLMOps]]></category>
		<category><![CDATA[Paper Reflections]]></category>
		<guid isPermaLink="false">https://neptune.ai/?p=44080</guid>

					<description><![CDATA[Closed Large Language Models (LLMs), which are proprietary and accessible only via APIs, have dominated the LLM space since around 2022 due to their high performance and versatility. However, Open LLMs have made substantial progress, narrowing the performance gap with their Closed LLM counterparts. Open LLMs are models whose architecture and parameters are publicly available&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Closed Large Language Models (LLMs), which are proprietary and accessible only via APIs, have dominated the LLM space since around 2022 due to their high performance and versatility. However, Open LLMs have made substantial progress, narrowing the performance gap with their Closed LLM counterparts. Open LLMs are models whose architecture and parameters are publicly available for use, modification, and distribution.</p>



<p>For instance, while Closed LLMs like Anthropic’s <a href="https://www.anthropic.com/claude" target="_blank" rel="noreferrer noopener nofollow">Claude</a> (released in March 2023) and OpenAI’s <a href="https://openai.com/index/gpt-4/" target="_blank" rel="noreferrer noopener nofollow">GPT-4</a> (released in March 2023) set new benchmarks upon their launches, the Open LLM <a href="https://ai.meta.com/blog/meta-llama-3/" target="_blank" rel="noreferrer noopener nofollow">Llama 3</a> released by Meta in April 2024 and <a href="https://www.deepseek.com/" target="_blank" rel="noreferrer noopener nofollow">DeepSeek-R1</a> released in January 2025 not only matched but <a href="/blog/fine-tuning-llama-3-with-lora#h-llama-3-performance" target="_blank" rel="noreferrer noopener">surpassed these models in tasks such as coding, reasoning, text classification, summarization, and question answering</a>.</p>



<p>While much of the discussion around LLMs centers on task and computational performance, in our paper <a href="https://arxiv.org/pdf/2411.05818" target="_blank" rel="noreferrer noopener nofollow"><em>Open LLMs are Necessary for Current Private Adaptations and Outperform their Closed Alternatives</em></a>, we focus on the privacy implications of using Open and Closed LLMs. Specifically, we explore whether and how models can be fine-tuned on sensitive data while ensuring robust privacy guarantees.</p>



<p>To this end, we define threat models, compare various Open and Closed LLMs that leverage <a href="https://en.wikipedia.org/wiki/Differential_privacy">di</a><a href="https://en.wikipedia.org/wiki/Differential_privacy" target="_blank" rel="noreferrer noopener nofollow">f</a><a href="https://en.wikipedia.org/wiki/Differential_privacy">ferential privacy (DP)</a> on classification and generation tasks and analyze methodological limitations. Our research results in a thorough analysis of the privacy-utility tradeoff under different privacy levels.</p>



<p>Our findings indicate that Open LLMs can be adapted to private data without leaking information to third parties, such as LLM providers and malicious users. Thus, they offer a significant privacy advantage over Closed, proprietary models.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-the-threat-space-in-adapting-llms-to-private-data">The threat space in adapting LLMs to private data</h2>



<p>The adaptation of Closed LLMs to private datasets introduces a multifaceted threat space. In typical scenarios, data curators provide their sensitive data to LLM providers for fine-tuning, producing a model tailored to the dataset. This customized model is subsequently queried by external parties, e.g., customers of the data curator.</p>



<p>The resulting threat space can be categorized into three key dimensions:</p>



<ol class="wp-block-list">
<li><strong>From the data curator to the LLM provider:</strong> The private data shared during fine-tuning may be susceptible to unauthorized access or misuse.</li>



<li><strong>From the querying party to the LLM provider:</strong> Queries submitted by end users, which often contain sensitive information intended for the data curator, are exposed to the LLM provider.</li>
</ol>



<ol start="3" class="wp-block-list">
<li><strong>From malicious end users to the adapted LLM:</strong> Malicious end users may attempt to <a href="/blog/adversarial-machine-learning-defense-strategies" target="_blank" rel="noreferrer noopener">extract private information</a> through the LLM&#8217;s responses to carefully crafted queries.</li>
</ol>



<p>In contrast to Closed LLMs, Open LLMs provide full control over the model and data, enabling private adaptation without the need to share sensitive information with a third party. This control eliminates the first two threat vectors associated with Closed LLMs, such as unauthorized access or misuse by the provider and exposure of user queries. With Open LLMs, data curators can directly fine-tune the model on private datasets using privacy-preserving techniques, ensuring end-to-end privacy.</p>


    <a
        href="/blog/adversarial-machine-learning-defense-strategies"
        id="cta-box-related-link-block_4f6d74281af895cb91f1169eae2edd8c"
        class="block-cta-box-related-link  l-margin__top--standard l-margin__bottom--standard"
        target="_blank" rel="nofollow noopener noreferrer"    >

    
    <div class="block-cta-box-related-link__description-wrapper block-cta-box-related-link__description-wrapper--full">

        
            <div class="c-eyebrow">

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-related--article.svg"
                    loading="lazy"
                    decoding="async"
                    width="16"
                    height="16"
                    alt=""
                    class="c-eyebrow__icon">

                <div class="c-eyebrow__text">
                    Related                </div>
            </div>

        
                    <h3 class="c-header" class="c-header" id="h-adversarial-machine-learning-defense-strategies">                Adversarial Machine Learning: Defense Strategies            </h3>        
                    <div class="c-button c-button--tertiary c-button--small">

                <span class="c-button__text">
                    Read more                </span>

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-button-arrow-right.svg"
                    loading="lazy"
                    decoding="async"
                    width="12"
                    height="12"
                    alt=""
                    class="c-button__arrow">

            </div>
            </div>

    </a>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-what-are-the-current-methods-for-private-adaptation-of-llms">What are the current methods for private adaptation of LLMs?&nbsp;</h2>



<p>It follows from our threat space analysis that restricting access to the fine-tuning dataset alone does not guarantee data privacy. <a href="/blog/adversarial-machine-learning-defense-strategies" target="_blank" rel="noreferrer noopener">Model outputs can still reveal sensitive information</a> from the fine-tuning data. If the fine-tuned model is exposed (e.g., via an API), it remains vulnerable to information extraction and inference attacks.<br></p>



<p><a href="https://en.wikipedia.org/wiki/Differential_privacy" target="_blank" rel="noreferrer noopener nofollow">Differential privacy (DP)</a> introduces a rigorous mathematical framework that ensures the privacy of individuals whose data is used in the fine-tuning process. Specifically, DP adds carefully calibrated noise to the model updates, making it statistically improbable to determine whether any individual&#8217;s data was included in the fine-tuning dataset. Its quantifiable and robust privacy guarantee makes DP valuable for <a href="https://arxiv.org/abs/2305.15594" target="_blank" rel="noreferrer noopener nofollow">protecting sensitive information in LLM fine-tuning</a>.</p>



<p>While DP provides privacy guarantees for both Open and Closed LLMs, it does not address the issue of trust in third-party providers for Closed LLMs. For these models, data curators must rely on the provider to implement safeguards and handle sensitive data responsibly.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="h-private-adaptation-methods-for-closed-llms">Private adaptation methods for Closed LLMs&nbsp;</h3>



<p>We can rule out fine-tuning services offered by LLM providers (e.g., <a href="https://platform.openai.com/docs/guides/fine-tuning" target="_blank" rel="noreferrer noopener nofollow">OpenAI</a> and <a href="https://aws.amazon.com/bedrock/amazon-models/titan" target="_blank" rel="noreferrer noopener nofollow">Amazon</a>), as this entails sharing private data with a third party. Closed LLMs are accessible only via APIs. Thus, we cannot access and adapt the model&#8217;s weights directly.</p>



<p>Instead, private adaptation methods for Closed LLMs rely on <a href="https://openreview.net/forum?id=x4OPJ7lHVU" target="_blank" rel="noreferrer noopener nofollow">privacy-preserving discrete prompts or private in-context learning (ICL)</a>. These approaches work by <a href="/blog/prompt-engineering-strategies" target="_blank" rel="noreferrer noopener">carefully crafting input prompts</a> or <a href="/blog/zero-shot-and-few-shot-learning-with-llms" target="_blank" rel="noreferrer noopener">selecting relevant examples to guide the model&#8217;s behavior</a>, all while ensuring that sensitive information in the prompts or examples is protected from potential leakage or inference attacks.</p>



<p>All methods we evaluate in our study follow the <a href="https://arxiv.org/abs/1610.05755" target="_blank" rel="noreferrer noopener nofollow">PATE (Private Aggregation of Teacher Ensembles)</a> framework. At a high level, PATE achieves data privacy by splitting the private dataset into non-overlapping partitions. Then, each partition is used to train a so-called teacher model. These teacher models are joined into an ensemble model by combining their outputs while adding noise, which preserves privacy.</p>



<p>This ensemble is then used to train a so-called student model in the following way: The ensemble makes predictions for samples from an unlabeled public dataset. The resulting <em>(sample, ensemble prediction) </em>pairs constitute the training data for the student model. Thus, the student learns to make the same predictions as the teacher ensemble but never sees sensitive data samples. The student is what’s released as the final model.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="628" src="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=1200%2C628&#038;ssl=1" alt="Overview of the PATE framework. The sensitive dataset is divided into non-overlapping partitions, and a separate teacher model is trained on each partition. All teachers are aggregated noisily into an ensemble model, which is used to make predictions on a public dataset. The samples from the public dataset, together with the ensemble’s predictions, constitute the training data for the student model, which is the model that is eventually queried by users. " class="wp-image-44102" srcset="https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?w=1200&amp;ssl=1 1200w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=768%2C402&amp;ssl=1 768w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=200%2C105&amp;ssl=1 200w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=220%2C115&amp;ssl=1 220w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=120%2C63&amp;ssl=1 120w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=160%2C84&amp;ssl=1 160w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=300%2C157&amp;ssl=1 300w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=480%2C251&amp;ssl=1 480w, https://i0.wp.com/neptune.ai/wp-content/uploads/2025/02/PATE-framework.png?resize=1020%2C534&amp;ssl=1 1020w" sizes="auto, (max-width: 1000px) 100vw, 1000px" /><figcaption class="wp-element-caption">Overview of the PATE framework. The sensitive dataset is divided into non-overlapping partitions, and a separate teacher model is trained on each partition. All teachers are aggregated noisily into an ensemble model, which is used to make predictions on a public dataset. The samples from the public dataset, together with the ensemble’s predictions, constitute the training data for the student model, which is the model that is eventually queried by users. | <a href="https://arxiv.org/pdf/1610.05755" target="_blank" rel="noreferrer noopener nofollow">Source</a></figcaption></figure>
</div>


<p>The private adaptation methods for Closed LLMs we analyze in our study build on this general framework. They differ in how the teachers are utilized and how their responses are aggregated:</p>



<ul class="wp-block-list">
<li><a href="https://openreview.net/forum?id=x4OPJ7lHVU" target="_blank" rel="noreferrer noopener nofollow">Differentially Private In-context Learning (DP-ICL)</a>: All teachers process the same prompt, and the ensemble’s response is the noisy consensus.</li>



<li><a href="https://arxiv.org/abs/2305.15594" target="_blank" rel="noreferrer noopener nofollow">PromptPATE</a>: The teacher ensemble assigns labels to public unlabeled data via private voting. These labeled public sequences are used to create new discrete student prompts, which are deployed with the LLM.</li>



<li><a href="https://openreview.net/forum?id=oZtt0pRnOl">DP-FewSho</a><a href="https://openreview.net/forum?id=oZtt0pRnOl" target="_blank" rel="noreferrer noopener nofollow">t</a><a href="https://openreview.net/forum?id=oZtt0pRnOl">Gen</a>: The teacher ensemble generates private synthetic <a href="/blog/zero-shot-and-few-shot-learning-with-llms" target="_blank" rel="noreferrer noopener">few-shot samples</a> that are used as samples for in-context learning.</li>



<li><a href="https://openreview.net/forum?id=Ifz3IgsEPX" target="_blank" rel="noreferrer noopener nofollow">DP-OPT</a>: A local LLM generates privacy-preserving prompts and instructions from the private dataset. These are used for in-context learning for the third-party Closed LLM.</li>
</ul>



<p>In our paper, we compare the privacy protection and performance of these four state-of-the-art methods for private adaptation of Closed LLMs. When applying them to the popular Closed LLMs <a href="https://www.anthropic.com/claude" target="_blank" rel="noreferrer noopener nofollow">Claude</a>, <a href="https://platform.openai.com/docs/models#gpt-base" target="_blank" rel="noreferrer noopener nofollow">GPT-3 Babbage</a>, <a href="https://platform.openai.com/docs/models#gpt-base" target="_blank" rel="noreferrer noopener nofollow">GPT-3 Davinci</a>, and <a href="https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo" target="_blank" rel="noreferrer noopener nofollow">GPT-4 Turbo</a>, we observe that compared to private adaptation of Open LLMs, these methods offer lower performance at a higher cost on various downstream tasks, including dialog summarization, classification, and generation. Further, all methods except DP-OPT leak training data to the LLM provider.</p>


    <a
        href="/blog/zero-shot-and-few-shot-learning-with-llms"
        id="cta-box-related-link-block_ddbc60a0d36ed24eabf77cce54ac1377"
        class="block-cta-box-related-link  l-margin__top--standard l-margin__bottom--standard"
        target="_blank" rel="nofollow noopener noreferrer"    >

    
    <div class="block-cta-box-related-link__description-wrapper block-cta-box-related-link__description-wrapper--full">

        
            <div class="c-eyebrow">

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-related--article.svg"
                    loading="lazy"
                    decoding="async"
                    width="16"
                    height="16"
                    alt=""
                    class="c-eyebrow__icon">

                <div class="c-eyebrow__text">
                    Related                </div>
            </div>

        
                    <h3 class="c-header" class="c-header" id="h-zero-shot-and-few-shot-learning-with-llms">                Zero-Shot and Few-Shot Learning with LLMs             </h3>        
                    <div class="c-button c-button--tertiary c-button--small">

                <span class="c-button__text">
                    Read more                </span>

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-button-arrow-right.svg"
                    loading="lazy"
                    decoding="async"
                    width="12"
                    height="12"
                    alt=""
                    class="c-button__arrow">

            </div>
            </div>

    </a>



<h3 class="wp-block-heading" class="wp-block-heading" id="h-private-adaptation-methods-for-open-llms">Private adaptation methods for Open LLMs&nbsp;</h3>



<p>Unlike Closed LLMs, Open LLMs provide access to their parameters, enabling more flexible and parameter-centric private adaptation methods. These methods typically follow the <a href="https://arxiv.org/abs/1607.00133" target="_blank" rel="noreferrer noopener nofollow">Differentially Private Stochastic Gradient Descent (DPSGD)</a> paradigm to ensure privacy. In DPSGD, the influence of each private data point is constrained during training through <a href="/blog/understanding-gradient-clipping-and-how-it-can-fix-exploding-gradients-problem" target="_blank" rel="noreferrer noopener">gradient clipping</a> and the addition of calibrated noise. This approach guarantees that the model does not memorize or leak sensitive information.</p>



<p>In our study, we explore three primary methods for private adaptation of Open LLMs:&nbsp;</p>



<ol class="wp-block-list">
<li>Prompt-based adaptation (<a href="https://arxiv.org/abs/2305.15594" target="_blank" rel="noreferrer noopener nofollow">PromptDPSGD</a>) introduces a small number of additional parameters (&lt;1% of the model&#8217;s total parameters) in the input space through <a href="https://aclanthology.org/2022.acl-short.8/" target="_blank" rel="noreferrer noopener nofollow">soft prompts</a> or <a href="https://aclanthology.org/2021.emnlp-main.243/" target="_blank" rel="noreferrer noopener nofollow">prefix-tuning</a> and adapts Differentially Private Stochastic Gradient Descent (DPSGD) to preserve privacy.</li>



<li>Parameter-efficient fine-tuning, such as <a href="https://arxiv.org/abs/2106.09685" target="_blank" rel="noreferrer noopener nofollow">LoRA</a>, only updates a relatively small number of parameters (&lt;10% of the model’s total parameters) within the model&#8217;s architecture to enable efficient updates. <a href="https://openreview.net/forum?id=Q42f0dfjECO" target="_blank" rel="noreferrer noopener nofollow">PrivateLoRA</a> extends this approach with DP guarantees by building on the DPSGD algorithm.</li>



<li>Full fine-tuning adaptations (<a href="https://openreview.net/forum?id=bVuP3ltATMz" target="_blank" rel="noreferrer noopener nofollow">DP-FineTune</a>) involve fine-tuning the entire model or a subset of its layers for comprehensive adaptation while adhering to differential privacy principles.</li>
</ol>



<p>Applying these methods to <a href="https://proceedings.mlr.press/v202/biderman23a/biderman23a.pdf" target="_blank" rel="noreferrer noopener nofollow">Vicuna</a>, <a href="https://huggingface.co/meta-llama" target="_blank" rel="noreferrer noopener nofollow">Llama-3</a>, <a href="https://github.com/openlm-research/open_llama" target="_blank" rel="noreferrer noopener nofollow">OpenLLaMa</a>, <a href="https://arxiv.org/abs/1910.13461" target="_blank" rel="noreferrer noopener nofollow">BART</a>, <a href="https://openreview.net/forum?id=SyxS0T4tvS" target="_blank" rel="noreferrer noopener nofollow">RoBERTa</a>, and <a href="https://arxiv.org/abs/2304.01373" target="_blank" rel="noreferrer noopener nofollow">the Pythia suite of models</a>, we find that private adaptation of Open LLMs improves performance on downstream tasks and reduces costs compared to their Closed counterparts. It also provides a critical privacy benefit by eliminating the risk of exposing private data and user queries to LLM providers.</p>


    <a
        href="/blog/fine-tuning-llama-3-with-lora"
        id="cta-box-related-link-block_d50b8d49a594edec7c1ac72d273775e4"
        class="block-cta-box-related-link  l-margin__top--standard l-margin__bottom--standard"
        target="_blank" rel="nofollow noopener noreferrer"    >

    
    <div class="block-cta-box-related-link__description-wrapper block-cta-box-related-link__description-wrapper--full">

        
            <div class="c-eyebrow">

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-related--article.svg"
                    loading="lazy"
                    decoding="async"
                    width="16"
                    height="16"
                    alt=""
                    class="c-eyebrow__icon">

                <div class="c-eyebrow__text">
                    Related                </div>
            </div>

        
                    <h3 class="c-header" class="c-header" id="h-fine-tuning-llama-3-with-lora-step-by-step-guide">                Fine-Tuning Llama 3 with LoRA: Step-by-Step Guide             </h3>        
                    <div class="c-button c-button--tertiary c-button--small">

                <span class="c-button__text">
                    Read more                </span>

                <img
                    src="https://neptune.ai/wp-content/themes/neptune/img/icon-button-arrow-right.svg"
                    loading="lazy"
                    decoding="async"
                    width="12"
                    height="12"
                    alt=""
                    class="c-button__arrow">

            </div>
            </div>

    </a>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-insightful-results">Insightful results</h2>



<p>Our analysis of private adaptation methods for both Closed and Open LLMs reveals several critical findings regarding data leakage, performance, and cost:</p>



<ol class="wp-block-list">
<li><strong>Query data leakage:</strong> All private adaptation methods for Closed LLMs leak query data to the LLM provider. This means that sensitive information from user queries is exposed during the adaptation process, posing a significant privacy risk.</li>



<li><strong>Training data leakage:</strong> Only one method (<a href="https://openreview.net/forum?id=Ifz3IgsEPX" target="_blank" rel="noreferrer noopener nofollow">DP-OPT</a>) of the four methods of private adaptation of Closed LLMs successfully protects private training data from the LLM provider. However, this method requires a local LLM to effectively protect the privacy of the training data. The remaining private adaptation methods for Closed LLMs leak a large fraction of the training data to the LLM provider, undermining the privacy guarantees of the adaptation process.</li>



<li><strong>Performance:</strong> All adaptation methods for Closed LLMs achieve lower downstream task performance than privacy-preserving local adaptations on Open LLMs, even when the Open LLMs are significantly smaller than their Closed counterparts.</li>



<li><strong>Cost:</strong> The training and query costs for private adaptations of Closed LLMs are substantially higher due to the API access costs imposed by the LLM provider. In contrast, private adaptations for Open LLMs are more cost-effective. We <a href="https://www.runpod.io/gpu-instance/pricing" target="_blank" rel="noreferrer noopener nofollow">estimated the costs assuming an A40 GPU with 48 GB of memory</a>. In this scenario, privately adopting a Closed LLM to text classification tasks with <a href="https://openreview.net/forum?id=x4OPJ7lHVU" target="_blank" rel="noreferrer noopener nofollow">DP-ICL</a> costs about $140. In contrast, fine-tuning an Open LLM with <a href="https://openreview.net/forum?id=Q42f0dfjECO" target="_blank" rel="noreferrer noopener nofollow">PrivateLoRA</a> on the same tasks costs about $30.</li>
</ol>



<p>This leads to the conclusion that for a truly privacy-preserving adaptation of LLMs, one should use Open LLMs. By offering full control over the model and data, Open LLMs eliminate the risks associated with third-party providers and enable robust privacy-preserving techniques. As a result, Open LLMs address the limitations of Closed LLMs and enable efficient and customizable adaptations tailored to sensitive datasets.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">44080</post-id>	</item>
		<item>
		<title>Understanding LLMs Requires More Than Statistical Generalization [Paper Reflection]</title>
		<link>https://neptune.ai/blog/understanding-llms-requires-more-than-statistical-generalization</link>
		
		<dc:creator><![CDATA[Patrik Reizinger]]></dc:creator>
		<pubDate>Thu, 19 Dec 2024 11:00:00 +0000</pubDate>
				<category><![CDATA[LLMOps]]></category>
		<category><![CDATA[Paper Reflections]]></category>
		<guid isPermaLink="false">https://neptune.ai/?p=42880</guid>

					<description><![CDATA[In our paper, Understanding LLMs Requires More Than Statistical Generalization, we argue that current machine learning theory cannot explain the interesting emergent properties of Large Language Models, such as reasoning or in-context learning. From prior work (e.g., Liu et al., 2023) and our experiments, we’ve seen that these phenomena cannot be explained by reaching globally&#8230;]]></description>
										<content:encoded><![CDATA[
<p>In our paper, <a href="https://proceedings.mlr.press/v235/reizinger24a.html" target="_blank" rel="noreferrer noopener nofollow"><em>Understanding LLMs Requires More Than Statistical Generalization</em></a><em>, </em>we<em> </em>argue that current machine learning theory cannot explain the interesting emergent properties of Large Language Models, such as reasoning or in-context learning. From prior work (e.g., <a href="https://proceedings.mlr.press/v202/liu23ao.html" target="_blank" rel="noreferrer noopener nofollow">Liu et al., 2023)</a> and our experiments, we’ve seen that these phenomena cannot be explained by reaching globally minimal test loss – the target of statistical generalization. In other words, model comparison based on the test loss is nearly meaningless.</p>



<p>We identified three areas where more research is required:</p>



<ul class="wp-block-list">
<li>Understanding the role of inductive biases in LLM training, including the role of architecture, data, and optimization.</li>



<li>Developing more adequate measures of generalization.</li>



<li>Using formal languages to study language models in well-defined scenarios to understand transfer performance.</li>
</ul>



<p>In this commentary, we focus on diving deeper into the role of inductive biases. Inductive biases affect which solution the neural network converges to, such as the model architecture or the optimization algorithm. For example, <a href="/blog/deep-learning-optimization-algorithms#h-stochastic-gradient-descent-sgd" target="_blank" rel="noreferrer noopener">Stochastic Gradient Descent (SGD)</a> favors neural networks <a href="https://math.stackexchange.com/questions/3451272/does-gradient-descent-converge-to-a-minimum-norm-solution-in-least-squares-probl" target="_blank" rel="noreferrer noopener nofollow">with minimum-norm weights</a>.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1080" height="600" src="https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=1080%2C600&#038;ssl=1" alt="Inductive biases influence model performance. Even if two models with parameters θ1 and θ2 yield the same training and test loss, their downstream performance can differ." class="wp-image-42892" style="width:578px;height:auto" srcset="https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?w=1080&amp;ssl=1 1080w, https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=768%2C427&amp;ssl=1 768w, https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=200%2C111&amp;ssl=1 200w, https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=220%2C122&amp;ssl=1 220w, https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=120%2C67&amp;ssl=1 120w, https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=160%2C89&amp;ssl=1 160w, https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=300%2C167&amp;ssl=1 300w, https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=480%2C267&amp;ssl=1 480w, https://i0.wp.com/neptune.ai/wp-content/uploads/2024/11/Inductive-biases-influence-model-performance.png?resize=1020%2C567&amp;ssl=1 1020w" sizes="auto, (max-width: 1000px) 100vw, 1000px" /><figcaption class="wp-element-caption">Inductive biases influence model performance. Even if two models with parameters <em>θ<sub>1</sub></em> and <em>θ<sub>2</sub></em> yield the same training and test loss, their downstream performance can differ.</figcaption></figure>
</div>


<h2 class="wp-block-heading" class="wp-block-heading" id="h-how-do-language-complexity-and-model-architecture-affect-generalization-ability">How do language complexity and model architecture affect generalization ability?</h2>



<p>In their <a href="https://arxiv.org/abs/2207.02098" target="_blank" rel="noreferrer noopener nofollow"><em>Neural Networks and the Chomsky Hierarchy</em></a> paper published in 2023, Delétang et al. showed how different neural network architectures generalize better for different language types.</p>



<p>Following the well-known <a href="https://en.wikipedia.org/wiki/Chomsky_hierarchy" target="_blank" rel="noreferrer noopener nofollow">Chomsky hierarchy</a>, they distinguished four grammar types (regular, context-free, context-sensitive, and recursively enumerable) and defined corresponding sequence prediction tasks. Then, they trained different model architectures to solve these tasks and evaluated if and how well the model generalized, i.e., if a particular model architecture could handle the required language complexity.</p>



<p>In our position paper, we follow this general approach to expose the interaction of architecture and data in formal languages to gain insights into complexity limitations in natural language processing. We study popular architectures used for language modeling, e.g., Transformers, State-Space Models (SSMs) such as Mamba, the LSTM, and its novel extended version, the <a href="https://arxiv.org/abs/2405.04517" target="_blank" rel="noreferrer noopener nofollow">xLSTM</a>.</p>



<p>To investigate how these models deal with formal languages of different complexity, we use a simple setup where each language consists only of two rules. During training, we monitor how well the models perform next-token prediction on the (in-distribution) test set, measured by accuracy.</p>



<p>However, our main question is whether these models generalize out-of-distribution. For this, we introduce the notion of rule extrapolation.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-can-models-adapt-to-changing-grammar-rules">Can models adapt to changing grammar rules?</h2>



<p>To understand rule extrapolation, let’s start with an example. A simple formal language is the <em>a</em><sup>n</sup><em>b</em><sup>n</sup> language, where the strings obey two rules:<br></p>



<div id="case-study-numbered-list-block_8aab16ce3eac5dee0ed37ffadf5bcdb7"
         class="block-case-study-numbered-list ">

    
    <h2 id="h-"></h2>

    <ul class="c-list">
                    <li class="c-list__item">
                <span class="c-list__counter">1</span>
                a’s come before b’s.            </li>
                    <li class="c-list__item">
                <span class="c-list__counter">2</span>
                The number of a’s and b’s is the same.            </li>
            </ul>
</div>



<p>Examples of valid strings include “<em>ab</em>” and “<em>aabb</em>,” whereas strings like “<em>baab</em>” (violates rule 1) and “<em>aab</em>” (violates rule 2) are invalid. Having trained on such strings, we feed the models an out-of-distribution (OOD) string, violating rule 1 (e.g., a string where the first token is <em>b</em>).&nbsp;</p>



<p>We find that most models still obey rule 2 when predicting tokens, which we call rule extrapolation – they do not discard the learned rules entirely but adapt to the new situation in which rule 1 is seemingly no longer relevant.&nbsp;</p>



<p>This finding is surprising because none of the studied model architectures includes conscious choices to promote rule extrapolation. It emphasizes our point from the position paper that we need to understand the inductive biases of language models to explain emergent (OOD) behavior, such as reasoning or good <a href="/blog/zero-shot-and-few-shot-learning-with-llms" target="_blank" rel="noreferrer noopener">zero-/few-shot prompting performance</a>.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-efficient-llm-training-requires-understanding-what-is-a-complex-language-for-an-llm">Efficient LLM training requires understanding what is a complex language for an LLM</h2>



<p>According to the Chomsky hierarchy, the context-free a<sup>n</sup>b<sup>n</sup> language is less complex than the context-sensitive <em>a</em><em><sup>n</sup></em><em>b</em><em><sup>n</sup></em><em>c</em><em><sup>n</sup></em> language, where the <em>n</em> a’s and <em>n</em> b’s are followed by an equal number of c’s.</p>



<p>Despite their different complexity, the two languages seem very similar to humans. Our experiments show that, e.g., Transformers can learn context-free and context-sensitive languages equally well. However, they seem to struggle with regular languages, which are deemed to be much simpler by the Chomsky hierarchy.</p>



<p>Based on this and similar observations, we conclude that language complexity, as the Chomsky hierarchy defines it, is not a suitable predictor for how well a neural network can learn a language. To guide architecture choices in language models, we need better tools to measure the complexity of the language task we want to learn.</p>



<p>It’s an open question what these could look like. Presumably, we’ll need to find different complexity measures for different model architectures that consider their specific inductive biases.</p>



<section
	id="i-box-block_cb390c6f4b086f4f5916116ee12f02c6"
	class="block-i-box  l-margin__top--large l-margin__bottom--large">

			<header class="c-header">
			<img
				src="https://neptune.ai/wp-content/themes/neptune/img/image-ratio-holder.svg"
				data-src="https://neptune.ai/wp-content/themes/neptune/img/blocks/i-box/header-icon.svg"
				width="24"
				height="24"
				class="c-header__icon lazyload"
				alt="">

			
            <h2 class="c-header__text animation " style='max-width: 100%;'   >
                 <strong>Editor&#8217;s note</strong>
            </h2>		</header>
	
	<div class="block-i-box__inner">
		

<div
    id="custom-text-block_9a7a03ec745553ec8ceb85d0c4e6fcfa"
    class="block-custom-text  white l-padding__top--0 l-padding__bottom--0"
    style="max-width: 100%; font-size: 1rem; line-height: 1.33; font-weight: 600;"
    >
    
    Searching for a free experiment tracking solution for your academic research?
    </div>



<p></p>



<p>Join 1000s of researchers, professors, students, and Kagglers using neptune.ai for free to make monitoring experiments, comparing runs, and sharing results far easier than with open source tools.</p>



<ul
    id="arrow-list-block_b5256b035912b48190dc842d0b6ab90d"
    class="block-arrow-list block-list-item--font-size-regular">
    

<li class="block-list-item ">
    <img loading="lazy" decoding="async"
        src="https://neptune.ai/wp-content/themes/neptune/img/image-ratio-holder.svg"
        data-src="https://neptune.ai/wp-content/themes/neptune/img/blocks/list-item/arrow.svg"
        width="10"
        height="10"
        class="block-list-item__arrow lazyload"
        alt="">

    

<p>Learn more about the <a href="/research" target="_blank" rel="noreferrer noopener">program</a></p>


</li>



<li class="block-list-item ">
    <img loading="lazy" decoding="async"
        src="https://neptune.ai/wp-content/themes/neptune/img/image-ratio-holder.svg"
        data-src="https://neptune.ai/wp-content/themes/neptune/img/blocks/list-item/arrow.svg"
        width="10"
        height="10"
        class="block-list-item__arrow lazyload"
        alt="">

    

<p><a previewlistener="true" href="https://docs.neptune.ai/" target="_blank" rel="noreferrer noopener">See the docs</a>&nbsp;or watch a short&nbsp;<a href="/walkthrough" target="_blank" rel="noreferrer noopener">product demo (2 min)</a></p>


</li>


</ul>


	</div>

</section>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-whats-next">What’s next?</h2>



<p>Understanding how and why LLMs are so successful paves the way to more data-, cost- and energy efficiency. If you want to dive deeper into this topic, our position paper&#8217;s “Background” section is full of references, and we discuss numerous concrete research questions.</p>



<p><br>If you’re new to the field, I particularly recommend <a href="https://arxiv.org/abs/1905.11604" target="_blank" rel="noreferrer noopener nofollow"><em>Same Pre-training Loss, Better Downstream: Implicit Bias Matters for Language Models</em></a> (2023) by Liu et al., which nicely demonstrates the shortcomings of current evaluation practices based on the test loss. I also encourage you to check out <a href="https://arxiv.org/abs/1905.11604" target="_blank" rel="noreferrer noopener nofollow"><em>SGD on Neural Networks Learns Functions of Increasing Complexity</em></a> (2023) by Nakkiran et al. to understand more deeply how using stochastic gradient descent affects what functions neural networks learn.</p>



<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">42880</post-id>	</item>
		<item>
		<title>Learn From Failure: Fine-Tuning LLMs With Trial-and-Error Data For Intuitionistic Propositional Logic Proving [Paper Reflection]</title>
		<link>https://neptune.ai/blog/fine-tuning-llms-with-trial-and-error-data-for-intuitionistic-propositional-logic-proving</link>
		
		<dc:creator><![CDATA[Chenyang An]]></dc:creator>
		<pubDate>Thu, 28 Nov 2024 11:30:00 +0000</pubDate>
				<category><![CDATA[LLMOps]]></category>
		<category><![CDATA[Paper Reflections]]></category>
		<guid isPermaLink="false">https://neptune.ai/?p=42845</guid>

					<description><![CDATA[With the rapid advancements in large language models (LLMs), transformer-based architectures are increasingly employed as tactical generators and premise selectors in automated theorem-proving systems, generating candidate proof steps or selecting useful premises based on the unfinished proof goal. According to Fields medalist Terence Tao, the new generation of AI technology will soon become useful as&#8230;]]></description>
										<content:encoded><![CDATA[
<p>With the rapid advancements in large language models (LLMs), transformer-based architectures are increasingly employed as tactical generators and premise selectors in automated theorem-proving systems, generating candidate proof steps or selecting useful premises based on the unfinished proof goal. According to Fields medalist Terence Tao, the new generation of AI technology <a href="https://www.scientificamerican.com/article/ai-will-become-mathematicians-co-pilot/" target="_blank" rel="noreferrer noopener nofollow">will soon become useful as a “co-pilot” for research mathematicians</a>.</p>



<p>However, training LLMs to serve as proof step generators faces a significant limitation: existing mathematical datasets include only correct proof paths. In academic publications, such as textbooks and research papers, mathematicians rarely include failed approaches in their presentations of proofs. Yet, it is almost always the case that these failed attempts guide them toward discovering valid proofs, and missing those failed attempts often leaves the readers wondering, “How do they get there?”.</p>



<p>In our paper, <a href="https://arxiv.org/abs/2404.07382" target="_blank" rel="noreferrer noopener nofollow">Learn from Failure: Fine-Tuning LLMs with Trial-and-Error Data for Intuitionistic Propositional Logic Proving</a>, we explored this problem experimentally. Our goal was to assess the influence of trial-and-error information in the training data on the performance of LLMs in theorem proving.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-how-do-mathematicians-develop-proofs">How do mathematicians develop proofs?</h2>



<p>In mathematical research, the number of incorrect attempts vastly outnumbers successful ones. Mathematical reasoning is inherently iterative and nonlinear, involving numerous failed approaches and refinements. The backtracking process, wherein one recognizes a failed path and revisits earlier stages to explore alternative directions, is vital to a mathematician’s chain of thought. Thus, unsuccessful paths not only pave the way to correct proofs but are also valuable as illustrations of structured proof-search techniques.</p>



<p>The primary motivation for using large language models (LLMs) in automated theorem provers (ATPs) is their capability to emulate human reasoning. Our ultimate goal is to capture the comprehensive and systematic methods human mathematicians use in theorem proving and potentially develop novel, superior strategies.</p>



<p>However, at the time we published our paper, current approaches to training LLMs for ATPs only utilized data on correct proof attempts. Given that a model solely trained on successful proof steps is learning none of the iterative trial-and-error processes mathematicians use, it is unsurprising that despite pre-training on extensive mathematical texts, the available state-of-the-art models exhibited only modest performance on challenging theorem-proving tasks.</p>



<section
	id="i-box-block_482a2522e7eed573ac4bf6a1a5d3374e"
	class="block-i-box  l-margin__top--large l-margin__bottom--large">

			<header class="c-header">
			<img
				src="https://neptune.ai/wp-content/themes/neptune/img/image-ratio-holder.svg"
				data-src="https://neptune.ai/wp-content/themes/neptune/img/blocks/i-box/header-icon.svg"
				width="24"
				height="24"
				class="c-header__icon lazyload"
				alt="">

			
            <h2 class="c-header__text animation " style='max-width: 100%;'   >
                 <strong>Editor&#8217;s note</strong>
            </h2>		</header>
	
	<div class="block-i-box__inner">
		

<div
    id="custom-text-block_2166eec450bae4338ddf550d1cfcdca5"
    class="block-custom-text  white l-padding__top--0 l-padding__bottom--0"
    style="max-width: 100%; font-size: 1rem; line-height: 1.33; font-weight: 600;"
    >
    
    Searching for a free experiment tracking solution for your academic research?
    </div>



<p></p>



<p>Join 1000s of researchers, professors, students, and Kagglers using neptune.ai for free to make monitoring experiments, comparing runs, and sharing results far easier than with open source tools.</p>



<ul
    id="arrow-list-block_371cddf0e1da51ec9af9489b6bdc6d35"
    class="block-arrow-list block-list-item--font-size-regular">
    

<li class="block-list-item ">
    <img loading="lazy" decoding="async"
        src="https://neptune.ai/wp-content/themes/neptune/img/image-ratio-holder.svg"
        data-src="https://neptune.ai/wp-content/themes/neptune/img/blocks/list-item/arrow.svg"
        width="10"
        height="10"
        class="block-list-item__arrow lazyload"
        alt="">

    

<p>Learn more about the <a href="/research" target="_blank" rel="noreferrer noopener">program</a></p>


</li>



<li class="block-list-item ">
    <img loading="lazy" decoding="async"
        src="https://neptune.ai/wp-content/themes/neptune/img/image-ratio-holder.svg"
        data-src="https://neptune.ai/wp-content/themes/neptune/img/blocks/list-item/arrow.svg"
        width="10"
        height="10"
        class="block-list-item__arrow lazyload"
        alt="">

    

<p><a previewlistener="true" href="https://docs.neptune.ai/" target="_blank" rel="noreferrer noopener">See the docs</a>&nbsp;or watch a short&nbsp;<a href="/walkthrough" target="_blank" rel="noreferrer noopener">product demo (2 min)</a></p>


</li>


</ul>


	</div>

</section>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-potential-benefits-of-training-with-trial-and-error-information">Potential benefits of training with trial-and-error information</h2>



<p>Now, assume that in addition to a vast collection of polished proofs, we train a model on all the trial-and-error information that could be found in mathematicians&#8217; draft papers or in their minds. What would we expect this model to be capable of?</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="h-generating-better-proof-step-candidates">Generating better proof-step candidates</h3>



<p>First, we expect the model to have a strong ability to propose high-quality guesses for single proof-step generation. After seeing large amounts of high-quality trial-and-error information in training, the model will learn how to make a highly reasonable (although possibly failed) first attempt when seeing the problem.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="h-judging-proof-step-candidates-in-reinforcement-learning">Judging proof step candidates in reinforcement learning</h3>



<p>Second, we expect models trained with trial-and-error information to be capable of dynamically evaluating each proof step&#8217;s potential. By “dynamic,” we mean that the confidence score the model assigns internally to the current proof strategy changes as the strategy unfolds. After generating each proof step, the model must decide whether to continue predicting the subsequent step along the current path or to initiate a backtracking operation. A higher probability of backtracking indicates a lower confidence in the current proof strategy.<br><br>A model equipped with sufficient trial-and-error data should become proficient in assessing the viability of proof strategies. The model could then serve as a reward function in reinforcement learning processes (e.g., <a href="https://arxiv.org/abs/2305.20050" target="_blank" rel="noreferrer noopener nofollow">OpenAI’s work on process supervision</a>), where obtaining high-quality reward functions for intermediate steps is a major challenge.<br><br>One caveat is that tracking trial-and-error information for highly complex mathematical problems can easily exceed a model’s context length. We sometimes encountered this problem in our experiments when we asked the model to prove very hard theorems. Once it is no longer possible to feed the entire history of proof attempts and backtraces into the model, we need to summarize it. Further research is required to explore efficient methods for this summarization process.</p>



<h3 class="wp-block-heading" class="wp-block-heading" id="h-going-beyond-the-well-trodden-path">Going beyond the well-trodden path&nbsp;</h3>



<p>Third, we expect a model trained on trial-and-error data to exhibit a strong capacity for thinking &#8220;outside the box.&#8221; Mathematicians often develop truly creative approaches to solving longstanding problems, producing work that impresses with its ingenuity and provokes curiosity about the thought processes involved.</p>



<p>However, except for a few remarkable cases (like the <a href="https://en.wikipedia.org/wiki/Srinivasa_Ramanujan#Mathematical_achievements" target="_blank" rel="noreferrer noopener nofollow">formulas discovered by Ramanujan</a>), most of these breakthroughs are built on extensive knowledge accumulated over time through trial and error. By identifying existing strategies as ineffective—and uncovering <em>why</em> they are inadequate—mathematicians are compelled to consider novel methods. We believe models can acquire this capability from extensive, high-quality trial-and-error information.</p>



<h2 class="wp-block-heading" class="wp-block-heading" id="h-where-do-we-go-from-here">Where do we go from here?</h2>



<p>Overall, we are optimistic about the future of automated reasoning. We speculate that mathematical reasoning is not fundamentally different from traditional NLP tasks and that given sufficient high-quality training data, LLMs can reach human-level performance. As we demonstrate <a href="https://arxiv.org/abs/2404.07382" target="_blank" rel="noreferrer noopener nofollow">in our paper</a>, incorporating trial-and-error information into the training data leads to substantial improvements even with today’s model architectures.</p>



<p>However, as we’ve discussed, the vast majority of current pre-training datasets for mathematical reasoning exhibit significant misalignments with the precise tasks we expect the model to perform. An obvious limitation of our approach is that it’s challenging to collect trial-and-error data from our math friends because of the tradition and community practice. We hope our work can raise the community&#8217;s awareness of the importance of trial-and-error data for automated theorem proving.</p>



<p>New state-of-the-art models (such as Meta’s <a href="https://arxiv.org/abs/2407.21783" target="_blank" rel="noreferrer noopener nofollow">Llama 3 family</a> and OpenAI’s <a href="https://openai.com/o1/" target="_blank" rel="noreferrer noopener nofollow">o1 model</a>) that became available after we published our paper have been trained extensively on trial-and-error reasoning data. This has led to significant performance improvements on traditional mathematical benchmarks, such as the <a href="https://github.com/hendrycks/math" target="_blank" rel="noreferrer noopener nofollow">MATH dataset</a>. Notably, o1 has the capability to <a href="https://openai.com/index/learning-to-reason-with-llms/" target="_blank" rel="noreferrer noopener nofollow">verify its outputs and perform backtracking during inference</a>, informed by previously explored proof searches. We believe this advancement is largely due to the substantial trial-and-error data included in the model&#8217;s training process.</p>



<p>Beyond theorem proving, training with trial-and-error data may play a pivotal role in shaping a new “scaling law of inference,” which complements <a href="https://arxiv.org/pdf/2001.08361" target="_blank" rel="noreferrer noopener nofollow">currently known LLM scaling laws</a>. By enabling the model to generate additional tokens, thereby allowing it to verify and backtrack on its own output, it can progressively tackle more complex problems. This concept, observed by OpenAI for their o1 model, <a href="https://openai.com/index/learning-to-reason-with-llms/" target="_blank" rel="noreferrer noopener nofollow">was reported</a> as a significant advancement. Furthermore, a <a href="https://arxiv.org/abs/2402.12875" target="_blank" rel="noreferrer noopener nofollow">recent paper</a> mathematically demonstrates that if a transformer is allowed to generate an arbitrary number of tokens, it has the potential to solve arbitrarily complex problems.</p>



<p>If you’d like to explore this space yourself, we’ve published <a href="https://huggingface.co/datasets/KomeijiForce/PropL" target="_blank" rel="noreferrer noopener nofollow">our dataset</a> and <a href="https://huggingface.co/KomeijiForce/llama-2-7b-propositional-logic-prover" target="_blank" rel="noreferrer noopener nofollow">our model weights</a> over at Hugging Face, and you can find <a href="https://github.com/ucsd-atp/PropL" target="_blank" rel="noreferrer noopener nofollow">source code on GitHub</a>. If you’re interested in how trial-and-error data could be used to improve LLM Agents, I recommend the recently published paper <a href="https://arxiv.org/abs/2403.02502" target="_blank" rel="noreferrer noopener nofollow"><em>Trial and Error: Exploration-Based Trajectory Optimization for LLM Agents</em></a>, whose <a href="https://huggingface.co/datasets/agent-eto/eto-sft-trajectory" target="_blank" rel="noreferrer noopener nofollow">dataset is available at Hugging Face</a> as well.</p>



<p></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">42845</post-id>	</item>
	</channel>
</rss>
