This commit is contained in:
2026-10-20 22:20:35 +03:30
parent d5cf18cdf2
commit 86395cc611
5 changed files with 2868 additions and 118 deletions
+113 -118
View File
@@ -463,15 +463,6 @@
"checkboxes": [],
"comments": []
},
{
"id": "c072d0a6-f2be-419b-8fb2-d127d73dd709",
"listId": "1706107f-ace2-4240-aa32-3d2031264a41",
"title": "Prepare Vector Data Store in XAiModels ...",
"description": "",
"labels": [],
"checkboxes": [],
"comments": []
},
{
"id": "b6d82a67-f038-4d7e-a624-4461c0b63f35",
"listId": "1706107f-ace2-4240-aa32-3d2031264a41",
@@ -497,118 +488,12 @@
"title": "InProgress",
"cards": [
{
"id": "5f8a8b2f-06ce-46a9-8101-f14e34b51249",
"id": "c072d0a6-f2be-419b-8fb2-d127d73dd709",
"listId": "171f43f3-ae73-49b7-9239-9f3fb695cc2b",
"title": "implement Api Key Mechanism using IDServer and Clients sides ...",
"title": "Prepare Vector Data Store in XAiModels ...",
"description": "",
"labels": [],
"checkboxes": [
{
"id": "66cf978d-2d2f-4bbc-a97c-504ba0ddba65",
"title": "R&D about how i can attach a Custom Entity in IDS Dbs;",
"checked": true
},
{
"id": "1ef7dc8c-5b19-499e-803e-500885eb3bb9",
"title": "Add Entites Related in XIdentityModels ...",
"checked": true
},
{
"id": "1509ec76-9372-40a1-b387-1f8e005d507e",
"title": "Add DbContext DbSets and Model Builder Configurations ...",
"checked": true
},
{
"id": "b4ed3da1-d967-4a11-b2c3-88a3c0aca5ad",
"title": "Test Migration Identity Dbs ...",
"checked": true
},
{
"id": "754d66a3-4e19-40c2-98e3-f7744da444f3",
"title": "Implements Application Manager ...",
"checked": true
},
{
"id": "4c68e1d8-4f1e-4415-913b-218a4e89666b",
"title": "Implement Requirement Tools for Safe Api Key ...",
"checked": true
},
{
"id": "14292514-bd6e-42d4-a8b7-24a91bda9827",
"title": "Implement XApiKeyValidator ...",
"checked": true
},
{
"id": "ba8bfae2-130d-4020-bd1b-daabc5199ddf",
"title": "Implement Rate Limiter ...",
"checked": true
},
{
"id": "d7c9ecdc-15e4-4efe-a593-17601a86db5c",
"title": "Implement Authentication Handler for Api Keys ...",
"checked": true
},
{
"id": "246701eb-7e7b-4756-be04-3af0e490b87b",
"title": "Register Authentication Middleware in App Startup ...",
"checked": true
},
{
"id": "ab67e976-6080-44ee-b49e-54aada0724a3",
"title": "Adding Dto and Enrichment Mechanism ...",
"checked": true
},
{
"id": "2828eb54-a27d-40cd-ac17-cadc06d1a68e",
"title": "Add Application Controller in Ids ...",
"checked": true
},
{
"id": "2e94cc30-d26c-4db6-bff9-8306de8e577c",
"title": "Test All Senarios inside Ids Itself ...",
"checked": true
},
{
"id": "73e8e5fe-e220-4215-bab3-37e789811b78",
"title": "Add Default ApiKey Acess to Read ...",
"checked": true
},
{
"id": "780b2443-071c-4395-87c9-3943e930ca45",
"title": "Add Summary to Test Api Controller Actions ...",
"checked": true
},
{
"id": "8069d964-fac5-451d-9953-3cb264312d11",
"title": "Add Support for Api Key Usage Auditing ...",
"checked": false
},
{
"id": "ecb1c403-b446-4a56-8152-adb566170378",
"title": "Refactor AccountController and TestIdentityController ...",
"checked": true
},
{
"id": "e0a92efc-1248-4994-8f78-e8efa2bc3005",
"title": "Add Application Controller Implementation inside Account Controller in XIdentityService and XIdentityHelper Modules ...",
"checked": true
},
{
"id": "88c8b057-fde1-4533-ab36-80bd23d2fd0d",
"title": "Create XApiKeyAccess Authorization Attribute in XIdentityService ...",
"checked": true
},
{
"id": "45c22102-feda-4212-94a0-60c837613ddf",
"title": "Extends XIdentitProvider and Add Support for Application, ApiKey, ApiKeyUsage and also ApiKey Custom Actions inside XIdentityService ...",
"checked": true
},
{
"id": "6fafa434-7b2f-44d5-b1d8-53109d43dfd0",
"title": "Others ...",
"checked": false
}
],
"checkboxes": [],
"comments": []
},
{
@@ -691,6 +576,116 @@
"id": "8c15334f-3b2e-4eca-999e-4c887cb628e9",
"title": "Test",
"cards": [
{
"id": "5f8a8b2f-06ce-46a9-8101-f14e34b51249",
"listId": "8c15334f-3b2e-4eca-999e-4c887cb628e9",
"title": "implement Api Key Mechanism using IDServer and Clients sides ...",
"description": "",
"labels": [],
"checkboxes": [
{
"id": "66cf978d-2d2f-4bbc-a97c-504ba0ddba65",
"title": "R&D about how i can attach a Custom Entity in IDS Dbs;",
"checked": true
},
{
"id": "1ef7dc8c-5b19-499e-803e-500885eb3bb9",
"title": "Add Entites Related in XIdentityModels ...",
"checked": true
},
{
"id": "1509ec76-9372-40a1-b387-1f8e005d507e",
"title": "Add DbContext DbSets and Model Builder Configurations ...",
"checked": true
},
{
"id": "b4ed3da1-d967-4a11-b2c3-88a3c0aca5ad",
"title": "Test Migration Identity Dbs ...",
"checked": true
},
{
"id": "754d66a3-4e19-40c2-98e3-f7744da444f3",
"title": "Implements Application Manager ...",
"checked": true
},
{
"id": "4c68e1d8-4f1e-4415-913b-218a4e89666b",
"title": "Implement Requirement Tools for Safe Api Key ...",
"checked": true
},
{
"id": "14292514-bd6e-42d4-a8b7-24a91bda9827",
"title": "Implement XApiKeyValidator ...",
"checked": true
},
{
"id": "ba8bfae2-130d-4020-bd1b-daabc5199ddf",
"title": "Implement Rate Limiter ...",
"checked": true
},
{
"id": "d7c9ecdc-15e4-4efe-a593-17601a86db5c",
"title": "Implement Authentication Handler for Api Keys ...",
"checked": true
},
{
"id": "246701eb-7e7b-4756-be04-3af0e490b87b",
"title": "Register Authentication Middleware in App Startup ...",
"checked": true
},
{
"id": "ab67e976-6080-44ee-b49e-54aada0724a3",
"title": "Adding Dto and Enrichment Mechanism ...",
"checked": true
},
{
"id": "2828eb54-a27d-40cd-ac17-cadc06d1a68e",
"title": "Add Application Controller in Ids ...",
"checked": true
},
{
"id": "2e94cc30-d26c-4db6-bff9-8306de8e577c",
"title": "Test All Senarios inside Ids Itself ...",
"checked": true
},
{
"id": "73e8e5fe-e220-4215-bab3-37e789811b78",
"title": "Add Default ApiKey Acess to Read ...",
"checked": true
},
{
"id": "780b2443-071c-4395-87c9-3943e930ca45",
"title": "Add Summary to Test Api Controller Actions ...",
"checked": true
},
{
"id": "8069d964-fac5-451d-9953-3cb264312d11",
"title": "Add Support for Api Key Usage Auditing ...",
"checked": true
},
{
"id": "ecb1c403-b446-4a56-8152-adb566170378",
"title": "Refactor AccountController and TestIdentityController ...",
"checked": true
},
{
"id": "e0a92efc-1248-4994-8f78-e8efa2bc3005",
"title": "Add Application Controller Implementation inside Account Controller in XIdentityService and XIdentityHelper Modules ...",
"checked": true
},
{
"id": "88c8b057-fde1-4533-ab36-80bd23d2fd0d",
"title": "Create XApiKeyAccess Authorization Attribute in XIdentityService ...",
"checked": true
},
{
"id": "45c22102-feda-4212-94a0-60c837613ddf",
"title": "Extends XIdentitProvider and Add Support for Application, ApiKey, ApiKeyUsage and also ApiKey Custom Actions inside XIdentityService ...",
"checked": true
}
],
"comments": []
},
{
"id": "07747425-25d1-478b-ba84-c56e978574b3",
"listId": "8c15334f-3b2e-4eca-999e-4c887cb628e9",
@@ -0,0 +1,583 @@
<!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>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,581 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>مستند فنی راه‌اندازی Qwen3.5-9B با Llamafile و 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: 26px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.document-title h2 {
font-size: 15px;
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-004</div>
<div>نسخه: ۲.۰</div>
<div>تاریخ تهیه: ۲۸ مهر ۱۴۰۵</div>
<div>طبقه‌بندی: داخلی / فنی</div>
</div>
</div>
<div class="document-title">
<span class="label">DEPLOYMENT & OPTIMIZATION GUIDE</span>
<h1>مستند فنی راه‌اندازی مدل Qwen3.5-9B</h1>
<h2>پیاده‌سازی گام‌به‌گام با Llamafile و AirLLM بر روی سیستم ۶۴GB RAM / 4GB VRAM</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>همکاران و ذینفعان محترم،</strong><br>
این مستند، نسخه به‌روزرسانی‌شده راهنمای استقرار مدل <strong>Qwen3.5-9B-The-Defiant-Fable-Uncensored-Heretic-NEO-IMATRIX-MAX-MTP-GGUF</strong> است. با توجه به درخواست‌های فنی جدید، دو مسیر پیاده‌سازی مجزا و بهینه برای سخت‌افزار هدف (۶۴ گیگابایت رم سیستم و ۴ گیگابایت حافظه گرافیکی) تشریح شده است: استفاده از <strong>Llamafile</strong> (برای اجرای مستقیم و بهینه فایل‌های GGUF) و <strong>AirLLM</strong> (برای بارگذاری لایه‌ای مدل‌های فرمت Hugging Face).
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>استراتژی تخصیص منابع سخت‌افزاری</h3>
<div class="subtitle">Hardware Resource Allocation Strategy</div>
</div>
</div>
<div class="section-content">
<p>با توجه به محدودیت شدید VRAM (۴ گیگابایت) و وفور RAM سیستم (۶۴ گیگابایت)، استراتژی اصلی بر پایه <strong>Offloading هیبریدی</strong> استوار است:</p>
<div class="info-box">
<strong>تحلیل حجم مدل:</strong><br>
• نسخه پیشنهادی GGUF: <code>Q4_K_M</code> یا <code>Q5_K_M</code> (حجم تقریبی: ۶.۸ تا ۷.۸ گیگابایت).<br>
• فایل پردازشگر بینایی (<code>mmproj-F16.gguf</code>): حجم تقریبی ۰.۵ تا ۱ گیگابایت.<br>
• <strong>مجموع مورد نیاز:</strong> حدود ۸ گیگابایت فضای حافظه (که به‌راحتی در ۶۴ گیگابایت RAM جای می‌گیرد).
</div>
<div class="success-box">
<strong>✅ راهکار بهینه:</strong><br>
مدل به‌صورت کامل در RAM سیستم بارگذاری می‌شود. سپس، با تنظیم دقیق پارامترهای موتور استنتاج، تعداد مشخصی از لایه‌ها (حدود ۱۵ تا ۲۰ لایه) به همراه کل فایل <code>mmproj</code> به ۴ گیگابایت VRAM منتقل می‌شوند. این کار سرعت را به‌شدت افزایش داده و از خطای Out of Memory (OOM) جلوگیری می‌کند.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>روش اول: پیاده‌سازی با Llamafile (پیشنهاد اصلی برای GGUF)</h3>
<div class="subtitle">Implementation via Llamafile (Recommended for GGUF)</div>
</div>
</div>
<div class="section-content">
<p>ابزار <strong>Llamafile</strong> (توسعه‌یافته توسط Mozilla) یک فایل اجرایی تک‌فایلی است که موتور <code>llama.cpp</code> و مدل را در خود جای می‌دهد. این روش ساده‌ترین، پایدارترین و بهینه‌ترین راه برای اجرای فایل‌های GGUF به‌همراه قابلیت چندوجهی (Multimodal) است.</p>
<div class="highlight-box">
<strong>گام ۱: دانلود فایل‌های ضروری</strong>
<p class="no-indent" style="margin-top: 10px;">۱. دانلود فایل اجرایی <code>llamafile</code> از مخزن رسمی Mozilla AI.<br>
۲. دانلود فایل مدل: <code>Qwen3.5-9B-...-Q4_K_M.gguf</code> (یا Q5_K_M).<br>
۳. دانلود فایل پردازشگر تصویر: <code>mmproj-F16.gguf</code> از همان مخزن Hugging Face.</p>
</div>
<div class="highlight-box">
<strong>گام ۲: تنظیم مجوزهای اجرایی (در لینوکس/مک)</strong>
<pre><code>chmod +x llamafile</code></pre>
</div>
<div class="highlight-box">
<strong>گام ۳: اجرای بهینه‌شده برای ۴ گیگابایت VRAM</strong>
<p class="no-indent" style="margin-top: 10px;">دستور زیر مدل را با استفاده از RAM سیستم اجرا کرده و دقیقاً ۱۸ لایه را به GPU منتقل می‌کند (ایمن برای ۴GB VRAM):</p>
<pre><code>./llamafile \
--model Qwen3.5-9B-The-Defiant-Fable-Q4_K_M.gguf \
--mmproj mmproj-F16.gguf \
--n-gpu-layers 18 \
--ctx-size 8192 \
--temp 0.7 \
--top-p 0.85 \
--repeat-penalty 1.0 \
--n-predict 512</code></pre>
</div>
<div class="warning-box">
<strong>⚠️ نکته حیاتی:</strong> اگر هنگام آپلود تصویر با خطای OOM مواجه شدید، مقدار <code>--n-gpu-layers</code> را به ۱۵ یا ۱۴ کاهش دهید. فایل <code>mmproj</code> به‌صورت پیش‌فرض سعی می‌کند خود را به GPU منتقل کند و نیاز به فضای رزرو شده دارد.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>روش دوم: پیاده‌سازی با AirLLM (مخصوص فرمت Hugging Face)</h3>
<div class="subtitle">Implementation via AirLLM (For Hugging Face Weights)</div>
</div>
</div>
<div class="section-content">
<p><strong>توضیح معماری:</strong> کتابخانه <strong>AirLLM</strong> به‌طور ذاتی برای اجرای مستقیم فایل‌های GGUF طراحی نشده است، بلکه برای بارگذاری لایه‌ای (Layer-wise) مدل‌های فرمت Hugging Face (<code>.safetensors</code> یا <code>.bin</code>) بهینه شده است. اگر قصد دارید از وزن‌های اصلی یا Fine-tune شده این مدل در فرمت HF استفاده کنید، این روش بهترین گزینه برای دور زدن محدودیت ۴ گیگابایت VRAM است.</p>
<div class="highlight-box">
<strong>گام ۱: نصب پیش‌نیازها</strong>
<pre><code>pip install airllm torch transformers</code></pre>
</div>
<div class="highlight-box">
<strong>گام ۲: اسکریپت پایتون برای بارگذاری لایه‌ای</strong>
<p class="no-indent" style="margin-top: 10px;">کد زیر به‌طور خودکار مدل را در RAM بارگذاری کرده و لایه‌ها را به‌صورت پویا به GPU منتقل می‌کند:</p>
<pre><code>from airllm import AutoModel
import torch
# شناسه مدل (مثال: نسخه پایه یا فاین‌تیون شده در فرمت HF)
# توجه: برای نسخه DavidAU، اگر مخزن HF در دسترس باشد، نام آن جایگزین شود
model_id = "Qwen/Qwen3.5-9B"
print("در حال بارگذاری مدل با استراتژی AirLLM...")
model = AutoModel.from_pretrained(
model_id,
compression=None # برای حفظ دقت کامل. در صورت نیاز به سرعت بیشتر: '4bit'
)
# توکنایزیشن ورودی
input_text = ["این تصویر را تحلیل کن و جزئیات آن را بگو."]
# نکته: برای ورودی چندوجهی در AirLLM، نیاز به پردازشگر تصویر جداگانه و الحاق Image Tokens است
input_tokens = model.tokenizer(
input_text,
return_tensors="pt",
truncation=True,
max_length=4096
)
# اجرای استنتاج
print("در حال تولید پاسخ...")
generation_output = model.generate(
input_tokens['input_ids'].cuda(),
max_new_tokens=256,
use_cache=True,
return_dict_in_generate=True
)
output = model.tokenizer.decode(generation_output.sequences[0])
print(output)
</code></pre>
</div>
<div class="info-box">
<strong>💡 مزیت AirLLM در این سخت‌افزار:</strong><br>
AirLLM به‌صورت پیش‌فرض فقط <strong>یک لایه</strong> را در هر لحظه در VRAM نگه می‌دارد. بنابراین، حتی یک مدل ۹ میلیارد پارامتری با دقت کامل (BF16) نیز به‌راحتی در ۴ گیگابایت VRAM اجرا می‌شود، زیرا کل بار محاسباتی بر روی ۶۴ گیگابایت RAM سیستم تقسیم شده و تنها نتایج میانی از GPU عبور می‌کنند.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>مقایسه فنی و انتخاب مسیر</h3>
<div class="subtitle">Technical Comparison & Path Selection</div>
</div>
</div>
<div class="section-content">
<table class="styled-table">
<thead>
<tr>
<th>شاخص ارزیابی</th>
<th>Llamafile (GGUF)</th>
<th>AirLLM (Hugging Face)</th>
</tr>
</thead>
<tbody>
<tr>
<td>سهولت راه‌اندازی</td>
<td style="color: var(--success); font-weight: 600;">بسیار بالا (تک‌فایل اجرایی)</td>
<td>متوسط (نیاز به محیط پایتون)</td>
</tr>
<tr>
<td>پشتیبانی چندوجهی (تصویر)</td>
<td style="color: var(--success); font-weight: 600;">عالی (با فایل mmproj)</td>
<td>پیچیده (نیاز به کدنویسی پردازش تصویر)</td>
</tr>
<tr>
<td>مدیریت ۴GB VRAM</td>
<td>خوب (با تنظیم دستی <code>-ngl</code>)</td>
<td style="color: var(--success); font-weight: 600;">عالی (لایه‌ای خودکار)</td>
</tr>
<tr>
<td>سرعت استنتاج (Tokens/sec)</td>
<td>بالا (به‌ویژه با نسخه MTP)</td>
<td>متوسط (به دلیل سربای انتقال لایه‌ها)</td>
</tr>
<tr class="highlight-row">
<td><strong>توصیه نهایی</strong></td>
<td style="color: var(--success); font-weight: 700;"><strong>انتخاب اول برای این سناریو</strong></td>
<td>انتخاب دوم (برای یکپارچه‌سازی در کد پایتون)</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">Conclusion & Final Recommendations</div>
</div>
</div>
<div class="section-content">
<div class="conclusion-box">
<h3>🎯 ارزیابی نهایی معماری</h3>
<p>برای سیستم هدف با ۶۴ گیگابایت RAM و ۴ گیگابایت VRAM، استفاده از <strong>Llamafile</strong> به‌همراه فایل‌های GGUF و <code>mmproj</code>، پایدارترین و کم‌دردسرترین مسیر برای بهره‌مندی از قابلیت‌های چندوجهی و سرعت بالای مدل Qwen3.5-9B است.</p>
<p>در صورتی که نیاز به ادغام عمیق مدل در یک پایپ‌لاین پایتونی دارید، <strong>AirLLM</strong> با مکانیزم بارگذاری لایه‌ای، محدودیت VRAM را به‌طور کامل خنثی می‌کند.</p>
<div class="highlight">
<strong>💡 توصیه‌های کلیدی برای حفظ پایداری:</strong><br>
۱. در Llamafile، هرگز مقدار <code>--n-gpu-layers</code> را برای این سخت‌افزار بالاتر از ۲۰ تنظیم نکنید.<br>
۲. در هر دو روش، <code>Repetition Penalty</code> را روی ۱.۰ نگه دارید تا از اختلال در عملکرد MTP جلوگیری شود.<br>
۳. برای کارهای برنامه‌نویسی دقیق، دما (Temperature) را به ۰.۶ کاهش دهید.
</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>
@@ -0,0 +1,513 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>مستند فنی راه‌اندازی و بهینه‌سازی مدل Qwen3.5-9B (نسخه چندوجهی)</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: 26px;
font-weight: 800;
margin-bottom: 10px;
letter-spacing: -0.5px;
}
.document-title h2 {
font-size: 15px;
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-003</div>
<div>نسخه: ۱.۰</div>
<div>تاریخ تهیه: ۲۸ مهر ۱۴۰۵</div>
<div>طبقه‌بندی: داخلی / فنی</div>
</div>
</div>
<div class="document-title">
<span class="label">DEPLOYMENT & OPTIMIZATION GUIDE</span>
<h1>مستند فنی راه‌اندازی و بهینه‌سازی مدل Qwen3.5-9B</h1>
<h2>پیاده‌سازی نسخه Uncensored-Heretic با قابلیت چندوجهی (Multimodal) بر روی سخت‌افزار با ۶۴ گیگابایت رم و ۴ گیگابایت VRAM</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>همکاران و ذینفعان محترم،</strong><br>
این مستند، راهنمای جامع و گام‌به‌گام استقرار مدل <strong>Qwen3.5-9B-The-Defiant-Fable-Uncensored-Heretic-NEO-IMATRIX-MAX-MTP-GGUF</strong> را ارائه می‌دهد. با توجه به محدودیت حافظه گرافیکی (۴ گیگابایت) و وفور حافظه سیستم (۶۴ گیگابایت)، استراتژی اصلی این سند بر پایه <strong>تخصیص هیبریدی منابع (Hybrid Resource Allocation)</strong> و <strong>بارگذاری لایه‌ای (GPU Offloading)</strong> طراحی شده است تا بهترین تعادل بین سرعت و پایداری حاصل شود.
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>تحلیل مدل و قابلیت‌های کلیدی</h3>
<div class="subtitle">Model Analysis & Key Capabilities</div>
</div>
</div>
<div class="section-content">
<p>این مدل ۹ میلیارد پارامتری، حاصل تنظیم دقیق (Fine-tune) و ادغام چندمرحله‌ای است که عملکردی فراتر از مدل‌های ۲۷ میلیارد پارامتری پایه در بنچمارک‌های کلیدی (مانند ARC-C) ارائه می‌دهد [[1]]. ویژگی‌های برجسته آن عبارتند از:</p>
<ul>
<li><strong>پشتیبانی از چندوجهی (Multimodal):</strong> قابلیت درک و تحلیل تصاویر با استفاده از فایل مکمل <code>mmproj</code> [[2]].</li>
<li><strong>پیش‌بینی چند توکنی (MTP):</strong> معماری بهینه‌شده برای افزایش سرعت استنتاج تا ۳ برابر در کوانتیزاسیون‌های خاص [[1]].</li>
<li><strong>کوانتیزاسیون IMATRIX:</strong> دقت ۲ تا ۴ درصد بالاتر نسبت به فایل‌های GGUF معمولی، به‌ویژه در پنجره‌های متنی طولانی [[1]].</li>
<li><strong>حالت‌های استدلال و دستور (Reasoning/Instruct):</strong> پشتیبانی از ۵ حالت مختلف (مانند Spoon و Einstein) که به صورت پویا در حین چت قابل تغییر هستند [[1]].</li>
</ul>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>استراتژی تخصیص منابع سخت‌افزاری</h3>
<div class="subtitle">Hardware Resource Allocation Strategy</div>
</div>
</div>
<div class="section-content">
<p>با توجه به مشخصات سیستم هدف (۶۴ گیگابایت RAM و ۴ گیگابایت VRAM)، استراتژی زیر برای جلوگیری از خطای کمبود حافظه (OOM) و حفظ سرعت مناسب تدوین شده است:</p>
<div class="info-box">
<strong>تحلیل حجم مدل:</strong><br>
• نسخه پیشنهادی: <code>Q4_K_M</code> یا <code>Q5_K_M</code> (حجم تقریبی: ۶.۸ تا ۷.۸ گیگابایت).<br>
• فایل پردازشگر بینایی (<code>mmproj-F16.gguf</code>): حجم تقریبی ۰.۵ تا ۱ گیگابایت.<br>
• <strong>مجموع مورد نیاز:</strong> حدود ۸ گیگابایت فضای حافظه.
</div>
<div class="success-box">
<strong>✅ راهکار بهینه:</strong><br>
از آنجا که ۶۴ گیگابایت رم سیستم به‌راحتی کل مدل را در خود جای می‌دهد، مدل به‌صورت کامل در RAM بارگذاری می‌شود. سپس، با استفاده از تکنیک <strong>GPU Offloading</strong>، حدود ۱۵ تا ۲۰ لایه از مدل به‌همراه کل فایل <code>mmproj</code> به ۴ گیگابایت VRAM منتقل می‌شود. این کار سرعت پردازش توکن‌ها را به‌شدت افزایش می‌دهد بدون آنکه باعث سرریز حافظه گرافیکی شود.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۳</div>
<div class="section-title">
<h3>راهنمای گام‌به‌گام راه‌اندازی (با LM Studio)</h3>
<div class="subtitle">Step-by-Step Setup Guide (LM Studio)</div>
</div>
</div>
<div class="section-content">
<p>نرم‌افزار <strong>LM Studio</strong> به دلیل رابط کاربری بصری و مدیریت هوشمند تخصیص حافظه، بهترین گزینه برای این پیکربندی سخت‌افزاری است.</p>
<div class="step-box" style="background: #f8fafc; border: 1px solid #e2e8f0; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
<strong>گام ۱: دانلود فایل‌های ضروری</strong>
<p class="no-indent" style="margin-top: 10px;">به صفحه Hugging Face مدل مراجعه کرده و دو فایل زیر را دانلود کنید:</p>
<ol style="margin-right: 20px; margin-top: 10px;">
<li>فایل اصلی مدل: <code>Qwen3.5-9B-The-Defiant-Fable...-Q4_K_M.gguf</code> (یا Q5_K_M)</li>
<li>فایل پردازشگر بینایی: <code>mmproj-F16.gguf</code> یا <code>mmproj-BF16.gguf</code> از همان مخزن [[2]].</li>
</ol>
</div>
<div class="step-box" style="background: #f8fafc; border: 1px solid #e2e8f0; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
<strong>گام ۲: بارگذاری مدل در LM Studio</strong>
<p class="no-indent" style="margin-top: 10px;">نرم‌افزار را باز کرده و از بخش <strong>AI Chat</strong>، فایل <code>.gguf</code> دانلودشده را انتخاب کنید. مطمئن شوید که فایل <code>mmproj</code> در همان پوشه قرار دارد تا نرم‌افزار به‌صورت خودکار آن را شناسایی کند.</p>
</div>
<div class="step-box" style="background: #f8fafc; border: 1px solid #e2e8f0; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
<strong>گام ۳: تنظیم بهینه GPU Offloading (حیاتی)</strong>
<p class="no-indent" style="margin-top: 10px;">در پنل سمت راست (Hardware Settings):</p>
<ul style="margin-right: 20px; margin-top: 10px;">
<li>گزینه <strong>GPU Offload</strong> را فعال کنید.</li>
<li>اسلایدر را روی عددی بین <strong>۱۵ تا ۲۰ لایه</strong> تنظیم کنید. (این مقدار حدود ۳ تا ۳.۵ گیگابایت از VRAM شما را اشغال می‌کند و فضای باقی‌مانده را برای فایل <code>mmproj</code> و بافرهای سیستمی حفظ می‌نماید).</li>
<li>گزینه <strong>Use Partial Offload</strong> باید فعال باشد.</li>
</ul>
</div>
<div class="step-box" style="background: #f8fafc; border: 1px solid #e2e8f0; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
<strong>گام ۴: پیکربندی پارامترهای تولید (Generation Parameters)</strong>
<p class="no-indent" style="margin-top: 10px;">برای دستیابی به بهترین عملکرد بر اساس توصیه‌های توسعه‌دهنده، مقادیر زیر را تنظیم کنید [[1]]:</p>
<ul style="margin-right: 20px; margin-top: 10px;">
<li><strong>Context Length:</strong> 8192 تا 16384 (بیشتر از این مقدار در حالت چندوجهی ممکن است باعث کندی شود).</li>
<li><strong>Temperature:</strong> 0.7 (برای حالت Instruct) یا 1.0 (برای حالت Reasoning/Thinking).</li>
<li><strong>Top_P:</strong> 0.80 تا 0.95</li>
<li><strong>Repetition Penalty:</strong> 1.0 (بسیار مهم: افزایش این مقدار عملکرد مدل‌های MTP را مختل می‌کند) [[1]].</li>
<li><strong>Min_P:</strong> 0.0</li>
</ul>
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>فعال‌سازی و تست قابلیت چندوجهی (Vision)</h3>
<div class="subtitle">Multimodal (Vision) Activation & Testing</div>
</div>
</div>
<div class="section-content">
<p>پس از اطمینان از بارگذاری صحیح فایل <code>mmproj</code>، آیکون گیره کاغذ (📎) یا آپلود تصویر در رابط کاربری فعال خواهد شد.</p>
<div class="warning-box">
<strong>نکته فنی مهم:</strong> پردازش تصویر به‌صورت پیش‌فرض تمام لایه‌های <code>mmproj</code> را به GPU منتقل می‌کند. اگر با خطای <code>Out of Memory (OOM)</code> مواجه شدید، تعداد لایه‌های مدل اصلی (GPU Offload) را ۲ تا ۳ واحد کاهش دهید تا فضای کافی برای پردازشگر بینایی در VRAM آزاد شود.
</div>
<p><strong>دستور تست پیشنهادی:</strong><br>
یک تصویر حاوی متن یا نمودار آپلود کرده و بپرسید: <br>
<code>"این تصویر را با جزئیات کامل تحلیل کن و داده‌های کلیدی آن را به صورت جدول استخراج کن."</code></p>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>جمع‌بندی و توصیه‌های نهایی</h3>
<div class="subtitle">Conclusion & Final Recommendations</div>
</div>
</div>
<div class="section-content">
<div class="conclusion-box">
<h3>🎯 ارزیابی نهایی معماری</h3>
<p>با پیکربندی پیشنهادی (بارگذاری کامل در RAM + انتقال ۱۵-۲۰ لایه به GPU)، این سیستم قادر است مدل ۹ میلیارد پارامتری چندوجهی را با سرعتی معقول (حدود ۸ تا ۱۵ توکن در ثانیه بسته به CPU) و پایداری کامل اجرا کند.</p>
<div class="highlight">
<strong>💡 توصیه‌های کلیدی برای حفظ پایداری:</strong><br>
۱. از کوانتیزاسیون‌های بالاتر از <code>Q5_K_M</code> خودداری کنید، زیرا فشار غیرضروری به رم سیستم وارد می‌کند.<br>
۲. در صورت استفاده از حالت <strong>MTP</strong> (فایل‌هایی که پسوند MTP دارند)، دمای مدل (Temperature) را حتماً زیر ۱.۰ نگه دارید تا از افت کیفیت جلوگیری شود [[1]].<br>
۳. برای کارهای برنامه‌نویسی دقیق، دما را به ۰.۶ کاهش دهید [[1]].
</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>