{"id":260478,"date":"2026-07-13T17:40:32","date_gmt":"2026-07-13T14:40:32","guid":{"rendered":"https:\/\/1kitap1.com\/en\/fine-tuning-ai-early-release-laurence-moroney\/"},"modified":"2026-07-13T17:40:32","modified_gmt":"2026-07-13T14:40:32","slug":"fine-tuning-ai-early-release-laurence-moroney","status":"publish","type":"post","link":"https:\/\/1kitap1.com\/en\/fine-tuning-ai-early-release-laurence-moroney\/","title":{"rendered":"Fine &#8211; Tuning AI Early Release &#8211; Laurence Moroney"},"content":{"rendered":"<figure style=\"text-align:center;margin:0 auto 1.5em;\"><img decoding=\"async\" src=\"https:\/\/1kitap1.com\/en\/wp-content\/uploads\/2026\/07\/5f799524f30128c4.jpg\" alt=\" - Unknown book cover\" style=\"max-width:300px;width:100%;height:auto;box-shadow:0 4px 12px rgba(0,0,0,.25);border-radius:4px;\"\/><\/figure>\n<p>Grouped Query Attention In this simple example, where there are 6 heads, instead of each Q having its own dedicated KV, we have a situation where Q1 and Q2 share a KV, Q3 and Q4 share one etc. This gives us a 50% reduction in KV Cache size. In LLama 3 8B, there are 32 query heads grouped into 8 groups of 4, and each shares 8 key-value heads. This reduces the KV cache by 75% compared to standard multi-head attention, dramatically improving inference speed and reducing memory requirements\u2014especially for long contexts.<\/p>\n<p>So, when it comes to fine tuning, it\u2019s good to consider models that use GQA because they can give you better inference performance without sacrificing much quality. Continued Innovation: Mistral and Mixtral Continuing the story of innovation being driven by smaller models, and the needs for efficiency that can be generally forgotten in larger models, let\u2019s now explore Mistral and Mixtral. Mistral 7B, introduced in September 2023 demonstrated that a relatively small model\u2014only 7B\u2014could compete with much larger models on benchmarks. It did with several key innovations.<\/p>\n<p>Sliding Window Attention As we pay attention to previous tokens, the longer the sequence of tokens, the more the scale of being able to manage it explodes in size. So, if every token has to look at every other token, including itself, we end up with a quadratic number of lookups. For 2 tokens, there would be 2 comparisons of 2 tokens each, so 4 lookups. With 10 tokens, this becomes 100.<\/p>\n<p>With 1,000 tokens we now have 1 Million lookups! How large would this get for a context window of 128k tokens? Mistral introduced a sliding window, where each token only directly attends to the previous 4,096 tokens. Your initial thoughts on this might be that information outside the context window might be lost, but think about it a little. If the context is 128k tokens, and you are using a sliding window of only 4k, it may feel like the majority of tokens are ignored.<\/p>\n<p>But in a multi-layer model, this isn\u2019t necessarily true. Let\u2019s explore this. Figure 2-9. Sliding Window Context movement. Imagine 10 tokens, with a 4 token context window. So, for example for tokens 7 through 10, the output of our sliding window will be the \u2018rightmost\u2019 token in Layer 2.<\/p>\n<blockquote>\n<p>Customizing Large Language Models With Early Release ebooks, you get books in their earliest form\u2014the author\u2019s raw and unedited content as they write\u2014so you can take advantage of these technologies long before the official release of these titles. Laurence Moroney OceanofPDF.com Fine-Tuning AI by Laurence Moroney Copyright \u00a9 2027 Laurence Moroney. All rights reserved. Published by O\u2019Reilly Media, Inc., 141 Stony Circle, Suite 195, Santa Rosa, CA 95401. O\u2019Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (https:\/\/oreilly.com).<\/p>\n<p>For more information, contact our corporate\/institutional sales department: 800-998-9938 or corporate@oreilly.com. Acquisitions Editor: Nicole Butterfield Development Editor: Michele Cronin Production Editor: Katherine Tozer Interior Designer: David Futato Interior Illustrator: Kate Dullea July 2027: First Edition Revision History for the Early Release 2026-03-06: First Release See https:\/\/oreilly.com\/catalog\/errata.csp?isbn=9798341673373 for release details. The O\u2019Reilly logo is a registered trademark of O\u2019Reilly Media, Inc. Fine- Tuning AI, the cover image, and related trade dress are trademarks of O\u2019Reilly Media, Inc.<\/p>\n<p>The views expressed in this work are those of the author and do not represent the publisher\u2019s views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk.<\/p>\n<p>If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and\/or rights. 979-8-341-67333-5 [LSI] OceanofPDF.com Brief Table of Contents (Not Yet Final) Chapter 1: From Generalist to Specialist (available) Chapter 2: Model Architectures: The DNA of AI (available) Chapter 3: The Fine-Tuner\u2019s Workshop (available) Chapter 4: Excavating Data (unavailable) Chapter 5: Synthetic Data (unavailable) Chapter 6: Formatting for Thought (unavailable) Chapter 7: The Mechanics of Adaptation (unavailable) Chapter 8: The Training Loop (unavailable) Chapter 9: Alignment (unavailable) Chapter 10: Case Study (unavailable) Chapter 11: Vision Language Models (unavailable) Chapter 12: Controlling the Canvas (unavailable) Chapter 13: Style Injection (unavailable) Chapter 14: Evaluation (unavailable) Chapter 15: Optimization and Quantization (unavailable) Chapter 16: Serving the Expert (unavailable) OceanofPDF.com Chapter 1.<\/p>\n<p>From Generalist to Specialist A NOTE FOR EARLY RELEASE READERS With Early Release ebooks, you get books in their earliest form\u2014the author\u2019s raw and unedited content as they write\u2014so you can take advantage of these technologies long before the official release of these titles. This will be the 1st chapter of the final book. Please note that the GitHub repo will be made active later on. If you\u2019d like to be actively involved in reviewing and commenting on this draft, please reach out to the editor at mcronin@oreilly.com.<\/p>\n<p>The honeymoon is over.<\/p>\n<\/blockquote>\n<p><em>This is a short excerpt from the opening of &ldquo;&rdquo; by Unknown, quoted for review and introduction purposes. All rights belong to the copyright holders.<\/em><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/1kitap1.com\/en\/fine-tuning-ai-early-release-laurence-moroney\/#Book_Information\" >Book Information<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/1kitap1.com\/en\/fine-tuning-ai-early-release-laurence-moroney\/#Reading_Word_Statistics\" >Reading &amp; Word Statistics<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/1kitap1.com\/en\/fine-tuning-ai-early-release-laurence-moroney\/#Most_Frequent_Words\" >Most Frequent Words<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/1kitap1.com\/en\/fine-tuning-ai-early-release-laurence-moroney\/#PDF_Download\" >PDF Download<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Book_Information\"><\/span>Book Information<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Unique ID:<\/strong> 5f799524f30128c4<\/li>\n<li><strong>File Extension:<\/strong> .pdf<\/li>\n<li><strong>File Size:<\/strong> 1,496,206 bytes (1.427 MB)<\/li>\n<li><strong>Title:<\/strong> &#8211;<\/li>\n<li><strong>Author:<\/strong> Unknown<\/li>\n<li><strong>ISBN:<\/strong> 9798341673373, 9798341673335<\/li>\n<li><strong>Pages:<\/strong> 87<\/li>\n<li><strong>Language:<\/strong> English (en)<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Reading_Word_Statistics\"><\/span>Reading &amp; Word Statistics<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Estimated Reading Time:<\/strong> 89.82 minutes<\/li>\n<li><strong>Total Words:<\/strong> 17,964<\/li>\n<li><strong>Total Characters:<\/strong> 109,198<\/li>\n<li><strong>Average Words per Page:<\/strong> 206.48<\/li>\n<li><strong>Average Characters per Page:<\/strong> 1255.15<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Most_Frequent_Words\"><\/span>Most Frequent Words<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>model (139), models (93), like (78), training (64), gpu (64), it\u2019s (62), tokens (61), attention (57), one (53), use (51), data (44), chapter (43), using (43), vram (43), need (42), see (41), memory (41), figure (37), get (36), also (35), fine (34), available (31), gpus (31), cuda (31), token (30), words (30), context (29), different (29), don\u2019t (29), many (28), look (28), that\u2019s (28), weights (28), work (27), example (27), window (27), tuning (26), you\u2019re (26), cloud (26), much (26), you\u2019ll (25), output (25), time (25), size (24), fine-tuning (23), code (23), book (23), language (22), first (22), single (22), system (22), hardware (22), now (21), lora (21), pytorch (21), nvidia (21), without (20), better (20), every (20), inference (20), layer (20), prompt (19), per (19), version (19), ultimately (18), think (18), architecture (18), understand (18), make (18), parameters (18), machine (18), layers (18), run (18), word (18), position (18), heads (18), bit (18), across (17), release (17), information (17), used (17), good (17), note (17), consider (17), doesn\u2019t (17), step (17), smaller (17), sequence (17), multiple (17), start (16), llama (16), embedding (16), between (16), learning (16), stack (16), gradients (16), colab (16), qlora (16), com (15), take (15).<\/p>\n<h2><span class=\"ez-toc-section\" id=\"PDF_Download\"><\/span>PDF Download<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align:center;\"><a href=\"https:\/\/1kitap1.com\/en\/wp-content\/uploads\/2026\/07\/fine-tuning-ai-early-release-laurence-moroney.pdf\" download rel=\"nofollow\" style=\"display:inline-block;background:#2271b1;color:#ffffff;padding:14px 36px;border-radius:6px;text-decoration:none;font-weight:bold;font-size:1.05em;\">&#11015;&#65039; PDF Download<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grouped Query Attention In this simple example, where there are 6 heads, instead of each Q having its own dedicated KV, we have a situation where Q1 and Q2 share a KV, Q3 and Q4 share one etc. This gives us a 50% reduction in KV Cache size. In LLama 3 8B, there are 32 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":260476,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-260478","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-english"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts\/260478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/comments?post=260478"}],"version-history":[{"count":0,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/posts\/260478\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/media\/260476"}],"wp:attachment":[{"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/media?parent=260478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/categories?post=260478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1kitap1.com\/en\/wp-json\/wp\/v2\/tags?post=260478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}