Spaces:
Running
Running
File size: 15,891 Bytes
ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 bf6bcb3 ff416d2 bf6bcb3 ff416d2 985ade5 ff416d2 2441746 ff416d2 2441746 ff416d2 985ade5 ff416d2 05dc7ea ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 318afc7 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 985ade5 ff416d2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="description"
content="Full-Stack Fine-Tuning for the Q Programming Language: A comprehensive approach to adapting LLMs for specialized domains.">
<meta name="keywords" content="Q Programming, Language Models, Fine-tuning, Quantitative Finance">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Full-Stack Fine-Tuning for the Q Programming Language</title>
<link href="https://fonts.googleapis.com/css?family=Google+Sans|Noto+Sans|Castoro"
rel="stylesheet">
<link rel="stylesheet" href="./static/css/bulma.min.css">
<link rel="stylesheet" href="./static/css/bulma-carousel.min.css">
<link rel="stylesheet" href="./static/css/bulma-slider.min.css">
<link rel="stylesheet" href="./static/css/fontawesome.all.min.css">
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/jpswalsh/academicons@1/css/academicons.min.css">
<link rel="stylesheet" href="./static/css/index.css">
<link rel="icon" href="./static/images/favicon.svg">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script defer src="./static/js/fontawesome.all.min.js"></script>
<script src="./static/js/bulma-carousel.min.js"></script>
<script src="./static/js/bulma-slider.min.js"></script>
<script src="./static/js/index.js"></script>
</head>
<body>
<section class="hero">
<div class="hero-body">
<div class="container is-max-desktop">
<div class="columns is-centered">
<div class="column has-text-centered">
<h1 class="title is-1 publication-title">Full-Stack Fine-Tuning for the Q Programming Language</h1>
<div class="is-size-5 publication-authors">
<span class="author-block">
<a href="https://x.com/brendanh0gan" target="_blank">Brendan R. Hogan</a><sup>1</sup>,</span>
<span class="author-block">
<a href="https://x.com/willccbb" target="_blank">Will Brown</a><sup>2</sup>,</span>
<span class="author-block">
<a href="https://x.com/adel_boyarsky" target="_blank">Adel Boyarsky</a><sup>1</sup>,
</span>
<span class="author-block">
<a href="https://scholar.google.com/citations?user=KLyaFtUAAAAJ&hl=en" target="_blank">Anderson Schneider</a><sup>1</sup>,
</span>
<span class="author-block">
<a href="https://scholar.google.com/citations?user=Hui4EIcAAAAJ&hl=en" target="_blank">Yuriy Nevmyvaka</a><sup>1</sup>
</span>
</div>
<div class="is-size-5 publication-authors">
<span class="author-block"><sup>1</sup>Morgan Stanley, New York, NY</span>
<span class="author-block"><sup>2</sup>Prime Intellect, San Francisco, CA</span>
</div>
<div class="column has-text-centered">
<div class="publication-links">
<span class="link-block">
<a href="https://arxiv.org/abs/2508.06813" target="_blank"
class="external-link button is-normal is-rounded is-dark">
<span class="icon">
<i class="ai ai-arxiv"></i>
</span>
<span>arXiv</span>
</a>
</span>
<!-- Code Link. -->
<span class="link-block">
<a href="https://github.com/morganstanley/MSML/tree/main/projects/Fullstack_LLM_Finetuning_Q" target="_blank"
class="external-link button is-normal is-rounded is-dark">
<span class="icon">
<i class="fab fa-github"></i>
</span>
<span>Code</span>
</a>
</span>
<!-- Models Link. -->
<span class="link-block">
<a href="https://huggingface.co/collections/morganstanley/qqwen-series-688e4266bc727e7a3143aacf" target="_blank"
class="external-link button is-normal is-rounded is-dark">
<span class="icon">
<i class="fas fa-robot"></i>
</span>
<span>Models</span>
</a>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="hero teaser">
<div class="container is-max-desktop">
<div class="hero-body">
<img src="./static/images/combined_api_qwen_performance.png" alt="Q Model Performance" style="width: 100%; height: auto;">
<h2 class="subtitle has-text-centered">
Our fully trained models outperform frontier models on Q programming tasks, with our 32B model surpassing Claude Opus-4 by 29.5%. Individual bars represent pass@(1, 2, 4, 6, 8, 16, 40) for 40 completions per problem.
</h2>
</div>
</div>
</section>
<section class="section">
<div class="container is-max-desktop">
<!-- Abstract. -->
<div class="columns is-centered has-text-centered">
<div class="column is-four-fifths">
<h2 class="title is-3">Abstract</h2>
<div class="content has-text-justified">
<p>
Even though large language models are becoming increasingly capable, it is still unreasonable to expect them to excel at tasks that are under-represented on the Internet. Leveraging LLMs for specialized applications, particularly in niche programming languages and private domains, remains challenging and largely unsolved.
</p>
<p>
In this work, we address this gap by presenting a comprehensive, open-source approach for adapting LLMs to the Q programming language, a popular tool in quantitative finance. We introduce a new LeetCode-style evaluation dataset for Q, benchmark major frontier models, then perform pretraining, supervised fine-tuning, and reinforcement learning to train a suite of models based on the Qwen-2.5 series, spanning five parameter sizes (1.5B, 3B, 7B, 14B, 32B).
</p>
<p>
Our best model achieves a pass@1 accuracy of 59% on our Q benchmark, surpassing the best-performing frontier model, Claude Opus-4, by 29.5%. Additionally, all our models, even our 1.5B variant, outperform GPT-4.1 on this task. We provide a detailed blueprint for dataset construction, model pretraining, supervised fine-tuning, and reinforcement learning that is broadly applicable to other specialized domains.
</p>
</div>
</div>
</div>
<!--/ Abstract. -->
<!-- Important Notice -->
<div class="columns is-centered has-text-centered">
<div class="column is-four-fifths">
<div class="notification is-warning">
<h3 class="title is-4">Note for Q Practitioners</h3>
<div class="content has-text-justified">
<p>
Our Q benchmark uses a LeetCode-style format that produces "Pythonic Q" code, which does not reflect typical Q usage in practice (database queries and analytics). While our models show strong performance on algorithmic tasks, practitioners may find that our pretrained models (before SFT/RL) provide better general-purpose Q assistance. This work serves as a blueprint for further adaptation to more representative Q datasets.
</p>
</div>
</div>
</div>
</div>
<!--/ Important Notice -->
</div>
</section>
<section class="section">
<div class="container is-max-desktop">
<div class="columns is-centered">
<div class="column is-full-width">
<h2 class="title is-3">Training Pipeline & Results</h2>
<!-- Dataset Construction -->
<h3 class="title is-4">Building the Dataset</h3>
<div class="content has-text-justified">
<p>
We started by creating a verifiable Q dataset through a model-in-the-loop approach. Using LeetCode problems as a foundation, we iteratively generated Q solutions, verified them programmatically, and used successful examples to train better models. This bootstrapping process involved careful separation of solution and test generation to prevent reward hacking, ultimately resulting in a diverse dataset covering multiple problem types and difficulty levels.
</p>
</div>
<div class="columns is-centered">
<div class="column is-8">
<img src="./static/images/dataset_distribution.png" alt="Dataset Distribution" style="width: 100%; height: auto;">
<p class="has-text-centered is-size-7"><em>Distribution of problem difficulty levels and categories in our Q-LeetCode dataset, showing comprehensive coverage across algorithmic topics.</em></p>
</div>
</div>
<!-- Pretraining -->
<h3 class="title is-4">Domain-Adaptive Pretraining</h3>
<div class="content has-text-justified">
<p>
We collected and curated Q code from open-source repositories and official documentation, creating a high-quality corpus for domain adaptation. Pretraining on this data gave our models foundational knowledge of Q syntax and idioms, providing a crucial boost that helped break through the bootstrapping plateau and established a strong foundation for subsequent fine-tuning stages.
</p>
</div>
<div class="columns is-centered">
<div class="column is-8">
<img src="./static/images/pretrain_models_performance.png" alt="Pretraining Performance" style="width: 100%; height: auto;">
<p class="has-text-centered is-size-7"><em>Performance improvements across all model sizes after domain-adaptive pretraining, with larger models showing greater gains.</em></p>
</div>
</div>
<!-- SFT -->
<h3 class="title is-4">Supervised Fine-Tuning</h3>
<div class="content has-text-justified">
<p>
Using our curated LeetCode-Q dataset, we performed supervised fine-tuning on multiple task types: description-to-Q, Python-to-Q, and Q-to-Python translation. This stage directly optimized our models for the specific algorithmic challenges in our benchmark, building on the general Q knowledge from pretraining to achieve substantial performance improvements across all model sizes.
</p>
</div>
<div class="columns is-centered">
<div class="column is-8">
<img src="./static/images/sft_models_performance.png" alt="SFT Performance" style="width: 100%; height: auto;">
<p class="has-text-centered is-size-7"><em>Significant performance gains from supervised fine-tuning across all model sizes, demonstrating the value of task-specific training.</em></p>
</div>
</div>
<!-- Reinforcement Learning -->
<h3 class="title is-4">Reinforcement Learning</h3>
<div class="content has-text-justified">
<p>
Finally, we applied reinforcement learning using programmatic rewards based on test case correctness. We explored both reasoning and non-reasoning variants, with particularly strong results for our 14B and 32B reasoning models. RL provided the final boost in performance, with reasoning models showing the ability to think through complex problems step-by-step before generating code solutions.
</p>
</div>
<div class="columns is-centered">
<div class="column is-8">
<img src="./static/images/rl_models_performance.png" alt="RL Performance" style="width: 100%; height: auto;">
<p class="has-text-centered is-size-7"><em>Performance improvements from reinforcement learning across model sizes, with reasoning variants showing particularly strong gains for larger models.</em></p>
</div>
</div>
<div class="content has-text-justified">
<p>
Interestingly, during RL training, we observed that our reasoning models learned to generate longer, more thoughtful completions over time. This suggests the models discovered that taking more time to reason through problems led to better solutions, naturally developing a "slow thinking" approach for complex algorithmic challenges.
</p>
</div>
<div class="columns is-centered">
<div class="column is-8">
<img src="./static/images/mean_completion_tokens.png" alt="Completion Length Evolution" style="width: 100%; height: auto;">
<p class="has-text-centered is-size-7"><em>Evolution of mean completion length during RL training, showing how the reasoning model learned to generate longer, more thoughtful responses for better results.</em></p>
</div>
</div>
<!-- Final Results -->
<h3 class="title is-4">Cumulative Impact</h3>
<div class="content has-text-justified">
<p>
Each stage of our pipeline contributed meaningfully to the final performance. The chart below shows how pretraining, supervised fine-tuning, and reinforcement learning each added value, with larger models benefiting more from each adaptation stage.
</p>
</div>
<div class="columns is-centered">
<div class="column is-10">
<img src="./static/images/qwen_stacked_value_add.png" alt="Cumulative Gains" style="width: 100%; height: auto;">
<p class="has-text-centered is-size-7"><em>Stacked chart showing the cumulative contribution of each training stage across all model sizes.</em></p>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="section">
<div class="container is-max-desktop">
<div class="columns is-centered">
<div class="column is-full-width">
<h2 class="title is-3">Key Contributions</h2>
<div class="content">
<ul>
<li><strong>New Q Benchmark:</strong> First LeetCode-style evaluation dataset for Q programming language with rigorous programmatic verification</li>
<li><strong>Complete Model Suite:</strong> Five model sizes (1.5B-32B) all outperforming GPT-4.1, with top models exceeding Claude Opus-4</li>
<li><strong>Practical Blueprint:</strong> End-to-end methodology for LLM domain adaptation with all code, data, and training scripts released</li>
<li><strong>Methodological Insights:</strong> Lessons on reward hacking, evaluation design, and scaling effects in specialized domains</li>
</ul>
</div>
</div>
</div>
</div>
</section>
<section class="section" id="BibTeX">
<div class="container is-max-desktop content">
<h2 class="title">BibTeX</h2>
<pre><code>@article{hogan2025fullstack,
author = {Hogan, Brendan R. and Brown, Will and Boyarsky, Adel and Schneider, Anderson and Nevmyvaka, Yuriy},
title = {Full-Stack Fine-Tuning for the Q Programming Language},
journal = {arXiv preprint},
year = {2025},
url = {https://arxiv.org/abs/XXXX.XXXXX}
}</code></pre>
</div>
</section>
<footer class="footer">
<div class="container">
<div class="content has-text-centered">
<a class="icon-link" target="_blank" href="#">
<i class="fas fa-file-pdf"></i>
</a>
<a class="icon-link" href="#" target="_blank" class="external-link">
<i class="fab fa-github"></i>
</a>
</div>
<div class="columns is-centered">
<div class="column is-8">
<div class="content">
<p>
This website is licensed under a <a rel="license" target="_blank"
href="http://creativecommons.org/licenses/by-sa/4.0/">Creative
Commons Attribution-ShareAlike 4.0 International License</a>.
</p>
</div>
</div>
</div>
</div>
</footer>
</body>
</html>
|