←back to Blog

University of Michigan Researchers Propose G-ACT: A Scalable Machine Learning Framework to Steer Programming Language Bias in LLMs

University of Michigan Researchers Propose G-ACT: A Scalable Machine Learning Framework to Steer Programming Language Bias in LLMs

Understanding the Target Audience

The target audience for this research consists of academic researchers, AI practitioners, data scientists, and business managers dedicated to the intersection of AI technology and scientific computing. They are particularly interested in the implications of large language models (LLMs) in generating scientific code.

  • Pain Points: The audience faces challenges in ensuring the accuracy and reliability of code generated by LLMs, particularly for scientific applications. Existing biases in model outputs and the complexities associated with steering LLM behavior towards specific programming languages exacerbate these issues.
  • Goals: They aim to improve the efficiency of scientific code generation, enhance the robustness of AI models, and ultimately facilitate the deployment of these technologies in real-world scientific workflows.
  • Interests: Their interests include advancements in machine learning frameworks, bias mitigation strategies, model interpretability, and practical applications of LLMs in various programming environments.
  • Communication Preferences: The audience prefers concise, technical analyses that provide actionable insights while being supported by empirical data and peer-reviewed research.

LLMs and the Need for Scientific Code Control

Large language models (LLMs) have rapidly evolved into complex natural language processors, enabling the development of agentic systems that manage intricate workflows. However, the application of LLMs for generating scientific code remains largely unexplored. Scientific software predominantly relies on languages such as C++ and CUDA, which are significantly underrepresented in most pretraining datasets. This discrepancy results in code generated by LLMs exhibiting syntactic or semantic errors, leading to complications such as compilation issues or unstable runtime behavior. Current agents depend heavily on user-defined control primitives and meticulously crafted prompts, which are susceptible to misinterpretation and can result in erratic execution flows.

Limitations of Existing Steering Methods

Recent methods have emerged to tackle steering challenges in LLMs by uncovering causal links within model activations and enabling neuron-level interventions. Techniques such as Supervised Fine-Tuning (SFT), weight modulation, and Reinforcement Learning from Human Feedback (RLHF) represent direct model steering methods, but they incur significant computational overhead and can diminish the model’s robustness and overall performance. Activation patching, which employs corrupted inputs as a baseline distribution, is a widely adopted approach for fine-grained output control. Nonetheless, these techniques require extensive model sweeps, often employing millions of evaluations, and are typically applied to multiple-choice question benchmarks rather than real-world scenarios.

Introduction of G-ACT Framework

Researchers from the University of Michigan have introduced the Gradient-refined Adaptive Activation Steering Framework (G-ACT) to address the challenge of steering scientific code generation towards specific programming languages in LLMs. This framework is based on evaluations of five causal LLMs in response to scientific coding prompts. G-ACT clusters per-prompt activation differences into steering directions and employs lightweight per-layer probes that are trained and refined online to identify appropriate steering vectors. The framework enhances concept-level control while ensuring scalability and interpretability, presenting a practical method for achieving reproducible behavior in agentic systems requiring consistent programming language choices for scientific computing tasks.

Model Evaluation and Baseline Biases

The research team evaluated five instruction-tuned LLMs, including Llama-3.2-3B-Instruct, Llama-3.3-70B-Instruct, Qwen2.5-Coder-32B-Instruct, Qwen2.5-14B-Instruct-1M, and QwQ-32B. Each model underwent testing on 84 benchmark questions with 25 repetitions per prompt at a sampling temperature of 1.0 to ensure statistical stability. Results from language preference evaluations revealed that Llama-3.2-3B demonstrated a strong preference for Java (76.2%), while Llama-3.3-70B favored Python (73.8%). In contrast, Qwen models exhibited varying biases, with Qwen2.5-Coder leaning towards Python (59.5%) and Qwen2.5-14B showing a preference for Julia (66.7%). These baseline results indicate that model scale, architecture, and fine-tuning data collectively contribute to reproducible biases in code generation.

Static Neuron Activation and Language Biasing

Analyzing static methods involves inducing language preference bias and testing code generation capabilities. Results related to preference bias indicate that selective activation of individual multiperceptron (MLP) neurons in baseline tests with Llama-3.2-3B-Instruct enables strong causal control over programming language selection. For CPP generation, results indicated nearly 100% CPP output across most problems, significantly minimizing Python, Java, and Julia outputs. Furthermore, code generation tests revealed two distinct behavioral regimes: Python-leaning tasks yielded 40-80% Python outputs for high-level operations, while CPP-dominant tasks demonstrated a 60-90% preference for CPP in performance-critical routines. Overall, the model achieved approximately 73% CPP generation more frequently than Python, yet still defaulted to Python for numerous prompts.

Gradient-Refined Activation Steering Results

This paper introduces a gradient-refined adaptive activation steering framework capable of controlling programming language selection in scientific code generation. The framework achieves significant improvements, elevating probe classification accuracy from 0% to 61.5% in the earlier layers of LLaMA-3.2 3B. Although it incurs a modest runtime overhead of 1.3-1.4 times slower generation, it remains practical through selective layer steering and caching optimizations. G-ACT provides a scalable and interpretable methodology for concept-level control, extending beyond programming languages by embedding persistent transformation matrices to ensure consistent model behavior across diverse users. This offers a new standard for reliable LLM steering within scientific computing contexts.

Check out the Paper. All credit for this research goes to the researchers involved in this project. Additionally, feel free to follow us on Twitter and consider joining our 100k+ ML SubReddit or subscribing to our Newsletter.