<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://thakicloud.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://thakicloud.github.io/" rel="alternate" type="text/html" /><updated>2026-07-14T05:35:15+09:00</updated><id>https://thakicloud.github.io/feed.xml</id><title type="html">Thaki Cloud Tech Blog | ThakiCloud | 다키클라우드 기술 블로그</title><subtitle>Thaki Cloud (ThakiCloud, 다키클라우드, thaki cloud, THAKI CLOUD, ثاكي كلاود)는 AI/ML Engineering, LLMOps, DevOps 분야의 최신 기술과 실무 경험을 공유하는 전문 기술 블로그입니다. 머신러닝 모델 운영, 쿠버네티스, 클라우드 인프라, AI 엔지니어링 커리어, 인공지능 기술 블로그, 다키클라우드 개발 팀의 깊이 있는 인사이트를 제공합니다. مدونة تقنية متخصصة في هندسة الذكاء الاصطناعي والحوسبة السحابية.</subtitle><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><entry xml:lang="ar"><title type="html">حذفنا 423 غيغابايت من GLM-5.2 دون تكميم: قياس الهدر في حقل الأس في BF16</title><link href="https://thakicloud.github.io/ar/llmops/lossless-bf16-compression/" rel="alternate" type="text/html" title="حذفنا 423 غيغابايت من GLM-5.2 دون تكميم: قياس الهدر في حقل الأس في BF16" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/llmops/lossless-bf16-compression</id><content type="html" xml:base="https://thakicloud.github.io/ar/llmops/lossless-bf16-compression/"><![CDATA[<p><img src="/assets/images/lossless-bf16-compression-hero.png" alt="رسم توضيحي تجريدي لمكعبات زجاجية متراصة تُضغط دون خسارة إلى كتلة أصغر" /></p>

<h2 id="نظرة-عامة">نظرة عامة</h2>

<p>كل فريق خدَم نموذجا كبيرا مفتوح الأوزان محليا يعرف أن العائق الأول هو دائما الحجم. نموذج مثل GLM-5.2، بأكثر من 700 مليار معامل، يقترب من 1.4 تيرابايت في صيغة BF16 الخام، وتوزيعه على عدة وحدات GPU يجعل ذاكرة VRAM تكلفة مباشرة. وكان الجواب على هذه المشكلة دائما تقريبا هو التكميم: خفض 16 بت إلى 8 ثم إلى 4 بل إلى 2، مع التضحية بقليل من الجودة في الطريق.</p>

<p>هذا المقال موجه لقادة الهندسة المسؤولين عن تكلفة الاستدلال، وللممارسين الذين ينشرون النماذج محليا (on-premises)، ولعلماء البيانات في البيئات الخاضعة للتنظيم الذين لا يمكنهم فقدان بت واحد من الدقة. نشر مؤخرا باحث باسم brianbell-x أنه حذف 423 غيغابايت من GLM-5.2. صار 1403 غيغابايت يساوي 980 غيغابايت، والمثير أن الطريقة لم تكن تكميما. لم تكن تشذيبا ولا تقطيرا، بل ضغطا بلا خسارة يعيد بناء الأصل بت ببت عند فك الضغط. فإذا كان شيء بلا خسارة ومع ذلك يتقلص بنسبة 30 بالمئة، فهذا يعني أن الصيغة الأصلية كانت تهدر هذا القدر بالضبط.</p>

<p>بدل أن نأخذ الادعاء على محمل الثقة، قررنا التحقق منه مباشرة. فتحنا 490 مليون وزن مُدرّب فعلي من Qwen2.5-0.5B وقِسنا إنتروبيا حقل الأس في BF16، مؤكدين أن الثمانية بتات المخصصة تحمل فقط 2.64 بت من المعلومات الحقيقية. جاء الحد النظري للضغط بلا خسارة عند 33.5 بالمئة، وهو ما تطابق تقريبا مع 30.17 بالمئة التي حققها المؤلف الأصلي بترميز فعلي. يغطي هذا المقال تلك القياسات ويشرح لماذا يحدث التوفير ليس على القرص فحسب بل في VRAM أيضا.</p>

<h2 id="ما-هي-هذه-التقنية">ما هي هذه التقنية</h2>

<p>علينا أولا أن نرى كيف يخزّن BF16 رقما واحدا. يقسم BF16 (brain floating point 16) الستة عشر بت إلى ثلاثة أجزاء: بت إشارة واحد، و8 بتات أس، و7 بتات جزء عشري (mantissa). يحصل الأس على 8 بتات كاملة لأن BF16 مصمم للحفاظ على نطاق ديناميكي واسع مماثل لـ FP32، حتى يستطيع تمثيل قيم كبيرة جدا أو صغيرة جدا.</p>

<p>المشكلة أن أوزان نموذج مُدرّب بالكاد تستخدم هذا النطاق الواسع. في شبكة عصبية مدربة جيدا، تتجمع معظم الأوزان حول قيم صغيرة قرب الصفر. ونتيجة لذلك يتكتل حقل الأس حول حفنة من القيم، ومن بين 256 احتمالا تستطيع الثمانية بتات تمثيلها، لا يظهر فعليا سوى جزء ضئيل. هنا يكمن الهدر: تُخصَّص 8 بتات، لكن المعلومات المحمولة فعليا أقل بكثير.</p>

<p>فكرة الضغط بلا خسارة بسيطة. رمّز حقل الأس منخفض المعلومات بترميز إنتروبي إلى تمثيل قصير، واترك الثمانية بتات من الإشارة والجزء العشري كما هي لأنها شبه غير قابلة للضغط. يجمع تنفيذ المؤلف الأصلي الإشارة والأس في رمز من 4 بتات يشير إلى جدول بحث يضم أكثر 15 تركيبة أُس شيوعا. أما القيم النادرة غير الموجودة في الجدول فتُخزَّن منفصلة بصيغتها الكاملة. تلخّص الصورة التالية هذه العملية.</p>

<pre><code class="language-mermaid">flowchart TB
    A["وزن BF16 مُدرّب&lt;br/&gt;16 بت = إشارة 1 + أس 8 + جزء عشري 7"] --&gt; B["تحليل حقل الأس&lt;br/&gt;يظهر عدد قليل من 256 قيمة"]
    B --&gt; C["قياس إنتروبيا الأس&lt;br/&gt;تخصيص 8 بت -&gt; نحو 2.64 بت"]
    C --&gt; D["استبدال الإشارة+الأس برمز 4 بت&lt;br/&gt;أكثر 15 تركيبة شيوعا -&gt; جدول بحث"]
    D --&gt; E["الحفاظ على الجزء العشري 7 بت كما هو&lt;br/&gt;بلا خسارة بت ببت"]
    E --&gt; F["تخزين الأسات النادرة بصيغتها الكاملة&lt;br/&gt;مع الحفاظ على العنونة ثابتة العرض"]
    F --&gt; G["الوزن المضغوط&lt;br/&gt;نحو 10.6 بت لكل وزن (توفير نحو 33%)"]
</code></pre>

<p>يختلف هذا النهج جوهريا عن التكميم. فالتكميم يقتطع الجزء العشري أو يقرّب القيم، مسقِطا الدقة فعليا. أما الضغط بلا خسارة فلا يسقط شيئا. إنه يعيد كتابة المعلومات نفسها برمز أقصر فقط، فيعيد فك الضغط الأوزان الأصلية دون خطأ بت واحد. تنتمي أعمال حديثة مثل DFloat11 و ZipNN إلى العائلة نفسها. أفاد ZipNN أن حقل الأس في BF16 لأوزان نماذج اللغة المدربة يحمل نحو 2.6 بت فقط من إنتروبيا شانون ضمن تخصيصه البالغ 8 بت. ما أردنا معرفته هو ما إذا كان هذا الرقم يتكرر على نموذج حقيقي.</p>

<h2 id="قياس-إنتروبيا-الأس-بأنفسنا">قياس إنتروبيا الأس بأنفسنا</h2>

<p>للتحقق، فتحنا نموذج BF16 مُدرّبا حقيقيا واحدا في بيئة عمل معزولة. كان الهدف Qwen2.5-0.5B، وهو نموذج منشور فعلي بـ 490 مليون وزن. حللنا البنية الثنائية لملف safetensors مباشرة، وقرأنا كل مصفوفة BF16 كأعداد صحيحة من 16 بت، واستخرجنا الثمانية بتات الخاصة بالأس، وحسبنا توزيع القيم وإنتروبيا شانون. لم نستخدم أي تقدير من إطار عمل، بل الأرقام المستخرجة من بايتات المصفوفة الفعلية فقط.</p>

<p>في ما يلي شفرة القياس الأساسية، وهي الجزء الذي يرى قيمة BF16 كعدد صحيح من 16 بت ويقتطع حقل الأس.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="n">numpy</span> <span class="k">as</span> <span class="n">np</span>

