توکنها و امبدینگها
هوش مصنوعی برای همه: هوش مصنوعی چطور باهوش شد؟
- Tokenization as dividing text into units that may be words, word parts, punctuation, or other fragments.
- Why visible word counts and model token counts can differ.
- Token identifiers as lookup keys rather than measurements of meaning.
- Embeddings as learned numerical representations.
- A two-dimensional picture of similarity, with the warning that real embeddings usually have many dimensions.
- Context-dependent representations and why a word can have different meanings in different sentences.
- The difference between representations used inside language models and embeddings designed for document retrieval.
واژه یا واحد؟
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><text class="tm-text" font-size="22" x="400" y="55" text-anchor="middle" direction="rtl">«کتابها رسیدند.»</text><rect class="tm-soft" rx="12" x="100" y="105" width="270" height="80"/><rect class="tm-soft" rx="12" x="430" y="105" width="270" height="80"/><text class="tm-text" font-size="18" x="235" y="153" text-anchor="middle" direction="rtl">«کتابها»</text><text class="tm-text" font-size="18" x="565" y="153" text-anchor="middle" direction="rtl">«رسیدند»</text><text class="tm-muted" font-size="16" x="400" y="225" text-anchor="middle" direction="rtl">۲ واژه</text><path class="tm-line" d="M235 190 V260"/><path class="tm-line" d="M565 190 V260"/><rect class="tm-accent" rx="10" x="110" y="275" width="145" height="60"/><rect class="tm-accent" rx="10" x="265" y="275" width="145" height="60"/><rect class="tm-accent" rx="10" x="420" y="275" width="145" height="60"/><rect class="tm-accent" rx="10" x="575" y="275" width="115" height="60"/><text class="tm-text" font-size="16" x="182" y="311" text-anchor="middle" direction="rtl">«کتاب»</text><text class="tm-text" font-size="16" x="337" y="311" text-anchor="middle" direction="rtl">«ها»</text><text class="tm-text" font-size="16" x="492" y="311" text-anchor="middle" direction="rtl">«رسیدند»</text><text class="tm-text" font-size="16" x="632" y="311" text-anchor="middle">«.»</text><text class="tm-text-accent" font-size="18" x="400" y="385" text-anchor="middle" direction="rtl">۴ token</text><text class="tm-muted" font-size="15" x="400" y="425" text-anchor="middle" direction="rtl">نیمفاصله هم بخشی از متن است</text></svg>
```
شناسه با بردار فرق دارد
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><defs><marker id="a" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto"><path d="M0,0 L0,6 L9,3 z" class="tm-arrow"/></marker></defs><rect x="55" y="62" width="190" height="82" rx="12" class="tm-surface"/><text x="150" y="96" text-anchor="middle" class="tm-text" font-size="18" direction="rtl">کتاب</text><text x="150" y="124" text-anchor="middle" class="tm-muted" font-size="15">token</text><rect x="305" y="62" width="190" height="82" rx="12" class="tm-soft"/><text x="400" y="96" text-anchor="middle" class="tm-text" font-size="18" direction="rtl">شناسهٔ ۱۲</text><text x="400" y="124" text-anchor="middle" class="tm-muted" font-size="15" direction="rtl">کلید مدخل</text><rect x="555" y="62" width="190" height="82" rx="12" class="tm-accent tm-pulse"/><text x="650" y="96" text-anchor="middle" class="tm-text" font-size="18" direction="rtl">بردار</text><text x="650" y="124" text-anchor="middle" class="tm-muted" font-size="15" direction="rtl">embedding آموختهشده</text><path d="M245 103 L300 103" class="tm-line" marker-end="url(#a)"/><path d="M495 103 L550 103" class="tm-line-accent" marker-end="url(#a)"/><text x="400" y="220" text-anchor="middle" class="tm-text" font-size="19" direction="rtl">بازنمایی عددی؛ محاسبات روی آن انجام میشود</text><rect x="160" y="285" width="210" height="70" rx="12" class="tm-soft"/><text x="265" y="327" text-anchor="middle" class="tm-text" font-size="18" direction="rtl">مؤلفهها</text><rect x="430" y="285" width="210" height="70" rx="12" class="tm-green"/><text x="535" y="327" text-anchor="middle" class="tm-text" font-size="18" direction="rtl">معنی پخششده</text></svg>
```
شباهت و محدودیت نقشه
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><text class="tm-text2" x="400" y="35" font-size="18" text-anchor="middle" direction="rtl">نقشهٔ دوبعدیِ سندها</text><circle class="tm-accent" cx="220" cy="210" r="12"/><text class="tm-text" x="220" y="245" font-size="15" text-anchor="middle" direction="rtl">راهنمای آبیاری گلدان</text><circle class="tm-green" cx="280" cy="225" r="12"/><text class="tm-text" x="300" y="270" font-size="15" text-anchor="middle" direction="rtl">زمان آب دادن به گیاه آپارتمانی</text><circle class="tm-taupe" cx="610" cy="210" r="12"/><text class="tm-text" x="610" y="245" font-size="15" text-anchor="middle" direction="rtl">روش تعویض لاستیک دوچرخه</text><line class="tm-line-accent" x1="232" y1="213" x2="268" y2="222" stroke-width="3"/><text class="tm-text-accent" x="250" y="180" font-size="14" text-anchor="middle" direction="rtl">نزدیکتر</text><rect class="tm-soft" x="85" y="325" width="630" height="80" rx="12"/><text class="tm-text2" x="400" y="355" font-size="15" text-anchor="middle" direction="rtl">فضای اصلی: بُعدهای بسیار بیشتر</text><text class="tm-muted" x="400" y="382" font-size="14" text-anchor="middle" direction="rtl">فرافکنی دوبعدی: بخشی از اطلاعات کنار میرود؛ فاصلهها ممکن است تغییر کنند</text><text class="tm-muted" x="400" y="430" font-size="13" text-anchor="middle" direction="rtl">محورها لزوماً نامِ معنایی ندارند</text></svg>
```
از بردار اولیه تا بافت
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><defs><marker id="arrow" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto"><path d="M0,0 L0,6 L9,3 z" class="tm-arrow"/></marker></defs><text x="400" y="45" text-anchor="middle" class="tm-text" font-size="22" direction="rtl">یک شناسه، یک بردار اولیه</text><rect x="325" y="80" width="150" height="54" rx="12" class="tm-accent"/><text x="400" y="114" text-anchor="middle" class="tm-text" font-size="20" direction="rtl">«شیر»</text><path d="M400 134 L400 175" class="tm-line" marker-end="url(#arrow)"/><rect x="300" y="180" width="200" height="58" rx="12" class="tm-soft"/><text x="400" y="215" text-anchor="middle" class="tm-text" font-size="18" direction="rtl">بردار اولیه</text><path d="M350 238 L215 273" class="tm-line-accent" marker-end="url(#arrow)"/><path d="M450 238 L585 273" class="tm-line-accent" marker-end="url(#arrow)"/><rect x="75" y="285" width="280" height="105" rx="12" class="tm-surface"/><text x="215" y="320" text-anchor="middle" class="tm-text" font-size="18" direction="rtl">«شیر آب چکه میکند»</text><text x="215" y="358" text-anchor="middle" class="tm-text2" font-size="17" direction="rtl">آب · چکه میکند</text><rect x="445" y="285" width="280" height="105" rx="12" class="tm-surface"/><text x="585" y="320" text-anchor="middle" class="tm-text" font-size="18" direction="rtl">«شیر در جنگل غرش میکند»</text><text x="585" y="358" text-anchor="middle" class="tm-text2" font-size="17" direction="rtl">جنگل · غرش میکند</text><rect x="85" y="400" width="260" height="38" rx="10" class="tm-green tm-enter"/><text x="215" y="425" text-anchor="middle" class="tm-text" font-size="16" direction="rtl">وسیلهٔ کنترل جریان آب</text><rect x="455" y="400" width="260" height="38" rx="10" class="tm-gold tm-enter"/><text x="585" y="425" text-anchor="middle" class="tm-text" font-size="16" direction="rtl">حیوان</text></svg>
```
دو کاربرد متفاوت embedding
```svg
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><defs><marker id="arrow" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto"><path d="M0,0 L0,6 L9,3 z" class="tm-arrow"/></marker></defs><rect x="35" y="55" width="340" height="330" rx="16" class="tm-soft"/><text x="205" y="90" text-anchor="middle" class="tm-text" font-size="20" direction="rtl">مدل زبانی</text><rect x="425" y="55" width="340" height="330" rx="16" class="tm-soft"/><text x="595" y="90" text-anchor="middle" class="tm-text" font-size="20" direction="rtl">جستوجوی سند</text><rect x="90" y="135" width="230" height="55" rx="10" class="tm-surface"/><text x="205" y="170" text-anchor="middle" class="tm-text" font-size="16" direction="rtl">جایگاههای متن</text><line x1="205" y1="190" x2="205" y2="230" class="tm-line" marker-end="url(#arrow)"/><rect x="90" y="235" width="230" height="55" rx="10" class="tm-surface"/><text x="205" y="270" text-anchor="middle" class="tm-text" font-size="16" direction="rtl">بازنمایی هر جایگاه</text><text x="205" y="330" text-anchor="middle" class="tm-muted" font-size="15" direction="rtl">پردازش و پیشبینی ادامه</text><rect x="475" y="135" width="240" height="55" rx="10" class="tm-surface"/><text x="595" y="170" text-anchor="middle" class="tm-text" font-size="16" direction="rtl">پرسش: آب دادن به گلدان</text><line x1="595" y1="190" x2="595" y2="225" class="tm-line" marker-end="url(#arrow)"/><rect x="475" y="230" width="240" height="55" rx="10" class="tm-surface"/><text x="595" y="265" text-anchor="middle" class="tm-text" font-size="16" direction="rtl">embedding پرسش</text><rect x="475" y="310" width="240" height="45" rx="10" class="tm-accent"/><text x="595" y="338" text-anchor="middle" class="tm-text" font-size="15" direction="rtl">سند مرتبط جلوتر</text><text x="595" y="375" text-anchor="middle" class="tm-muted" font-size="13" direction="rtl">شباهت ≠ درستی یا کاملبودن</text></svg>
```
بازگشت به دوره