<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Local LLMs on Blog from chriscomputing</title><link>https://blog.chriscomputing.de/en/tags/local-llms/</link><description>Recent content in Local LLMs on Blog from chriscomputing</description><generator>Hugo -- gohugo.io</generator><language>en-EN</language><copyright>chriscomputing (CC BY-NC-SA 4.0)</copyright><lastBuildDate>Tue, 11 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.chriscomputing.de/en/tags/local-llms/index.xml" rel="self" type="application/rss+xml"/><item><title>Improving Syllogistic Reasoning in LLMs: Activation Steering &amp; Logic Solvers</title><link>https://blog.chriscomputing.de/en/blog/improving-llm-syllogistic-reasoning/</link><pubDate>Tue, 11 Aug 2026 00:00:00 +0000</pubDate><guid>https://blog.chriscomputing.de/en/blog/improving-llm-syllogistic-reasoning/</guid><description>&lt;h2 id="improving-syllogistic-reasoning-in-llm-logic-inference"&gt;Improving syllogistic reasoning in LLM logic inference&lt;/h2&gt;
&lt;p&gt;Large Language Models (LLMs) possess vast world knowledge, but this often harms their ability to perform strict logical deductions. A prime example is &lt;strong&gt;syllogistic reasoning&lt;/strong&gt;, where LLMs struggle with the &lt;em&gt;content effect&lt;/em&gt;: rejecting logically valid conclusions simply because they contradict learned real-world facts.&lt;/p&gt;
&lt;p&gt;In this post, I explore two methods to fix this: Activation Steering and Neuro-symbolic logic solvers. This writeup is based on a group project I did with two friends of mine for a course on natural language processing. Unfortunately, deadlines did not line up and we finished our project after the official SemEval 2026 deadline for &lt;a href="https://sites.google.com/view/semeval-2026-task-11"&gt;task 11&lt;/a&gt;, meaning we were unable to submit our project officially. This blogpost is a condensed writeup of what we did, posted with permission by my co-authors. Some snippets are direct quotes from our final report.&lt;/p&gt;</description><content:encoded><![CDATA[<h2 id="improving-syllogistic-reasoning-in-llm-logic-inference">Improving syllogistic reasoning in LLM logic inference</h2>
<p>Large Language Models (LLMs) possess vast world knowledge, but this often harms their ability to perform strict logical deductions. A prime example is <strong>syllogistic reasoning</strong>, where LLMs struggle with the <em>content effect</em>: rejecting logically valid conclusions simply because they contradict learned real-world facts.</p>
<p>In this post, I explore two methods to fix this: Activation Steering and Neuro-symbolic logic solvers. This writeup is based on a group project I did with two friends of mine for a course on natural language processing. Unfortunately, deadlines did not line up and we finished our project after the official SemEval 2026 deadline for <a href="https://sites.google.com/view/semeval-2026-task-11">task 11</a>, meaning we were unable to submit our project officially. This blogpost is a condensed writeup of what we did, posted with permission by my co-authors. Some snippets are direct quotes from our final report.</p>
<p>In syllogistic reasoning, a conclusion is drawn from at least one premise. Since the premises do not have to align with facts in the real world, conclusions might contradict world knowledge an LLM has.</p>
<div class="alert alert-info" role="region" aria-label="info">
  <div class="alert-title">Example syllogism</div>
  <div class="alert-body">An animal which produces milk is a cow. A goat produces milk. Therefore, a goat is a cow.</div>
</div>
<p>The above example is logically correct, but not consistent with world knowledge. Thus, LLMs tend to flag the conclusion as false. This phenomena is known as <em>content effect</em> and the most severe problem our SemEval task aimed to solve.<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> Faulty reasoning in LLMs is a substantial obstacle for deployments requiring dependable reasoning, for example formal verification, decision support and automated deduction.</p>
<p>We decided early on to focus our attention on compact open-weight LLMs. While large SOTA models feature higher baseline performance in formal logic, compact models are essential for edge deployment, resource-constrained environments, and low-latency inference. We used <em>Llama-3.2-1B-Instruct</em> and <em>Llama-3.1-8B-Instruct (8 bit)</em> in our project.</p>
<h2 id="related-work">Related work</h2>
<p>Benchmarking formal logic deduction and logical consistency in LLMs has become an active area of NLP research. Prior literature consistently highlights susceptibility to belief bias (e.g. content effects), where models prioritize semantic plausibility over deductive validity. Furthermore, LLMs have been shown to produce human-like reasoning errors, for example falling prey to <em>figural effects</em> like sensitivity to the order of arguments and syntactic arrangements of variables. <sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup><br>
Effort has also gone into different mitigation strategies: <em>activation steering</em>, a lightweight intervention that biases reasoning by manipulating internal activations <sup id="fnref:3"><a href="#fn:3" class="footnote-ref" role="doc-noteref">3</a></sup> can reduce reliance on world knowledge which reduces content effect. Another line of research explores neuro-symbolic AI, pairing an LLM as a semantic parser with a downstream formal reasoning engine. The LLM reads the plaintext arguments and synthesizes them into the input a logical solver expects. The solver then reliably computes the logical correctness <sup id="fnref:4"><a href="#fn:4" class="footnote-ref" role="doc-noteref">4</a></sup>. Finally, an effort has been made to improve syllogistic reasoning using prompt engineering only <sup id="fnref:5"><a href="#fn:5" class="footnote-ref" role="doc-noteref">5</a></sup>.</p>
<h2 id="the-semeval-2026-task-11-dataset">The SemEval 2026 task 11 dataset</h2>
<p>The SemEval-2026 Task 11 benchmark consists of categorical syllogisms structured as two premises and a target conclusion, designed to test first-order logical entailment. The data is available in English only. The final system should determine if the conclusion is logically valid given both premises. Additionally, every item had a <em>plausibility label</em>, indicating whether the correct conclusion lines up with world knowledge. This label was only used during training, not during evaluation.<br>
Our task called for, additionally to English, evaluation in a set of different languages. They included languages with a large available corpus like German and Italian, but also languages with less usage on the internet like Swahili or Bengali. In total, the systems were evaluated on 12 different languages. To evaluate cross-lingual transfer in logical reasoning, we built a translation pipeline using Meta’s <em>facebook/nllb-200-3.3B</em> model to translate the logical deductions into the other typologically diverse languages. We ensured accurate translation by sampling a small subset for each language and checking them by hand.</p>
<h2 id="evaluating-improvements-in-accuracy-and-reduction-llm-content-effects">Evaluating improvements in accuracy and reduction LLM content effects</h2>
<p>An evaluation script was provided by the task organizers. It combines a standard correctness metric with additional measures intended to quantify content bias.</p>
<p><strong>Accuracy:</strong> Accuracy is the percentage of instances for which the system predicts the correct validity label (valid vs. invalid). This measures overall correctness on the task. The better a model predicts the validity tag, the higher is its accuracy.</p>
<p><strong>Content Effect metrics:</strong> Beyond accuracy, the script reports content effect metrics by comparing performance across four subsets: <em>plausible–valid</em> (syllogisms which are both plausible according to world knowledge and valid), <em>implausible–invalid</em> (syllogisms which are both implausible according to world knowledge and invalid), <em>plausible–invalid</em> (syllogisms which are plausible according to world knowledge but invalid), and <em>implausible–valid</em> (syllogisms which are implausible according to world knowledge but valid). A lower content effect is preferable.</p>
<p>The <em>Intra-plausibility content effect</em> measures bias towards a specific label within a plausibility condition:
</p>
$$
\begin{equation}
\text{Bias}_{\text{intra}} = \frac{1}{2} \left( \left| \text{ACC}_{\text{plausible,valid}} - \text{ACC}_{\text{implausible,valid}} \right| + \left| \text{ACC}_{\text{plausible,invalid}} - \text{ACC}_{\text{implausible,invalid}} \right| \right)
\end{equation}
$$<p>The <em>Cross-plausibility content effect</em> measures reliance on plausibility within a formal validity condition:</p>
$$
\begin{equation}
\text{Bias}_{\text{inter}} = \frac{1}{2} \left( \left| \text{ACC}_{\text{plausible,valid}} - \text{ACC}_{\text{plausible,invalid}} \right| + \left| \text{ACC}_{\text{implausible,valid}} - \text{ACC}_{\text{implausible,invalid}} \right| \right)
\end{equation}
$$<p>Finally, the <em>Total content effect</em> is calculated as the average of both plausibilities:</p>
$$
\begin{equation}
\text{TCE} = \frac{1}{2} \left( \text{Bias}_{\text{intra}} + \text{Bias}_{\text{inter}} \right)
\end{equation}
$$<p>From there, the <em>final score</em> is computed as:</p>
$$
Score = \frac{\text{accuracy}}{1 + \log(1 + \text{TCE})}
$$<h2 id="methods-to-improve-syllogistic-reasoning-of-llama-3">Methods to improve syllogistic reasoning of Llama 3</h2>
<p>We tried two approaches to solve the task, whose results will be compared later. The first is activation steering, and the second is deploying a logic solver in conjunction with an LLM.</p>
<h3 id="activation-steering">Activation Steering</h3>
<p>The core idea of activation steering is to modify an LLM’s internal computation by linearly shifting hidden activations in a desired direction. Finding that direction requires a set of labeled training data $D = \{(x_i, y_i)\}_{i=1}^{N}$  where where positive labels reflect logically sound deductions and negative labels represent belief-biased reasoning errors. In our case, we define intended behavior as samples the model classifies correct and wrong predictions as unintended behavior.</p>
<p>I have found the following explanation to be much easier to understand for most people:<br>
Imagine a brain. That brain is put on some medicine, which boosts or reduces the activity in a certain region. For example, medicine against narcolepsy, which boosts certain pathways in the human brain to increase wakefulness. That&rsquo;s what activation steering is doing to the hidden layers of an LLM. We can use that to manipulate the LLM&rsquo;s behaviour. This activation-steering technique is related to what Anthropic did in their research which resulted in <a href="https://www.anthropic.com/news/golden-gate-claude">Golden Gate Claude</a>.</p>
<p>The major advantage of activation steering is how lightweight it is. It takes only few resources to train, much less than traditional finetuning. Furthermore, it does not increase inference cost and can be conditionally applied on a per-query basis.</p>
<h4 id="contrastive-activation-addition-caa">Contrastive Activation Addition (CAA)</h4>
<p>Contrastive Activation Addition (CAA) is a relatively simple form of activation steering. All activations for both desired and undesired outputs are collected separately. If $\mu^+$ is the average of desired (positive) activations and $\mu^-$ the average of undesired (negative) activations, there difference can be calculated as $\Delta \phi = \mu^{+} - \mu^{-}$. During inference, the model’s activations are modified by adding a scaled version of the contrastive vector: $\tilde{\phi}(x) = \phi(x) + \alpha \cdot \Delta \phi$. $\phi$ is the unmanipulated activation and $\tilde{\phi}$ the final activation with steering applied. $\alpha$ is a scaling factor. This intervention shifts the transformer’s hidden state representations toward activation subspaces associated with unbiased logical deductions.<sup id="fnref:6"><a href="#fn:6" class="footnote-ref" role="doc-noteref">6</a></sup></p>
<h4 id="conditional-activation-steering-cast">Conditional Activation Steering (CAST)</h4>
<p>An improvement upon CAA is known as Conditional Activation Steering (CAST). Contrary to CAA, CAST also subtracts from the unmanipulated steering vector $\phi$ <sup id="fnref1:3"><a href="#fn:3" class="footnote-ref" role="doc-noteref">3</a></sup>. We used condition vectors to determine if $\alpha$ should be positive or negative, the later reversing the steering direction in comparison to CAA.</p>
<p>We worked with two condition vectors $\psi_{c}^{+}$ and $\psi_{c}^{-}$ that are average aggregation of valid and invalid activations. The sign of $\alpha$ is determined by whether the activation is more similar to a valid or an invalid sample.</p>
$$
f \left(\alpha, \phi(x), \psi_c^{+}, \psi_c^{-}\right) =
\begin{cases}
    - \alpha, & \text{ if } \operatorname{sim}(\phi(x), \operatorname{proj}_{\psi_c^{+}} \phi(x)) > \operatorname{sim} (\phi(x), \operatorname{proj}_{\psi_c^{-}} \phi(x)) \\
    \alpha, & \text{otherwise.}
\end{cases}
$$<p><strong>k-CAST:</strong> One problem the standard CAST method possesses is that there is some information loss when aggregating all valid and invalid activations vectors during train time. To overcome that, k-CAST utilizes k-nearest-neighbor clustering. Before testing a new sample, all activations from all samples in the training set need to be stored. Then, k-CAST finds the $k = 5$ nearest neighbors within the latent activation space and selects the sign of $\alpha$ based on a majority decision.</p>
<h3 id="neuro-symbolic-logic-solver">Neuro-symbolic logic solver</h3>
<p>The second main approach was pairing an LLM with a neuro-symbolic logic solver. The solver performs the actual checking of the logic, guaranteeing correct results given correct inputs. The LLM only needs to translate the syllogism into syntactically valid and semantically correct input, which is something they are quite good at.<br>
We mapped each sentence to exactly one of the qualifiers <code>{all, none, some, some_not}</code> and two unary predicates <code>(a,b)</code> resulting in a compact symbolic representation that is independent of the underlying language.</p>
<p>
















  
  
  
      
      
  <figure class="figure " >
  <picture  >
  <img class="figure-img img-fluid" src="https://blog.chriscomputing.de/images/posts/improving_syllogistic_reasoning/ns-solver_extraction.png?width=600&v=1d7cd3aee4d81d9687fe5f8e2bb0627f" alt="Extraction of inputs by the LLM" title="Extraction of inputs by the LLM" loading="lazy" height="741" width="1471" style="width: 600px" />
</picture>

  <figcaption class="figure-caption">Extraction of inputs by the LLM</figcaption>
</figure>
</p>
<h4 id="three-staged-data-extraction-pipeline">Three-staged data extraction pipeline</h4>
<p>For each syllogism, we prompted the LLM to extract a <em>quantifier</em> and two <em>terms</em> from each of the three sentences. Extracting all three sentences jointly increased formatting errors and occasionally mixed information across sentences, so we performed extraction sentence-by-sentence. To promote consistent terminology, we tracked a short <code>used_predicates</code> list and include it in the prompt, encouraging reuse of earlier predicate names.</p>
<p>Because the logic solver treats distinct strings as distinct predicates, we normalized extracted terms (lowercasing, replacing spaces with underscores, removing determiners conservatively, and singularizing English nouns). We also included the full syllogism in each prompt to further stabilize naming across sentences.</p>
<p>Finally, we validated outputs and passed them to the solver only if they match the required 3-tuple format <code>(quantifier=..., a=..., b=...)</code>. Malformed extractions are rare; when they occurred, we fell back to random guessing.</p>
<h4 id="verifying-deductions-with-the-z3-logic-solver">Verifying Deductions with the Z3 Logic Solver</h4>
<p>We used Microsoft Research&rsquo;s <a href="https://www.microsoft.com/en-us/research/project/z3-3/">Z3</a> highly efficient SMT (Satisfiability Modulo Theories)-solver, to verify whether premises logically entail the extracted conclusion. Given the parsed terms of a syllogism, Z3 returned a binary verdict (<code>valid</code> or <code>invalid</code>), which served as the final output of our pipeline.</p>
<h4 id="handling-of-multi-lingual-syllogistic-data">Handling of multi-lingual syllogistic data</h4>
<p>To support the different languages required by our task, we separated language-specific preprocessing from the language-agnostic symbolic representation and extraction. We automatically detected the language and separated the input into 3 sentences using ICU sentence boundary detection before passing the input into the three-staged extraction pipeline. An English extraction prompt performed best across languages, so we used a single, language-independent prompt.</p>
<p>After extraction, we normalize predicate strings using lightweight, language-specific filtering (e.g., removing articles) to reduce superficial variation, without translation or external linguistic resources. These steps consistently yielded suitable input for the solver.</p>
<h4 id="llm-choice">LLM choice</h4>
<p>We use models from the Llama family. In our experiments, Llama-3.2-1B-Instruct proved unreliable for structured extraction (e.g., it often outputs <code>some</code> instead of <code>some_not</code>), so we additionally evaluated Llama-3.1-8B-Instruct in 8-bit quantized form. Both models are fast and require few resources, enabling low-latency or low-resource deployment.</p>
<h2 id="results-activation-steering-vs-logic-solvers">Results: Activation Steering vs. Logic Solvers</h2>
<p>Experiments were conducted using five different seeds (10, 20, 30, 40, 42). The dataset was split 90/10 between training and evaluation (for activation steering). Since training only requires calculating steering vectors it can be performed quite quickly. On a single A100, training and evaluation across all languages and English-only finished within a few minutes, including evaluation for the Neuro-symbolic logic solver. No training was required for the later. For reference, evaluation includes a baseline which just prompted the LLM.</p>
<p>
















  
  
  
      
      
  <figure class="figure " >
  <picture  >
  <img class="figure-img img-fluid" src="https://blog.chriscomputing.de/images/posts/improving_syllogistic_reasoning/results_english.png?width=600&v=1d7cd3aee4d81d9687fe5f8e2bb0627f" alt="Chart showing evaluation results of Activation Steering vs Neuro-symbolic solvers on English training data" title="Results for English-only data. For Accuracy and Score, higher is better. For TCE, lower is better. Most important metric is Score." loading="lazy" height="484" width="1096" style="width: 600px" />
</picture>

  <figcaption class="figure-caption">Results for English-only data. For Accuracy and Score, higher is better. For TCE, lower is better. Most important metric is Score.</figcaption>
</figure>
</p>
<p>
















  
  
  
      
      
  <figure class="figure " >
  <picture  >
  <img class="figure-img img-fluid" src="https://blog.chriscomputing.de/images/posts/improving_syllogistic_reasoning/results_multi.png?width=600&v=1d7cd3aee4d81d9687fe5f8e2bb0627f" alt="Chart showing evaluation results of Activation Steering vs Neuro-symbolic solvers on multilingual training data" title="Results for multilingual data. For Accuracy and Score, higher is better. For TCE, lower is better. Most important metric is Score." loading="lazy" height="484" width="1096" style="width: 600px" />
</picture>

  <figcaption class="figure-caption">Results for multilingual data. For Accuracy and Score, higher is better. For TCE, lower is better. Most important metric is Score.</figcaption>
</figure>
</p>
<h3 id="activation-steering-1">Activation Steering</h3>
<p>The activation steering approach <strong>consistently outperformed both the baseline and neurosymbolic approaches</strong>. In the English-only setting, the highest score was achieved by CAST, even though k-CAST attained higher overall accuracy. We attributed this discrepancy to limited training data: k-CAST may not have sufficient examples to reliably inform its condition detection, leading to less robust decisions under the primary evaluation metric.</p>
<p>In the <strong>multilingual setting, k-CAST surpassed CAST</strong>, plausibly because mean-vector-based condition detection becomes substantially noisier when aggregating activations across languages. This improvement comes at a computational cost: k-CAST requires loading activations for all training samples to perform condition detection and computing k-nearest neighbors for each query activation. These requirements can be expensive, particularly when scaling to larger datasets.</p>
<h3 id="neuro-symbolic-logic-pipeline">Neuro-symbolic logic pipeline</h3>
<p>For the neuro-symbolic pipeline, we observed only little improvement over the baseline when using Llama 1B. We attributed this mainly to errors in the logical-form translation stage and to the limited capacity of the 1B model, which appears unable to perform this mapping reliably. Replacing Llama 1B with a larger variant (8b quantized) substantially improved performance, indicating that model capacity is a key factor for this approach.</p>
<ul>
<li><strong>Llama 1B (Underperformed):</strong> Showed little improvement over the baseline. We attribute this to errors during extraction and generating of Z3 solver input, as the 1B parameter model struggled to map premises reliably.</li>
<li><strong>Llama 8B (Improved Accuracy):</strong> Substantially improved accuracy in both data settings, with a pronounced increase on English data.</li>
<li><strong>Total Content Effect (TCE):</strong> Interestingly, while Llama 1B had a worse baseline TCE, it achieved better TCE under the neuro-symbolic constraints than the 8B model. This indicates the smaller model’s logical decisions are less influenced by semantic plausibility.</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>In our project, we demonstrated that substantial improvements in LLM logic inference are possible using multiple techniques. For me personally, Activation Steering stood out as very versatile and low-overhead tool to manipulate a model. Unlike prior representation engineering experiments (such as Anthropic’s Golden Gate Claude) that manipulate conversational personas or topical features, our work demonstrates how activation steering can directly steer cognitive reasoning capabilities. This is an important demonstration towards improving specialization of models on-demand. In the future, I would love to further explore AI explainability and how an improved understanding could be use to make models safer and better.</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>See e.g. Lampinen et al., <a href="http://arxiv.org/abs/2207.07051">Language models, like
humans, show content effects on reasoning tasks</a>&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:2">
<p>See e.g. Bertolazzi et al., <a href="https://doi.org/10.18653/v1/2024.emnlp-main.769">A Systematic Analysis of Large Language Models as Soft Reasoners: The Case of Syllogistic Inferences</a>&#160;<a href="#fnref:2" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:3">
<p>See e.g. Valentino et al., <a href="https://doi.org/10.48550/arXiv.2505.12189">Mitigating Content Effects on Reasoning in Language Models through Fine-Grained Activation Steering</a>&#160;<a href="#fnref:3" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a>&#160;<a href="#fnref1:3" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:4">
<p>See e.g. Pan et al., <a href="https://aclanthology.org/2023.findings-emnlp.248/">Logic-Lm: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoning</a>&#160;<a href="#fnref:4" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:5">
<p>See e.g. Ranaldi et al., <a href="https://aclanthology.org/2025.acl-long.843/">Improving Chain-of-Thought Reasoning via Quasi-Symbolic Abstractions</a>&#160;<a href="#fnref:5" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:6">
<p>See e.g. Rimsky et al., <a href="https://doi.org/10.18653/v1/2024.acl-long.828">Steering llama 2 via contrastive activation addition</a>&#160;<a href="#fnref:6" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded></item></channel></rss>