<span class="k">def</span> <span class="nf">bf16_exponent_bytes</span><span class="p">(</span><span class="n">raw</span><span class="p">:</span> <span class="n">np</span><span class="p">.</span><span class="n">ndarray</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">np</span><span class="p">.</span><span class="n">ndarray</span><span class="p">:</span>
    <span class="c1"># raw = قيم BF16 مرئية كـ uint16. الأس = البتات 14..7 (8 بت)
</span>    <span class="nf">return </span><span class="p">((</span><span class="n">raw</span> <span class="o">&gt;&gt;</span> <span class="mi">7</span><span class="p">)</span> <span class="o">&amp;</span> <span class="mh">0xFF</span><span class="p">).</span><span class="nf">astype</span><span class="p">(</span><span class="n">np</span><span class="p">.</span><span class="n">uint8</span><span class="p">)</span>

<span class="c1"># حلّل ترويسة safetensors، اقرأ مصفوفات BF16 كـ uint16، واحسب
# إنتروبيا شانون من تكرار قيم الأس.
</span></code></pre></div></div>

<p>كانت النتيجة أكثر إثارة مما توقعنا. في ما يلي ما أظهره مسح عبر 290 مصفوفة BF16 بمجموع 494 مليون وزن.</p>

<table>
  <thead>
    <tr>
      <th>البند</th>
      <th>القيمة المقاسة</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>عدد مصفوفات BF16</td>
      <td>290</td>
    </tr>
    <tr>
      <td>إجمالي الأوزان</td>
      <td>494,032,768</td>
    </tr>
    <tr>
      <td>قيم الأس الظاهرة فعليا</td>
      <td>38 من أصل 256</td>
    </tr>
    <tr>
      <td>إنتروبيا شانون لحقل الأس</td>
      <td><strong>2.6386 بت</strong> (من 8 مخصصة)</td>
    </tr>
    <tr>
      <td>نصيب أكثر 3 أسات شيوعا</td>
      <td>نحو 72 بالمئة من كل الأوزان</td>
    </tr>
    <tr>
      <td>البت لكل وزن بعد الضغط</td>
      <td>16 بت -&gt; 10.64 بت</td>
    </tr>
    <tr>
      <td>التوفير النظري بلا خسارة</td>
      <td><strong>33.5 بالمئة</strong></td>
    </tr>
  </tbody>
</table>

<p>يستطيع حقل الأس تمثيل 256 قيمة، لكن ظهرت 38 فقط، وغطت أعلى 3 منها 72 بالمئة من كل الأوزان. كانت إنتروبيا شانون 2.6386 بت، مطابقة تقريبا لـ 2.6 بت التي أفاد بها ZipNN. بعبارة أخرى، كان حقل الأس البالغ 8 بت يحمل 2.64 بت فقط من المعلومات، والبتات الـ 5.36 المتبقية هدر خالص.</p>

<p>إزالة هذا الهدر بلا خسارة تخفض البت لكل وزن من 16 إلى 10.64، مع الحفاظ على الثمانية بتات من الإشارة والجزء العشري وضغط الأس حتى حده الإنتروبي. وكتوفير، هذا يعادل 33.5 بالمئة.</p>

<p><img src="/assets/images/lossless-bf16-compression-results.png" alt="مخطط لقياس Qwen2.5-0.5B يظهر أن حقل الأس في BF16 يستخدم فعليا 2.64 بت فقط، وأن ضغطه بلا خسارة يقلّص GLM-5.2 من 1403 غيغابايت إلى نحو 980 غيغابايت" /></p>

<p>بإسقاط هذه الـ 33.5 بالمئة على حجم GLM-5.2 (753B)، يصبح 1403 غيغابايت نحو 933 غيغابايت. أما القيمة التي حققها المؤلف الأصلي بترميز فعلي فكانت 980 غيغابايت، أي توفير 30.17 بالمئة. الفجوة البالغة نحو 3 نقاط مئوية بين حدنا النظري (33.5 بالمئة) والتنفيذ الفعلي (30.17 بالمئة) ليست صدفة. فمرمّزات الإنتروبيا الفعلية لا تبلغ حد شانون كاملا، ويجب تخزين قيم الأس النادرة بصيغتها الكاملة، ويجب أن تكون الرموز ثابتة العرض للسماح بالوصول العشوائي على GPU، وكل ذلك يضيف عبئا طفيفا. أن تتقارب النظرية والتنفيذ إلى هذا الحد دليل قوي على أن الادعاء الأصلي صحيح وأن النهج سليم.</p>

<h2 id="لماذا-تتقلص-vram-أيضا-على-gpu">لماذا تتقلص VRAM أيضا على GPU</h2>

<p>هنا النقطة الأسهل إساءة فهمها. معظم الضغط يتقلص على القرص فقط ويعود إلى حجمه الكامل لحظة تحميل النموذج على GPU، لأنه يجب فك ضغطه للحساب. لكن الـ 30 بالمئة في هذا الضغط بلا خسارة هي رقم VRAM لا رقم قرص. وهذا ما يجعل هذه التقنية مختلفة عن ضغط الملفات العادي.</p>

<p>السر في الرموز ثابتة العرض. لأن رمز كل وزن مضغوط بالعرض نفسه، يمكنك حساب موضع الوزن رقم N بالضبط دون فك ضغط. لا حاجة لتمرير فك تعبئة منفصل ولا لنسخة ثانية بالصيغة الأصلية. تقرأ نواة GPU البايتات المضغوطة مباشرة وتبحث عن كل رمز في جدول صغير محفوظ في المسجلات (registers) أثناء إجراء الضرب. الصيغة الكاملة من 16 بت لا توجد أبدا في VRAM. لذلك تظهر الـ 30 بالمئة في البصمة الفعلية للذاكرة، لا على القرص فحسب.</p>

<p>الأثر العملي كبير. خدمة نموذج 1403 غيغابايت تتطلب 18 بطاقة H100 سعة 80 غيغابايت على الأقل. ومع خفض الضغط بلا خسارة له إلى 980 غيغابايت، ينخفض ذلك إلى نحو 13. توفّر خمس وحدات GPU دون فقدان بت واحد من الجودة. إذا كان التكميم مقايضة للجودة بالذاكرة، فهذه التقنية أقرب إلى وجبة غداء مجانية. لكنها ليست مجانية تماما، ونتناول الثمن أدناه.</p>

<h2 id="الآثار-على-منتجات-thakicloud">الآثار على منتجات ThakiCloud</h2>

<p>هذه التقنية جذابة بشكل خاص من منظور ai-platform لدى ThakiCloud. الـ ai-platform بنية تحتية تخدم النماذج لبيئات عملاء متنوعة فوق Kubernetes وجدولة GPU المبنية على Kueue. كثير من العملاء المحليين يطلبون السحابة المحلية والسيادية، وفي تلك البيئات تكون كل وحدة GPU نفقة رأسمالية ومهلة توريد. يقلّل الضغط بلا خسارة عدد وحدات GPU المطلوبة دون التضحية بأي دقة، ما يجعله ورقة أسهل في الإقناع من التكميم أمام العملاء الحساسين للجودة في القطاعات المنظمة. في المال أو الرعاية الصحية، حيث تصبح قابلية إعادة إنتاج مخرجات النموذج خاضعة للتدقيق، يمكن أن يكون التطابق بت ببت متطلبا بحد ذاته.</p>

<p>الأثر أكبر في الإعدادات متعددة المستأجرين التي تخدم نماذج كبيرة بـ vLLM أو SGLang. استعادة 30 بالمئة من VRAM تتيح تركيب نافذة سياق أكبر على العتاد نفسه، أو تشغيل مزيد من الطلبات المتزامنة، أو تحميل نموذج أكبر على عقدة واحدة. تراكم هذا النوع من كفاءة الموارد بالضبط هو حيث ينافس ai-platform على تكلفة خدمة منخفضة. الضغط بلا خسارة محور متعامد مع التكميم و paged attention والتوازي التنسوري، فيُضاف مباشرة فوق التحسينات القائمة.</p>

<p>والخدمة منخفضة التكلفة تغذّي بدورها اقتصاديات الوكلاء. Paxis، وهو مستوى التحكم Agent-Native Cloud لدى ThakiCloud، يشغّل مئات المهارات في صناديق رمل معزولة ويمرّر كل فعل عبر بوابات سياسة وسجلات تدقيق، وهذه أحمال عمل الوكلاء تستدعي نماذج كبيرة مفتوحة الأوزان مرارا. وكلما انخفضت تكلفة وحدة الخدمة، أمكن تشغيل الوكلاء بجرأة أكبر، فتكون كفاءة موارد ai-platform ركيزة لاقتصاديات تشغيل Paxis.</p>

<h2 id="القيود-والاعتراضات">القيود والاعتراضات</h2>

<p>هذه التقنية ليست علاجا شاملا. أولا، فرضية انخفاض إنتروبيا الأس تصح فقط في النماذج المدربة جيدا. يجب أن تتجمع الأوزان قرب الصفر ليتكتل الأس، لذا فالنماذج غير المدربة بما يكفي، أو ذات التوزيعات الواسعة، أو المكمَّمة بشدة أصلا، ستشهد توفيرا أقل. كما أن قياسنا يأتي من نموذج واحد، فالأرقام الفعلية ستتغير بحسب البنية وطريقة التدريب.</p>

<p>ثانيا، فك رموز الضغط في الوقت الحقيقي يتطلب من نواة GPU معالجة البحث والضرب معا. وإن لم تُحسَّن تلك النواة جيدا، فقد ينتهي بك الأمر إلى توفير الذاكرة مع زيادة زمن الاستجابة. قد تعمل أسرع في أحمال العمل المقيدة بعرض نطاق الذاكرة، لكن هذا يعتمد بشدة على العتاد وتنفيذ النواة، لذا يجب قياس الأداء على GPU المستهدف قبل النشر.</p>

<p>ثالثا، بما أنه بلا خسارة، لا يستطيع هذا النهج بلوغ توفير الضغط الشديد مثل التكميم إلى 4 بت. توفير 30 بالمئة ممتاز، لكنه يخدم غرضا مختلفا عن التكميم الذي يتنازل عن قليل من الجودة ليتقلص 4 أضعاف. الاثنان متكاملان لا متنافسان، والجواب الواقعي يجمعهما: ضغط بلا خسارة حيث تكون الدقة حاسمة تماما، وتكميم حيث يوجد فسحة في الجودة.</p>

<p>أخيرا، تستند هذه النتيجة إلى تجربة عامة لباحث واحد وإلى إعادة إنتاج صغيرة النطاق من جانبنا. تطبيقها في الإنتاج يتطلب التحقق المستقل من التطابق بت ببت للضغط وإعادة البناء، ومن أداء النواة، ومن توفير VRAM الفعلي على النموذج المستهدف وحزمة الخدمة.</p>

<h2 id="المصادر">المصادر</h2>

<ul>
  <li>brianbell-x, “Lossless Model Compression Experiment”: <a href="https://brianbell-x.github.io/weight-compression/">https://brianbell-x.github.io/weight-compression/</a></li>
  <li>النموذج المقاس: Qwen/Qwen2.5-0.5B (Hugging Face)</li>
  <li>أعمال ذات صلة: ZipNN, DFloat11 (عائلة ترميز إنتروبيا الأس في BF16)</li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="lossless-compression" /><category term="bf16" /><category term="quantization" /><category term="vram" /><category term="llmops" /><category term="self-hosting" /><category term="vllm" /><category term="paxis" /><summary type="html"><![CDATA[ادعى أحدهم أنه قلّص GLM-5.2 من 1403 غيغابايت إلى 980 غيغابايت. لا تكميم ولا تشذيب، بل ضغط بلا خسارة مطابق للأصل بت ببت. كان من الصعب تصديق ذلك، لذا فتحنا 490 مليون وزن من Qwen2.5-0.5B وقِسنا بأنفسنا إنتروبيا حقل الأس في BF16. اتضح أن الثمانية بتات المخصصة لا تحمل فعليا سوى 2.64 بت من المعلومات، ما يعني إمكانية إزالة نحو 33.5 بالمئة دون خسارة. يشرح هذا المقال من أين يأتي هذا الهدر، ولماذا يظهر التوفير ليس على القرص فحسب بل في ذاكرة VRAM أيضا، بالاستناد إلى بيانات مقاسة.]]></summary></entry><entry xml:lang="ar"><title type="html">أين تضع نموذجا مكمَّما؟ أربعة أنماط للنشر مع AWS و Unsloth</title><link href="https://thakicloud.github.io/ar/llmops/unsloth-aws-quantization-deploy/" rel="alternate" type="text/html" title="أين تضع نموذجا مكمَّما؟ أربعة أنماط للنشر مع AWS و Unsloth" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/llmops/unsloth-aws-quantization-deploy</id><content type="html" xml:base="https://thakicloud.github.io/ar/llmops/unsloth-aws-quantization-deploy/"><![CDATA[<p><img src="/assets/images/unsloth-aws-quantization-deploy-hero.png" alt="رسم توضيحي تجريدي لنموذج كبير يُقطَّر إلى طبقات مضغوطة تتدفق نحو بنية خدمة سحابية" /></p>

<h2 id="نظرة-عامة">نظرة عامة</h2>

<p>هناك بالفعل مقالات كثيرة عن كيفية تكميم نموذج. GPTQ و AWQ و GGUF و Unsloth Dynamic؛ وصفة لتقليص نموذج 16 بت إلى 4 بت تبعد بضع عمليات بحث. لكن النقطة التي تتعثر عندها الفرق فعلا هي ما يأتي بعد ذلك. أين بالضبط تضع ذلك الملف ذا الـ 4 بت، وكيف؟ هل تشغّله مباشرة على مثيل EC2، أم تغلّفه في نقطة نهاية SageMaker، أم تدرجه في حجيرة على عنقود EKS الذي تديره أصلا؟ لا يوجد جواب واحد، لكن توجد خريطة تتفرع بحسب صيغة ملف النموذج.</p>

<p>هذا المقال موجه لمهندسي المنصات الذين ينشرون نماذج مفتوحة الأوزان على بنيتهم التحتية، وللممارسين الذين يصممون تكلفة الاستدلال. نشرت AWS مؤخرا دليلا مع Unsloth بعنوان “Deploying quantized models on Amazon SageMaker AI with Unsloth” ينظّم قرار النشر هذا في أربعة أنماط. نحلل المنطق الأساسي لهذا الدليل، ونشرح لماذا تحدد صيغة ملف النموذج بيئة التشغيل، وبيئة التشغيل بدورها تحدد خدمة AWS، ونربط هذا التفكير بكيفية تصميم بنية مثل ThakiCloud التي تقوم بالخدمة متعددة المستأجرين على Kubernetes.</p>

<p>نوضّح أمرا مسبقا: أمثلة الأوامر هنا مسارات تم التحقق منها في دليل AWS الرسمي ووثائق Unsloth، ولم نختلق أي أرقام قياس أداء. بيئة تحققنا هي Apple Silicon، لذا لم نتمكن فعليا من تشغيل وإعادة إنتاج تكميم Unsloth وخدمة vLLM المعتمدين على CUDA محليا. لذلك فهذا المقال ليس تقرير تجربة بل تحليل بنيوي لدليل موثوق.</p>

<h2 id="لماذا-يعود-التكميم-مهما-عند-النشر">لماذا يعود التكميم مهما عند النشر</h2>

<p>يُناقَش التكميم عادة بوصفه مسألة سرعة تدريب أو استدلال فقط. لكن دليل AWS يشير إلى أن التكميم عند مرحلة النشر يغيّر ثلاثة أمور دفعة واحدة. الأول قرار المثيل. فمع صيرورة نموذج كبير قابلا للتشغيل عمليا على GPU أصغر بل على CPU، تنخفض فئة المثيل المطلوبة نفسها. الثاني ملف تعريف الإقلاع والتخزين. فملفات النموذج الأصغر تُنقل وتُخزَّن أسرع، ما يساعد على الإقلاع البارد والتوسع الأفقي. الثالث مرونة النشر. إذ يمكنك اختيار نموذج أصغر للاستدلال الحساس للتكلفة وتصدير أعلى دقة للاستدلال الحساس للجودة.</p>

<p>قوة Unsloth أنه يربط الضبط الدقيق والتشغيل والتصدير والنشر في سير عمل واحد. وبخاصة، يتيح تكميم Unsloth Dynamic v2.0 تشغيل وضبط نماذج LLM المكمَّمة مع الحفاظ على الدقة قدر الإمكان، ويُفاد أن التدريب المدرك للتكميم (QAT)، المبني بالتعاون مع PyTorch، يستعيد جزءا كبيرا من الدقة المفقودة في التكميم الساذج إلى 4 بت. بعبارة أخرى، يمكنك اختيار موضعك بدقة على مقايضة الجودة مقابل الحجم قبل النشر.</p>

<h2 id="الصيغة-تحدد-بيئة-التشغيل-وبيئة-التشغيل-تحدد-aws">الصيغة تحدد بيئة التشغيل، وبيئة التشغيل تحدد AWS</h2>

<p>الفكرة الجوهرية للدليل: لا تبدأ قرار النشر من “أي خدمة أستخدم”. بل ابدأ من “إلى أي صيغة أصدّر”، وسيتبع الباقي طبيعيا. هناك فرعان.</p>

<p>الأول GGUF. وهو صيغة ملف واحد تجمع الأوزان والمُرمِّز (tokenizer) والبيانات الوصفية معا، وتستخدمه بيئات تشغيل خفيفة مثل llama.cpp و Ollama و Unsloth. على AWS يُربَط هذا الفرع بـ Amazon EC2 أو حاوية SageMaker AI مخصصة. إنه المسار حين تريد التحقق بخفة والاحتفاظ بتحكم مباشر.</p>

<p>الثاني safetensors المدمجة. فدمج وتصدير أوزان 16 بت أو 8 بت أو FP8 أو 4 بت بواسطة Unsloth يتيح التشغيل على محركات عالية الإنتاجية مثل vLLM و SGLang، ويُربَط ذلك بحاويات الاستدلال للنماذج الكبيرة (LMI) في SageMaker AI، أو EKS، أو ECS. إنه مسار الخدمة الإنتاجية حيث تهمّ الإنتاجية والتوسع. تلخّص الصورة التالية هذا الفرع.</p>

<pre><code class="language-mermaid">flowchart TB
    A["الضبط الدقيق أو التنزيل بواسطة Unsloth"] --&gt; B{"اختيار بيئة تشغيل الخدمة"}
    B --&gt;|"ملف واحد خفيف"| C["تصدير GGUF&lt;br/&gt;أوزان + مُرمِّز + بيانات وصفية"]
    B --&gt;|"محرك عالي الإنتاجية"| D["تصدير safetensors مدمجة&lt;br/&gt;16 / 8 / FP8 / 4 بت"]
    C --&gt; E["llama.cpp · Ollama · Unsloth"]
    D --&gt; F["vLLM · SGLang"]
    E --&gt; G["Amazon EC2&lt;br/&gt;أو حاوية SageMaker مخصصة"]
    F --&gt; H["حاوية SageMaker LMI&lt;br/&gt;أو EKS · ECS"]
    G --&gt; I["التحقق من بيئة التشغيل على EC2"]
    H --&gt; I
    I --&gt; J["ترقية نفس تركيبة الملف+بيئة التشغيل&lt;br/&gt;إلى نشر مُدار"]
</code></pre>

<h2 id="الإعداد-والدمج">الإعداد والدمج</h2>

<p>سير العمل الذي يعرضه الدليل من أربع خطوات. اضبط أو نزّل نموذجا في Unsloth، صدّره بالصيغة المطابقة لبيئة التشغيل المستهدفة، تحقق من بيئة التشغيل على EC2 أو محليا، ثم رقِّ نفس تركيبة الملف وبيئة التشغيل مباشرة إلى نشر مُدار. عبارة “نفس تركيبة الملف وبيئة التشغيل” مهمة هنا، لأنه إذا اختلفت الصيغة أو المحرك بين التحقق والإنتاج، يتسلل سلوك غير متوقع.</p>

<p>يتفرع التصدير من Unsloth بحسب بيئة التشغيل المستهدفة. مسار GGUF يبدو هكذا.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># تصدير GGUF (مسار llama.cpp / Ollama / EC2)
</span><span class="n">model</span><span class="p">.</span><span class="nf">save_pretrained_gguf</span><span class="p">(</span>
    <span class="sh">"</span><span class="s">qwen-merged-gguf</span><span class="sh">"</span><span class="p">,</span>
    <span class="n">tokenizer</span><span class="p">,</span>
    <span class="n">quantization_method</span><span class="o">=</span><span class="sh">"</span><span class="s">q4_k_m</span><span class="sh">"</span><span class="p">,</span>
<span class="p">)</span>
</code></pre></div></div>

<p>مسار safetensors المدمجة يستهدف vLLM أو SGLang.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># تصدير safetensors مدمجة (مسار vLLM / SGLang / SageMaker LMI)
</span><span class="n">model</span><span class="p">.</span><span class="nf">save_pretrained_merged</span><span class="p">(</span>
    <span class="sh">"</span><span class="s">qwen-merged-16bit</span><span class="sh">"</span><span class="p">,</span>
    <span class="n">tokenizer</span><span class="p">,</span>
    <span class="n">save_method</span><span class="o">=</span><span class="sh">"</span><span class="s">merged_16bit</span><span class="sh">"</span><span class="p">,</span>  <span class="c1"># أو merged_4bit، إلخ
</span><span class="p">)</span>
</code></pre></div></div>

<p>يمكن التحقق من خدمة النموذج المدمج المصدَّر مباشرة بـ vLLM.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># التحقق من الخدمة على EC2 أو محليا</span>
vllm serve ./qwen-merged-16bit <span class="nt">--port</span> 8000
</code></pre></div></div>

<p>للنشر المبني على الحاويات، توفر حاويات التعلم العميق من AWS (DLCs) بيئات Docker محسّنة عبر EC2 و EKS و ECS. وحاوية vLLM DLC على وجه الخصوص مضبوطة للاستدلال عالي الأداء وتدعم أصلا التوازي التنسوري وتوازي خطوط الأنابيب عبر عدة وحدات GPU وعقد. أي أن تكوينا تم التحقق منه على مثيل EC2 واحد يتدفق بسلاسة إلى حجيرة EKS تستخدم بيئة التشغيل نفسها للتوسع الأفقي.</p>

<h2 id="الآثار-على-منتجات-thakicloud">الآثار على منتجات ThakiCloud</h2>

<p>تتداخل خريطة النشر هذه مباشرة مع فلسفة تصميم ai-platform لدى ThakiCloud. يخدم ai-platform النماذج فوق Kubernetes وجدولة GPU المبنية على Kueue، والمبدأ الذي يذكره دليل AWS، وهو أن الصيغة تحدد بيئة التشغيل وبيئة التشغيل تحدد البنية التحتية، غير مقيّد بسحابة بعينها. فتقسيم GGUF للتحقق الخفيف والنشر الطرفي مقابل safetensors المدمجة للخدمة عالية الإنتاجية المبنية على vLLM ينطبق بالتساوي سواء كان EKS من AWS أو Kubernetes محلي. بل إن ThakiCloud، الذي لديه كثير من العملاء الذين يطلبون السحابة المحلية والسيادية، يستفيد أكثر من حيث قابلية النقل بتوحيد مسار النشر عبر صيغة الملف وبيئة التشغيل بدل الارتباط بخدمة مُدارة بعينها.</p>

<p>عمليا، يستطيع ai-platform الجمع بين التوازي التنسوري وتوازي خطوط الأنابيب اللذين توفرهما vLLM DLC وبين طابور Kueue للتشغيل متعدد المستأجرين. يمكنه اختيار تصدير بدقة مختلفة لكل عميل، مسندا نماذج 4 بت المدمجة للأحمال الحساسة للتكلفة و FP8 أو 16 بت للحساسة للجودة. وإذا استخدمت QAT من Unsloth لاستعادة الدقة حتى عند 4 بت، تتسع النقطة التي تربح فيها تكلفة خدمة منخفضة وجودة معا. هذا المطابقة الدقيقة بين الصيغة وبيئة التشغيل هي بالضبط خلفية منافسة ai-platform على تكلفة وحدة خدمة منخفضة.</p>

<p>وهذه الخدمة منخفضة التكلفة تغذّي بدورها اقتصاديات الوكلاء. Paxis، مستوى التحكم Agent-Native Cloud لدى ThakiCloud، يشغّل المهارات في صناديق رمل معزولة ويستدعي نماذج كبيرة مفتوحة الأوزان مرارا، فإذا كمّمت نموذج مجال مضبوطا بواسطة Unsloth ووضعته على ai-platform، أمكن لوكلاء Paxis استهلاكه بثمن زهيد. توحيد النشر المبني على الصيغة هو بحد ذاته البنية التي تخفض تكلفة وحدة أحمال عمل الوكلاء.</p>

<h2 id="القيود-والاعتراضات">القيود والاعتراضات</h2>

<p>كخريطة نشر، هذا الدليل واضح، لكن ثمة تحفظات. أولا، تتفاوت الجودة والإنتاجية الفعليتان كثيرا بحسب تركيبة طريقة التكميم وبيئة التشغيل. كم تحتفظ نماذج 4 بت المدمجة بالدقة على vLLM، أو هل يعطي التوازي التنسوري توسعا خطيا فعلا على نموذج بعينه، يجب قياسه مباشرة على النموذج والعتاد المستهدفين؛ فعموميات الدليل وحدها لا تخبرك.</p>

<p>ثانيا، تأتي ملاءمة الخدمات المُدارة بثمن هو التكلفة والارتباط. حاويات SageMaker LMI تخفّض العبء التشغيلي، لكن في البيئات ذات المتطلبات المحلية القوية، قد يكون تشغيل بيئة التشغيل نفسها بنفسك على EKS أو Kubernetes الخاص بك أفضل للتحكم والتكلفة. كون دليل AWS خريطة جيدة أمر منفصل عن الحكم بنقل تلك الخريطة إلى بنيتك التحتية، وهو قرار كل فريق بنفسه.</p>

<p>ثالثا، كما أُشير أعلاه، هذا المقال تحليل بنيوي دون إعادة إنتاج محلية. قبل التبني الفعلي، يجب تصدير النموذج المستهدف بواسطة Unsloth وخدمته على vLLM وتأكيد زمن الاستجابة والإنتاجية والدقة لكل صيغة عبر قياساتك الخاصة.</p>

<h2 id="المصادر">المصادر</h2>

<ul>
  <li>AWS Machine Learning Blog, “Deploying quantized models on Amazon SageMaker AI with Unsloth”: <a href="https://aws.amazon.com/blogs/machine-learning/deploying-quantized-models-on-amazon-sagemaker-ai-with-unsloth/">https://aws.amazon.com/blogs/machine-learning/deploying-quantized-models-on-amazon-sagemaker-ai-with-unsloth/</a></li>
  <li>Unsloth Documentation: <a href="https://unsloth.ai/docs">https://unsloth.ai/docs</a></li>
  <li>AWS, “Deploy LLMs on Amazon EKS using vLLM Deep Learning Containers”</li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="unsloth" /><category term="quantization" /><category term="aws" /><category term="sagemaker" /><category term="vllm" /><category term="llmops" /><category term="self-hosting" /><category term="paxis" /><summary type="html"><![CDATA[كثير من الفرق تعرف كيف تقلّص نموذجا إلى 4 بت باستخدام Unsloth. لكن لحظة اتخاذ القرار بوضع ذلك الملف على EC2، أو تغليفه في نقطة نهاية SageMaker، أو تشغيله كحجيرة (pod) في EKS، يتعثر معظمها. يقدم دليل AWS المشترك مع Unsloth خريطة واضحة لذلك. الفكرة الأساسية: صيغة ملف النموذج تحدد بيئة التشغيل، وبيئة التشغيل تحدد خدمة AWS. يغطي هذا المقال أين يذهب GGUF، وأين تذهب safetensors المدمجة، وكيف ينسجم هذا التفكير مع بنية الخدمة لدى ThakiCloud.]]></summary></entry><entry xml:lang="ar"><title type="html">متى يمكنك الوثوق بالنموذج الرخيص: خفض تكاليف التعرف الضوئي على المستندات متعددة اللغات بواسطة سلسلة نماذج رؤية ولغة معتمدة على الثقة</title><link href="https://thakicloud.github.io/ar/research/confidence-gated-ocr-vlm-cascade/" rel="alternate" type="text/html" title="متى يمكنك الوثوق بالنموذج الرخيص: خفض تكاليف التعرف الضوئي على المستندات متعددة اللغات بواسطة سلسلة نماذج رؤية ولغة معتمدة على الثقة" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/research/confidence-gated-ocr-vlm-cascade</id><content type="html" xml:base="https://thakicloud.github.io/ar/research/confidence-gated-ocr-vlm-cascade/"><![CDATA[<p>كل مهندس ربط نموذج رؤية ولغة (VLM) بخط أنابيب لتحليل المستندات وقف على الأرجح عند المفترق نفسه مرة واحدة على الأقل. يمكن لنموذج يقل عدد معاملاته عن مليار أن يقرأ معظم المستندات بشكل كافٍ، لكن بمجرد أن تكون حالة المسح رديئة أو يكون المستند مكتوبًا بنظام كتابة غير مألوف، يُنتج ذلك النموذج الصغير نفسه إجابة خاطئة بثقة تامة. وفي الوقت نفسه، توجيه كل مستند إلى نموذج رؤية ولغة كبير ومكلف ليس خيارًا محتملاً من ناحية التكلفة. تصوغ الورقة البحثية المقدَّمة في هذا المقال هذا المفترق كسلسلة (cascade) يحكمها عتبة ثقة واحدة، وتُشير إلى أن اللحظة التي تصبح فيها إشارة الثقة نفسها أقل موثوقية تتزامن تحديدًا مع اللحظة التي تحتاج فيها السلسلة إليها أكثر ما تحتاج. يستحق هذا القراءة لأي مهندس سحابة أو ذكاء اصطناعي في كوريا يصمم تكلفة التعرف الضوئي على المستندات أو خدمة نماذج الرؤية واللغة.</p>

<h2 id="المشكلة-نجحت-السلاسل-مع-النصوص-فهل-تنجح-مع-الصور-أيضًا">المشكلة: نجحت السلاسل مع النصوص، فهل تنجح مع الصور أيضًا؟</h2>

<p>توجيه السلسلة (cascade routing)، حيث يعمل نموذج رخيص افتراضيًا وينتقل إلى نموذج مكلف فقط عندما تكون الثقة منخفضة، هو تقنية مُثبَتة بالفعل في خدمة نماذج اللغة الكبيرة النصية. يُعدّ FrugalGPT المثال الرائد، إذ أبلغ عن تخفيضات في التكلفة تصل إلى 98% مع الحفاظ على جودة مماثلة لاستخدام النموذج الأعلى أداءً فقط. والسؤال هو ما إذا كانت هذه الفكرة تنتقل مباشرة إلى التعرف الضوئي على المستندات. على عكس المطالبات النصية، تتفاوت صعوبة صور المستندات بشدة على طول ثلاثة محاور: جودة المسح، واللغة ونظام الكتابة، وتعقيد التخطيط. عتبة ثقة مضبوطة لتحقيق أمثلية التكلفة على فاتورة إنجليزية نظيفة يمكن أن تكون خاطئة تمامًا على مسح مشوَّه بلغة منخفضة الموارد، وهذا التباين هو نقطة انطلاق الورقة الأساسية.</p>

<h2 id="المساهمة-الأساسية-عتبة-ثقة-واحدة-ترسم-حدود-باريتو-بأكملها">المساهمة الأساسية: عتبة ثقة واحدة ترسم حدود باريتو بأكملها</h2>

<p>تبني الورقة سلسلة من مرحلتين تتكوّن من نموذج رؤية ولغة رخيص (نموذج يقل عن مليار معامل من فئة PaddleOCR-VL) ونموذج رؤية ولغة كبير ومكلف، مُعامَل بعتبة ثقة واحدة τ. في هذا الهيكل، حيث لا يحدث التصعيد إلى النموذج المكلف إلا عندما تنخفض درجة ثقة النموذج الرخيص عن τ، تشتق الورقة معدل التصعيد والتكلفة المتوقعة ومعدل الخطأ المتوقع جميعها كدوال لـ τ. والمثير للاهتمام أن “استخدام النموذج الرخيص دائمًا” و”استخدام النموذج المكلف دائمًا”، اللذين غالبًا ما يعدّهما الممارسون خيارين منفصلين، ليسا في الواقع سوى الطرفين τ=0 وτ=1 لهذه العائلة أحادية المعامل نفسها.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-pareto-frontier.png" alt="Pareto Frontier: Expected Cost vs. Expected Error Rate" />
<em>رسم توضيحي مفاهيمي يُظهر كيف ترسم عتبة الثقة τ حدود باريتو بين السياسة الرخيصة دائمًا والسياسة المكلفة دائمًا. هذا المنحنى مُشتَقّ من النموذج التحليلي للورقة وليس من بيانات مقاسة، وقيم المعاملات توضيحية.</em></p>

<p>ما إذا كانت هذه الحدود ترسم منحنى محدَّبًا ناعمًا (concave) يعتمد على افتراض واحد فقط: أن درجة ثقة النموذج الرخيص قادرة على ترتيب مدى الفائدة التي سيجلبها التصعيد بشكل صحيح. تُظهر الورقة أنه عندما يتحقق هذا الافتراض، تأخذ الحدود الشكل المحدَّب نفسه المُثبَت بالفعل لسلاسل نماذج اللغة الكبيرة النصية، لكنها تشير أيضًا إلى أن هذا الافتراض هو بالضبط الافتراض الأكثر عرضة للانهيار في الحالات التي تكون فيها السلسلة أكثر جاذبية. تدفع أنظمة الكتابة منخفضة الموارد النموذج إلى إنتاج إجابات خاطئة بثقة، وتُختزَل الثقة الإدراكية والثقة الاستدلالية في قيمة عددية واحدة، وتفشل الثقة على مستوى الحرف تمامًا في اكتشاف الأخطاء البنيوية الناتجة عن الجداول أو التخطيطات المنهارة، وتنحرف العتبة المضبوطة على نوع مستند واحد بمجرد نقلها إلى نوع آخر.</p>

<p>تنتظم هذه الأنماط الأربعة في أربعة أنماط فشل متمايزة، ومن بينها، الذي تصفه الورقة بالأخطر ليس “ثقة منخفضة لكن صحيحة” بل “ثقة عالية لكن خاطئة”. عندما يواجه النموذج الرخيص نظام كتابة غير مألوف وينتج نتيجة معقولة وسلسة لكنها خاطئة بثقة عالية، لا يُصعَّد ذلك المستند أبدًا. تعتقد السلسلة أنها تعاملت مع هذا المستند بشكل جيد، بينما هي في الواقع تحمل بصمت أسوأ أنواع الأخطاء.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-shift-failure.png" alt="High-Confidence-but-Wrong Rate by Document Covariate" />
<em>رسم توضيحي مفاهيمي يُظهر كيف يتفاوت معدل المخرجات ذات الثقة العالية لكن الخاطئة من النموذج الرخيص حسب متغيرات المستند المصاحبة. هذه ليست بيانات مقاسة بل قيمة مُشتَقّة من نتائج مُبلَّغ عنها في أدبيات سابقة مُستشهَد بها.</em></p>

<p>لا تتوقف الورقة عند هذا الحد. فهي تتناول أيضًا الاتجاه الذي تنزاح فيه حدود التكلفة مقابل الدقة نفسها مع انتقال مجتمع المستندات من الفواتير الإنجليزية النظيفة نحو أنظمة الكتابة منخفضة الموارد، والمسحات المتدهورة، والتخطيطات المعقدة. مع تدهور جودة المسح، يرتفع معدل خطأ النموذج الرخيص، مما يوسّع المجال الذي يمكن للسلسلة استغلاله، لكن في الوقت نفسه هناك خطر أن تتداخل المنطقة التي تتركّز فيها الأخطاء مع المنطقة التي تصبح فيها تنبؤات ثقة النموذج نفسها غير مستقرة. على محور اللغة ونظام الكتابة، تستشهد الورقة بما أبلغ عنه معيار GlotOCR من أن معظم نماذج الرؤية واللغة تعمل جيدًا فقط على أقل من عشرة أنظمة كتابة، وأن حتى أفضل نموذج ينهار بعد تجاوز ثلاثين نظام كتابة، وأن الهلوسة تزداد أيضًا مع اللغات منخفضة الموارد. على محور تعقيد التخطيط، تستشهد بأبحاث سابقة تُظهر أنه حتى مع دقة عالية على مستوى الحرف، يمكن أن يكون المستند بأكمله خاطئًا بسبب عناصر بنيوية مثل الجداول وترتيب القراءة والعلامات المائية.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-frontier-shift.png" alt="Pareto Frontier Shift Under Covariate Distribution Shift" />
<em>رسم توضيحي مفاهيمي يُظهر كيف تنزاح حدود باريتو للتكلفة مقابل الدقة مع انتقال مجتمع المستندات من الفواتير الإنجليزية النظيفة نحو أنظمة الكتابة منخفضة الموارد، والمسحات الضعيفة الجودة، والتخطيطات المعقدة. هذه نتيجة مُشتَقّة من النموذج التحليلي وليست بيانات مقاسة.</em></p>

<p>بناءً على هذا التحليل، تقدّم الورقة إرشادات تصميم واضحة. لا تستخدم عتبة عامة واحدة عبر جميع المستندات، بل عايِر العتبات بشكل منفصل، ولو بشكل تقريبي على الأقل، حسب نظام الكتابة وجودة المسح. صمّم بوابة الثقة كنظام متعدد الإشارات ينظر إلى الثقة البصرية والإشارات البنيوية معًا بدلاً من احتمالية فك ترميز واحدة. وفي المناطق التي يتذبذب فيها كل من النموذج الرخيص والمكلف معًا، مثل أكثر أنظمة الكتابة منخفضة الموارد، فإن الخيار الصادق هو تجاوز السلسلة كليًا وإما تصعيد كل شيء أو توجيهه إلى مراجعة بشرية.</p>

<h2 id="المساهمة-في-الشركة-والمجتمع-والعلم">المساهمة في الشركة والمجتمع والعلم</h2>

<p>تستخدم أحمال عمل تحليل المستندات في منصة ThakiCloud للذكاء الاصطناعي بالفعل نماذج من فئة PaddleOCR-VL كمسار افتراضي. يوفّر نموذج عتبة الثقة الذي تبنيه هذه الورقة لتلك الأحمال مساحة تصميم لسياسة توجيه قائمة على مبادئ، بدلاً من الثنائية بين “الرخيص دائمًا” و”المكلف دائمًا”. اجتماعيًا، فإن المؤسسات والأفراد الذين يتعاملون بشكل أساسي مع مستندات بلغات منخفضة الموارد أو مسحات ضعيفة الجودة هم بالضبط من ينبغي أن يتمكّنوا من الوصول إلى أتمتة دقيقة للمستندات دون تكلفة استدعاء نموذج رؤية ولغة كبير باستمرار، وهذه الورقة تُحدّد كميًا التناقض القائل بأن هذه الفئة بالتحديد هي حيث تكون إشارة ثقة السلسلة الأكثر عرضة للانهيار. بعبارة أخرى، تُظهر بوضوح النقطة التي تصبح فيها تقنية لخفض التكلفة أقل موثوقية بالنسبة لفئة المستخدمين الأكثر احتياجًا إليها. علميًا، توسّع الورقة أدبيات تحسين تكلفة السلاسل والتوجيه من طراز FrugalGPT، المُثبَتة بالفعل في مجال نماذج اللغة الكبيرة النصية، لتشمل مجال نماذج الرؤية واللغة متعددة الوسائط والتعرف الضوئي على المستندات، وتُقدّم الأدبيات الحالية خطوة إلى الأمام من خلال ترك تصنيف منظّم لأنماط الفشل يوضّح بالتحديد تحت أي ظروف (نظام الكتابة، جودة المسح، التخطيط) ينهار معايرة الثقة.</p>

<h2 id="القيود">القيود</h2>

<p>كما تذكر الورقة نفسها، فإن هذا بحث تحليلي يتبنّى موقفًا معينًا، وليس بحثًا تجريبيًا. كان المؤلفون يخططون لتنفيذ السلسلة فعليًا وقياسها، لكن ذلك التنفيذ فشل في مرحلة تجهيز البنية التحتية، ونتيجة لذلك لا يظهر في الورقة أي رقم دقة أو زمن استجابة أو تكلفة أو معيار قياسي قاسه المؤلفون بأنفسهم. كل ادعاء كمّي في الورقة هو أحد أمرين: خاصية مُشتَقّة رياضيًا من النموذج التحليلي، أو نتيجة منقولة مباشرة من أبحاث سابقة مُستشهَد بها. يُدرج المؤلفون أنفسهم بالتفصيل ما يجب أن تقيسه الأبحاث اللاحقة بالضرورة. يجب رسم منحنى معايرة بين ثقة النموذج الرخيص والصحة الفعلية، عبر مجموعات مستندات مقسَّمة حسب جودة المسح واللغة والتخطيط؛ ويجب التحقق مما إذا كانت نقاط التكلفة والخطأ الفعلية التي يتم الوصول إليها عند عتبات مختلفة تتبع الحدود المحدَّبة التي تتنبأ بها الورقة أم تنهار بدلاً من ذلك؛ كما يجب تحديد مقدار الانحراف الذي تُظهره عتبة مضبوطة على مجتمع مستندات واحد عند نقلها إلى مجتمع آخر. كذلك، تتناول الورقة فقط سلسلة من مرحلتين تستخدم عتبة عددية واحدة، ولا تتناول شكل الحدود بالنسبة للسلاسل متعددة المراحل، أو الموجّهات المتعلَّمة، أو التصاميم القائمة على التجميع (clustering).</p>

<p>يمكن الاطلاع على صفحة تفاصيل الورقة عبر الرابط التالي: <a href="https://huggingface.co/datasets/thaki-AI/daily-paper-2026-07-14-confidence-gated-ocr-vlm-cascade">https://huggingface.co/datasets/thaki-AI/daily-paper-2026-07-14-confidence-gated-ocr-vlm-cascade</a></p>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="research" /><category term="model-cascade" /><category term="vision-language-model" /><category term="document-ocr" /><category term="confidence-calibration" /><category term="inference-cost-optimization" /><category term="pareto-frontier" /><category term="multilingual-ocr" /><category term="LLM-routing" /><summary type="html"><![CDATA[حتى في عصر تقرأ فيه نماذج الرؤية واللغة الخفيفة جدًا، التي تقل معاملاتها عن مليار، المستندات جيدًا، لا تزال المستندات الصعبة حقًا بحاجة إلى نموذج كبير. نقدّم ورقة بحثية تحليلية تصوغ رياضيًا سلسلة تتنقّل بين نموذجين عبر عتبة ثقة واحدة، وتُثبت أن اللحظة التي يَخون فيها مؤشر الثقة أكثر ما يكون هي بالضبط اللحظة التي تحتاج فيها السلسلة إليه أكثر ما تحتاج.]]></summary></entry><entry xml:lang="en"><title type="html">We Deleted 423GB from GLM-5.2 Without Quantization: Measuring the Waste in BF16 Exponents</title><link href="https://thakicloud.github.io/en/llmops/lossless-bf16-compression/" rel="alternate" type="text/html" title="We Deleted 423GB from GLM-5.2 Without Quantization: Measuring the Waste in BF16 Exponents" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/en/llmops/lossless-bf16-compression</id><content type="html" xml:base="https://thakicloud.github.io/en/llmops/lossless-bf16-compression/"><![CDATA[<p><img src="/assets/images/lossless-bf16-compression-hero.png" alt="Abstract illustration of densely packed glass cubes being losslessly compacted into a smaller cluster" /></p>

<h2 id="overview">Overview</h2>

<p>Any team that has served a large open-weight model locally knows the first wall is always size. A model like GLM-5.2, with more than 700 billion parameters, approaches 1.4 terabytes in raw BF16, and fitting it across several GPUs makes VRAM the direct cost. The answer to this problem has almost always been quantization: dropping 16 bits to 8, to 4, even to 2, trading a bit of quality along the way.</p>

<p>This post is written for engineering leaders who own inference cost, practitioners deploying models on premises, and data scientists in regulated environments who cannot lose a single bit of precision. Recently a researcher named brianbell-x published that they had deleted 423GB from GLM-5.2. 1403GB became 980GB, and the striking part was that the method was not quantization. It was not pruning or distillation either, but lossless compression that reconstructs the original bit for bit when decompressed. If something is lossless yet shrinks by 30 percent, it means the original format was wasting exactly that much.</p>

<p>Rather than take the claim on faith, we decided to verify it directly. We opened 490 million actual trained weights of Qwen2.5-0.5B and measured the entropy of the BF16 exponent field, confirming that the 8 allocated bits carry only 2.64 bits of real information. The theoretical lossless bound came out to 33.5 percent, which lined up almost exactly with the 30.17 percent the original author achieved with a real codec. This post covers that measurement and explains why the saving happens not only on disk but in VRAM.</p>

<h2 id="what-the-technique-is">What the technique is</h2>

<p>First we need to see how BF16 stores a single number. BF16 (brain floating point 16) divides 16 bits into three parts: 1 sign bit, 8 exponent bits, and 7 mantissa bits. The exponent gets a full 8 bits because BF16 is designed to keep the same wide dynamic range as FP32, so it can represent very large or very small values.</p>

<p>The problem is that the weights of a trained model barely use that wide range. In a well-trained neural network, most weights cluster around small values near zero. As a result the exponent field bunches around a handful of values, and out of the 256 possibilities that 8 bits can express, only a small fraction actually appear. That is where the waste lives: 8 bits are allocated, but the actual information carried is far less.</p>

<p>The idea of lossless compression is simple. Entropy-code the low-information exponent field into a short representation, and leave the near-incompressible 8 bits of sign and mantissa alone. The original author’s implementation combines sign and exponent into a 4-bit code that points into a lookup table of the 15 most common exponent combinations. Rare values not in the table are stored separately in full form. The process is summarized below.</p>

<pre><code class="language-mermaid">flowchart TB
    A["Trained BF16 weight&lt;br/&gt;16 bit = sign 1 + exponent 8 + mantissa 7"] --&gt; B["Analyze exponent field&lt;br/&gt;only a few of 256 values appear"]
    B --&gt; C["Measure exponent entropy&lt;br/&gt;8 bit allocation -&gt; ~2.64 bit"]
    C --&gt; D["Replace sign+exponent with a 4-bit code&lt;br/&gt;15 most common combos -&gt; lookup table"]
    D --&gt; E["Keep the 7-bit mantissa intact&lt;br/&gt;bit-for-bit lossless"]
    E --&gt; F["Store rare exponents in full form&lt;br/&gt;keep fixed-width addressing"]
    F --&gt; G["Compressed weight&lt;br/&gt;~10.6 bit per weight (~33% saved)"]
</code></pre>

<p>This approach is fundamentally different from quantization. Quantization truncates the mantissa or rounds values, actually discarding precision. Lossless compression discards nothing. It simply rewrites the same information in a shorter code, so decompression restores the original weights without a single bit of error. Recent work like DFloat11 and ZipNN belongs to the same family. ZipNN reported that the BF16 exponent field of trained LLM weights holds only about 2.6 bits of Shannon entropy within its 8-bit allocation. What we wanted to know was whether that number reproduces on a real model.</p>

<h2 id="measuring-exponent-entropy-ourselves">Measuring exponent entropy ourselves</h2>

<p>To verify, we opened one real trained BF16 model in an isolated workspace. The target was Qwen2.5-0.5B, a real deployed model with 490 million weights. We parsed the binary layout of the safetensors file directly, read each BF16 tensor as 16-bit integers, extracted the 8 bits of the exponent, and computed the value distribution and Shannon entropy. We used no framework estimate, only the numbers from the actual tensor bytes.</p>

<p>The core measurement code, the part that views a BF16 value as a 16-bit integer and slices out the exponent field, is below.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="n">numpy</span> <span class="k">as</span> <span class="n">np</span>

<span class="k">def</span> <span class="nf">bf16_exponent_bytes</span><span class="p">(</span><span class="n">raw</span><span class="p">:</span> <span class="n">np</span><span class="p">.</span><span class="n">ndarray</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">np</span><span class="p">.</span><span class="n">ndarray</span><span class="p">:</span>
    <span class="c1"># raw = BF16 values viewed as uint16. Exponent = bits 14..7 (8 bits)
</span>    <span class="nf">return </span><span class="p">((</span><span class="n">raw</span> <span class="o">&gt;&gt;</span> <span class="mi">7</span><span class="p">)</span> <span class="o">&amp;</span> <span class="mh">0xFF</span><span class="p">).</span><span class="nf">astype</span><span class="p">(</span><span class="n">np</span><span class="p">.</span><span class="n">uint8</span><span class="p">)</span>

<span class="c1"># Parse the safetensors header, read BF16 tensors as uint16, and compute the
# Shannon entropy from the frequency of exponent values.
</span></code></pre></div></div>

<p>The result was more dramatic than expected. Here is what a sweep across 290 BF16 tensors totaling 494 million weights showed.</p>

<table>
  <thead>
    <tr>
      <th>Item</th>
      <th>Measured</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>BF16 tensors</td>
      <td>290</td>
    </tr>
    <tr>
      <td>Total weights</td>
      <td>494,032,768</td>
    </tr>
    <tr>
      <td>Distinct exponent values that appear</td>
      <td>38 out of 256</td>
    </tr>
    <tr>
      <td>Exponent field Shannon entropy</td>
      <td><strong>2.6386 bits</strong> (of 8 allocated)</td>
    </tr>
    <tr>
      <td>Share of top 3 most common exponents</td>
      <td>about 72 percent of all weights</td>
    </tr>
    <tr>
      <td>Bits per weight after compression</td>
      <td>16 bit -&gt; 10.64 bit</td>
    </tr>
    <tr>
      <td>Theoretical lossless saving</td>
      <td><strong>33.5 percent</strong></td>
    </tr>
  </tbody>
</table>

<p>The exponent field can express 256 values, but only 38 actually appeared, and the top 3 of those covered 72 percent of all weights. The Shannon entropy was 2.6386 bits, matching ZipNN’s reported ~2.6 bits almost exactly. In other words, the 8-bit exponent field was carrying only 2.64 bits of information, and the remaining 5.36 bits were pure waste.</p>

<p>Removing that waste losslessly drops bits per weight from 16 to 10.64, keeping the 8 bits of sign and mantissa intact while compressing the exponent to its entropy bound. As a saving, that is 33.5 percent.</p>

<p><img src="/assets/images/lossless-bf16-compression-results.png" alt="Chart of the Qwen2.5-0.5B measurement showing the BF16 exponent field uses only 2.64 bits in practice, and losslessly compressing it shrinks GLM-5.2 from 1403GB to about 980GB" /></p>

<p>Projecting this 33.5 percent onto GLM-5.2 (753B) scale, 1403GB becomes about 933GB. The value the original author achieved with a real codec was 980GB, a 30.17 percent saving. The roughly 3 percentage point gap between our theoretical bound (33.5 percent) and the actual implementation (30.17 percent) is no accident. Real entropy coders do not fully reach the Shannon bound, rare exponent values must be stored in full form, and codes must be fixed-width to allow random access on the GPU, all of which add slight overhead. That theory and implementation landed this close is strong evidence that the original claim is true and the approach is sound.</p>

<h2 id="why-vram-shrinks-too-on-the-gpu">Why VRAM shrinks too, on the GPU</h2>

<p>Here is the most easily misunderstood point. Most compression only shrinks on disk and returns to full size the moment the model is loaded onto the GPU, because it has to be decompressed to compute. Yet this lossless compression’s 30 percent is a VRAM number, not a disk number. That is what makes this technique different from ordinary file compression.</p>

<p>The trick is in the fixed-width codes. Because every weight’s compressed code is the same width, you can compute exactly where weight N lives without decompressing. No separate unpacking pass and no second copy in the original format are needed. The GPU kernel reads the compressed bytes directly and looks each code up in a tiny table held in registers while performing the multiply. The full 16-bit form never exists in VRAM. That is why the 30 percent shows up in actual memory footprint, not just on disk.</p>

<p>The practical implication is large. Serving a 1403GB model requires at least 18 of the 80GB H100 cards. With lossless compression bringing it to 980GB, that drops to around 13. You save five GPUs without losing a single bit of quality. If quantization was a trade of quality for memory, this technique is closer to a free lunch. Of course it is not entirely free, and we cover the cost below.</p>

<h2 id="implications-for-thakicloud-products">Implications for ThakiCloud products</h2>

<p>This technique is especially attractive from the perspective of ThakiCloud’s ai-platform. The ai-platform is infrastructure that serves models to diverse customer environments on top of Kubernetes and Kueue-based GPU scheduling. Many domestic customers require on-premises and sovereign cloud, and in those environments every single GPU is capital expenditure and procurement lead time. Lossless compression reduces the required GPU count without sacrificing any precision, making it an easier card to pitch than quantization to quality-sensitive regulated customers. In finance or healthcare, where reproducibility of model output becomes subject to audit, bit-for-bit identity can itself be a requirement.</p>

<p>The effect is largest in multi-tenant setups serving large models with vLLM or SGLang. Reclaiming 30 percent of VRAM lets you fit a larger context window on the same hardware, run more concurrent requests, or load a bigger model on one node. The accumulation of exactly this kind of resource efficiency is where ai-platform competes on low serving cost. Lossless compression is an axis orthogonal to quantization, paged attention, and tensor parallelism, so it adds directly on top of existing optimizations.</p>

<p>Low-cost serving in turn feeds agent economics. Paxis, ThakiCloud’s Agent-Native Cloud control plane, runs hundreds of skills in isolated sandboxes and passes every action through policy gates and audit logs, and these agent workloads call large open-weight models repeatedly. The lower the serving unit cost, the more aggressively agents can run, so ai-platform’s resource efficiency underpins Paxis’s operating economics.</p>

<h2 id="limitations-and-counterarguments">Limitations and counterarguments</h2>

<p>This technique is not a cure-all. First, the premise that exponent entropy is low only holds for well-trained models. Weights must cluster near zero for the exponent to bunch, so undertrained models, models with wide distributions, or models already heavily quantized will see a smaller saving. Our measurement also comes from a single model, so the actual numbers will vary with architecture and training method.</p>

<p>Second, decoding compressed codes in real time requires the GPU kernel to handle lookup and multiply together. If that kernel is not well optimized, you can end up saving memory but increasing latency. It may even run faster in workloads bottlenecked on memory bandwidth, but this depends heavily on hardware and kernel implementation, so you must benchmark on the target GPU before deploying.</p>

<p>Third, being lossless, this approach cannot reach the savings of aggressive compression like 4-bit quantization. A 30 percent saving is excellent, but it serves a different purpose than quantization, which gives up a little quality to shrink by 4x. The two are complementary rather than competing, and a realistic answer combines them: lossless compression where precision is absolutely critical, quantization where there is quality headroom.</p>

<p>Finally, this result is based on one researcher’s public experiment and our small-scale reproduction. Applying it in production requires independently verifying bit identity of compression and reconstruction, kernel performance, and actual VRAM saving on the target model and serving stack.</p>

<h2 id="sources">Sources</h2>

<ul>
  <li>brianbell-x, “Lossless Model Compression Experiment”: <a href="https://brianbell-x.github.io/weight-compression/">https://brianbell-x.github.io/weight-compression/</a></li>
  <li>Measured model: Qwen/Qwen2.5-0.5B (Hugging Face)</li>
  <li>Related work: ZipNN, DFloat11 (BF16 exponent entropy coding family)</li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="lossless-compression" /><category term="bf16" /><category term="quantization" /><category term="vram" /><category term="llmops" /><category term="self-hosting" /><category term="vllm" /><category term="paxis" /><summary type="html"><![CDATA[Someone claimed they shrank GLM-5.2 from 1403GB to 980GB. Not quantization, not pruning, but lossless compression that is bit-for-bit identical to the original. It was hard to believe, so we opened up 490 million weights of Qwen2.5-0.5B and measured the entropy of the BF16 exponent field ourselves. The 8 allocated bits were actually carrying only 2.64 bits of information, which means roughly 33.5 percent can be removed losslessly. This post walks through where that waste comes from, and why the savings show up not only on disk but in VRAM, using measured data.]]></summary></entry><entry xml:lang="en"><title type="html">Where Do You Put a Quantized Model? Four AWS and Unsloth Deployment Patterns</title><link href="https://thakicloud.github.io/en/llmops/unsloth-aws-quantization-deploy/" rel="alternate" type="text/html" title="Where Do You Put a Quantized Model? Four AWS and Unsloth Deployment Patterns" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/en/llmops/unsloth-aws-quantization-deploy</id><content type="html" xml:base="https://thakicloud.github.io/en/llmops/unsloth-aws-quantization-deploy/"><![CDATA[<p><img src="/assets/images/unsloth-aws-quantization-deploy-hero.png" alt="Abstract illustration of a large model distilled into compact layers flowing into cloud serving infrastructure" /></p>

<h2 id="overview">Overview</h2>

<p>There are already plenty of posts on how to quantize a model. GPTQ, AWQ, GGUF, Unsloth Dynamic; a recipe to shrink a 16-bit model to 4-bit is a few searches away. Yet the point where teams actually stall is what comes next. Where exactly do you put that 4-bit file, and how? Do you launch it directly on an EC2 instance, wrap it in a SageMaker endpoint, or drop it into a pod on the EKS cluster you already run? There is no single answer, but there is a map that branches on the format of the model file.</p>

<p>This post is written for platform engineers deploying open-weight models on their own infrastructure and for practitioners designing inference cost. AWS recently published a guide with Unsloth, “Deploying quantized models on Amazon SageMaker AI with Unsloth,” that organizes this deployment decision into four patterns. We dissect the core logic of that guide, explain why the model file format decides the runtime and the runtime in turn decides the AWS service, and connect this way of thinking to how infrastructure like ThakiCloud, which does multi-tenant serving on Kubernetes, is designed.</p>

<p>One thing to state up front: the command examples here are paths verified in the AWS official guide and Unsloth docs, and we have not invented any benchmark numbers. Our verification environment is Apple Silicon, so we could not actually run and reproduce the CUDA-dependent Unsloth quantization and vLLM serving locally. This post is therefore not an experiment report but a structural analysis of a verified guide.</p>

<h2 id="why-quantization-matters-again-at-deployment">Why quantization matters again at deployment</h2>

<p>Quantization is usually discussed only as a matter of training or inference speed. But the AWS guide points out that at the deployment stage, quantization changes three things at once. First, the instance decision. As a large model becomes practical to run on a smaller GPU or even a CPU, the required instance tier itself drops. Second, the startup and storage profile. Smaller model files move and store faster, which helps cold starts and scale-out. Third, deployment flexibility. You can pick a smaller model for cost-sensitive inference and a higher-precision export for quality-sensitive inference.</p>

<p>Unsloth’s strength is that it ties fine-tuning, running, exporting, and deploying into a single workflow. In particular, Unsloth Dynamic v2.0 quantization lets you run and fine-tune quantized LLMs while preserving accuracy as much as possible, and quantization-aware training (QAT), built in collaboration with PyTorch, is reported to recover much of the accuracy lost to naive 4-bit quantization. In other words, you can choose precisely where on the quality-versus-size trade-off to sit before deployment.</p>

<h2 id="format-decides-the-runtime-runtime-decides-aws">Format decides the runtime, runtime decides AWS</h2>

<p>The core insight of the guide is: do not start the deployment decision from “which service should I use.” Instead, start from “which file format should I export to,” and the rest follows naturally. There are two branches.</p>

<p>One is GGUF. GGUF is a single-file format that bundles weights, tokenizer, and metadata together, and lightweight runtimes such as llama.cpp, Ollama, and Unsloth use it. On AWS this branch maps to Amazon EC2 or a SageMaker AI custom container. It is the path for when you want to validate lightly and keep direct control.</p>

<p>The other is merged safetensors. Merging and exporting 16-bit, 8-bit, FP8, or 4-bit weights with Unsloth lets you run on high-throughput engines like vLLM and SGLang, which maps to SageMaker AI Large Model Inference (LMI) containers, EKS, or ECS. It is the path for production serving where throughput and scale matter. The branch is summarized below.</p>

<pre><code class="language-mermaid">flowchart TB
    A["Fine-tune or download with Unsloth"] --&gt; B{"Choose serving runtime"}
    B --&gt;|"lightweight single file"| C["Export GGUF&lt;br/&gt;weights + tokenizer + metadata"]
    B --&gt;|"high-throughput engine"| D["Export merged safetensors&lt;br/&gt;16 / 8 / FP8 / 4-bit"]
    C --&gt; E["llama.cpp · Ollama · Unsloth"]
    D --&gt; F["vLLM · SGLang"]
    E --&gt; G["Amazon EC2&lt;br/&gt;or SageMaker custom container"]
    F --&gt; H["SageMaker LMI container&lt;br/&gt;or EKS · ECS"]
    G --&gt; I["Validate the runtime on EC2"]
    H --&gt; I
    I --&gt; J["Promote the same file+runtime combo&lt;br/&gt;to managed deployment"]
</code></pre>

<h2 id="setup-and-integration">Setup and integration</h2>

<p>The workflow the guide lays out has four steps. Fine-tune or download a model in Unsloth, export it in the format that matches your target runtime, validate the runtime on EC2 or locally, then promote the same file and runtime combination straight into a managed deployment. The phrase “same file and runtime combination” matters here, because if the format or engine differs between validation and production, unexpected behavior creeps in.</p>

<p>Exporting from Unsloth branches by target runtime. The GGUF path looks like this.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Export GGUF (llama.cpp / Ollama / EC2 path)
</span><span class="n">model</span><span class="p">.</span><span class="nf">save_pretrained_gguf</span><span class="p">(</span>
    <span class="sh">"</span><span class="s">qwen-merged-gguf</span><span class="sh">"</span><span class="p">,</span>
    <span class="n">tokenizer</span><span class="p">,</span>
    <span class="n">quantization_method</span><span class="o">=</span><span class="sh">"</span><span class="s">q4_k_m</span><span class="sh">"</span><span class="p">,</span>
<span class="p">)</span>
</code></pre></div></div>

<p>The merged safetensors path targets vLLM or SGLang.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Export merged safetensors (vLLM / SGLang / SageMaker LMI path)
</span><span class="n">model</span><span class="p">.</span><span class="nf">save_pretrained_merged</span><span class="p">(</span>
    <span class="sh">"</span><span class="s">qwen-merged-16bit</span><span class="sh">"</span><span class="p">,</span>
    <span class="n">tokenizer</span><span class="p">,</span>
    <span class="n">save_method</span><span class="o">=</span><span class="sh">"</span><span class="s">merged_16bit</span><span class="sh">"</span><span class="p">,</span>  <span class="c1"># or merged_4bit, etc.
</span><span class="p">)</span>
</code></pre></div></div>

<p>The exported merged model can be validated for serving directly with vLLM.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Validate serving on EC2 or locally</span>
vllm serve ./qwen-merged-16bit <span class="nt">--port</span> 8000
</code></pre></div></div>

<p>For container-based deployment, AWS Deep Learning Containers (DLCs) provide optimized Docker environments across EC2, EKS, and ECS. The vLLM DLC in particular is tuned for high-performance inference and natively supports tensor parallelism and pipeline parallelism across multiple GPUs and nodes. That is, a configuration validated on a single EC2 instance flows smoothly into an EKS pod using the same runtime for horizontal scaling.</p>

<h2 id="implications-for-thakicloud-products">Implications for ThakiCloud products</h2>

<p>This deployment map overlaps directly with the design philosophy of ThakiCloud’s ai-platform. The ai-platform serves models on top of Kubernetes and Kueue-based GPU scheduling, and the principle the AWS guide states, that format decides runtime and runtime decides infrastructure, is not tied to any specific cloud. The split of GGUF for lightweight validation and edge deployment versus merged safetensors for vLLM-based high-throughput serving applies identically whether it is AWS EKS or on-premises Kubernetes. If anything, for ThakiCloud, which has many customers requiring on-premises and sovereign cloud, standardizing the deployment path by file format and runtime rather than binding to a specific managed service is more advantageous for portability.</p>

<p>In practice, the ai-platform can combine the tensor parallelism and pipeline parallelism the vLLM DLC provides with Kueue queuing to run multi-tenant. It can pick a different-precision export per customer, assigning 4-bit merged models to cost-sensitive workloads and FP8 or 16-bit to quality-sensitive ones. If you use Unsloth’s QAT to recover accuracy even at 4-bit, the point at which you win both low serving cost and quality widens. This fine-grained matching of format and runtime is exactly the background to ai-platform competing on low serving unit cost.</p>

<p>This low-cost serving in turn feeds agent economics. Paxis, ThakiCloud’s Agent-Native Cloud control plane, runs skills in isolated sandboxes and calls large open-weight models repeatedly, so if you quantize a fine-tuned domain model with Unsloth and put it on the ai-platform, Paxis agents can consume it cheaply. Format-based deployment standardization is itself the structure that lowers the unit cost of agent workloads.</p>

<h2 id="limitations-and-counterarguments">Limitations and counterarguments</h2>

<p>As a deployment map this guide is clear, but there are caveats. First, actual quality and throughput vary greatly with the combination of quantization method and runtime. How much accuracy a 4-bit merged model retains on vLLM, or whether tensor parallelism actually gives linear scaling on a specific model, must be measured directly on the target model and hardware; the guide’s generalities alone cannot tell you.</p>

<p>Second, the convenience of managed services comes at the cost of expense and lock-in. SageMaker LMI containers reduce operational burden, but in environments with strong on-premises requirements, running the same runtime yourself on EKS or your own Kubernetes may be better for control and cost. The AWS guide being a good map is separate from the judgment of porting that map to your own infrastructure, which is each team’s own call.</p>

<p>Third, as noted above, this post is a structural analysis without local reproduction. Before actual adoption you must export the target model with Unsloth, serve it on vLLM, and confirm per-format latency, throughput, and accuracy with your own benchmarks.</p>

<h2 id="sources">Sources</h2>

<ul>
  <li>AWS Machine Learning Blog, “Deploying quantized models on Amazon SageMaker AI with Unsloth”: <a href="https://aws.amazon.com/blogs/machine-learning/deploying-quantized-models-on-amazon-sagemaker-ai-with-unsloth/">https://aws.amazon.com/blogs/machine-learning/deploying-quantized-models-on-amazon-sagemaker-ai-with-unsloth/</a></li>
  <li>Unsloth Documentation: <a href="https://unsloth.ai/docs">https://unsloth.ai/docs</a></li>
  <li>AWS, “Deploy LLMs on Amazon EKS using vLLM Deep Learning Containers”</li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="unsloth" /><category term="quantization" /><category term="aws" /><category term="sagemaker" /><category term="vllm" /><category term="llmops" /><category term="self-hosting" /><category term="paxis" /><summary type="html"><![CDATA[Plenty of teams know how to shrink a model to 4-bit with Unsloth. But the moment they have to decide whether to put that file on EC2, wrap it in a SageMaker endpoint, or launch it as an EKS pod, most get stuck. The AWS guide co-authored with Unsloth gives a clear map for this. The key idea: the model file format decides the runtime, and the runtime decides the AWS service. This post covers where GGUF goes, where merged safetensors goes, and how this thinking maps onto ThakiCloud's serving infrastructure.]]></summary></entry><entry xml:lang="en"><title type="html">When Can You Trust the Cheap Model: Cutting Multilingual Document OCR Costs with a Confidence-Gated VLM Cascade</title><link href="https://thakicloud.github.io/en/research/confidence-gated-ocr-vlm-cascade/" rel="alternate" type="text/html" title="When Can You Trust the Cheap Model: Cutting Multilingual Document OCR Costs with a Confidence-Gated VLM Cascade" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/en/research/confidence-gated-ocr-vlm-cascade</id><content type="html" xml:base="https://thakicloud.github.io/en/research/confidence-gated-ocr-vlm-cascade/"><![CDATA[<p>Any engineer who has hooked a VLM into a document parsing pipeline has probably faced the same fork in the road at some point. A model with well under a billion parameters can read most documents just fine, yet the moment a scan is degraded or written in an unfamiliar script, that same small model confidently produces the wrong answer. Routing every document to an expensive, large VLM instead isn’t affordable either. The paper introduced in this post formalizes that fork in the road as a cascade governed by a single confidence threshold, and points out that the very moment the confidence signal itself becomes least trustworthy happens to coincide with the moment the cascade needs it most. It’s worth a read for any cloud or AI engineer in Korea designing document OCR or VLM serving costs.</p>

<h2 id="the-problem-cascades-worked-for-text-but-do-they-work-for-images-too">The Problem: Cascades Worked for Text, But Do They Work for Images Too?</h2>

<p>Cascade routing, where a cheap model runs by default and only escalates to an expensive model when confidence is low, is already a proven technique in text LLM serving. FrugalGPT is the flagship example, reporting cost reductions of up to 98% while maintaining quality comparable to using only the top-performing model. The question is whether this idea transfers directly to document OCR. Unlike text prompts, document images vary wildly in difficulty along three axes: scan quality, language and script, and layout complexity. A confidence threshold tuned for cost-optimality on a clean English invoice can be completely off the mark on a distorted low-resource-language scan, and that mismatch is the paper’s core starting point.</p>

<h2 id="core-contribution-a-single-confidence-threshold-traces-the-entire-pareto-frontier">Core Contribution: A Single Confidence Threshold Traces the Entire Pareto Frontier</h2>

<p>The paper builds a two-stage cascade consisting of a cheap VLM (a sub-billion-parameter model on the order of PaddleOCR-VL) and an expensive large VLM, parameterized by a single confidence threshold τ. In this structure, where escalation to the expensive model happens only when the cheap model’s confidence score falls below τ, the paper derives the escalation rate, expected cost, and expected error rate all as functions of τ. What’s interesting is that “always use the cheap model” and “always use the expensive model,” which practitioners often treat as separate options, turn out to be nothing more than the two endpoints, τ=0 and τ=1, of this single parameter family.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-pareto-frontier.png" alt="Pareto Frontier: Expected Cost vs. Expected Error Rate" />
<em>A conceptual diagram of how the confidence threshold τ traces the Pareto frontier between the always-cheap and always-expensive policies. This curve is derived from the paper’s analytical model rather than measured data, and the parameter values are illustrative.</em></p>

<p>Whether this frontier forms a smooth, concave curve hinges on a single assumption: that the cheap model’s confidence score can correctly rank how much benefit escalation would bring. The paper shows that when this assumption holds, the frontier takes the same concave shape already proven for text LLM cascades, but it also points out that this assumption is precisely the one most likely to break down in the situations where a cascade is most attractive. Low-resource scripts push the model to confidently produce wrong answers, perceptual confidence and inferential confidence get collapsed into a single scalar value, character-level confidence fails entirely to detect structural errors from broken tables or layout, and a threshold tuned on one document type drifts out of calibration the moment it’s moved to another type.</p>

<p>These four collapse into distinct failure modes, and among them the one the paper flags as most dangerous isn’t “low confidence but correct” but rather “high confidence but wrong.” When a cheap model encounters an unfamiliar script and produces a plausible, fluent, yet wrong result with high confidence, that document is never escalated. The cascade believes it handled the document well, while in fact it is quietly carrying the worst kind of error.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-shift-failure.png" alt="High-Confidence-but-Wrong Rate by Document Covariate" />
<em>A conceptual diagram of how the rate of high-confidence-but-wrong outputs from the cheap VLM varies by document covariate. This is not measured data but a value derived from results reported in cited prior literature.</em></p>

<p>The paper doesn’t stop there. It also addresses which direction the cost-accuracy frontier itself shifts as the document population moves from clean English invoices toward low-resource scripts, degraded scans, and complex layouts. As scan quality degrades, the cheap model’s error rate rises, which widens the room for a cascade to exploit, but at the same time there is a risk that the region where errors concentrate overlaps with the region where the model’s confidence predictions themselves become unstable. On the language and script axis, the paper cites the GlotOCR benchmark’s finding that most VLMs work well on fewer than ten scripts, even the top model collapses past thirty scripts, and hallucination increases together with low-resource languages. On the layout complexity axis, it cites prior work showing that even high character-level accuracy can still be wrong at the whole-document level because of structural elements like tables, reading order, and watermarks.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-frontier-shift.png" alt="Pareto Frontier Shift Under Covariate Distribution Shift" />
<em>A conceptual diagram of how the cost-accuracy Pareto frontier shifts as the document population moves from clean English invoices toward low-resource scripts, low-quality scans, and complex layouts. This is a result derived from the analytical model rather than measured data.</em></p>

<p>Based on this analysis, the paper’s design guidance is clear. Don’t use a single global threshold across all documents; calibrate thresholds separately, at least coarsely, by script and scan quality. Design the confidence gate as a multi-signal system that looks at visual confidence and structural signals together rather than a single decoder probability. And in regions where both the cheap and expensive models wobble together, such as the most low-resource scripts, the honest choice is to skip the cascade entirely and either escalate everything or route to human review.</p>

<h2 id="contribution-to-the-company-society-and-science">Contribution to the Company, Society, and Science</h2>

<p>ThakiCloud’s AI platform document-parsing workloads already use PaddleOCR-VL-class models as the default path. The confidence threshold model this paper builds offers that workload a principled routing policy design space, instead of the binary choice between “always cheap” and “always expensive.” Viewed socially, the institutions and individuals who mainly handle low-resource-language or low-quality-scan documents are exactly the ones who should be able to access accurate document automation without the cost of constantly calling a large VLM, and this paper quantitatively pins down the paradox that it is precisely this group where a cascade’s confidence signal is most likely to break. In other words, it explicitly surfaces the point where a cost-reduction technique becomes least trustworthy for the very users who need it most. Scientifically, it extends the FrugalGPT-style cascade and routing cost optimization literature, already validated in the text LLM domain, into the multimodal VLM and document OCR domain, and it advances the field by leaving behind an organized taxonomy of failure modes for exactly which conditions (script, scan quality, layout) break confidence calibration.</p>

<h2 id="limitations">Limitations</h2>

<p>As the paper itself states, this is an analytical, position-taking piece of research, not an empirical one. The authors had planned to actually implement and measure the cascade, but that execution failed at the infrastructure provisioning stage, and as a result not a single measured accuracy, latency, cost, or benchmark number from the authors themselves appears in the paper. Every quantitative claim in the paper is one of two things: a property mathematically derived from the analytical model, or a result carried over directly from cited prior work. The authors themselves lay out specifically what follow-up research must measure. A calibration curve needs to be drawn between the cheap model’s confidence and actual correctness, across document sets split by scan quality, language, and layout; it must be verified whether the actual cost-error points reached at various thresholds follow the concave frontier the paper predicts or collapse instead; and how much a threshold tuned on one document population drifts when moved to another population also needs to be quantified. The paper also covers only a two-stage cascade using a single scalar threshold, and does not address the frontier shape for multi-stage cascades, learned routers, or clustering-based designs.</p>

<p>The paper’s detail page can be found at the following link: <a href="https://huggingface.co/datasets/thaki-AI/daily-paper-2026-07-14-confidence-gated-ocr-vlm-cascade">https://huggingface.co/datasets/thaki-AI/daily-paper-2026-07-14-confidence-gated-ocr-vlm-cascade</a></p>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="research" /><category term="model-cascade" /><category term="vision-language-model" /><category term="document-ocr" /><category term="confidence-calibration" /><category term="inference-cost-optimization" /><category term="pareto-frontier" /><category term="multilingual-ocr" /><category term="LLM-routing" /><summary type="html"><![CDATA[Even in an era where sub-billion-parameter, ultra-lightweight VLMs read documents well, the truly hard documents still need a large model. We introduce an analytical paper that formalizes a cascade shuttling between two models via a single confidence threshold, and shows that the moment confidence is most likely to betray you is exactly the moment the cascade needs it most.]]></summary></entry><entry xml:lang="ko"><title type="html">양자화 없이 GLM-5.2에서 423GB를 지웠다: BF16 지수 필드의 낭비를 실측하다</title><link href="https://thakicloud.github.io/ko/llmops/lossless-bf16-compression/" rel="alternate" type="text/html" title="양자화 없이 GLM-5.2에서 423GB를 지웠다: BF16 지수 필드의 낭비를 실측하다" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/ko/llmops/lossless-bf16-compression</id><content type="html" xml:base="https://thakicloud.github.io/ko/llmops/lossless-bf16-compression/"><![CDATA[<p><img src="/assets/images/lossless-bf16-compression-hero.png" alt="조밀하게 쌓인 유리 큐브가 손실 없이 더 작은 덩어리로 압축되는 모습을 표현한 추상 일러스트" /></p>

<h2 id="개요">개요</h2>

<p>로컬에서 대형 오픈웨이트 모델을 서빙해 본 팀이라면 첫 번째 벽이 언제나 용량이라는 것을 압니다. GLM-5.2처럼 7천억 개가 넘는 파라미터를 가진 모델은 BF16 원본만으로 1.4테라바이트에 육박하고, 이걸 GPU 여러 장에 올리려면 VRAM이 곧 돈이 됩니다. 그동안 이 문제의 정답은 거의 항상 양자화였습니다. 16비트를 8비트로, 4비트로, 심지어 2비트로 줄이면서 약간의 품질을 내주는 거래였지요.</p>

<p>이 글은 추론 비용을 책임지는 엔지니어링 리더와 온프레미스로 모델을 서빙하려는 실무자, 그리고 정밀도를 한 비트도 잃을 수 없는 규제 환경의 데이터 과학자를 위한 것입니다. 최근 brianbell-x라는 연구자가 GLM-5.2에서 423GB를 지웠다고 공개했습니다. 1403GB가 980GB가 되었는데, 놀라운 것은 그 방식이 양자화가 아니라는 점이었습니다. 프루닝도, 증류도 아니고, 압축을 풀면 원본과 비트 단위로 완전히 동일한 무손실 압축이라고 했습니다. 무손실인데 30퍼센트가 줄어든다면, 원본 형식이 그만큼 낭비하고 있었다는 뜻입니다.</p>

<p>저희는 이 주장을 그대로 믿는 대신, 직접 검증하기로 했습니다. Qwen2.5-0.5B의 실제 학습된 가중치 4억 9천만 개를 열어 BF16 지수 필드의 엔트로피를 측정했고, 그 결과 8비트를 할당받은 지수가 실제로는 2.64비트어치의 정보만 담고 있음을 확인했습니다. 이론적 무손실 압축 한계는 33.5퍼센트였고, 이것은 원 저자가 실제 코덱으로 달성한 30.17퍼센트와 거의 맞아떨어졌습니다. 이 글은 그 측정 과정과, 왜 이 절감이 디스크뿐 아니라 VRAM에서도 일어나는지를 설명합니다.</p>

<h2 id="이-기술은-무엇인가">이 기술은 무엇인가</h2>

<p>먼저 BF16이 한 숫자를 어떻게 저장하는지 봐야 합니다. BF16(brain floating point 16)은 16비트를 세 부분으로 나눕니다. 부호 1비트, 지수 8비트, 가수 7비트입니다. 지수가 8비트나 되는 이유는 BF16이 FP32와 같은 넓은 표현 범위를 유지하도록 설계되었기 때문입니다. 즉 아주 크거나 아주 작은 값까지 표현할 수 있도록 지수에 넉넉하게 8비트를 준 것입니다.</p>

<p>문제는 학습이 끝난 모델의 가중치가 이 넓은 범위를 거의 쓰지 않는다는 데 있습니다. 잘 학습된 신경망의 가중치는 대부분 0 근처의 작은 값에 몰려 있습니다. 그 결과 지수 필드는 몇 개의 값 주위로 강하게 뭉치고, 8비트가 표현할 수 있는 256가지 가능성 중 극히 일부만 실제로 등장합니다. 여기서 낭비가 생깁니다. 8비트를 할당했지만 실제로 담기는 정보량은 그보다 훨씬 적습니다.</p>

<p>무손실 압축의 아이디어는 단순합니다. 정보량이 적은 지수 필드는 엔트로피 부호화로 짧게 표현하고, 정보량이 많아 압축이 거의 안 되는 부호와 가수 8비트는 그대로 둡니다. 원 저자의 구현은 부호와 지수를 묶어 4비트 코드로 치환하고, 이 코드가 가장 흔한 15개 지수 조합을 담은 룩업 테이블을 가리키게 했습니다. 룩업 테이블에 없는 드문 값은 전체 형식으로 따로 저장합니다. 이 과정을 도식으로 정리하면 다음과 같습니다.</p>

<pre><code class="language-mermaid">flowchart TB
    A["학습된 BF16 가중치&lt;br/&gt;16비트 = 부호 1 + 지수 8 + 가수 7"] --&gt; B["지수 필드 분석&lt;br/&gt;256개 값 중 실제로는 소수만 등장"]
    B --&gt; C["지수 엔트로피 측정&lt;br/&gt;8비트 할당 → 실제 약 2.64비트"]
    C --&gt; D["부호+지수를 4비트 코드로 치환&lt;br/&gt;가장 흔한 15개 조합 → 룩업 테이블"]
    D --&gt; E["가수 7비트는 그대로 보존&lt;br/&gt;비트 단위 무손실"]
    E --&gt; F["드문 지수는 전체 형식으로 저장&lt;br/&gt;고정폭 주소 유지"]
    F --&gt; G["압축된 가중치&lt;br/&gt;가중치당 약 10.6비트 (약 33% 절감)"]
</code></pre>

<p>이 접근은 양자화와 근본적으로 다릅니다. 양자화는 가수를 잘라내거나 값을 반올림해 정밀도를 실제로 버립니다. 반면 이 무손실 압축은 어떤 값도 버리지 않습니다. 같은 정보를 더 짧은 부호로 다시 적을 뿐이므로, 압축을 풀면 원본 가중치가 비트 하나 틀리지 않고 그대로 복원됩니다. DFloat11이나 ZipNN 같은 최근 연구가 같은 계열에 속하는데, ZipNN은 학습된 LLM 가중치의 BF16 지수 필드가 8비트 할당 안에서 약 2.6비트의 섀넌 엔트로피만 가진다고 보고했습니다. 저희가 궁금했던 것은 이 숫자가 실제 모델에서도 재현되는가였습니다.</p>

<h2 id="직접-측정해-본-지수-엔트로피">직접 측정해 본 지수 엔트로피</h2>

<p>검증을 위해 격리된 작업 환경에서 실제 학습된 BF16 모델 하나를 열었습니다. 대상은 Qwen2.5-0.5B로, 4억 9천만 개의 가중치를 가진 실제 배포 모델입니다. safetensors 파일의 바이너리 레이아웃을 직접 파싱해 각 BF16 텐서를 16비트 정수로 읽은 뒤, 지수에 해당하는 8비트를 추출해 값의 분포와 섀넌 엔트로피를 계산했습니다. 어떤 프레임워크의 추정치도 쓰지 않고, 실제 텐서 바이트에서 나온 숫자만 사용했습니다.</p>

<p>핵심 측정 코드는 다음과 같습니다. BF16 값을 16비트 정수로 본 뒤 지수 필드만 잘라내는 부분입니다.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="n">numpy</span> <span class="k">as</span> <span class="n">np</span>

<span class="k">def</span> <span class="nf">bf16_exponent_bytes</span><span class="p">(</span><span class="n">raw</span><span class="p">:</span> <span class="n">np</span><span class="p">.</span><span class="n">ndarray</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">np</span><span class="p">.</span><span class="n">ndarray</span><span class="p">:</span>
    <span class="c1"># raw = BF16 값을 uint16으로 본 것. 지수 = 비트 14..7 (8비트)
</span>    <span class="nf">return </span><span class="p">((</span><span class="n">raw</span> <span class="o">&gt;&gt;</span> <span class="mi">7</span><span class="p">)</span> <span class="o">&amp;</span> <span class="mh">0xFF</span><span class="p">).</span><span class="nf">astype</span><span class="p">(</span><span class="n">np</span><span class="p">.</span><span class="n">uint8</span><span class="p">)</span>

<span class="c1"># safetensors 헤더를 파싱해 BF16 텐서를 uint16로 읽고
# 지수 필드의 등장 빈도로 섀넌 엔트로피를 계산합니다.
</span></code></pre></div></div>

<p>측정 결과는 예상보다 훨씬 극적이었습니다. 290개의 BF16 텐서, 총 4억 9천4백만 개의 가중치를 훑은 결과입니다.</p>

<table>
  <thead>
    <tr>
      <th>항목</th>
      <th>측정값</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>BF16 텐서 수</td>
      <td>290개</td>
    </tr>
    <tr>
      <td>전체 가중치 수</td>
      <td>494,032,768개</td>
    </tr>
    <tr>
      <td>실제 등장한 지수 값</td>
      <td>256개 중 38개뿐</td>
    </tr>
    <tr>
      <td>지수 필드 섀넌 엔트로피</td>
      <td><strong>2.6386비트</strong> (8비트 할당 중)</td>
    </tr>
    <tr>
      <td>가장 흔한 지수 상위 3개의 비중</td>
      <td>전체의 약 72퍼센트</td>
    </tr>
    <tr>
      <td>원본 대비 압축 후 가중치당 비트</td>
      <td>16비트 → 10.64비트</td>
    </tr>
    <tr>
      <td>이론적 무손실 절감률</td>
      <td><strong>33.5퍼센트</strong></td>
    </tr>
  </tbody>
</table>

<p>지수 필드는 256가지 값을 표현할 수 있지만 실제로는 38가지만 등장했고, 그중 상위 3개가 전체 가중치의 72퍼센트를 덮었습니다. 섀넌 엔트로피는 2.6386비트로, ZipNN이 보고한 약 2.6비트와 거의 정확히 일치했습니다. 즉 8비트를 할당한 지수 필드가 실제로는 2.64비트어치의 정보만 담고 있었고, 나머지 5.36비트는 순수한 낭비였던 셈입니다.</p>

<p>이 낭비를 무손실로 걷어내면 가중치당 비트 수는 16비트에서 10.64비트로 줄어듭니다. 부호와 가수 8비트를 그대로 보존하고 지수를 엔트로피 한계까지 압축했을 때의 값입니다. 절감률로는 33.5퍼센트입니다.</p>

<p><img src="/assets/images/lossless-bf16-compression-results.png" alt="Qwen2.5-0.5B 실측 결과. BF16 지수 필드가 실제로는 2.64비트만 쓰며, 이를 무손실로 압축하면 GLM-5.2 기준 1403GB가 약 980GB로 줄어든다는 것을 보여주는 차트" /></p>

<p>이 33.5퍼센트를 GLM-5.2(753B) 규모로 투영하면 1403GB가 약 933GB가 됩니다. 원 저자가 실제 코덱으로 달성한 값은 980GB, 즉 30.17퍼센트 절감이었습니다. 저희의 이론적 한계(33.5퍼센트)와 실제 구현(30.17퍼센트) 사이의 3퍼센트포인트 차이는 우연이 아닙니다. 실제 엔트로피 부호화기는 섀넌 한계에 완전히 도달하지 못하고, 드문 지수 값은 전체 형식으로 저장해야 하며, GPU에서 임의 접근을 하려면 코드 폭을 고정해야 하기 때문에 약간의 오버헤드가 붙습니다. 이론과 구현이 이렇게 가깝게 맞아떨어졌다는 것은 원 저자의 주장이 사실이며 접근법이 건전하다는 강력한 증거입니다.</p>

<h2 id="gpu에서-왜-vram까지-줄어드는가">GPU에서 왜 VRAM까지 줄어드는가</h2>

<p>여기서 가장 오해하기 쉬운 지점을 짚어야 합니다. 대부분의 압축은 디스크에서만 작아지고, 모델을 GPU에 올리는 순간 원래 크기로 되돌아갑니다. 압축을 풀어야 계산할 수 있기 때문입니다. 그런데 이 무손실 압축의 30퍼센트는 디스크 숫자가 아니라 VRAM 숫자입니다. 이것이 이 기법이 단순한 파일 압축과 다른 이유입니다.</p>

<p>비결은 고정폭 코드에 있습니다. 모든 가중치의 압축 코드가 같은 너비를 가지므로, N번째 가중치가 어느 주소에 있는지를 압축을 풀지 않고도 곧바로 계산할 수 있습니다. 별도의 언패킹 과정이나 원본 형식의 두 번째 복사본이 필요 없습니다. GPU 커널은 압축된 바이트를 그대로 읽어 들이고, 레지스터에 올려 둔 작은 룩업 테이블에서 코드를 조회하면서 곱셈을 수행합니다. 완전한 16비트 형식은 VRAM 안에 결코 존재하지 않습니다. 그래서 30퍼센트라는 숫자가 디스크뿐 아니라 실제 메모리 점유에도 그대로 나타나는 것입니다.</p>

<p>실무적으로 이것이 의미하는 바는 큽니다. 1403GB 모델을 서빙하려면 80GB H100이 최소 18장은 필요합니다. 무손실 압축으로 980GB가 되면 13장 안팎으로 내려갑니다. 품질을 한 비트도 잃지 않고 GPU 다섯 장을 아끼는 셈입니다. 양자화가 품질과 메모리를 맞바꾸는 거래였다면, 이 기법은 공짜 점심에 가깝습니다. 물론 완전히 공짜는 아니고, 뒤에서 그 대가를 다루겠습니다.</p>

<h2 id="thakicloud-제품-적용-시사점">ThakiCloud 제품 적용 시사점</h2>

<p>이 기법은 ThakiCloud의 ai-platform 관점에서 특히 매력적입니다. ai-platform은 Kubernetes와 Kueue 기반 GPU 스케줄링 위에서 다양한 고객 환경에 모델을 서빙하는 인프라입니다. 온프레미스와 소버린 클라우드를 요구하는 국내 고객이 많은데, 이런 환경에서는 GPU 한 장 한 장이 곧 자본 지출이고 조달 리드타임입니다. 무손실 압축은 정밀도를 전혀 희생하지 않으면서 필요 GPU 수를 줄여 주므로, 품질에 민감한 규제 산업 고객에게 양자화보다 설득하기 쉬운 카드입니다. 금융이나 의료처럼 모델 출력의 재현성이 감사 대상이 되는 곳에서는 비트 단위 동일성이 그 자체로 요구사항이 되기도 합니다.</p>

<p>특히 vLLM이나 SGLang으로 대형 모델을 서빙하는 멀티테넌트 구성에서 효과가 큽니다. VRAM에서 30퍼센트를 되찾으면 같은 하드웨어에 더 큰 컨텍스트 윈도우를 잡거나, 더 많은 동시 요청을 태우거나, 한 노드에 더 큰 모델을 올릴 수 있습니다. ai-platform이 낮은 서빙 비용에서 경쟁력을 갖는 지점이 바로 이런 자원 효율의 누적입니다. 무손실 압축은 양자화, 페이지드 어텐션, 텐서 병렬화와 직교하는 별개의 축이므로 기존 최적화 위에 그대로 더해집니다.</p>

<p>한편 저비용 서빙은 에이전트 경제성으로 이어집니다. ThakiCloud의 Agent-Native Cloud 제어 평면인 Paxis는 격리된 샌드박스에서 수백 개의 스킬을 실행하고 모든 행동을 정책 게이트와 감사 로그로 통과시키는데, 이런 에이전트 워크로드는 대형 오픈웨이트 모델을 반복 호출합니다. 서빙 단가가 내려갈수록 에이전트를 더 공격적으로 돌릴 수 있으므로, ai-platform의 자원 효율이 곧 Paxis의 운용 경제성을 떠받치는 구조입니다.</p>

<h2 id="한계-및-반론">한계 및 반론</h2>

<p>이 기법이 만능은 아닙니다. 먼저 지수 엔트로피가 낮다는 전제는 잘 학습된 모델에서만 성립합니다. 가중치가 0 근처에 몰려 있어야 지수가 뭉치는데, 학습이 덜 되었거나 분포가 넓은 모델, 혹은 이미 강하게 양자화된 모델에서는 절감 폭이 작아집니다. 저희 측정도 특정 모델 하나에서 나온 값이므로, 아키텍처와 학습 방식에 따라 실제 수치는 달라질 수 있습니다.</p>

<p>둘째, 압축 코드를 실시간으로 해석하려면 GPU 커널이 룩업과 곱셈을 함께 처리해야 합니다. 이 커널이 잘 최적화되지 않으면 메모리는 아꼈지만 지연 시간이 늘어나는 역효과가 날 수 있습니다. 메모리 대역폭이 병목인 워크로드에서는 오히려 빨라질 수도 있지만, 이는 하드웨어와 커널 구현에 크게 의존하므로 실제 배포 전에 대상 GPU에서 반드시 벤치마크해야 합니다.</p>

<p>셋째, 이 방식은 어디까지나 무손실이라 4비트 양자화 같은 공격적 압축이 주는 절감에는 미치지 못합니다. 30퍼센트 절감은 훌륭하지만, 품질을 조금 내주고 4배를 줄이는 양자화와는 목적이 다릅니다. 두 기법은 경쟁 관계가 아니라 보완 관계이며, 정밀도가 절대적으로 중요한 구간에는 무손실 압축을, 품질 여유가 있는 구간에는 양자화를 쓰는 식의 조합이 현실적인 답입니다.</p>

<p>마지막으로 이 결과는 한 연구자의 공개 실험과 저희의 소규모 재현에 기반합니다. 프로덕션에 적용하려면 대상 모델과 서빙 스택에서 압축과 복원의 비트 동일성, 커널 성능, 실제 VRAM 절감을 독립적으로 검증하는 과정이 반드시 필요합니다.</p>

<h2 id="출처">출처</h2>

<ul>
  <li>brianbell-x, “Lossless Model Compression Experiment”: <a href="https://brianbell-x.github.io/weight-compression/">https://brianbell-x.github.io/weight-compression/</a></li>
  <li>측정 대상 모델: Qwen/Qwen2.5-0.5B (Hugging Face)</li>
  <li>관련 연구: ZipNN, DFloat11 (BF16 지수 엔트로피 부호화 계열)</li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="lossless-compression" /><category term="bf16" /><category term="quantization" /><category term="vram" /><category term="llmops" /><category term="self-hosting" /><category term="vllm" /><category term="paxis" /><summary type="html"><![CDATA[누군가 GLM-5.2에서 1403GB를 980GB로 줄였다고 했습니다. 양자화도, 프루닝도 아니고, 비트 단위로 완전히 동일한 무손실 압축이라고요. 처음엔 믿기 어려웠습니다. 그래서 직접 Qwen2.5-0.5B의 가중치 4억 9천만 개를 열어 BF16 지수 필드의 엔트로피를 측정했습니다. 8비트를 할당받은 지수가 실제로는 2.64비트만 쓰고 있었고, 이론적으로 33.5퍼센트를 무손실로 줄일 수 있다는 계산이 나왔습니다. 이 낭비가 어디서 오는지, 왜 디스크뿐 아니라 VRAM까지 줄어드는지 실측 데이터로 풀어봅니다.]]></summary></entry><entry xml:lang="ko"><title type="html">양자화한 모델을 어디에 올릴 것인가: AWS와 Unsloth의 배포 패턴 4가지</title><link href="https://thakicloud.github.io/ko/llmops/unsloth-aws-quantization-deploy/" rel="alternate" type="text/html" title="양자화한 모델을 어디에 올릴 것인가: AWS와 Unsloth의 배포 패턴 4가지" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/ko/llmops/unsloth-aws-quantization-deploy</id><content type="html" xml:base="https://thakicloud.github.io/ko/llmops/unsloth-aws-quantization-deploy/"><![CDATA[<p><img src="/assets/images/unsloth-aws-quantization-deploy-hero.png" alt="대형 모델이 압축된 층으로 정제되어 클라우드 서빙 인프라로 흘러 들어가는 모습을 표현한 추상 일러스트" /></p>

<h2 id="개요">개요</h2>

<p>모델을 양자화하는 방법을 다룬 글은 이미 넘칩니다. GPTQ, AWQ, GGUF, Unsloth Dynamic까지, 16비트 모델을 4비트로 줄이는 레시피는 검색 몇 번이면 찾을 수 있습니다. 그런데 정작 실무에서 팀이 멈추는 지점은 그다음입니다. 4비트로 줄인 그 파일을, 대체 어디에 어떻게 올려야 하는가. EC2 인스턴스에 직접 띄울 것인가, SageMaker 엔드포인트로 감쌀 것인가, 아니면 이미 굴리고 있는 EKS 클러스터의 파드로 넣을 것인가. 이 질문에는 정답이 하나가 아니라, 모델 파일의 형식에 따라 갈리는 지도가 있습니다.</p>

<p>이 글은 자체 인프라에 오픈웨이트 모델을 서빙하려는 플랫폼 엔지니어와 추론 비용을 설계하는 실무자를 위한 것입니다. 최근 AWS가 Unsloth와 함께 공개한 “Deploying quantized models on Amazon SageMaker AI with Unsloth” 가이드는 이 배포 결정을 네 가지 패턴으로 정리했습니다. 저희는 이 가이드의 핵심 논리를 뜯어보고, 왜 모델 파일 형식이 런타임을 정하고 런타임이 다시 AWS 서비스를 정하는지, 그리고 이 사고방식이 ThakiCloud처럼 Kubernetes 기반으로 멀티테넌트 서빙을 하는 인프라 설계와 어떻게 이어지는지 정리합니다.</p>

<p>먼저 밝혀 둘 것이 있습니다. 이 글의 명령 예시는 AWS 공식 가이드와 Unsloth 문서에서 확인한 경로이며, 벤치마크 수치를 지어내지 않았습니다. 본 검증 환경은 Apple Silicon이라 CUDA가 필요한 Unsloth 양자화와 vLLM 서빙을 로컬에서 실제로 돌려 재현하지는 못했습니다. 따라서 이 글은 실험 리포트가 아니라, 검증된 가이드에 대한 구조 분석입니다.</p>

<h2 id="왜-배포-단계에서-양자화가-다시-중요해지는가">왜 배포 단계에서 양자화가 다시 중요해지는가</h2>

<p>양자화는 흔히 학습이나 추론 속도의 문제로만 이야기됩니다. 하지만 AWS 가이드는 배포 단계에서 양자화가 세 가지를 동시에 바꾼다고 짚습니다. 첫째는 인스턴스 결정입니다. 큰 모델이 더 작은 GPU나 심지어 CPU에서도 실용적으로 돌아갈 수 있게 되면서, 필요한 인스턴스 등급 자체가 내려갑니다. 둘째는 기동과 저장 프로파일입니다. 모델 파일이 작아지면 옮기고 저장하는 속도가 빨라져 콜드 스타트와 스케일 아웃이 유리해집니다. 셋째는 배포 유연성입니다. 비용에 민감한 추론에는 더 작은 모델을, 품질에 민감한 추론에는 더 높은 정밀도의 내보내기를 골라 쓸 수 있습니다.</p>

<p>Unsloth의 장점은 파인튜닝, 실행, 내보내기, 배포를 하나의 워크플로로 묶는다는 데 있습니다. 특히 Unsloth Dynamic v2.0 양자화는 정확도를 최대한 보존하면서 양자화된 LLM을 실행하고 파인튜닝할 수 있게 하고, PyTorch와 협업한 양자화 인식 학습(QAT)은 순진한 4비트 양자화 대비 잃어버린 정확도를 상당 부분 회복한다고 보고됩니다. 즉 배포 전에 품질과 크기의 거래를 어느 지점에서 할지 세밀하게 고를 수 있습니다.</p>

<h2 id="파일-형식이-런타임을-정하고-런타임이-aws를-정한다">파일 형식이 런타임을 정하고, 런타임이 AWS를 정한다</h2>

<p>가이드의 핵심 통찰은 배포 결정을 “어느 서비스를 쓸까”에서 시작하지 말라는 것입니다. 대신 “어떤 파일 형식으로 내보낼까”에서 출발하면 나머지가 자연스럽게 따라옵니다. 두 갈래가 있습니다.</p>

<p>한쪽은 GGUF입니다. GGUF는 가중치와 토크나이저, 메타데이터를 하나의 파일로 묶는 단일 파일 형식으로, llama.cpp, Ollama, Unsloth 같은 경량 런타임이 이걸 씁니다. AWS에서는 이 갈래가 Amazon EC2나 SageMaker AI 커스텀 컨테이너로 매핑됩니다. 가볍게 검증하고 직접 통제하고 싶을 때의 경로입니다.</p>

<p>다른 한쪽은 병합 safetensors입니다. Unsloth로 16비트, 8비트, FP8, 4비트 가중치를 병합해 내보내면 vLLM이나 SGLang 같은 고처리량 엔진에서 돌릴 수 있고, 이것은 SageMaker AI의 대형 모델 추론(LMI) 컨테이너나 EKS, ECS로 매핑됩니다. 처리량과 확장이 중요한 프로덕션 서빙의 경로입니다. 이 갈래를 도식으로 정리하면 다음과 같습니다.</p>

<pre><code class="language-mermaid">flowchart TB
    A["Unsloth로 파인튜닝 또는 다운로드"] --&gt; B{"서빙 런타임 선택"}
    B --&gt;|"경량 단일 파일"| C["GGUF 내보내기&lt;br/&gt;가중치+토크나이저+메타데이터"]
    B --&gt;|"고처리량 엔진"| D["병합 safetensors 내보내기&lt;br/&gt;16 · 8 · FP8 · 4비트"]
    C --&gt; E["llama.cpp · Ollama · Unsloth"]
    D --&gt; F["vLLM · SGLang"]
    E --&gt; G["Amazon EC2&lt;br/&gt;또는 SageMaker 커스텀 컨테이너"]
    F --&gt; H["SageMaker LMI 컨테이너&lt;br/&gt;또는 EKS · ECS"]
    G --&gt; I["EC2에서 로컬 검증"]
    H --&gt; I
    I --&gt; J["동일 파일+런타임 조합으로&lt;br/&gt;관리형 배포에 승격"]
</code></pre>

<h2 id="설치-및-통합">설치 및 통합</h2>

<p>가이드가 제시하는 워크플로는 네 단계로 요약됩니다. Unsloth에서 모델을 파인튜닝하거나 다운로드하고, 원하는 런타임에 맞는 형식으로 내보내고, EC2나 로컬에서 런타임을 검증한 뒤, 같은 파일과 런타임 조합을 그대로 관리형 배포로 승격하는 것입니다. 여기서 “같은 파일과 런타임 조합”이라는 점이 중요합니다. 검증 환경과 프로덕션 환경에서 형식이나 엔진이 달라지면 예상치 못한 동작이 끼어들기 때문입니다.</p>

<p>Unsloth에서 내보내기는 목적지 런타임에 따라 갈립니다. GGUF 경로는 다음과 같은 형태입니다.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># GGUF 내보내기 (llama.cpp / Ollama / EC2 경로)
</span><span class="n">model</span><span class="p">.</span><span class="nf">save_pretrained_gguf</span><span class="p">(</span>
    <span class="sh">"</span><span class="s">qwen-merged-gguf</span><span class="sh">"</span><span class="p">,</span>
    <span class="n">tokenizer</span><span class="p">,</span>
    <span class="n">quantization_method</span><span class="o">=</span><span class="sh">"</span><span class="s">q4_k_m</span><span class="sh">"</span><span class="p">,</span>
<span class="p">)</span>
</code></pre></div></div>

<p>병합 safetensors 경로는 vLLM이나 SGLang을 겨냥합니다.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># 병합 safetensors 내보내기 (vLLM / SGLang / SageMaker LMI 경로)
</span><span class="n">model</span><span class="p">.</span><span class="nf">save_pretrained_merged</span><span class="p">(</span>
    <span class="sh">"</span><span class="s">qwen-merged-16bit</span><span class="sh">"</span><span class="p">,</span>
    <span class="n">tokenizer</span><span class="p">,</span>
    <span class="n">save_method</span><span class="o">=</span><span class="sh">"</span><span class="s">merged_16bit</span><span class="sh">"</span><span class="p">,</span>  <span class="c1"># 또는 merged_4bit 등
</span><span class="p">)</span>
</code></pre></div></div>

<p>내보낸 병합 모델은 vLLM으로 곧바로 서빙 검증을 할 수 있습니다.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># EC2 또는 로컬에서 서빙 검증</span>
vllm serve ./qwen-merged-16bit <span class="nt">--port</span> 8000
</code></pre></div></div>

<p>컨테이너 기반 배포에서는 AWS Deep Learning Container(DLC)가 EC2, EKS, ECS에 걸쳐 최적화된 도커 환경을 제공합니다. 특히 vLLM DLC는 고성능 추론에 맞춰져 있어 여러 GPU와 노드에 걸친 텐서 병렬화와 파이프라인 병렬화를 기본 지원합니다. 즉 EC2에서 단일 인스턴스로 검증한 구성을, 같은 런타임을 쓰는 EKS 파드로 옮겨 수평 확장하는 흐름이 매끄럽게 이어집니다.</p>

<h2 id="thakicloud-제품-적용-시사점">ThakiCloud 제품 적용 시사점</h2>

<p>이 배포 지도는 ThakiCloud의 ai-platform 설계 철학과 그대로 겹칩니다. ai-platform은 Kubernetes와 Kueue 기반 GPU 스케줄링 위에서 모델을 서빙하는데, AWS 가이드가 말하는 “형식이 런타임을 정하고 런타임이 인프라를 정한다”는 원칙은 특정 클라우드에 종속되지 않습니다. GGUF는 경량 검증과 엣지 배포로, 병합 safetensors는 vLLM 기반 고처리량 서빙으로 가른다는 분기는 AWS의 EKS든 온프레미스 Kubernetes든 동일하게 적용됩니다. 오히려 온프레미스와 소버린 클라우드를 요구하는 국내 고객이 많은 ThakiCloud에게는, 특정 관리형 서비스에 묶이지 않고 파일 형식과 런타임만으로 배포 경로를 표준화하는 이 사고방식이 이식성 측면에서 더 유리합니다.</p>

<p>실무적으로 ai-platform은 vLLM DLC가 제공하는 텐서 병렬화와 파이프라인 병렬화를 Kueue 큐잉과 결합해 멀티테넌트로 운용할 수 있습니다. 고객마다 다른 정밀도의 내보내기를 골라, 비용 민감 워크로드에는 4비트 병합 모델을, 품질 민감 워크로드에는 FP8이나 16비트를 배정하는 식의 세분화가 가능합니다. Unsloth의 QAT로 4비트에서도 정확도를 회복해 두면, 낮은 서빙 비용과 품질을 동시에 잡는 지점이 넓어집니다. ai-platform이 낮은 서빙 단가에서 경쟁력을 갖는 배경이 바로 이런 형식과 런타임의 세밀한 매칭입니다.</p>

<p>이 저비용 서빙은 다시 에이전트 경제성으로 이어집니다. ThakiCloud의 Agent-Native Cloud 제어 평면인 Paxis는 격리 샌드박스에서 스킬을 실행하며 대형 오픈웨이트 모델을 반복 호출하는데, 파인튜닝한 도메인 모델을 Unsloth로 양자화해 ai-platform에 올려 두면 Paxis 에이전트가 그 모델을 저렴하게 소비할 수 있습니다. 형식 기반 배포 표준화가 곧 에이전트 워크로드의 단가를 떨어뜨리는 구조입니다.</p>

<h2 id="한계-및-반론">한계 및 반론</h2>

<p>이 가이드는 배포 지도로서는 명확하지만 몇 가지 유의점이 있습니다. 먼저 양자화 방식과 런타임의 조합에 따라 실제 품질과 처리량은 크게 달라집니다. 4비트 병합 모델이 vLLM에서 얼마나 정확도를 유지하는지, 텐서 병렬화가 특정 모델에서 실제로 선형 확장을 주는지는 대상 모델과 하드웨어에서 직접 측정해야 하며, 가이드의 일반론만으로는 알 수 없습니다.</p>

<p>둘째, 관리형 서비스의 편의는 비용과 종속성을 대가로 합니다. SageMaker LMI 컨테이너는 운영 부담을 줄여 주지만, 온프레미스 요구가 강한 환경에서는 EKS나 자체 Kubernetes로 같은 런타임을 직접 운용하는 편이 통제와 비용 면에서 나을 수 있습니다. AWS 가이드가 좋은 지도인 것과 별개로, 그 지도를 자기 인프라에 옮길 때의 판단은 각 팀의 몫입니다.</p>

<p>셋째, 이 글은 앞서 밝힌 대로 로컬 재현을 하지 못한 구조 분석입니다. 실제 도입 전에는 대상 모델을 Unsloth로 내보내 vLLM에서 서빙해 보고, 형식별 지연 시간과 처리량, 정확도를 자체 벤치마크로 확인하는 과정이 반드시 필요합니다.</p>

<h2 id="출처">출처</h2>

<ul>
  <li>AWS Machine Learning Blog, “Deploying quantized models on Amazon SageMaker AI with Unsloth”: <a href="https://aws.amazon.com/blogs/machine-learning/deploying-quantized-models-on-amazon-sagemaker-ai-with-unsloth/">https://aws.amazon.com/blogs/machine-learning/deploying-quantized-models-on-amazon-sagemaker-ai-with-unsloth/</a></li>
  <li>Unsloth Documentation: <a href="https://unsloth.ai/docs">https://unsloth.ai/docs</a></li>
  <li>AWS, “Deploy LLMs on Amazon EKS using vLLM Deep Learning Containers”</li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="llmops" /><category term="unsloth" /><category term="quantization" /><category term="aws" /><category term="sagemaker" /><category term="vllm" /><category term="llmops" /><category term="self-hosting" /><category term="paxis" /><summary type="html"><![CDATA[Unsloth로 모델을 4비트로 줄이는 방법을 아는 팀은 많습니다. 그런데 그 파일을 실제로 EC2에 올릴지, SageMaker 엔드포인트로 감쌀지, EKS 파드로 띄울지 정하는 순간 대부분 막힙니다. AWS가 Unsloth와 함께 낸 배포 가이드는 이 질문에 명확한 지도를 제시합니다. 핵심은 모델 파일 형식이 런타임을 정하고, 런타임이 AWS 서비스를 정한다는 것입니다. GGUF는 어디로, 병합 safetensors는 어디로 가야 하는지, 그리고 이것이 ThakiCloud의 서빙 인프라 설계와 어떻게 맞닿는지 정리합니다.]]></summary></entry><entry xml:lang="ko"><title type="html">싼 모델을 믿어도 될 때는 언제인가: 신뢰도 기반 VLM 캐스케이드로 다국어 문서 OCR 비용 줄이기</title><link href="https://thakicloud.github.io/ko/research/confidence-gated-ocr-vlm-cascade/" rel="alternate" type="text/html" title="싼 모델을 믿어도 될 때는 언제인가: 신뢰도 기반 VLM 캐스케이드로 다국어 문서 OCR 비용 줄이기" /><published>2026-07-14T00:00:00+09:00</published><updated>2026-07-14T00:00:00+09:00</updated><id>https://thakicloud.github.io/ko/research/confidence-gated-ocr-vlm-cascade</id><content type="html" xml:base="https://thakicloud.github.io/ko/research/confidence-gated-ocr-vlm-cascade/"><![CDATA[<p>문서 파싱 파이프라인에 VLM을 붙여본 엔지니어라면 한 번쯤 같은 갈림길에 서봤을 겁니다. 10억 파라미터도 안 되는 작은 모델로 대부분의 문서를 충분히 읽을 수 있는데, 정작 스캔 상태가 나쁘거나 낯선 문자 체계로 된 문서 앞에서는 그 작은 모델이 자신 있게 틀린 답을 내놓습니다. 그렇다고 모든 문서를 값비싼 대형 VLM에 넘기자니 비용이 감당이 안 됩니다. 이 글에서 소개하는 논문은 이 갈림길을 “신뢰도 임계값 하나로 조절하는 캐스케이드”라는 수식으로 풀어내고, 그 신뢰도라는 신호 자체가 가장 믿을 수 없어지는 지점이 하필 캐스케이드가 가장 필요한 지점과 겹친다는 점을 짚습니다. 문서 OCR이나 VLM 서빙 비용을 설계하는 국내 클라우드·AI 엔지니어라면 읽어볼 가치가 있는 내용입니다.</p>

<h2 id="문제의식-캐스케이드는-텍스트에서-통했는데-이미지에서도-통할까">문제의식: 캐스케이드는 텍스트에서 통했는데, 이미지에서도 통할까</h2>

<p>값싼 모델을 기본으로 돌리고 확신이 낮을 때만 비싼 모델로 넘기는 캐스케이드 라우팅은 텍스트 LLM 서빙에서 이미 검증된 기법입니다. FrugalGPT가 대표적으로, 최고 성능 모델 하나만 쓰는 것과 비슷한 품질을 유지하면서 비용을 최대 98%까지 줄일 수 있다고 보고했습니다. 문제는 이 아이디어를 문서 OCR로 그대로 옮길 수 있느냐입니다. 텍스트 프롬프트와 달리 문서 이미지는 스캔 품질, 언어와 문자 체계, 레이아웃 복잡도라는 세 가지 축을 따라 난이도가 크게 요동칩니다. 깨끗한 영문 인보이스에서 비용 최적으로 튜닝한 신뢰도 임계값이 뒤틀린 저자원 언어 스캔본에서는 완전히 어긋날 수 있다는 것이 이 논문의 핵심 출발점입니다.</p>

<h2 id="핵심-기여-신뢰도-임계값-하나로-파레토-프론티어-전체를-그려낸다">핵심 기여: 신뢰도 임계값 하나로 파레토 프론티어 전체를 그려낸다</h2>

<p>논문은 저렴한 VLM(PaddleOCR-VL급 10억 파라미터 이하 모델)과 값비싼 대형 VLM으로 구성된 2단 캐스케이드를 신뢰도 임계값 τ 하나로 매개변수화한 모델을 세웁니다. 저렴한 모델이 내놓는 신뢰도 점수가 τ보다 낮을 때만 비싼 모델로 에스컬레이션하는 구조에서, 에스컬레이션 비율과 기대 비용, 기대 오류율을 전부 τ의 함수로 유도합니다. 흥미로운 점은 실무자들이 흔히 별개의 선택지로 여기는 “항상 싼 모델만 쓰기”와 “항상 비싼 모델만 쓰기”가 사실 이 하나의 매개변수 가족에서 τ=0과 τ=1인 양 끝단일 뿐이라는 사실입니다.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-pareto-frontier.png" alt="Pareto Frontier: Expected Cost vs. Expected Error Rate" />
<em>신뢰도 임계값 τ가 항상-저가 정책과 항상-고가 정책 사이의 파레토 프론티어를 어떻게 그려내는지 보여주는 개념도입니다. 실측 데이터가 아니라 논문이 세운 해석적 모델에서 유도된 곡선이며, 파라미터 값은 예시입니다.</em></p>

<p>이 프론티어가 매끄럽게 오목한 곡선을 그리는지는 단 하나의 가정에 달려 있습니다. 바로 저렴한 모델의 신뢰도 점수가 “에스컬레이션했을 때 얼마나 이득인지”를 올바르게 순위 매길 수 있어야 한다는 것입니다. 논문은 이 가정이 성립할 때 프론티어가 텍스트 LLM 캐스케이드에서 이미 증명된 것과 같은 형태의 오목 곡선이 된다는 것을 보이면서도, 정작 캐스케이드가 가장 매력적인 상황일수록 이 가정이 깨지기 쉽다는 점을 지적합니다. 저자원 문자 체계는 모델이 확신에 찬 채로 틀린 답을 내놓게 만들고, 지각적 확신과 추론적 확신이 하나의 스칼라 값으로 뭉뚱그려지며, 글자 단위 신뢰도는 표나 레이아웃이 무너진 구조적 오류를 전혀 감지하지 못하고, 한 문서 유형에서 튜닝한 임계값은 다른 유형으로 옮기면 그대로 어긋납니다.</p>

<p>이 네 가지는 각각 하나의 실패 모드로 정리되는데, 그중 논문이 가장 위험하다고 못 박는 것은 “낮은 확신인데 정답”이 아니라 “높은 확신인데 오답”입니다. 낯선 문자 체계를 만난 저렴한 모델이 그럴듯하고 매끄러운, 그러나 틀린 결과를 자신 있게 내놓으면 이 문서는 절대 에스컬레이션되지 않습니다. 캐스케이드는 자신이 이 문서를 잘 처리했다고 믿으면서 실은 가장 나쁜 오류를 조용히 떠안고 가는 셈입니다.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-shift-failure.png" alt="High-Confidence-but-Wrong Rate by Document Covariate" />
<em>문서 유형별로 저렴한 VLM이 높은 신뢰도를 유지하면서도 틀린 결과를 내놓는 비율이 어떻게 달라지는지 보여주는 개념도입니다. 실측이 아니라 인용된 문헌의 보고 결과를 바탕으로 도출한 값입니다.</em></p>

<p>논문은 여기서 그치지 않고 문서 집단이 깨끗한 영문 인보이스에서 저자원 문자 체계, 손상된 스캔, 복잡한 레이아웃 쪽으로 이동할 때 비용-정확도 프론티어 자체가 어느 방향으로 밀려나는지도 다룹니다. 스캔 품질이 나빠지면 저렴한 모델의 오류율이 오르면서 캐스케이드가 파고들 여지 자체는 커지지만, 동시에 오류가 몰리는 구간이 모델의 신뢰도 예측도 불안정해지는 구간과 겹칠 위험이 있습니다. 언어와 문자 체계 축에서는 GlotOCR 벤치마크가 보고한 대로 대부분의 VLM이 열 개 미만의 문자 체계에서만 잘 작동하고, 최상위 모델조차 서른 개를 넘어서면 무너지며, 저자원 언어일수록 환각까지 함께 늘어난다는 결과를 근거로 듭니다. 레이아웃 복잡도 축에서는 글자 단위 정확도가 높아도 표나 읽기 순서, 워터마크 같은 구조적 요소 때문에 문서 전체로는 틀릴 수 있다는 선행 연구를 인용합니다.</p>

<p><img src="/assets/images/posts/research/confidence-gated-ocr-vlm-cascade/fig-frontier-shift.png" alt="Pareto Frontier Shift Under Covariate Distribution Shift" />
<em>문서 집단이 깨끗한 영문 인보이스에서 저자원 문자 체계, 저품질 스캔, 복잡한 레이아웃 쪽으로 이동함에 따라 비용-정확도 프론티어가 어떻게 밀려나는지 보여주는 개념도입니다. 실측 데이터가 아니라 해석적 모델에서 유도된 결과입니다.</em></p>

<p>이 분석을 바탕으로 논문이 제시하는 설계 지침은 명확합니다. 전체 문서에 하나의 전역 임계값을 쓰지 말고 문자 체계와 스캔 품질별로 최소한 거칠게라도 나눠 임계값을 따로 보정해야 하고, 신뢰도 게이트를 디코더 확률 하나가 아니라 시각적 확신과 구조적 신호를 함께 보는 다중 신호로 설계해야 하며, 가장 저자원인 문자 체계처럼 저렴한 모델도 비싼 모델도 함께 흔들리는 구간에서는 아예 캐스케이드를 쓰지 말고 전량 에스컬레이션하거나 사람이 검토하는 편이 정직한 선택이라는 것입니다.</p>

<h2 id="회사와-사회-과학에-대한-기여">회사와 사회, 과학에 대한 기여</h2>

<p>ThakiCloud의 AI 플랫폼이 다루는 문서 파싱 워크로드는 이미 PaddleOCR-VL급 모델을 기본 경로로 쓰고 있습니다. 이 논문이 세운 신뢰도 임계값 모델은 그 워크로드에 “항상 싼 모델” 또는 “항상 비싼 모델”이라는 이분법 대신 원칙에 기반한 라우팅 정책 설계 공간을 제공합니다. 사회적으로 보면, 저자원 언어나 저품질 스캔 문서를 주로 다루는 기관과 개인이야말로 대형 VLM을 상시로 부르는 비용 없이 정확한 문서 자동화에 접근할 수 있어야 할 대상인데, 이 논문은 바로 그 집단에서 캐스케이드의 신뢰도 신호가 가장 깨지기 쉽다는 역설을 정량적으로 짚어냅니다. 즉 자동화 비용을 낮추는 기법이 가장 절실한 사용자 집단에서 오히려 가장 신뢰하기 어려워지는 지점을 명시적으로 드러낸 셈입니다. 과학적으로는 텍스트 LLM 도메인에서 검증된 FrugalGPT류 캐스케이드·라우팅 비용 최적화 문헌을 멀티모달 VLM과 문서 OCR 도메인으로 확장하면서, 신뢰도 캘리브레이션이 구체적으로 어떤 조건(문자 체계, 스캔 품질, 레이아웃)에서 무너지는지를 정리된 실패 모드 분류표로 남겼다는 점에서 기존 문헌을 한 단계 진전시켰습니다.</p>

<h2 id="한계">한계</h2>

<p>이 논문은 스스로 밝히듯 해석적이고 입장을 밝히는 성격의 연구이지 실증 연구가 아닙니다. 캐스케이드를 실제로 구현해 측정할 계획이었으나 그 실행이 인프라 프로비저닝 단계에서 실패했고, 그 결과 저자들이 직접 측정한 정확도나 지연시간, 비용, 벤치마크 수치는 하나도 제시되지 않습니다. 논문에 등장하는 모든 정량적 주장은 두 가지 중 하나입니다. 해석적 모델에서 수학적으로 유도된 성질이거나, 인용한 선행 연구가 이미 보고한 결과를 그대로 가져온 것입니다. 저자들 스스로도 후속 연구가 반드시 측정해야 할 것을 구체적으로 나열합니다. 스캔 품질과 언어, 레이아웃별로 나눈 문서 집합에서 저렴한 모델의 신뢰도와 실제 정오답 사이의 보정 곡선을 그려야 하고, 여러 임계값에서 실제로 도달하는 비용-오류 지점들이 논문이 예측한 오목한 프론티어를 따르는지 아니면 무너지는지를 확인해야 하며, 하나의 임계값을 다른 문서 집단으로 옮겼을 때 얼마나 어긋나는지도 정량화해야 합니다. 또한 이 논문은 단일 스칼라 임계값을 쓰는 2단 캐스케이드만 다루고 있어, 다단계 캐스케이드나 학습된 라우터, 클러스터링 기반 설계의 프론티어 형태는 다루지 않습니다.</p>

<p>논문 상세 페이지는 다음 링크에서 확인할 수 있습니다: <a href="https://huggingface.co/datasets/thaki-AI/daily-paper-2026-07-14-confidence-gated-ocr-vlm-cascade">https://huggingface.co/datasets/thaki-AI/daily-paper-2026-07-14-confidence-gated-ocr-vlm-cascade</a></p>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="research" /><category term="model-cascade" /><category term="vision-language-model" /><category term="document-ocr" /><category term="confidence-calibration" /><category term="inference-cost-optimization" /><category term="pareto-frontier" /><category term="multilingual-ocr" /><category term="LLM-routing" /><summary type="html"><![CDATA[10억 파라미터 미만의 초경량 VLM이 문서를 잘 읽는 시대에도, 정말 어려운 문서는 대형 모델이 필요합니다. 신뢰도 임계값 하나로 두 모델을 오가는 캐스케이드를 수식으로 세우고, 그 신뢰도가 가장 배신하기 쉬운 순간이 바로 캐스케이드가 가장 필요한 순간이라는 사실을 규명한 분석 논문을 소개합니다.]]></summary></entry><entry xml:lang="ar"><title type="html">Claude Code يشاهد الفيديو: claude-video يحقن الإطارات والنصوص في الوكيل عبر /watch</title><link href="https://thakicloud.github.io/ar/agentops/claude-video-agent-watch/" rel="alternate" type="text/html" title="Claude Code يشاهد الفيديو: claude-video يحقن الإطارات والنصوص في الوكيل عبر /watch" /><published>2026-07-13T00:00:00+09:00</published><updated>2026-07-13T00:00:00+09:00</updated><id>https://thakicloud.github.io/ar/agentops/claude-video-agent-watch</id><content type="html" xml:base="https://thakicloud.github.io/ar/agentops/claude-video-agent-watch/"><![CDATA[<h2 id="نظرة-عامة">نظرة عامة</h2>

<p>اقتصرت وكلاء البرمجة حتى الآن على قراءة النص فقط. ملفات المصدر والسجلات والوثائق واستجابات الواجهات، كلها كانت حروفا. ومع ذلك، فإن جزءا كبيرا مما يهم فعليا يعيش داخل الفيديو. تسجيلات عروض المنتجات، وشاشات إعادة إنتاج الأخطاء، وتسجيلات الاجتماعات، والفيديوهات التعليمية، ومقاطع إصدارات المنافسين. يفتح الإنسان أحدها فيقول “تنكسر الشاشة قرب الدقيقة 2:30”، لكن بالنسبة للوكيل كان ذلك الفيديو مجرد ملف ثنائي لا يمكن فتحه.</p>

<p>يهدم <code class="language-plaintext highlighter-rouge">claude-video</code> هذا الجدار بشكل رقيق. باختصار هو “يمنح Claude القدرة على مشاهدة الفيديو”، وما يفعله فعليا هو تحويل الفيديو إلى صور إطارات ونص مصحوب بطوابع زمنية، ثم دفعها إلى سياق Claude متعدد الوسائط عبر أداة Read. حتى يوليو 2026 تجاوز 5400 نجمة على GitHub، وتضعه بعض الإحصاءات عند 7000، مما يجعله أحد أكثر المشاريع تداولا في هذه اللحظة.</p>

<p>جمهور هذا المقال واضح. المطورون ومهندسو المنصات الذين يستخدمون وكلاء البرمجة مثل Claude Code وCursor وCopilot وGemini CLI في العمل الفعلي ويتساءلون كيف يدخلون المواد المرئية إلى خطوط أنابيبهم. وكل من يتساءل عن معنى هذه التقنية لتصميم منصات الوكلاء بما يتجاوز مجرد الراحة. الجواب المختصر: يعدّ claude-video مثالا جيدا على كيفية إضافة حاسة جديدة (البصر) إلى الوكيل عبر “إطار مُشغّل رقيق مع تركيبة من أدوات مُثبتة”، وهو ينسجم تماما مع الاتجاه الذي تنتهجه ThakiCloud في Paxis.</p>

<p><img src="/assets/images/claude-video-agent-watch-hero.png" alt="صورة تجريدية تصوّر وكيلا يكتسب البصر بينما تتدفق إطارات الفيديو وموجات الصوت نحو عدسة واحدة" /></p>

<h2 id="ما-هذه-الأداة">ما هذه الأداة</h2>

<p>لا يبني claude-video نموذجا جديدا. إنه مهارة تربط بشكل رقيق بين ثلاث أدوات مفتوحة المصدر مُثبتة بالفعل. يتولى <code class="language-plaintext highlighter-rouge">yt-dlp</code> تنزيل الفيديو والحصول على الترجمات، ويتولى <code class="language-plaintext highlighter-rouge">ffmpeg</code> استخراج الإطارات وتحويل الصوت، ويتولى <code class="language-plaintext highlighter-rouge">Whisper</code> تفريغ الكلام عند غياب الترجمات. أما التجميع النهائي والحكم فتقوم بهما أداة Read متعددة الوسائط في Claude. الجديد المكتوب هو خط الأنابيب الذي يصل هذه القطع الأربع، ومنطق إزالة التكرار الذي يصفّي الإطارات بذكاء.</p>

<p>الواجهة الأساسية أمر شرطة مائلة واحد هو <code class="language-plaintext highlighter-rouge">/watch</code>. يمرّر المستخدم رابط فيديو أو مسارا محليا، ويرفق سؤالا، ويحدد نطاقا عند الحاجة. عندها “يشاهد” الوكيل الفيديو ويجيب. مصادر الإدخال واسعة. ليس YouTube فحسب بل Instagram وX وVimeo وعموم أي موقع يدعمه yt-dlp، إضافة إلى تسجيلات Zoom وLoom وملفات mp4 المحلية.</p>

<p>يبدو التدفق الكامل هكذا.</p>

<pre><code class="language-mermaid">flowchart TB
    A["الوكيل: /watch رابط·مسار + سؤال&lt;br/&gt;اختياري --start / --end"] --&gt; B["yt-dlp: التحقق من الترجمات أولا"]
    B --&gt; C{"هل توجد ترجمات؟"}
    C --&gt;|نعم| D["استخدام الترجمات المجانية كنص مؤقّت زمنيا"]
    C --&gt;|لا| E["استخراج صوت أحادي 16kHz ثم&lt;br/&gt;تفريغ Whisper&lt;br/&gt;Groq large-v3 أولا · OpenAI بديل"]
    A --&gt; F["استخراج الإطارات بـ ffmpeg&lt;br/&gt;efficient · balanced · token-burner"]
    F --&gt; G["إزالة التكرار&lt;br/&gt;16x16 رمادي · مقابل آخر إطار محفوظ"]
    D --&gt; H["المحاذاة زمنيا: الإطارات + النص"]
    E --&gt; H
    G --&gt; H
    H --&gt; I["الحقن في سياق Claude متعدد الوسائط Read"]
</code></pre>

<p>الفرق عن المقاربات السابقة واضح. حتى الآن كان “الذكاء الاصطناعي يلخّص فيديو YouTube” يعني غالبا قراءة العنوان والوصف ونص الترجمة فقط ثم التخمين. لا يخمّن claude-video من العنوان. يرى الإطارات الفعلية كصور ويقرأ الترجمات أو النص إلى جانبها، جامعا بين البصر والسمع. أسئلة مثل ماذا يظهر على الشاشة، أو متى بالضبط تنكسر الواجهة، لا يمكن الإجابة عنها من نص الترجمة وحده؛ يجب رؤية الإطارات.</p>

<h2 id="التثبيت-والاستخدام">التثبيت والاستخدام</h2>

<p>يسير التثبيت في مسارين. يربطه مستخدمو Claude Code عبر سوق الإضافات.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Claude Code: سجّل السوق ثم ثبّت مهارة watch</span>
/plugin marketplace add bradautomates/claude-video
/plugin <span class="nb">install </span>watch@claude-video
</code></pre></div></div>

<p>على نحو خمسين مضيف وكيل بما فيها Cursor وCopilot وGemini CLI، ثبّته عالميا وفق مواصفة Agent Skills.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># مواصفة Agent Skills (مشتركة عبر نحو 50 مضيفا)</span>
npx skills add bradautomates/claude-video <span class="nt">-g</span>
</code></pre></div></div>

<p>لا حاجة لأي إعداد إضافي للبدء. إن غاب <code class="language-plaintext highlighter-rouge">yt-dlp</code> و<code class="language-plaintext highlighter-rouge">ffmpeg</code> فسيثبّتان تلقائيا عبر brew عند أول تشغيل على macOS، وعلى Linux وWindows تُطبع أوامر التثبيت الدقيقة. مفتاح واجهة Whisper ليس مطلوبا دائما؛ إنه ضروري فقط حين لا يملك الفيديو أي ترجمات. كثير من الفيديوهات العامة تأتي مع ترجمات وتُعالج على المسار المجاني.</p>

<p>الاستخدام سطر أمر واحد.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># اطرح سؤالا عن ملف محلي</span>
/watch tutorial.mp4 <span class="s2">"ما اللغة المستخدمة في هذا الدرس؟"</span>

<span class="c"># ركّز على مقطع محدد من فيديو YouTube</span>
/watch https://youtu.be/VIDEO <span class="s2">"ماذا يحدث قرب 2:30؟"</span> <span class="nt">--start</span> 2:00 <span class="nt">--end</span> 3:00
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">--start</code> و<code class="language-plaintext highlighter-rouge">--end</code> مهمان. تمزيق فيديو طويل بأكمله إلى إطارات يفجّر السياق والتكلفة. تضييق النطاق ينزّل ذلك الجزء فقط ويستخرج منه الإطارات، موفّرا الرموز. عمليا، الحركة القياسية هي تضييق النطاق، مثل “مقطع العرض ذي الاثنتي عشرة دقيقة فقط من تسجيل اجتماع مدته 45 دقيقة”.</p>

<h2 id="الآلية-الداخلية-الترجمات-أولا-استخراج-الإطارات-إزالة-التكرار-التفريغ">الآلية الداخلية: الترجمات أولا، استخراج الإطارات، إزالة التكرار، التفريغ</h2>

<p>سبب كون claude-video مثيرا للاهتمام هو أن حكما عمليا مطبوع في طريقة وصل القطع. لنمرّ على التصميم الموثّق خطوة بخطوة. الأرقام والمعاملات أدناه هي قيم التصميم التي نشرها المشروع، وليست قياسات أجريتها في هذه البيئة.</p>

<p>أولا، التفريغ يبدأ بالترجمات. يتحقق yt-dlp من وجود ترجمات أولا، وإن وُجدت استخدمها مباشرة كنص مصحوب بطوابع زمنية دون تنزيل جسم الفيديو. الأمر فوري ومجاني. وفقط عند غياب الترجمات يستخرج صوتا أحاديا بتردد 16kHz ويسلّمه إلى Whisper. هنا، مراعاة للسرعة والتكلفة، يفضّل whisper-large-v3 من Groq ويرتد إلى whisper-1 من OpenAI إن لم يتوفر.</p>

<p>ثانيا، يقدّم استخراج الإطارات ثلاثة مستويات تفصيل. يفكّ <code class="language-plaintext highlighter-rouge">efficient</code> الإطارات المفتاحية فقط وينتهي فوريا تقريبا. يفضّل <code class="language-plaintext highlighter-rouge">balanced</code> إطارات تغيّر المشهد لكنه يكمّل بأخذ عينات منتظم مراع للمدة حين تقل. يشغّل <code class="language-plaintext highlighter-rouge">token-burner</code> كشف المشاهد دون سقف لسحب أقصى دقة، محرقا الرموز بالمقابل. تختار “التصفّح السريع أم النظر بدقة” حسب الغرض.</p>

<p>ثالثا، إزالة التكرار هي درّة هذا المشروع الصغيرة. يُصغَّر كل إطار مستخرج إلى صورة مصغّرة رمادية 16x16، ويُحسب متوسط الفرق المطلق ليس مقابل الإطار السابق مباشرة بل مقابل <strong>آخر إطار محفوظ</strong>. إن كانت تلك القيمة عند العتبة 2.0 أو أدنى، يُسقَط الإطار. سبب المقارنة مع آخر إطار محفوظ بدلا من السابق هو المفتاح. المقارنة إطارا بإطار تُبقي التلاشي البطيء جدا يمر بوصفه “بالكاد تغيّر”، لكن المقارنة مع آخر إطار محفوظ تلتقط لحظة تجاوز التغيّر التراكمي للعتبة. إنه تصميم مفيد فعلا في أمور مثل الفيديوهات التعليمية حيث تتقدم الشرائح ببطء.</p>

<p>رابعا، التجميع النهائي. تُحاذى صور الإطارات والنص زمنيا، فتدخل الإطارات سياق Claude كصور والنص كنص مصحوب بأوقات. يقرأ Claude “في هذه اللحظة تُظهر الشاشة كذا، وقيل كذا حينها” معا ويجيب.</p>

<h2 id="ما-تحققت-منه-سلوك-موثّق-وملاحظة-إعادة-إنتاج">ما تحققت منه: سلوك موثّق وملاحظة إعادة إنتاج</h2>

<p>بصراحة. بيئة تأليف هذا المقال تمنع تنزيل الفيديو الخارجي، لذا لم أستطع تشغيل قياس مباشر يثبّت claude-video ويمزّق فيديو YouTube حقيقيا إلى إطارات. لذلك لا أختلق أي أرقام زمن استجابة أو دقة. بدلا من ذلك أعرض تصميم المشروع المنشور وسلوكه بأمانة وأترك نقاط تحقق قابلة لإعادة الإنتاج.</p>

<p>ما يتأكد باستمرار عبر الوثائق وتقارير المستخدمين المتعددة هو التالي. تُفرّغ الفيديوهات العامة ذات الترجمات مجانا دون تنزيل. للإطارات ثلاثة مستويات تفصيل، efficient وbalanced وtoken-burner، يختلف كل منها في السرعة والدقة. تستخدم إزالة التكرار مقارنة رمادية 16x16 بعتبة 2.0. مسار بديل التفريغ هو Groq whisper-large-v3 ثم OpenAI whisper-1. يقدّم التفرّع <code class="language-plaintext highlighter-rouge">mathiaschu/watch</code> نسخة تستبدل خطوة التفريغ بـ <code class="language-plaintext highlighter-rouge">mlx-whisper</code> محليا، فتعمل بالكامل على الجهاز دون مفتاح واجهة.</p>

<p>للتحقق مباشرة، أنصح بهذا. اقطع فيديو عاما قصيرا يملك ترجمات إلى مقطع دون دقيقة بـ <code class="language-plaintext highlighter-rouge">--start</code>/<code class="language-plaintext highlighter-rouge">--end</code>، وألقه إلى <code class="language-plaintext highlighter-rouge">/watch</code>، وشغّله بتفصيل efficient ثم token-burner، مقارنا عدد الإطارات ورموز الاستجابة. تُظهر هذه المقارنة بأوضح شكل أثر “تضييق النطاق مع اختيار التفصيل” على التكلفة. بدلا من الاستشهاد بأرقام دون قياس، فإن قياس هذين المحورين في بيئتك أدق.</p>

<h2 id="تبعات-على-منتجات-thakicloud">تبعات على منتجات ThakiCloud</h2>

<p>ينسجم claude-video طبيعيا مع المحورين اللذين تدفع بهما ThakiCloud.</p>

<p>أولا، <strong>عدسة Paxis</strong>. Paxis هو مستوى التحكم للسحابة الأصيلة للوكلاء في ThakiCloud، ويعامل Skills وTools وPolicies وAudit Logs كموارد من الدرجة الأولى. ما يبرهنه claude-video هو تماما بنية “إطار رقيق، مهارة سميكة” التي يهدف إليها Paxis. دون تدريب نموذج جديد، يربط أدوات مُثبتة (yt-dlp وffmpeg وWhisper) عبر إطار مهارات ليضيف حاسة جديدة إلى الوكيل. يختار Skill Harness في Paxis من أكثر من 960 مهارة عبر BM25 ويشغّلها في بيئة معزولة، ومهارة متعددة الوسائط مثل claude-video مرشحة للجلوس مباشرة على هذا الإطار. وبخاصة أن تنزيل الفيديو وتشغيل ffmpeg يتعاملان مع روابط وثنائيات عشوائية، فإن التشغيل المعزول في Paxis وبوابة السياسات مع سجلات التدقيق تؤتي ثمارها مباشرة. حين يُسجّل في سجل التدقيق أي فيديو عُولج، وإلى أي نطاق، وبأي تفصيل، يمكن التحكم في التكلفة والوصول إلى البيانات معا.</p>

<p>ثانيا، <strong>عدسة ai-platform</strong>. يعتمد مسار تفريغ claude-video أساسا على واجهات خارجية (Groq وOpenAI). للعملاء ذوي متطلبات محلية أو سيادية، ذلك الجزء خطر كما هو. هنا يقدّم ai-platform في ThakiCloud الجواب. إن خدمت STT من فئة Whisper داخليا على K8s مع جدولة GPU بواسطة Kueue، أمكنك إنهاء تفريغ الفيديو داخل شبكة مغلقة دون إرساله للخارج. إنه الاتجاه ذاته الذي سلكه التفرّع باختيار mlx-whisper للتفريغ المحلي، منفَّذا على نطاق مؤسسي. خط أنابيب يفرّغ كميات كبيرة من تسجيلات الاجتماعات بلا ترجمات دفعيا على عنقود GPU داخلي، مع استهلاك الوكلاء للنتائج، هو حالة استخدام نموذجية لـ ai-platform الذي تكمن قوته في الخدمة متعددة المستأجرين وكفاءة التكلفة.</p>

<p>تكمّل العدستان إحداهما الأخرى. حين يدعم ai-platform التفريغ ومعالجة الإطارات منخفضة التكلفة داخل شبكة مغلقة، ينسّق Paxis المهارات متعددة الوسائط فوقها بالسياسات والتدقيق. بنية “البنية التحتية الرخيصة تجعل حاسة الوكيل الجديدة اقتصادية” تصح هنا أيضا.</p>

<h2 id="القيود-والاعتراضات">القيود والاعتراضات</h2>

<p>بضعة أمور يجب قولها بوضوح.</p>

<p>أولا، تكلفة الرموز. لحظة دخول الإطارات السياق كصور، تتراكم الرموز بسرعة. تشغيل فيديو طويل بأكمله في وضع token-burner قد يكبّد تكلفة كبيرة لكل سؤال. انضباط التضييق بـ <code class="language-plaintext highlighter-rouge">--start</code>/<code class="language-plaintext highlighter-rouge">--end</code> والبدء بتفصيل efficient ضروري. الاستخدام المتهور طلبا للراحة يجعل الفاتورة تستجيب أولا.</p>

<p>ثانيا، إزالة التكرار ليست حلا سحريا. الرمادي 16x16 بعتبة 2.0 يناسب الفيديوهات ذات التغيّر المنفصل مثل الشرائح والعروض، لكن على لقطات محمولة باليد باهتزاز كاميرا مستمر أو شاشات تهم فيها تغيّرات نصية دقيقة، قد يفوّت أو يبقي أكثر من اللازم. العتبة مرشحة للضبط حسب طبيعة الفيديو.</p>

<p>ثالثا، ثقة المصدر والمسائل القانونية. تنزيل الفيديوهات من مواقع عشوائية بـ yt-dlp قد يتعارض مع شروط الخدمة المستهدفة وحقوق النشر. عند إدخاله في خط أنابيب مؤسسي، يجب تثبيت المصادر المسموح بها بالسياسة، وهذا بالضبط سبب الحاجة إلى بوابة سياسات مثل Paxis.</p>

<p>رابعا، الاعتماد على واجهات خارجية. إن خرج تفريغ الفيديوهات بلا ترجمات إلى Groq أو OpenAI، تغادر البيانات المنشأة. لتسجيلات الاجتماعات الداخلية الحساسة، ذلك انكشاف كما هو ما لم تبدّل المسار إلى خدمة Whisper الداخلية المذكورة أعلاه.</p>

<p>ومع ذلك، تبقى الصورة الكبرى صحيحة. كسر claude-video فرضية أن “وكلاء البرمجة تقرأ النص فقط” بطريقة رقيقة وعملية. مقاربة توسيع حاسة عبر تركيبة من أدوات مُثبتة بدلا من نموذج جديد هي نمط يستحق الرجوع إليه باستمرار من منظور تصميم منصات الوكلاء.</p>

<h2 id="المصادر">المصادر</h2>

<ul>
  <li><a href="https://github.com/bradautomates/claude-video">bradautomates/claude-video (GitHub)</a></li>
  <li><a href="https://github.com/bradautomates/claude-video/blob/main/README.md">claude-video/README.md (GitHub)</a></li>
  <li><a href="https://github.com/mathiaschu/watch">mathiaschu/watch، تفرّع التفريغ المحلي بـ mlx-whisper (GitHub)</a></li>
  <li><a href="https://knightli.com/en/2026/07/08/claude-video-watch-video-transcript-frames-skill/">claude-video: Let Claude Watch Videos with /watch (knightli.com)</a></li>
  <li><a href="https://www.coddykit.com/pages/blog-detail?id=512902&amp;slug=claude-video-the-open-source-tool-that-lets-ai-coding-agents-watch-and-analyze-a">Claude Video: The Open-Source Tool That Lets AI Coding Agents Watch and Analyze Any Video (CoddyKit)</a></li>
</ul>]]></content><author><name>{&quot;name&quot;=&gt;nil, &quot;avatar&quot;=&gt;nil, &quot;bio&quot;=&gt;nil, &quot;location&quot;=&gt;&quot;Seoul, Korea&quot;, &quot;email&quot;=&gt;&quot;info@thakicloud.co.kr&quot;, &quot;uri&quot;=&gt;nil, &quot;home&quot;=&gt;nil, &quot;links&quot;=&gt;[{&quot;label&quot;=&gt;&quot;Website&quot;, &quot;icon&quot;=&gt;&quot;fas fa-fw fa-link&quot;, &quot;url&quot;=&gt;&quot;https://thakicloud.co.kr&quot;}, {&quot;label&quot;=&gt;&quot;GitHub&quot;, &quot;icon&quot;=&gt;&quot;fab fa-fw fa-github&quot;, &quot;url&quot;=&gt;&quot;https://github.com/thakicloud&quot;}]}</name><email>info@thakicloud.co.kr</email></author><category term="agentops" /><category term="agentops" /><category term="claude-code" /><category term="multimodal" /><category term="agent-skills" /><category term="video-understanding" /><category term="ffmpeg" /><category term="whisper" /><category term="platform-engineering" /><summary type="html"><![CDATA[طالما اقتصرت وكلاء البرمجة على قراءة النص فقط. يربط claude-video بشكل رقيق بين yt-dlp وffmpeg وWhisper ليحوّل فيديوهات YouTube وZoom وLoom أو الملفات المحلية إلى صور إطارات ونصوص مؤقّتة زمنيا، ثم يحقنها في سياق Claude متعدد الوسائط عبر أداة Read. يفكّك هذا المقال التثبيت والاستخدام الفعليين لهذه المهارة مفتوحة المصدر (أكثر من 5400 نجمة على GitHub) وآليتها الداخلية (الترجمات أولا، استخراج الإطارات على ثلاثة مستويات، إزالة التكرار، بديل التفريغ)، ويقرأ معناها من خلال إطار مهارات Paxis السحابة الأصيلة للوكلاء في ThakiCloud وعدسة خدمة ai-platform.]]></summary></entry></feed>