SentencePiece + Unigram LM (Kudo 2018): Olasılıksal Tokenizasyon ve Subword Regularization
SentencePiece framework + Unigram language model algoritması. Kudo 2018'in olasılıksal yaklaşımı: büyük vocab'tan başla, EM ile budama. Viterbi forward encoding, subword regularization, ▁ whitespace-as-character. Llama, T5, Mistral'in tercihi. Türkçe ve multilingual avantajları.
Şükrü Yusuf KAYA
60 dakikalık okuma
İleri🎲 Tokenization'ı olasılıksal hale getirmek — Llama'nın tokenizer'ı
BPE ve WordPiece tek bir doğru segmentation verir. Unigram LM (Kudo 2018) bunun yerine olasılık dağılımı öğrenir: her token P(x) değeriyle. SentencePiece bunu whitespace-free dilleri (Japonca, Çince) ve multilingual settings için ideal yapan framework. Llama, T5, Mistral hepsi SentencePiece kullanır — modern LLM'in fiili standardı. 60 dakika sonra: Unigram LM training'in EM mantığını, Viterbi encoding'in NP-hard segmentation'ı nasıl polinom zamanda çözdüğünü, subword regularization'ın veri augmentation as tokenization felsefesini tam kavrayacaksın.
Ders Haritası#
- Kavram ayrımı: SentencePiece (framework) vs Unigram LM (algorithm)
- ▁ whitespace-as-character mucizesi — multilingual'ın anahtarı
- Unigram LM'in özü: olasılık dağılımı, segmentation olarak değil
- Training Algorithm: vocab büyük başlat → EM → prune → repeat
- EM step detayı: P(token) güncelleme
- Pruning criterion: ΔL marjinal kazanç
- Viterbi Encoding: en olası segmentation polinom zamanda
- Subword Regularization (Kudo 2018): n-best sampling
- SentencePiece BPE mode vs Unigram mode — kararı
- Byte fallback (2020 update): UNK eliminasyonu
- Türkçe için training + Llama-3 Türkçe analizi
- Egzersizler + summary + FAQ
1. SentencePiece (Framework) vs Unigram LM (Algorithm)#
Yaygın karışıklık#
"SentencePiece kullanıyorum" cümlesi belirsiz. SentencePiece bir framework, içinde dört algoritma var:
| Algoritma | SentencePiece mode | Kim kullanıyor |
|---|---|---|
| BPE | --model_type=bpe | Llama-2 (legacy), GPT-NeoX |
| Unigram LM | --model_type=unigram | Llama-3, T5, mT5, Mistral, XLNet, ALBERT |
| Char | --model_type=char | Nadir, baseline |
| Word | --model_type=word | Nadir, baseline |
"SentencePiece" denildiğinde ne kastediliyor genelde#
Modern: SentencePiece Unigram LM (Kudo 2018). Çünkü en yüksek kalite sonuçlar verir.
SentencePiece framework'ün özelliği#
- Whitespace handling: ile pre-tokenization gerekmez
▁ - Algorithm-agnostic: yukarıdaki dört algo aynı framework
- Byte fallback: rare characters bytes'a düşer
- Fast Rust/C++: production-ready
- Multilingual native: design'dan multilingual
Bu derste odak Unigram LM, ama framework özelliklerini de göreceğiz.
2. ▁ Whitespace-as-Character — Multilingual'ın Anahtarı#
▁Problem#
WordPiece ve klasik BPE whitespace pre-tokenization gerektirir:
"merhaba dünya" → ["merhaba", "dünya"] → her birini tokenize
Japonca/Çince whitespace yok:
"私は学生です" → ??? hangi sınırla bölelim
SentencePiece çözümü: ▁ (U+2581 "lower one eighth block")#
▁Whitespace'i bir karakter olarak korur, input olduğu gibi tokenize edilir:
"merhaba dünya" → "▁merhaba▁dünya" (öne ▁ ekle, space'leri ▁ yap)
▁- = word "merhaba" başlıyor
▁merhaba - = continuation (bir önceki tokenın devamı)
hava
Avantajları#
- Reversible: → orijinal string. Lossless.
tokens.join("").replace("▁", " ") - Whitespace-free dilleri: Japonca için Almanca space gibi davranır, ama her cümle bir tek
▁ile başlar.▁ - No pre-tokenization rule: Multilingual model tek tokenizer ile yüzlerce dilde çalışır.
Türkçe örnek#
Original: "Merhaba dünya" Normalized: "▁Merhaba▁dünya" Llama-3 Unigram LM tokenization: ["▁Merhaba", "▁dünya"] # 2 token Daha karmaşık: "İstanbul Boğazı'nda balıkçı tekneleri sallanıyor." → ["▁İstanbul", "▁Boğazı", "'", "nda", "▁balıkçı", "▁tekne", "leri", "▁sallanıyor", "."]
Dikkat: word-internal continuations taşımıyor (), word-start ile ().
▁leri▁▁tekneKarşılaştırma: GPT-2 byte-level vs SentencePiece#
GPT-2 byte-level: " merhaba dünya" → [" merhaba", " dünya"] # space byte ile token başlar SentencePiece: "merhaba dünya" → ["▁merhaba", "▁dünya"] # ▁ ile word-start
İkisi de same idea (space-as-token-prefix), farklı encoding'le. Pratik fark: GPT-2 byte-level her zaman 256 base byte garanti, SentencePiece char-based (byte fallback opsiyonel).
3. Unigram Language Model'in Özü#
BPE/WordPiece felsefesi#
"İki token'ı deterministik olarak birleştir."
Unigram LM felsefesi#
"Her token'a olasılık ata. Bir cümle için en olası segmentation'ı bul."
Matematiksel formülasyon#
Vocab , her token'ı için olasılık . Cümle için:
V = {x_1, x_2, ..., x_|V|}x_ip(x_i)sP(s) = max over segmentations seg(s): ∏ over token x in seg: p(x)
(Veya alternatif: tüm segmentation'lar üzerinde marginalize:)
P(s) = Σ over seg(s): ∏ over x in seg: p(x)
Niye "Unigram"#
Unigram = her token bağımsız. Markov-0 assumption. Bigram olsaydı olurdu. Unigram'ın basitliği training'i tractable yapar.
p(x_t | x_{t-1})Felsefik fark: belirsizlik kabul edilir#
"playing" kelimesi:
- BPE: deterministic ["play", "##ing"]
- Unigram LM:
- segmentation A = ["play", "ing"], P = p("play") · p("ing") = 0.001 · 0.002 = 2e-6
- segmentation B = ["playing"], P = p("playing") = 5e-7
- segmentation C = ["pla", "y", "ing"], P = 1e-9
- Best (most likely) = A.
Bu, belirsizlik kabul edip en olasıyı seçme yaklaşımı. BPE deterministic olarak benzer sonucu üretir ama Unigram'ın dağılımı farklı applications için kullanılabilir (subword regularization, marginalization).
4. Training Algorithm: Büyük Başla → Buda#
Yaklaşımın paradoksu#
BPE: küçük başla (chars), büyüt (merges).
Unigram LM: büyük başla, küçült.
Niye? Çünkü pruning sırasında her token'ın corpus'a katkısı ölçülebilir. Bottom-up'tan farklı: her aşamada bilgili bir tercih yapıyoruz.
Algoritma yüksek seviye#
1. Initialize vocab V0 (large, ~1M tokens) - All characters + frequent substrings + suffix array candidates 2. Run EM to estimate p(x) for all x in V 3. Compute "loss" for each token (marginal contribution) 4. Remove bottom η% (e.g., 20%) tokens with smallest loss 5. Repeat 2-4 until |V| ≤ target_vocab_size 6. Return final vocab V* and probabilities p(x)
Hyperparameters#
- target_vocab_size: typical 8K, 32K, 64K, 128K
- initial_vocab_size_multiplier: 5-10x target (yani 32K target için 160K-320K init)
- shrink_factor (η): 0.75 (her round %75'e küçült)
- n_iter: EM iterations per round (typical 2)
- n_rounds: total pruning rounds (typical ~10-20)
5. EM Step: P(token) Güncellemesi#
Expectation-Maximization sezgisi#
Her cümle için en olası segmentation'ı bul (E-step). Bu segmentation'lardan token frequencies'i topla, normalize → yeni p(x) (M-step).
sE-step (her cümle için Viterbi forward)#
Cümlenin en olası segmentation'ını dinamik programlama ile bul (Section 7'de detay). Output: token list.
M-step (frequency update)#
def m_step(corpus_segmentations, vocab): counts = defaultdict(int) for seg in corpus_segmentations: for token in seg: counts[token] += 1 total = sum(counts.values()) p = {token: counts[token] / total for token in vocab} return p
Soft EM versus hard EM#
Soft EM: Her segmentation üzerinde marginalize:
E[count(x)] = Σ over seg: P(seg | s) · count(x in seg)
Mathematically purest. Computationally yavaş (tüm segmentation'lar gerekli).
Hard EM (SentencePiece default): Sadece Viterbi best segmentation kullan:
E[count(x)] = count(x in best_seg(s))
Pratik, hızlı, sonuçlar Soft EM'e çok yakın.
Iterations#
Round başına 2 EM iteration genellikle yeterli. Convergence: total log-likelihood çok az değişir.
python
def train_unigram_em(corpus_sentences, vocab, n_iter=2): """Run n_iter EM iterations on corpus to update p(x).""" # Initial p(x) = uniform or seeded from frequency p = init_uniform(vocab) for it in range(n_iter): # ----- E-step ----- all_segmentations = [] for sentence in corpus_sentences: seg = viterbi_best_segmentation(sentence, vocab, p) all_segmentations.append(seg) # ----- M-step ----- counts = defaultdict(int) for seg in all_segmentations: for token in seg: counts[token] += 1 total = sum(counts.values()) new_p = {x: counts.get(x, 0) / total for x in vocab} # Smoothing: add epsilon to prevent p(x) = 0 for x in vocab: if new_p[x] == 0: new_p[x] = 1e-10 # Re-normalize s = sum(new_p.values()) p = {x: new_p[x] / s for x in vocab} return pEM loop pseudocode (hard EM)
6. Pruning: Her Token'ın "Vazgeçilebilirliği"#
EM sonrası elimizde var. Şimdi vocab'ı küçültmek istiyoruz. Hangi token'lar silinmeli?
p(x)Loss = "marjinal katkı"#
Bir token 'i sildiğimizde corpus log-likelihood'unun ne kadar düşeceğini ölç:
xΔL(x) = log P(corpus | V) - log P(corpus | V \ {x})
xxΔL(x)Marjinal katkı düşük → ucuz silinir#
- küçük →
ΔL(x)silinince corpus likelihood çok düşmüyor → safe to removex - büyük →
ΔL(x)kritik → keepx
Sıralama ve budama#
def prune_vocab(vocab, p, corpus, keep_fraction=0.75): losses = {} for x in vocab: if is_basic_char(x): # Skip required chars continue # Compute log-likelihood without x L_without_x = compute_corpus_loglikelihood(corpus, vocab - {x}, p) L_with_x = compute_corpus_loglikelihood(corpus, vocab, p) losses[x] = L_with_x - L_without_x # positive (with > without) sorted_tokens = sorted(losses.items(), key=lambda kv: kv[1]) n_remove = int(len(vocab) * (1 - keep_fraction)) to_remove = set(t for t, _ in sorted_tokens[:n_remove]) return vocab - to_remove
Efficient approximation#
Tüm corpus'u re-segment etmek yerine, sadece x'i içeren segmentation'ları yeniden hesapla. SentencePiece source code Rust ile bunu paralel yapar (her token için marjinal hesaplama bağımsız).
Niye fraction-based (keep 75%) ve bir kerede tek token değil#
Aynı anda %25 silmek hızlı. Tek tek silmek (greedy) daha doğru ama 100x yavaş. Pratik trade-off.
7. Viterbi Encoding: En Olası Segmentation Polinom Zamanda#
Problem#
p(x)sargmax over seg(s): ∏ over x in seg: p(x)
Naive search NP-hard: için olası segmentation sayısı 'e kadar olabilir.
s2^|s|Çözüm: Dynamic Programming#
Viterbi forward algorithm — ( = string length, = max token length).
O(L · M)LMAlgorithm sezgisi#
Her pozisyon için: "Cümlenin prefix'inin en yüksek likelihood segmentation'ı."
is[0:i]best[i](log_prob, prev_index)ibest[0] = (0, -1) # boş prefix, log prob 0 for i in 1..L: best[i] = (-inf, -1) for j in max(0, i-M)..i: substr = s[j:i] if substr in vocab: cand_log_prob = best[j].log_prob + log p(substr) if cand_log_prob > best[i].log_prob: best[i] = (cand_log_prob, j) # Backtrack to recover segmentation tokens = [] i = L while i > 0: j = best[i].prev_index tokens.append(s[j:i]) i = j tokens.reverse()
Karmaşıklık analizi#
- L positions × M token-length candidates per position = O(L · M)
- M typically 10-20 (max token length). L typically 50-200 chars per sentence.
- Pratik: ~1000-5000 operations per sentence. Çok hızlı.
Türkçe örnek#
Sentence: "kitaplarım", vocab: .
{"▁kitap": 0.001, "lar": 0.005, "ım": 0.01, "▁": 0.1, "k": 0.05, ..., "▁kitaplarım": 0.00001}Viterbi forward:
i=0: best[0] = (log 1, none) i=1 ("▁"): best[1] = (log 0.1, 0) i=6 ("▁kitap"): best[6] = (log 0.001, 0) [or via base chars] i=9 ("▁kitaplar"): best[9] = best[6] + log p("lar") = (log 0.001 + log 0.005, 6) i=11 ("▁kitaplarım"): best[11] = best[9] + log p("ım") = (log 0.001 + log 0.005 + log 0.01, 9) Final segmentation: ["▁kitap", "lar", "ım"]
python
import math def viterbi_best_segmentation(s, vocab, p): """ Find best segmentation of s under unigram LM (vocab, p). Returns list of tokens. """ L = len(s) # best[i] = (log_prob, prev_index) best = [(-math.inf, -1)] * (L + 1) best[0] = (0.0, -1) M = max(len(t) for t in vocab) # Or set explicitly e.g. 16 for i in range(1, L + 1): for j in range(max(0, i - M), i): substr = s[j:i] if substr in vocab: cand = best[j][0] + math.log(p[substr]) if cand > best[i][0]: best[i] = (cand, j) # If no valid segmentation, fall back (e.g., byte fallback) if best[L][0] == -math.inf: return None # Caller handles UNK / byte fallback # Backtrack tokens = [] i = L while i > 0: j = best[i][1] tokens.append(s[j:i]) i = j tokens.reverse() return tokensViterbi forward: O(L·M)
8. Subword Regularization (Kudo 2018): Data Augmentation as Tokenization#
Insight#
Training time'da deterministic best segmentation kullanmak yerine, n-best segmentation'lardan örnekleme yap. Bu, modele "aynı cümle farklı tokenize edilebilir" mesajını verir → regularization etkisi.
Pratik mekanizma#
P(seg | s) ∝ exp(α · log P(seg))
α- : deterministic best (no regularization).
α = ∞ - : uniform over n-best.
α = 0 - : pratik aralık.
α ∈ [0.1, 1.0]
Sonuçlar (Kudo 2018 paper)#
- NMT BLEU +0.3 to +0.8 improvement.
- Low-resource languages özellikle benefit.
- Inference time'da deterministic kullan (regularization sadece training).
Pratik ayarlar#
import sentencepiece as spm sp = spm.SentencePieceProcessor(model_file="tr-unigram.model") # Deterministic (inference time) ids_det = sp.encode("Merhaba dünya", out_type=int) # Sampling (training time) ids_samp = sp.encode("Merhaba dünya", out_type=int, enable_sampling=True, alpha=0.1, nbest_size=-1)
Modern alternatif: BPE-dropout (Provilkov 2020)#
BPE için aynı fikri uygular: training'de random olarak bazı merge rule'larını skip et. Llama paper'larında kullanılmadı (deterministic BPE), ama yeni nesil tokenizer training'de görülüyor.
9. SentencePiece BPE vs Unigram Mode — Hangisi Ne Zaman#
Implementation farkları#
- BPE mode: Klasik BPE algoritması, sadece SentencePiece framework içinde paketlenmiş. whitespace handling + byte fallback ekleri.
▁ - Unigram mode: Bu derste anlatılan probabilistic algorithm.
Empirical karşılaştırma (Llama-2 paper, public Llama-3 reports)#
| Metrik | SP BPE | SP Unigram | Galip |
|---|---|---|---|
| Training time | Daha hızlı | Daha yavaş (10-50x) | BPE |
| Inference time | O(V·L) | O(L·M) ~ daha hızlı | Unigram |
| Vocab quality (perplexity) | Baseline | %2-5 daha düşük perplexity | Unigram |
| Multilingual | İyi | Çok iyi | Unigram |
| Determinism | %100 | Sample mümkün | Application |
| Subword regularization | Yok (BPE-dropout extras) | Built-in | Unigram |
| Memory footprint | Düşük | Düşük | Eşit |
Gerçek dünya kararları#
- Llama-2 (Meta, 2023): SentencePiece BPE mode, 32K vocab. Cause: production stability tercihi.
- Llama-3 (Meta, 2024): tiktoken BPE (cl100k-style), 128K vocab. Geri BPE'ye dönüş — çünkü Llama-3 multilingual'ı genişletti ama BPE+byte yeterince güçlü.
- T5 (Google, 2019): SentencePiece Unigram, 32K vocab. Tradition.
- Mistral (2023): SentencePiece BPE, 32K vocab.
- Gemini (2024): Custom tokenizer, public details limited (muhtemelen BPE variant).
2026 trendi#
Modern LLM'lerin çoğu byte-level BPE veya tiktoken-style BPE'ye kaydı. Unigram LM encoder-style ve multilingual seq2seq (T5, mT5) için hâlâ güçlü.
10. Byte Fallback — UNK'in Eliminasyonu (2020+ Update)#
Klasik SentencePiece (pre-2020)#
Vocab'da olmayan char → . WordPiece'le aynı problem.
<unk>Modern SentencePiece (2020+)#
--byte_fallback=true"naïve" — assume "ï" not in vocab SentencePiece byte fallback ON: → ["▁na", "<0xC3>", "<0xAF>", "ve"] # ï UTF-8: 0xC3 0xAF byte fallback OFF: → ["▁na", "<unk>", "ve"]
Vocab'a 256 byte token ekle#
Special tokens olarak ... (256 byte) eklenir. Vocab her zaman bu byte'ları içerir.
<0x00><0xFF>Sonuç: UNK eliminated#
Llama, Mistral byte fallback'i kullanır → asla UNK üretmezler. Üretim sisteminde invariant.
Trade-off#
- Pro: robustness, multilingual, asla UNK
- Con: rare chars 1-3 byte token harcar (Türkçe'de minor problem, ASCII dışı rare chars)
Türkçe etkisi#
Türkçe karakterler (ÇĞİÖŞÜçğıöşü) çoğu zaman vocab'da yer kazanır (frequent). Byte fallback emoji, rare Unicode, math sembol gibi durumlar için.
11. Türkçe İçin SentencePiece Unigram Training#
python
import sentencepiece as spm # Türkçe corpus dosyalarıinput_files = "corpus/wiki-tr.txt,corpus/news-tr.txt,corpus/literature-tr.txt" spm.SentencePieceTrainer.train( input=input_files, model_prefix="tr-unigram-32k", vocab_size=32000, model_type="unigram", character_coverage=0.9995, # Türkçe için 0.9995 (%99.95 char coverage) input_sentence_size=10_000_000, # Subsample for speed shuffle_input_sentence=True, # Whitespace marker (default ▁) add_dummy_prefix=True, remove_extra_whitespaces=True, # Pretokenization (default off — Unigram'ın güzelliği) split_by_whitespace=True, # True for Western, False for CJK split_by_unicode_script=True, # Byte fallback byte_fallback=True, # Special tokens pad_id=0, unk_id=1, bos_id=2, eos_id=3, user_defined_symbols=["<|im_start|>", "<|im_end|>", "<|user|>", "<|assistant|>"], # EM iterations num_threads=16, num_sub_iterations=2, max_sentencepiece_length=16, # Pruning seed_sentencepiece_size=1_000_000, shrinking_factor=0.75,) # Train log: "starting EM training... iteration 0: vocab=160000 ..."# Final: tr-unigram-32k.model, tr-unigram-32k.vocab files # Loadsp = spm.SentencePieceProcessor(model_file="tr-unigram-32k.model")print(sp.encode("İstanbul Boğazı'nda balıkçı tekneleri.", out_type=str))# Expected: ['▁İstanbul', '▁Boğazı', "'", 'nda', '▁balıkçı', '▁tekne', 'leri', '.']Türkçe SentencePiece Unigram training (production-grade config)
Training Notları (Production)#
- character_coverage: Türkçe için 0.9995 (rare chars'a byte fallback). Japonca için 0.9999 (daha fazla char). İngilizce için 1.0 OK.
- vocab_size: Türkçe-only 32K sweet spot. Multilingual TR-EN 50K-64K. TR-multilang 100K+.
- num_threads: 16-core CPU → 32 thread = 2x oversubscription pratik (linear scaling 16'ya kadar).
- max_sentencepiece_length: 16 default OK. 8 daha küçük token'lar (yavaş encoding), 24 daha rare uzun token'lar.
- input_sentence_size: Çok büyük corpus için 10M sentence subsample yeterli (>10M çok büyük speedup vermez).
- byte_fallback: True her zaman. Üretimde UNK istemezsin.
- add_dummy_prefix: True (her cümle başına ekle). Decoding'de strip edilir.
▁
Training time benchmark (Türkçe 5GB Wiki + 5GB OSCAR-tr)#
- 16-core Intel Xeon: ~45 minutes
- 32-core EPYC: ~22 minutes
- 64-core: ~12 minutes (diminishing returns)
Output dosyaları#
- (~500KB-2MB): Protocol Buffers binary
tr-unigram-32k.model - (~250KB): "token\tlog_prob" per line, human readable
tr-unigram-32k.vocab
12. Llama-3 ve Türkçe — Modern Multilingual Tokenization#
Llama-3 tokenizer#
- Algorithm: BPE (tiktoken-style, byte-level)
- Vocab: 128K
- Source: Public tiktoken benzeri (GPT-4o tarzı)
o200k_base - NOT SentencePiece anymore (Llama-2'den geri çekildi)
Llama-2 vs Llama-3 Türkçe fertility karşılaştırması#
| Tokenizer | Türkçe corpus fertility | Niye |
|---|---|---|
| Llama-2 (SP BPE 32K) | 2.4 token/word | English-dominant corpus |
| Llama-3 (BPE 128K) | 1.7 token/word | 4x vocab + multilingual |
| Trendyol-LLM (SP BPE 32K, TR-balanced) | 1.4 token/word | TR-focused |
| GPT-4o (o200k 200K) | 1.5 token/word | 200K multilingual |
| BERT-base-Turkish (WP 32K) | 1.55 token/word | TR-only |
Conclusion#
TR-only 32K vocab modeller multilingual 100K+'dan hâlâ daha verimli Türkçe için. Multilingual'ın avantajı: tek model çoklu dil. TR-only'ın avantajı: token efficiency.
Capstone bağlantısı#
Modül 6.10 capstone: TR-balanced Unigram LM 32K eğit, Llama-3'ten daha düşük fertility'ye ulaş (target: 1.3-1.4 token/word).
13. Egzersizler#
Egzersiz 1#
Unigram LM training'de niye büyük başla, küçült yaklaşımı kullanılıyor? Bottom-up (BPE gibi) yapılsa ne dezavantaj olur?
Egzersiz 2#
Viterbi forward algorithm'in karmaşıklığı O(L·M). Eğer M (max token length) sabit değil de L'ye lineer büyürse, karmaşıklık ne olur?
Egzersiz 3#
Subword regularization (n-best sampling) inference time'da uygulansa ne olur? Pro/Con açıkla.
Egzersiz 4#
Vocab'da , , , token'ları var. "kitaplarım" cümlesinin iki olası segmentation'ını ve hangisinin tercih edileceğini açıkla (p(▁kitap)=0.001, p(▁kitaplar)=0.0005, p(lar)=0.005, p(ım)=0.01).
▁kitap▁kitaplarlarımEgzersiz 5#
SentencePiece byte fallback ON. Türkçede emoji "🇹🇷" (4 byte: 0xF0 0x9F 0x87 0xB9 0xF0 0x9F 0x87 0xB7) nasıl tokenize edilir? Toplam token sayısı?
Egzersiz 6#
Llama-3 SentencePiece'ten BPE'ye geçti. Bu kararı şu açılardan değerlendir: (1) multilingual coverage, (2) inference speed, (3) training cost, (4) ecosystem compat.
✅ Ders 6.5 Özeti — Olasılıksal Tokenization'ın Gücü
SentencePiece Unigram LM olasılıksal bir tokenization yaklaşımı: deterministik segmentation yerine dağılım, big-vocab-then-prune felsefesi, EM training, Viterbi encoding. whitespace-as-character ile multilingual native, byte fallback ile UNK'siz. Llama-2, T5, Mistral'in tokenizer'ı. Subword regularization training-time data augmentation olarak çalışır. 2024'te Llama-3 BPE'ye geri döndü ama SP Unigram encoder family + multilingual seq2seq için hâlâ güçlü. Modül 6.6'da GPT-style byte-level BPE ve tiktoken regex pre-tokenizer'ı keşfedeceğiz.
▁Sıradaki Ders: GPT-2/GPT-4 Byte-Level BPE + tiktoken Regex#
Modül 6.6'da: GPT serisinin tokenizer'ları — niye byte-level, regex pre-tokenizer'ın gücü, GPT-2 50K vs GPT-3.5 100K (cl100k) vs GPT-4o 200K (o200k) evrim. tiktoken library production-grade kullanım, prompt engineering için token counting kritikliği, Türkçe maliyet ekonomisi.
Sık Sorulan Sorular
İki sebep: (1) Kudo (SentencePiece yazarı) 2018'de Unigram LM'i SP framework ile birlikte tanıttı — birlikte popüler oldular. (2) Unigram LM **özgün katkı**, BPE zaten vardı. Pratikte 'SentencePiece' = 'SentencePiece Unigram' yaygın algı, ama framework her iki algo'yu destekler.
Yorumlar & Soru-Cevap
(0)Yorum yazmak için giriş yap.
Yorumlar yükleniyor...
İlgili İçerikler
Modül 0: Kurs Çerçevesi ve Atölye Kurulumu
LLM Engineer Kimdir? Junior'dan Staff'a Yapay Zekâ Mühendisliği Kariyer Haritası
Öğrenmeye BaşlaModül 0: Kurs Çerçevesi ve Atölye Kurulumu
Kurs Felsefesi: Neden Bu Yol, Neden Bu Sıra — 8 Aylık Müfredatın İskeleti
Öğrenmeye BaşlaModül 0: Kurs Çerçevesi ve Atölye Kurulumu