Files
xSaherelmWorkspace/Documents/Docs/Developer/AirLLM-Document.html
T
2026-10-20 22:20:35 +03:30

583 lines
19 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>بررسی فنی و راهنمای جامع ابزار AirLLM</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root {
--primary: #1a365d;
--primary-light: #2c5282;
--accent: #c9a961;
--accent-dark: #a8893f;
--bg: #faf9f6;
--card-bg: #ffffff;
--text: #1a202c;
--text-muted: #4a5568;
--border: #e2e8f0;
--success: #38a169;
--danger: #e53e3e;
--warning: #dd6b20;
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Vazirmatn', Tahoma, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.9;
font-size: 15px;
padding: 30px 15px;
}
.document-container {
max-width: 950px;
margin: 0 auto;
background: var(--card-bg);
box-shadow: var(--shadow);
border-radius: 12px;
overflow: hidden;
}
.document-header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
color: white;
padding: 50px 40px 40px;
position: relative;
border-bottom: 4px solid var(--accent);
}
.document-header::before {
content: '';
position: absolute;
top: 0; right: 0;
width: 200px; height: 200px;
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
border-radius: 50%;
transform: translate(50%, -50%);
}
.header-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
position: relative;
z-index: 1;
}
.company-badge {
display: flex;
align-items: center;
gap: 12px;
}
.company-logo {
width: 60px; height: 60px;
background: var(--accent);
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: 800;
font-size: 10px;
text-align: center;
line-height: 1.2;
}
.doc-meta {
text-align: left;
font-size: 12px;
opacity: 0.9;
}
.doc-meta div { margin-bottom: 3px; }
.document-title {
text-align: center;
position: relative;
z-index: 1;
padding: 20px 0;
}
.document-title .label {
display: inline-block;
background: rgba(201,169,97,0.2);
color: var(--accent);
padding: 4px 16px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
margin-bottom: 15px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-title h1 {
font-size: 28px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.document-title h2 {
font-size: 16px;
font-weight: 400;
opacity: 0.9;
}
.document-body {
padding: 40px;
}
.intro-text {
background: linear-gradient(to left, #f7fafc, #edf2f7);
border-right: 4px solid var(--accent);
padding: 20px 25px;
border-radius: 8px;
margin-bottom: 35px;
font-size: 14px;
color: var(--text-muted);
}
.section {
margin-bottom: 40px;
page-break-inside: avoid;
}
.section-header {
display: flex;
align-items: center;
gap: 15px;
padding-bottom: 12px;
border-bottom: 2px solid var(--border);
margin-bottom: 20px;
}
.section-number {
width: 50px; height: 50px;
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: 20px;
flex-shrink: 0;
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
}
.section-title { flex: 1; }
.section-title h3 {
font-size: 19px;
font-weight: 700;
color: var(--primary);
margin-bottom: 2px;
}
.section-title .subtitle {
font-size: 12px;
color: var(--text-muted);
}
.section-content {
padding-right: 10px;
}
.section-content p {
margin-bottom: 12px;
text-align: justify;
text-indent: 20px;
}
.section-content p.no-indent { text-indent: 0; }
.highlight-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #f6e05e;
border-right: 4px solid var(--accent);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.highlight-box strong {
color: var(--accent-dark);
}
.info-box {
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
border: 1px solid #90cdf4;
border-right: 4px solid var(--primary-light);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.success-box {
background: linear-gradient(to left, #f0fff4, #e6fffa);
border: 1px solid #9ae6b4;
border-right: 4px solid var(--success);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.warning-box {
background: linear-gradient(to left, #fffaf0, #fef5e7);
border: 1px solid #fbd38d;
border-right: 4px solid var(--warning);
padding: 18px 22px;
border-radius: 8px;
margin: 20px 0;
font-size: 14px;
}
.styled-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.styled-table thead {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
}
.styled-table th {
padding: 14px 16px;
text-align: right;
font-weight: 600;
font-size: 13px;
}
.styled-table td {
padding: 13px 16px;
border-bottom: 1px solid var(--border);
font-size: 13px;
}
.styled-table tbody tr:last-child td { border-bottom: none; }
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
.styled-table .highlight-row {
background: #fffaf0 !important;
font-weight: 600;
}
pre {
background-color: #1a202c;
color: #e2e8f0;
padding: 20px;
border-radius: 8px;
overflow-x: auto;
direction: ltr;
text-align: left;
margin: 15px 0;
font-family: 'Courier New', Courier, monospace;
font-size: 13px;
line-height: 1.6;
border-right: 4px solid var(--accent);
}
code {
font-family: 'Courier New', Courier, monospace;
background-color: #edf2f7;
color: var(--danger);
padding: 2px 6px;
border-radius: 4px;
font-size: 13px;
direction: ltr;
display: inline-block;
}
pre code {
background-color: transparent;
color: inherit;
padding: 0;
}
.conclusion-box {
background: linear-gradient(135deg, var(--primary), var(--primary-light));
color: white;
padding: 30px;
border-radius: 12px;
margin: 30px 0;
text-align: center;
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
}
.conclusion-box h3 {
font-size: 22px;
font-weight: 800;
margin-bottom: 15px;
color: var(--accent);
}
.conclusion-box p {
font-size: 14px;
line-height: 1.8;
text-indent: 0 !important;
margin-bottom: 15px;
}
.conclusion-box .highlight {
background: rgba(201,169,97,0.2);
padding: 15px 20px;
border-radius: 8px;
margin-top: 20px;
border: 1px solid rgba(201,169,97,0.4);
}
.document-footer {
background: var(--primary);
color: white;
padding: 25px 40px;
text-align: center;
font-size: 12px;
margin-top: 40px;
}
.document-footer .footer-brand {
font-weight: 700;
color: var(--accent);
margin-bottom: 5px;
font-size: 14px;
}
.footer-divider {
width: 60px;
height: 2px;
background: var(--accent);
margin: 10px auto;
}
.page-info {
text-align: center;
padding: 15px;
font-size: 11px;
color: var(--text-muted);
border-top: 1px solid var(--border);
margin-top: 30px;
}
@media print {
body { background: white; padding: 0; }
.document-container { box-shadow: none; border-radius: 0; }
.section { page-break-inside: avoid; }
}
@media (max-width: 768px) {
.document-body { padding: 25px 20px; }
.document-header { padding: 30px 20px; }
.header-top { flex-direction: column; gap: 15px; }
.doc-meta { text-align: center; }
}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="company-badge">
<div class="company-logo">فن آوران<br>ساحر علم</div>
</div>
<div class="doc-meta">
<div>شماره مستند: TECH-1405-002</div>
<div>نسخه: ۱.۰</div>
<div>تاریخ تهیه: ۲۸ مهر ۱۴۰۵</div>
<div>طبقه‌بندی: داخلی / فنی</div>
</div>
</div>
<div class="document-title">
<span class="label">TECHNICAL REVIEW & GUIDE</span>
<h1>بررسی فنی و راهنمای جامع ابزار AirLLM</h1>
<h2>تحلیل معماری، قابلیت‌ها و راهنمای پیاده‌سازی مدل‌های زبانی بزرگ روی سخت‌افزار محدود</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>همکاران و ذینفعان محترم،</strong><br>
این مستند به‌عنوان تحلیلی جامع و مبتنی بر بررسی‌های فنی عمیق، ابزار <strong>AirLLM</strong> را از منظر معماری، کارایی و نحوه پیاده‌سازی مورد ارزیابی قرار می‌دهد. هدف از تهیه این سند، ارائه شفافیت کامل فنی و تسهیل تصمیم‌گیری برای به‌کارگیری این راهکار در زیرساخت‌های هوش مصنوعی با منابع محدود است.
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>خلاصه اجرایی</h3>
<div class="subtitle">Executive Summary</div>
</div>
</div>
<div class="section-content">
<p>ابزار AirLLM یک کتابخانه پیشرفته در حوزه هوش مصنوعی است که با هدف کاهش چشمگیر مصرف حافظه گرافیکی (VRAM) در هنگام استنتاج (Inference) و آموزش (Training) مدل‌های زبانی بزرگ (LLM) طراحی شده است. این ابزار امکان اجرای مدل‌های عظیم (مانند مدل‌های ۷۰ میلیارد پارامتری و بالاتر) را روی کارت‌های گرافیک با ظرفیت حداقل ۴ گیگابایت فراهم می‌کند، بدون آنکه نیاز به کوانتیزاسیون (Quantization)، تقطیر (Distillation) یا هرس کردن (Pruning) مدل باشد.</p>
<div class="highlight-box">
<strong>نتیجه کلیدی:</strong> با به‌کارگیری AirLLM، محدودیت‌های سخت‌افزاری به حداقل رسیده و امکان استقرار مدل‌های پیشرفته (حتی مدل‌های ۶۷۱ میلیارد پارامتری مانند DeepSeek-V3) روی سخت‌افزارهای سطح متوسط با مصرف حدود ۱۲ گیگابایت VRAM میسر می‌گردد.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>معماری و مکانیزم عملکرد</h3>
<div class="subtitle">Architecture & Mechanism</div>
</div>
</div>
<div class="section-content">
<p>مکانیزم اصلی AirLLM بر پایه تکنیک <strong>«بارگذاری لایه‌ای» (Layer-wise Loading)</strong> استوار است. به جای بارگذاری کل مدل در حافظه گرافیکی، این ابزار فرآیند را به گام‌های زیر تقسیم می‌کند:</p>
<div class="info-box">
<strong>گام ۱: تجزیه و ذخیره‌سازی اولیه</strong><br>
در اولین اجرا، مدل اصلی از مخزن Hugging Face دریافت شده و به صورت لایه‌به‌لایه در حافظه دیسک (Storage) ذخیره می‌شود.
<br><br>
<strong>گام ۲: بارگذاری پویا در GPU</strong><br>
در حین فرآیند استنتاج، تنها <strong>یک لایه</strong> از مدل در هر لحظه روی GPU بارگذاری می‌شود.
<br><br>
<strong>گام ۳: محاسبه و انتقال حالت (State)</strong><br>
پس از انجام محاسبات روی لایه فعلی، نتایج میانی (Activations) به لایه بعدی منتقل شده و لایه قبلی بلافاصله از VRAM تخلیه می‌شود.
</div>
<div class="success-box">
<strong>💡 نتیجه معماری:</strong> این رویکرد باعث می‌شود حافظه VRAM مورد نیاز، به جای وابستگی به اندازه کل مدل، تنها به اندازه بزرگ‌ترین لایه مدل وابسته باشد که انقلابی در مدیریت منابع محسوب می‌شود.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>مدل‌های پشتیبانی‌شده و مصرف حافظه</h3>
<div class="subtitle">Supported Models & VRAM Consumption</div>
</div>
</div>
<div class="section-content">
<p>این کتابخانه با تقریباً تمام خانواده‌های مدل‌های متن‌باز محبوب سازگاری کامل دارد. جدول زیر نمایی از توانایی AirLLM در مدیریت منابع برای مدل‌های مختلف را نشان می‌دهد:</p>
<table class="styled-table">
<thead>
<tr>
<th>نام مدل</th>
<th>اندازه تقریبی</th>
<th>حداقل VRAM مورد نیاز</th>
</tr>
</thead>
<tbody>
<tr>
<td>Qwen3 / Mistral / Phi</td>
<td>≈8B</td>
<td style="color: var(--success); font-weight: 600;">~۱ تا ۲ گیگابایت</td>
</tr>
<tr>
<td>Qwen3-30B / Mixtral (MoE)</td>
<td>30–47B</td>
<td style="color: var(--success); font-weight: 600;">~۱ تا ۳ گیگابایت</td>
</tr>
<tr>
<td>Qwen3.8-27B (dense VL)</td>
<td>27B</td>
<td style="color: var(--success); font-weight: 600;">~۳.۳۳ گیگابایت</td>
</tr>
<tr>
<td>Qwen3.8-Flash-Next (MoE + PLE)</td>
<td>~180B</td>
<td style="color: var(--success); font-weight: 600;">~۵.۹۵ گیگابایت</td>
</tr>
<tr>
<td>Llama 3.x 70B (full precision)</td>
<td>70B</td>
<td style="color: var(--success); font-weight: 600;">~۴ گیگابایت</td>
</tr>
<tr class="highlight-row">
<td>DeepSeek-V3</td>
<td>671B</td>
<td style="color: var(--accent-dark); font-weight: 700;">~۱۲ گیگابایت</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>راهنمای گام‌به‌گام پیاده‌سازی</h3>
<div class="subtitle">Step-by-Step Implementation Guide</div>
</div>
</div>
<div class="section-content">
<p>برای استقرار و اجرای این ابزار، مراحل زیر به دقت طراحی و پیاده‌سازی شده‌اند:</p>
<div class="warning-box">
<strong>پیش‌نیاز حیاتی:</strong> اطمینان از وجود فضای دیسک کافی در پوشه کش Hugging Face برای ذخیره‌سازی لایه‌های تجزیه‌شده مدل در اولین اجرا.
</div>
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">گام ۱: نصب کتابخانه</h4>
<pre><code>pip install airllm</code></pre>
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">گام ۲: مقداردهی اولیه مدل</h4>
<pre><code>from airllm import AutoModel
# شناسه مخزن Hugging Face مدل مورد نظر را وارد کنید
model = AutoModel.from_pretrained("Qwen/Qwen3-32B")
# نکته: برای فعال‌سازی فشرده‌سازی و افزایش سرعت تا ۳ برابر (اختیاری):
# model = AutoModel.from_pretrained("model-name", compression='4bit')
</code></pre>
<h4 style="margin-top: 20px; color: var(--primary); font-size: 16px;">گام ۳: آماده‌سازی ورودی و اجرای استنتاج</h4>
<pre><code>MAX_LENGTH = 128
input_text = ['What is the capital of United States?']
input_tokens = model.tokenizer(
input_text,
return_tensors="pt",
return_attention_mask=False,
truncation=True,
max_length=MAX_LENGTH,
padding=False
)
generation_output = model.generate(
input_tokens['input_ids'].cuda(),
max_new_tokens=20,
use_cache=True,
return_dict_in_generate=True
)
output = model.tokenizer.decode(generation_output.sequences[0])
print(output)
</code></pre>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>جمع‌بندی و توصیه‌های فنی</h3>
<div class="subtitle">Conclusion & Technical Recommendations</div>
</div>
</div>
<div class="section-content">
<p>با توجه به تحلیل‌های انجام‌شده، به‌کارگیری AirLLM مزایای بی‌نظیری را برای پروژه‌هایی با محدودیت سخت‌افزاری فراهم می‌آورد:</p>
<table class="styled-table">
<thead>
<tr>
<th>مزیت</th>
<th>روش سنتی (بارگذاری کامل)</th>
<th>روش AirLLM (لایه‌ای)</th>
</tr>
</thead>
<tbody>
<tr>
<td>مصرف VRAM</td>
<td style="color: var(--danger); font-weight: 600;">بسیار بالا (غیرقابل اجرا روی GPUهای ضعیف)</td>
<td style="color: var(--success); font-weight: 600;">بهینه و متناسب با اندازه لایه</td>
</tr>
<tr>
<td>نیاز به کوانتیزاسیون</td>
<td>الزامی برای کاهش مصرف</td>
<td style="color: var(--success); font-weight: 600;">غیرالزامی (حفظ دقت کامل)</td>
</tr>
<tr>
<td>سرعت استنتاج (با فشرده‌سازی)</td>
<td>پایه</td>
<td style="color: var(--success); font-weight: 600;">تا ۳ برابر سریع‌تر (با 4bit/8bit)</td>
</tr>
<tr class="highlight-row">
<td><strong>ارزش خالص فنی</strong></td>
<td>—</td>
<td style="color: var(--success); font-weight: 700; font-size: 15px;">بسیار بالاتر</td>
</tr>
</tbody>
</table>
<div class="conclusion-box">
<h3>🎯 توصیه نهایی معماری</h3>
<p>با توجه به بررسی‌های جامع فنی، استفاده از AirLLM بهترین انتخاب برای استقرار مدل‌های زبانی بزرگ در محیط‌هایی با محدودیت VRAM است.</p>
<p>این راهکار نه تنها هزینه‌های زیرساختی را به شکل قابل‌توجهی کاهش می‌دهد، بلکه بدون قربانی کردن دقت مدل (در حالت بدون فشرده‌سازی)، عملکردی پایدار و قابل اتکا ارائه می‌کند.</p>
<div class="highlight">
<strong>💎 ارزش پیشنهادی:</strong><br>
حذف محدودیت سخت‌افزاری + حفظ دقت مدل + امکان فشرده‌سازی اختیاری برای افزایش سرعت + سازگاری گسترده با اکوسیستم Hugging Face
</div>
</div>
</div>
</div>
<div class="page-info">
این مستند محرمانه بوده و صرفاً جهت استفاده داخلی در شرکت فن آوران ساحر علم تهیه شده است. هرگونه کپی‌برداری یا افشا بدون اجازه کتبی ممنوع است.
</div>
</div>
<footer class="document-footer">
<div class="footer-brand">طراحی و تدوین: هادی خزاعی اصل | معمار ارشد و توسعه‌دهنده سامانه‌های نرم‌افزاری</div>
<div class="footer-divider"></div>
<div>شرکت: فن آوران ساحر علم &nbsp;|&nbsp; تاریخ تهیه: ۲۸ مهر ۱۴۰۵ &nbsp;|&nbsp; نسخه: ۱.۰ &nbsp;|&nbsp; طبقه‌بندی: داخلی / فنی</div>
</footer>
</div>
</body>
</html>