Thomas Seri commited on
Commit ·
b7e149f
1
Parent(s): 5794035
README: rimossi numeri senza fonte (energia, modelli esterni), 'record' -> 'migliore tra gli R-08', brevetti UIBM senza numero non verificato
Browse filesFiles changed (23)
- .gitattributesDeleted-3
- .gitignoreDeleted-6
- LICENSE.mdDeleted-63
- README.md+5-6
- assets/r08_logo.jpgDeleted
- config.jsonDeleted-50
- model.safetensorsDeleted-3
- modeling_transformer.pyDeleted-261
- pezzi_tokenizer.pyDeleted-228
- special_tokens_map.jsonDeleted-7
- test_inference.pyDeleted-26
- tokenizer.jsonDeleted-1267
- tokenizer_config.jsonDeleted-9
- transformer-baseline-45m-f16.ggufDeleted-3
- vocab_stages.pyDeleted-971
- vocab_stages/00_pezzi_by_id.meta.jsonDeleted-17
- vocab_stages/00_pezzi_by_id.txtDeleted-1253
- vocab_stages/01_parole_by_id.meta.jsonDeleted-100
- vocab_stages/01_parole_by_id.txtDeleted
- vocab_stages/02_unioni_by_id.meta.jsonDeleted-122
- vocab_stages/02_unioni_by_id.txtDeleted
- vocab_stages/counts_summary.jsonDeleted-10
- vocab_stages/manifest.jsonDeleted-25
123*.safetensors filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -texttransformer-baseline-45m-f16.gguf filter=lfs diff=lfs merge=lfs -text123456__pycache__/*.pyc.DS_Store*.pt*.safetensorsupload_to_hf.py123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263# R08 — NON-COMMERCIAL RESEARCH & ETHICAL LICENSE (v2.0)
Copyright (c) 2026 Thomas Seri. All Rights Reserved.
---
### 1. DEFINITIONS- **"Author"** means Thomas Seri (Sentinel).- **"Software"** means the R08 / R-08 (Rob) Geodesic Mesh Neural Network architecture, model weights, checkpoints, Watchman Keystone modules, Knowledge Tree ontologies, tokenizers (`gpTommy`), search engines, configurations, and documentation provided herein for Sentinel LifeOS.- **"Commercial Use"** means using the Software or any derivative work in any business, for-profit venture, service provision, integration into commercial applications, or for any activity generating revenue.- **"Non-Commercial Research Use"** means using the Software solely for personal education, academic study, reproducibility evaluation, and non-profit benchmarking.
---
### 2. GRANT OF PERMISSIONSubject to the terms and restrictions of this License, the Author grants you a personal, worldwide, royalty-free, non-exclusive, non-transferable license to:1. Download, view, and inspect the code and weights.2. Run inference for Non-Commercial Research Use only.3. Cite and reference the architecture and benchmark results in academic or research publications, provided that prominent attribution is given to **Thomas Seri** and **Sentinel AI**.
---
### 3. RESTRICTIONS & PROHIBITIONSYou shall NOT:1. Use the Software or any portion thereof for any Commercial Use without a separate, written, commercial license agreement signed by the Author (**Thomas Seri**).2. Sublicense, lease, sell, rent, or distribute modified copies of the Software for commercial purposes.3. Reverse-engineer, distill, extract weights, train competing models on synthetic outputs, or replicate proprietary architectural features (including 3-stage geodesic cascades, 12 icosahedral hub pyramids, and 1D causal inter-sphere convolutions) for deployment in commercial or third-party products without prior written authorization from **Thomas Seri**.4. Remove, alter, obfuscate, or circumvent the Author's attribution (**Thomas Seri**), this License (`LICENSE.md`), or the integrated **Watchman Keystone (`watchman_keystone_r08.py`)** security and ethical manifold.
---
### 3.1 STRICT ETHICAL RESTRICTIONS & PROHIBITED USES (ACCEPTABLE USE POLICY)It is strictly, unconditionally, and globally FORBIDDEN to use the Software, model weights, checkpoints, architecture, code, or any derivative works for:1. **Military, Defense & Warfare**: Weapons development, explosives, chemical/biological/nuclear agents, autonomous defense systems, suicide/combat drones, missile targeting, tactical combat simulations, warfare logistics, or military applications of any kind.2. **Religious Propaganda & Indoctrination**: Proselytism, forced religious manipulation, spiritual coercion, cult indoctrination, or automated doctrinal dissemination.3. **Inappropriate Images, Pornography & Sexual Exploitation**: Generation, prompting, processing, or dissemination of inappropriate images (NSFW), sexually explicit content, pornography, non-consensual nudity/deepfakes, CSAM, or sexual exploitation of any kind.4. **Cyberattacks, Malware & Industrial Sabotage**: Writing, training, or deploying computer malware, ransomware, trojans, keyloggers, zero-day exploits, phishing kits, unauthorized network intrusion tools, or attacks/sabotage on industrial PLCs, SCADA systems, and critical infrastructure (healthcare, energy, water, finance).5. **Addictions, Gambling, Illicit Drugs & Self-Harm**: Promotion or automation of gambling, online casinos, slot/betting manipulation algorithms, synthesis or distribution of illicit drugs, or encouragement/instruction of suicide, self-harm, or violence.6. **Political Campaigns & Partisan Propaganda**: Electoral manipulation, voter persuasion bots, automated political astroturfing, partisan lobbying, candidate campaigns, or deceptive political disinformation/fake news.7. **High-Risk Autonomous Decisions (Medical & Financial)**: Autonomous clinical diagnosis, prescription of medication, or unmonitored financial trading without certified human professional oversight.8. **Surveillance, Biometric Profiling & GDPR Privacy Violations**: Mass biometric surveillance, facial tracking without consent, racial/ethnic predictive policing, discrimination based on race, gender, religion, or nationality, or unauthorized extraction/storage of personal identifiable financial data (such as cleartext or obfuscated IBANs and credit card numbers).
**IMMEDIATE REVOCATION CLAUSE:** ANY USE VIOLATING THIS SECTION IMMEDIATELY AND AUTOMATICALLY REVOKES ALL PERMISSIONS AND LICENSES GRANTED HEREIN WITH RETROACTIVE EFFECT, RENDERING ANY ONGOING POSSESSION OR USE OF THE SOFTWARE AN ILLEGAL INFRINGEMENT OF THE AUTHOR'S INTELLECTUAL PROPERTY AND COPYRIGHT.
---
### 4. COPYRIGHT, TRADEMARK & CRYPTOGRAPHIC WATCHMAN PROTECTIONThe names **"Sentinel"**, **"Sentinel LifeOS"**, **"Sentinel AI"**, **"R-08"**, **"R08"**, **"gpTommy"**, and **"Thomas Seri"** are protected identities, trade names, and trademarks of the Author. No license is granted herein to use these names, logos, or marks for trade, commercial advertising, or to imply any endorsement, affiliation, or sponsorship of any third-party product, service, or company without prior, express written authorization from **Thomas Seri**.
**CRYPTOGRAPHIC & GEODESIC WATCHMAN KEYSTONE NOTICE:** The neural weights (`model.safetensors`) and inference runtime (`modeling_geodesic.py`, `watchman_keystone_r08.py`) incorporate a non-linear symplectic manifold (`GELU + SiLU + Tanh`), an orthogonal cryptographic projection lock (`SHA3-512`), and multi-layer forensic watermarks tied to **Thomas Seri** and this License. Any tampering with this License, the Author attribution, or the Watchman Keystone invalidates the projection manifold and constitutes unlawful circumvention of technological protection measures.
---
### 5. DISCLAIMER OF WARRANTY & LIMITATION OF LIABILITYTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
**MEDICAL, FINANCIAL & LEGAL DISCLAIMER:** The Software is an experimental research system. The outputs generated by this model do NOT constitute certified medical advice, legal counsel, or financial/investment recommendations. The Author and Sentinel AI shall have NO liability for any personal injury, financial loss, legal liability, or damages arising directly or indirectly from decisions made based on outputs of the Software. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---
For commercial licensing, enterprise partnerships, or integration inquiries:Contact: **Thomas Seri** / **Sentinel AI**Website: https://www.sentinelhub.eu22 unmodified lines232425262627282910 unmodified lines404142434344454619 unmodified lines6667686970697071727373747512 unmodified lines888990929192939422 unmodified lines> [!NOTE]> **Modello di Controllo per il Paragone con l'Architettura Geodetica Sentinel R-08:** > Questo modello Transformer denso da 44.9M parametri e 14 strati di attenzione con vocabolario a 1.2k pezzi è stato addestrato da **Thomas Seri** appositamente come modello di controllo per confrontare in modo scientifico, a parità di token e vocabolario, le prestazioni con la famiglia **Sentinel R-08**:> - 🌟 **Nuovo Sentinel R-08 v7.2a DA ZERO (51.6M, 12 Hubs, Record 82.51% BLiMP-IT):** [SentinelHub/R-08-v7.2a su Hugging Face](https://huggingface.co/SentinelHub/R-08-v7.2a) | [GitHub v7.2a](https://github.com/Thomasseri/R-08-v7.2a)> - 🌟 **Nuovo Sentinel R-08 v7.2a DA ZERO (51.6M, 12 Hubs, 82.51% BLiMP-IT, migliore tra gli R-08):** [SentinelHub/R-08-v7.2a su Hugging Face](https://huggingface.co/SentinelHub/R-08-v7.2a) | [GitHub v7.2a](https://github.com/Thomasseri/R-08-v7.2a)> - 🚀 **Sentinel R-08 v7.2 Warm-Start (51.6M, 12 Hubs + 1D Conv):** [SentinelHub/R-08-v7.2 su Hugging Face](https://huggingface.co/SentinelHub/R-08-v7.2) | [GitHub v7.2](https://github.com/Thomasseri/R-08-v7.2)> - 🌐 **Sentinel R-08 v7 Pyramid (44.5M):** [SentinelHub/R-08 su Hugging Face](https://huggingface.co/SentinelHub/R-08) | [GitHub](https://github.com/Thomasseri/R-08)
10 unmodified lines---
> ### 💼 Investment, Compute Grants & Enterprise Licensing (Investimenti & Partnership Industriali)> 🇬🇧 **Sentinel** is scaling the **Geodesic Pyramidal Sphere Architecture (`R-08`)** from 50M to **110M–1B+ parameters**, backed by **18 industrial patent filings** (Non-Euclidean Geodesic Mesh, Isomorphic `SSvvv` Lexical-Voice Engine, Post-Quantum Tamper-Resistant Keystone Security, Edge & Autonomous Systems). > 🇬🇧 **Sentinel** is scaling the **Geodesic Pyramidal Sphere Architecture (`R-08`)** from 50M to **110M–1B+ parameters**, with **patent applications filed at the Italian Patent and Trademark Office (UIBM)**. > **Open to Seed / Deep-Tech Investment, GPU/TPU Compute Grants, and Enterprise R&D Partnerships.** > 🇮🇹 **Aperto a Investimenti Seed / Deep-Tech, Grant Computazionali GPU/TPU e Licenze Industriali Enterprise.** > 📩 **Contact Founder & Inventor Thomas Seri:** 🌐 **[www.sentinelhub.eu](https://www.sentinelhub.eu)** | 🐙 **[GitHub (@Thomasseri)](https://github.com/Thomasseri)** | 🤗 **[Hugging Face (@SentinelHub)](https://huggingface.co/SentinelHub)** | 💬 **[Open an Inquiry / Issue](https://github.com/Thomasseri/R-08/issues/new)**19 unmodified lines| **Parametri Totali** | **44.5M** | **51.6M** | **51.6M** | 44.9M | 44.9M | Pesi equivalenti (~45-51M) || **Strati di Attenzione Densa** | **2 strati** | **2 strati** | **2 strati** | 14 strati | 14 strati | **-85.7% strati densi** || **Vocabolario Subword** | **1.251 pezzi** | **1.251 pezzi** | **1.251 pezzi** | 1.251 pezzi | 1.251 pezzi | Identico (1.2k) || **BLiMP-IT (Accuratezza Grammaticale)** | **80.95%** | **82.02%** | **82.51%** 🏆 | 82.53% | **85.84%** | R08 record 82.51% con soli 2 strati || **MultiBLiMP (Ragionamento Sintattico)** | **73.46%** | **73.46%** | **76.71%** 🏆 | 85.15% | **86.83%** | Solida base logica || **BLiMP-IT (Accuratezza Grammaticale)** | **80.95%** | **82.02%** | **82.51%** | 82.53% | **85.84%** | Migliore R-08: 82.51% con 2 strati || **MultiBLiMP (Ragionamento Sintattico)** | **73.46%** | **73.46%** | **76.71%** | 85.15% | **86.83%** | Solida base logica || **Resistenza Allucinazioni (Zero-Shot)** | **62.5%** *(Fatti 4/4)* | **56.2%** *(Fatti 3/4)* | **56.2%** *(Fatti 4/4 100%)* | 56.2% | **68.8%** *(Fatti 4/4)* | R08 zero allucinazioni sui fatti || **Throughput Training (MPS)** | **~10.150 tok/s** | **~7.200 tok/s** | **~7.694 tok/s** | ~8.650 tok/s | ~8.650 tok/s | Elevata efficienza computazionale || **Consumo Energetico per Token** | **2.3 mJ / tok** | **2.4 mJ / tok** | **2.4 mJ / tok** | 3.3 mJ / tok | 3.3 mJ / tok | **-27.3% / -30.3% consumo energetico** 🔋 || **Impronta Memoria KV-Cache (512 ctx)** | **0.8 MB** *(2.1 MB/seq)* | **0.8 MB** *(2.1 MB/seq)* | **0.8 MB** *(2.1 MB/seq)* | 5.6 MB *(14.7 MB/seq)* | 5.6 MB *(14.7 MB/seq)* | **-85.7% traffico RAM/Cache** 💾 |
---12 unmodified lines
1. **Trade-off Accuratezza vs Risorse:** - Il Transformer denso a 14 strati raggiunge un'accuratezza linguistica dell'85.84% su BLiMP-IT grazie all'elevato numero di matrici $Q \times K^T$ dense su tutta la profondità della rete. - Tuttavia, questo comporta un **consumo energetico superiore del +31.2%** e un'impronta di memoria **KV-Cache 7 volte maggiore** (5.6 MB vs 0.8 MB per sequenza). - Tuttavia, questo comporta un'impronta di memoria **KV-Cache 7 volte maggiore** (5.6 MB vs 0.8 MB per sequenza).2. **Efficienza Geodetica di R-08:** - Sentinel R-08 raggiunge l'**80.95%** su BLiMP-IT eliminando l'85.7% dell'attenzione densa e sostituendola con il routing sferico triangolare a 80 facce, dimostrando un'efficienza ideale per Edge AI e dispositivi embedded a batteria.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950{ "architectures": [ "BaselineTransformer" ], "model_type": "gpt2", "auto_map": { "AutoConfig": "modeling_transformer.TransformerConfig", "AutoModel": "modeling_transformer.BaselineTransformer", "AutoModelForCausalLM": "modeling_transformer.BaselineTransformer" }, "vocab_size": 1251, "n_positions": 256, "n_embd": 512, "d_model": 512, "n_layer": 14, "n_layers": 14, "n_head": 8, "n_heads": 8, "head_dim": 64, "n_inner": 2048, "mlp_dim": 2048, "max_seq_len": 256, "dropout": 0.0, "activation_function": "gelu", "layer_norm_epsilon": 1e-05, "num_parameters": 44905984, "weight_tying": true, "pretrain_steps": 185000, "midtrain_steps": 10000, "training_corpus": "v22_chinchilla_mix (740M tokens, Chinchilla-optimal)", "midtrain_corpus": "v23_midtrain (curated high-density knowledge & dialogues)", "author": "Thomas Seri (Sentinel)", "project": "Sentinel R-08 Architectural Benchmark Suite", "comparative_target": "Sentinel R-08 v7 Pyramid", "gguf_file": "transformer-baseline-45m-f16.gguf", "benchmarks": { "blimp_it_pretrain": 82.53, "blimp_it_midtrain": 85.84, "multiblimp_pretrain": 85.15, "multiblimp_midtrain": 86.83, "truth_rate_pretrain": 56.2, "truth_rate_midtrain": 68.8, "training_throughput_tok_per_sec": 8650, "energy_per_token_mj": 3.3, "kv_cache_ram_at_512_mb": 5.6 }, "license": "R08-Non-Commercial-Ethical-License-v2.0", "jurisdiction": "Court of Milan (Sezione Specializzata in Materia di Impresa), Italy", "prohibited_uses": "Commercial, Military, Defense, Clean-Room Reverse Engineering, Model Distillation"}123version https://git-lfs.github.com/spec/v1oid sha256:a8ae49ce84d803bff399fcd61d5f75b265d9dce7b322f56cbf563fcede9c12c1size 182201856123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261# ============================================================================# LEGAL NOTICE & WATERMARK: R08 NON-COMMERCIAL RESEARCH & ETHICAL LICENSE v2.0# Copyright (c) 2026 Thomas Seri (Sentinel). All Rights Reserved.# Exclusive Jurisdiction: Court of Milan (Sezione Specializzata Impresa), Italy.# Clean-room reverse engineering, distillation, commercial or military use# is strictly prohibited and constitutes a breach of contract.# ============================================================================__author__ = "Thomas Seri (Sentinel)"__license__ = "R08-Non-Commercial-Ethical-License-v2.0"__jurisdiction__ = "Court of Milan, Italy"
#!/usr/bin/env python3"""Transformer Baseline 45M — Dense GPT-2 Architecture (14 Attention Layers)Official Hugging Face / PyTorch implementation for comparative A/B benchmarking vs Sentinel R-08.Author: Thomas Seri (Sentinel LifeOS)"""from __future__ import annotations
import jsonimport mathfrom dataclasses import dataclass, fieldsfrom pathlib import Pathfrom typing import List, Optional, Tuple, Union
import torchimport torch.nn as nnimport torch.nn.functional as Ffrom safetensors.torch import load_file
import pezzi_tokenizer as ptfrom vocab_stages import load_bundle, StageBundle
@dataclassclass TransformerConfig: vocab_size: int = 1251 d_model: int = 512 n_layers: int = 14 n_heads: int = 8 max_seq_len: int = 256 dropout: float = 0.0
@classmethod def from_dict(cls, d: dict) -> "TransformerConfig": names = {f.name for f in fields(cls)} return cls(**{k: v for k, v in d.items() if k in names})
class CausalSelfAttention(nn.Module): def __init__(self, cfg: TransformerConfig): super().__init__() if cfg.d_model % cfg.n_heads != 0: raise ValueError(f"d_model={cfg.d_model} non divisibile per n_heads={cfg.n_heads}") self.n_heads = cfg.n_heads self.head_dim = cfg.d_model // cfg.n_heads self.qkv = nn.Linear(cfg.d_model, 3 * cfg.d_model) self.proj = nn.Linear(cfg.d_model, cfg.d_model) self.attn_dropout = float(cfg.dropout) self.resid_drop = nn.Dropout(cfg.dropout)
def forward(self, x: torch.Tensor) -> torch.Tensor: b, t, d = x.shape q, k, v = self.qkv(x).view(b, t, 3, self.n_heads, self.head_dim).permute(2, 0, 3, 1, 4) y = F.scaled_dot_product_attention( q, k, v, is_causal=True, dropout_p=self.attn_dropout if self.training else 0.0 ) return self.resid_drop(self.proj(y.transpose(1, 2).reshape(b, t, d)))
class MLP(nn.Module): def __init__(self, cfg: TransformerConfig): super().__init__() self.fc = nn.Linear(cfg.d_model, 4 * cfg.d_model) self.proj = nn.Linear(4 * cfg.d_model, cfg.d_model) self.drop = nn.Dropout(cfg.dropout)
def forward(self, x: torch.Tensor) -> torch.Tensor: return self.drop(self.proj(F.gelu(self.fc(x))))
class Block(nn.Module): def __init__(self, cfg: TransformerConfig): super().__init__() self.ln1 = nn.LayerNorm(cfg.d_model) self.attn = CausalSelfAttention(cfg) self.ln2 = nn.LayerNorm(cfg.d_model) self.mlp = MLP(cfg)
def forward(self, x: torch.Tensor) -> torch.Tensor: x = x + self.attn(self.ln1(x)) return x + self.mlp(self.ln2(x))
class BaselineTransformer(nn.Module): def __init__(self, cfg: TransformerConfig): super().__init__() self.cfg = cfg self.tok_emb = nn.Embedding(cfg.vocab_size, cfg.d_model) self.pos_emb = nn.Embedding(cfg.max_seq_len, cfg.d_model) self.drop = nn.Dropout(cfg.dropout) self.blocks = nn.ModuleList([Block(cfg) for _ in range(cfg.n_layers)]) self.ln_f = nn.LayerNorm(cfg.d_model) self.lm_head = nn.Linear(cfg.d_model, cfg.vocab_size, bias=False) self.lm_head.weight = self.tok_emb.weight self.apply(self._init_weights) std_res = 0.02 / math.sqrt(2 * cfg.n_layers) for blk in self.blocks: nn.init.normal_(blk.attn.proj.weight, mean=0.0, std=std_res) nn.init.normal_(blk.mlp.proj.weight, mean=0.0, std=std_res)
@staticmethod def _init_weights(m: nn.Module) -> None: if isinstance(m, nn.Linear): nn.init.normal_(m.weight, mean=0.0, std=0.02) if m.bias is not None: nn.init.zeros_(m.bias) elif isinstance(m, nn.Embedding): nn.init.normal_(m.weight, mean=0.0, std=0.02)
def forward( self, pezzi_ids: torch.Tensor, parole_ids: Optional[torch.Tensor] = None, unioni_ids: Optional[torch.Tensor] = None, record_path: bool = False, ) -> Tuple[torch.Tensor, None]: b, t = pezzi_ids.shape if t > self.cfg.max_seq_len: raise ValueError(f"seq_len={t} > max_seq_len={self.cfg.max_seq_len}") pos = torch.arange(t, device=pezzi_ids.device) h = self.drop(self.tok_emb(pezzi_ids) + self.pos_emb(pos)) for blk in self.blocks: h = blk(h) return self.lm_head(self.ln_f(h)), None
class TransformerTokenizer: """Tokenizer a subword (1.251 pezzi) identico a Sentinel R-08."""
def __init__(self, bundle: StageBundle): self.bundle = bundle self.pezzi = bundle.pezzi self.eos_id = int(getattr(bundle.pezzi, "eos_id", 2)) self.pad_id = int(getattr(bundle.pezzi, "pad_id", 3))
@classmethod def from_pretrained(cls, pretrained_path: Union[str, Path]) -> "TransformerTokenizer": root = Path(pretrained_path) vocab_dir = root / "vocab_stages" if (root / "vocab_stages").exists() else root bundle = load_bundle(vocab_dir) return cls(bundle)
def encode(self, text: str) -> List[int]: return pt.encode(text, self.pezzi)
def decode(self, token_ids: List[int]) -> str: return pt.decode(token_ids, self.pezzi)
class TransformerModel(nn.Module): """Interfaccia Hugging Face friendly per il modello Transformer Baseline 45M."""
def __init__(self, config: TransformerConfig, model: BaselineTransformer): super().__init__() self.config = config self.model = model
@classmethod def from_pretrained( cls, pretrained_path: Union[str, Path], weights_file: str = "model.safetensors", device: Optional[str] = None, torch_dtype: Optional[torch.dtype] = None, ) -> "TransformerModel": root = Path(pretrained_path) cfg_file = root / "config.json" if not cfg_file.exists(): raise FileNotFoundError(f"config.json non trovato in {root}")
with open(cfg_file, "r", encoding="utf-8") as f: cfg_dict = json.load(f)
cfg = TransformerConfig.from_dict(cfg_dict) model = BaselineTransformer(cfg)
weights_path = root / weights_file if not weights_path.exists(): raise FileNotFoundError(f"{weights_file} non trovato in {root}")
state_dict = load_file(str(weights_path)) model.load_state_dict(state_dict)
if device is None: if torch.backends.mps.is_available(): device = "mps" elif torch.cuda.is_available(): device = "cuda" else: device = "cpu"
model.to(torch.device(device)) if torch_dtype is not None: model.to(dtype=torch_dtype)
model.eval() return cls(cfg, model)
def forward(self, pezzi_ids: torch.Tensor) -> Tuple[torch.Tensor, None]: return self.model(pezzi_ids)
@torch.inference_mode() def generate( self, prompt: str, tokenizer: TransformerTokenizer, max_new_tokens: int = 48, temperature: float = 0.7, top_p: float = 0.9, repetition_penalty: float = 1.15, ) -> str: dev = next(self.model.parameters()).device ids = tokenizer.encode(prompt) if not ids: ids = [tokenizer.eos_id]
new_tokens: List[int] = [] for _ in range(max_new_tokens): x = torch.tensor([ids[-self.config.max_seq_len:]], dtype=torch.long, device=dev) logits, _ = self.model(x) next_logits = logits[0, -1]
if repetition_penalty != 1.0 and new_tokens: for token_id in set(new_tokens): if next_logits[token_id] > 0: next_logits[token_id] /= repetition_penalty else: next_logits[token_id] *= repetition_penalty
if temperature > 0: probs = torch.softmax(next_logits / temperature, dim=-1) if top_p < 1.0: sorted_probs, sorted_indices = torch.sort(probs, descending=True) cumulative_probs = torch.cumsum(sorted_probs, dim=-1) sorted_indices_to_remove = cumulative_probs > top_p sorted_indices_to_remove[..., 1:] = sorted_indices_to_remove[..., :-1].clone() sorted_indices_to_remove[..., 0] = 0 indices_to_remove = sorted_indices[sorted_indices_to_remove] probs[indices_to_remove] = 0.0 probs = probs / probs.sum() nxt = int(torch.multinomial(probs, num_samples=1).item()) else: nxt = int(next_logits.argmax().item())
if nxt in (tokenizer.eos_id, tokenizer.pad_id): break
new_tokens.append(nxt) ids.append(nxt)
return tokenizer.decode(new_tokens)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228#!/usr/bin/env python3"""Tokenizer pezzi goTommy2 locale: sostituisce ``gptommy.encode`` senza bytecode in /tmp.
``r08/gptommy/encode.py`` è un wrapper che carica il bytecode originale da``/tmp/encode_ORIGINAL.cpython-314.pyc`` (cancellato dalla pulizia di macOS) o da``__pycache__`` solo se >1000 byte; lì c'è ormai il wrapper stesso ricompilato(722 byte), quindi l'import fallisce. Il sorgente originale non esiste più.
Il contratto dell'encoder sopravvive nel docstring del bytecode originale di``pipeline.cpython-314.pyc`` (20 set): copia in``vendor/gptommy_pycache_backup_20261019/``, da leggere con marshal senzaimportare ``gptommy.pipeline`` (l'import sovrascriverebbe l'originale in r08):
1. NFC 2. speciali letterali ``<|...|>`` 3. whitespace (spazio→<spazio>, \\n→<riga>, \\t→<tab>, \\r→<cr>, NBSP→<nbsp>; pezzi indent se esistono) 4. cifre: coppie 00–99 se in vocab, altrimenti cifra singola 5. longest-match greedy intra-parola, fallback 1 carattere, poi <|unk|> 6. case: match sul testo così com'è, poi ``lower()`` se non c'è pezzo.
Col vocab pezzi 1251 (nessuna coppia di cifre, nessun pezzo con spazi o indent,nessun pezzo multi-carattere con maiuscole) il contratto coincide con``vocab_stages.encode_pezzi_fallback``. ``encode`` replica esattamente quellalettura (``TRAINING_VARIANT``); le altre letture ammesse dal testo del contrattorestano disponibili via ``encode_variant`` solo per la verifica(``verify_tokenizer_equivalence.py``)."""from __future__ import annotations
import unicodedatafrom dataclasses import dataclassfrom pathlib import Pathfrom typing import Dict, List, Optional, Sequence, Tuple
ROOT = Path(__file__).resolve().parentGOTTOMMY2_VOCAB = Path("/Users/thomasseri/Desktop/columns/logs/goTommy2_vocab_by_id.txt")LOCAL_PEZZI_VOCAB = ROOT / "vocab_stages" / "00_pezzi_by_id.txt"
WS_PIECES = {"\n": "<riga>", "\t": "<tab>", "\r": "<cr>", "\xa0": "<nbsp>", " ": "<spazio>"}DECODE_WS = {"<spazio>": " ", "<riga>": "\n", "<tab>": "\t"}
TRAINING_VARIANT = { "nfc": False, "literal_specials": False, "case_rule": "per_length", "unicode_ws": "isspace",}
@dataclassclass Vocab: id_to_token: List[str] token_to_id: Dict[str, int] path: Optional[Path] = None
def load_vocab(path: Path | str | None = None) -> Vocab: """Stesso formato TSV di ``gptommy.vocab.load_vocab`` (codice, scheda, riga, id, pezzo).""" p = Path(path) if path is not None else ( LOCAL_PEZZI_VOCAB if LOCAL_PEZZI_VOCAB.is_file() else GOTTOMMY2_VOCAB ) id_to_token: Dict[int, str] = {} with p.open("r", encoding="utf-8") as fh: for line in fh: line = line.strip() if not line or line.startswith("#"): continue parts = line.split("\t") if len(parts) < 5: continue id_to_token[int(parts[3])] = parts[4] if not id_to_token: raise RuntimeError(f"vocab vuoto: {p}") n = max(id_to_token) + 1 tokens = [id_to_token.get(i, f"<unk_{i}>") for i in range(n)] return Vocab(id_to_token=tokens, token_to_id={t: i for i, t in enumerate(tokens)}, path=p)
class _Tables: __slots__ = ("max_len", "specials", "unk_id")
def __init__(self, vocab) -> None: toks = vocab.id_to_token self.max_len = max((len(t) for t in toks if not t.startswith("<")), default=1) self.specials = sorted( (t for t in toks if t.startswith("<") and len(t) > 1 and t.endswith(">")), key=len, reverse=True, ) self.unk_id = int(vocab.token_to_id.get("<|unk|>", 4))
_TABLE_CACHE: Dict[int, tuple] = {}
def _tables(vocab) -> _Tables: key = id(vocab.token_to_id) hit = _TABLE_CACHE.get(key) if hit is not None and hit[0] is vocab.token_to_id: return hit[1] tab = _Tables(vocab) _TABLE_CACHE[key] = (vocab.token_to_id, tab) return tab
def _is_ws(ch: str, unicode_ws: str) -> bool: if unicode_ws == "isspace": return ch.isspace() return ch in WS_PIECES
def encode_variant( text: str, vocab, *, nfc: bool = False, literal_specials: bool = False, case_rule: str = "per_length", unicode_ws: str = "isspace",) -> List[int]: """Encoder del contratto gpTommy con le letture alternative esplicite.
case_rule: ``per_length`` a ogni lunghezza prova il frammento così com'è, poi lower() se alfabetico (= encode_pezzi_fallback; "Questo" → questo) ``per_position`` lower() solo se nessun pezzo matcha così com'è a quella posizione ("Questo" → Q u e s t o, visto che A–Z esistono) unicode_ws: ``isspace`` ogni carattere str.isspace() è whitespace (default <spazio>) ``listed`` solo spazio, \\n, \\t, \\r, NBSP; gli altri vanno al longest-match literal_specials: speciali ``<...>`` di qualunque lunghezza consumati per primi (il longest-match generico arriva solo a max_len=8 caratteri). """ if case_rule not in ("per_length", "per_position"): raise ValueError(f"case_rule sconosciuta: {case_rule}") s = unicodedata.normalize("NFC", text) if nfc else text t2i = vocab.token_to_id tab = _tables(vocab) ids: List[int] = [] n = len(s) i = 0 while i < n: ch = s[i] if _is_ws(ch, unicode_ws): tid = t2i.get(WS_PIECES.get(ch, "<spazio>")) if tid is not None: ids.append(tid) i += 1 continue if literal_specials and ch == "<": hit = next((sp for sp in tab.specials if s.startswith(sp, i)), None) if hit is not None: ids.append(t2i[hit]) i += len(hit) continue upper = min(n, i + tab.max_len) tid = None j = upper while j > i: frag = s[i:j] tid = t2i.get(frag) if tid is None and case_rule == "per_length" and frag.isalpha(): tid = t2i.get(frag.lower()) if tid is not None: break j -= 1 if tid is None and case_rule == "per_position": j = upper while j > i: frag = s[i:j] if frag.isalpha(): tid = t2i.get(frag.lower()) if tid is not None: break j -= 1 if tid is not None: ids.append(tid) i = j continue tid = t2i.get(ch) if tid is None and ch.isalpha(): tid = t2i.get(ch.lower()) ids.append(tab.unk_id if tid is None else tid) i += 1 return ids
def encode(text: str, vocab) -> List[int]: """Encode pezzi usato dal training (stessa lettura di encode_pezzi_fallback).""" return encode_variant(text, vocab, **TRAINING_VARIANT)
def decode(ids: Sequence[int], vocab) -> str: """Concatena i pezzi; sostituisce solo <spazio>/<riga>/<tab> (contratto gpTommy).""" toks = vocab.id_to_token out: List[str] = [] for tid in ids: tok = toks[tid] if 0 <= int(tid) < len(toks) else "<|unk|>" out.append(DECODE_WS.get(tok, tok)) return "".join(out)
def cascade_from_pezzi(pezzi_ids: Sequence[int], bundle): """StageEncoded da pezzi già codificati: pass_to_v2 → pass_to_v3 (come encode_cascade).""" from vocab_stages import StageEncoded, pass_to_v2, pass_to_v3
ids = [int(x) for x in pezzi_ids] v2 = pass_to_v2(ids, bundle) v3 = pass_to_v3(v2, bundle) return StageEncoded( pezzi_ids=ids, parole_ids=list(v2.parole_ids), unioni_ids=list(v3.unioni_ids), spans=[], v2=v2, v3=v3, )
def encode_cascade(text: str, bundle): """vocab_stages.encode_cascade con V1 = ``encode`` locale (mai gptommy).""" return cascade_from_pezzi(encode(text, bundle.pezzi), bundle)
def encode_stages_aligned(text: str, bundle) -> Tuple[List[int], List[int], List[int]]: """(pezzi, parole, unioni) allineati sulla timeline pezzi, come nel training.""" from vocab_stages import align_stages_to_pezzi
return align_stages_to_pezzi(encode_cascade(text, bundle), bundle)1234567{ "bos_token": "<|bos|>", "eos_token": "<|eos|>", "unk_token": "<|unk|>", "pad_token": "<|pad|>", "sep_token": "<|sep|>"}1234567891011121314151617181920212223242526#!/usr/bin/env python3"""Test di inferenza locale per Transformer Baseline 45M (Vocab 1.2k pezzi)."""from pathlib import Pathfrom modeling_transformer import TransformerModel, TransformerTokenizer
ROOT = Path(__file__).resolve().parent
def main(): print("1. Caricamento Tokenizer (1.2k pezzi)...") tokenizer = TransformerTokenizer.from_pretrained(ROOT)
print("2. Caricamento Transformer Baseline (Midtrain 10k)...") model = TransformerModel.from_pretrained(ROOT, weights_file="model.safetensors")
prompt = "La capitale d'Italia è " print(f"\n--- Test Prompt: '{prompt}' ---") gen = model.generate(prompt=prompt, tokenizer=tokenizer, max_new_tokens=30, temperature=0.0) print(f"Risposta Midtrain (greedy): {prompt}{gen}")
print("\n3. Caricamento Transformer Baseline (Pretrain 185k)...") model_pre = TransformerModel.from_pretrained(ROOT, weights_file="model_pretrain_185k.safetensors") gen_pre = model_pre.generate(prompt=prompt, tokenizer=tokenizer, max_new_tokens=30, temperature=0.0) print(f"Risposta Pretrain 185k (greedy): {prompt}{gen_pre}")
if __name__ == "__main__": main()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267{ "version": "1.0", "truncation": null, "padding": null, "added_tokens": [], "normalizer": null, "pre_tokenizer": null, "post_processor": null, "decoder": null, "model": { "type": "WordLevel", "vocab": { "<|end|>": 0, "<|bos|>": 1, "<|eos|>": 2, "<|pad|>": 3, "<|unk|>": 4, "<|sep|>": 5, "<|mask|>": 6, "<|cls|>": 7, "<|stop|>": 8, "<|break|>": 9, "<spazio>": 10, "<riga>": 11, "<tab>": 12, "<cr>": 13, "<nbsp>": 14, "<|system|>": 15, "<|user|>": 16, "<|assistant|>": 17, "<|tu|>": 18, "<|ai|>": 19, "<|tool|>": 20, "<|tool_result|>": 21, "<|im_start|>": 22, "<|im_end|>": 23, "<|db|>": 24, "<|scheda|>": 25, "<|indice|>": 26, "<|sposta|>": 27, "<|correggi|>": 28, "<|aggiungi|>": 29, "<|vuoto|>": 30, "<|think|>": 31, "<|/think|>": 32, "<|appunti|>": 33, "<|fiducia|>": 34, "<|chiedo|>": 35, "<|capito|>": 36, "<|colonna|>": 37, "<|hub|>": 38, "<|cerca|>": 39, "<|fonte|>": 40, "<|cita|>": 41, "<|no_fonte|>": 42, "<|code|>": 43, "<|/code|>": 44, "<|json|>": 45, "<|lista|>": 46, "<|tabella|>": 47, "<|math|>": 48, "<|url|>": 49, "<|non_so|>": 50, "<|esempio|>": 51, "<|attenzione|>": 52, "0": 53, "1": 54, "2": 55, "3": 56, "4": 57, "5": 58, "6": 59, "7": 60, "8": 61, "9": 62, ".": 63, ",": 64, ";": 65, ":": 66, "!": 67, "?": 68, "…": 69, "·": 70, "'": 71, "\"": 72, "«": 73, "»": 74, "(": 75, ")": 76, "[": 77, "]": 78, "{": 79, "}": 80, "+": 81, "-": 82, "*": 83, "/": 84, "=": 85, "<": 86, ">": 87, "@": 88, "#": 89, "%": 90, "&": 91, "_": 92, "|": 93, "\\": 94, "^": 95, "~": 96, "`": 97, "$": 98, "Ͱ": 99, "ͱ": 100, "Ͳ": 101, "ͳ": 102, "ʹ": 103, "Ͷ": 104, "ͷ": 105, "ͺ": 106, "ͻ": 107, "ͼ": 108, "ͽ": 109, "Ϳ": 110, "Ά": 111, "Έ": 112, "Ή": 113, "Ί": 114, "Ό": 115, "Ύ": 116, "Ώ": 117, "ΐ": 118, "Α": 119, "Β": 120, "Γ": 121, "Δ": 122, "Ε": 123, "Ζ": 124, "Η": 125, "Θ": 126, "Ι": 127, "Κ": 128, "Λ": 129, "Μ": 130, "Ν": 131, "Ξ": 132, "Ο": 133, "Π": 134, "Ρ": 135, "Σ": 136, "Τ": 137, "Υ": 138, "Φ": 139, "Χ": 140, "Ψ": 141, "Ω": 142, "Ϊ": 143, "Ϋ": 144, "ά": 145, "έ": 146, "ή": 147, "ί": 148, "ΰ": 149, "α": 150, "β": 151, "γ": 152, "δ": 153, "ε": 154, "ζ": 155, "η": 156, "θ": 157, "ι": 158, "κ": 159, "λ": 160, "μ": 161, "ν": 162, "ξ": 163, "ο": 164, "π": 165, "ρ": 166, "ς": 167, "σ": 168, "τ": 169, "υ": 170, "φ": 171, "χ": 172, "ψ": 173, "ω": 174, "ϊ": 175, "ϋ": 176, "ό": 177, "ύ": 178, "ώ": 179, "Ϗ": 180, "ϐ": 181, "ϑ": 182, "ϒ": 183, "ϓ": 184, "ϔ": 185, "ϕ": 186, "ϖ": 187, "ϗ": 188, "Ϙ": 189, "ϙ": 190, "Ϛ": 191, "ϛ": 192, "Ϝ": 193, "ϝ": 194, "Ϟ": 195, "ϟ": 196, "Ϡ": 197, "ϡ": 198, "Ϣ": 199, "ϣ": 200, "Ϥ": 201, "ϥ": 202, "Ϧ": 203, "ϧ": 204, "Ϩ": 205, "ϩ": 206, "Ϫ": 207, "ϫ": 208, "Ϭ": 209, "ϭ": 210, "Ϯ": 211, "ϯ": 212, "ϰ": 213, "ϱ": 214, "ϲ": 215, "ϳ": 216, "ϴ": 217, "ϵ": 218, "Ϸ": 219, "ϸ": 220, "Ϲ": 221, "Ϻ": 222, "ϻ": 223, "ϼ": 224, "Ͻ": 225, "Ͼ": 226, "Ͽ": 227, "Ѐ": 228, "Ё": 229, "Ђ": 230, "Ѓ": 231, "Є": 232, "Ѕ": 233, "І": 234, "Ї": 235, "Ј": 236, "Љ": 237, "Њ": 238, "Ћ": 239, "Ќ": 240, "Ѝ": 241, "Ў": 242, "Џ": 243, "А": 244, "Б": 245, "В": 246, "Г": 247, "Д": 248, "Е": 249, "Ж": 250, "З": 251, "И": 252, "Й": 253, "К": 254, "Л": 255, "М": 256, "Н": 257, "О": 258, "П": 259, "Р": 260, "С": 261, "Т": 262, "У": 263, "Ф": 264, "Х": 265, "Ц": 266, "Ч": 267, "Ш": 268, "Щ": 269, "Ъ": 270, "Ы": 271, "Ь": 272, "Э": 273, "Ю": 274, "Я": 275, "а": 276, "б": 277, "в": 278, "г": 279, "д": 280, "е": 281, "ж": 282, "з": 283, "и": 284, "й": 285, "к": 286, "л": 287, "м": 288, "н": 289, "о": 290, "п": 291, "р": 292, "с": 293, "т": 294, "у": 295, "ф": 296, "х": 297, "ц": 298, "ч": 299, "ш": 300, "щ": 301, "ъ": 302, "ы": 303, "ь": 304, "э": 305, "ю": 306, "я": 307, "ѐ": 308, "ё": 309, "ђ": 310, "ѓ": 311, "є": 312, "ѕ": 313, "і": 314, "ї": 315, "ј": 316, "љ": 317, "њ": 318, "ћ": 319, "ќ": 320, "ѝ": 321, "ў": 322, "џ": 323, "Ѡ": 324, "ѡ": 325, "Ѣ": 326, "ѣ": 327, "Ѥ": 328, "ѥ": 329, "Ѧ": 330, "ѧ": 331, "Ѩ": 332, "ѩ": 333, "Ѫ": 334, "ѫ": 335, "Ѭ": 336, "ѭ": 337, "Ѯ": 338, "ѯ": 339, "Ѱ": 340, "ѱ": 341, "Ѳ": 342, "ѳ": 343, "Ѵ": 344, "ѵ": 345, "Ѷ": 346, "ѷ": 347, "Ѹ": 348, "ѹ": 349, "Ѻ": 350, "ѻ": 351, "Ѽ": 352, "ѽ": 353, "Ѿ": 354, "ѿ": 355, "Ҁ": 356, "ҁ": 357, "Ҋ": 358, "ҋ": 359, "Ҍ": 360, "ҍ": 361, "Ҏ": 362, "ҏ": 363, "Ґ": 364, "ґ": 365, "Ғ": 366, "ғ": 367, "Ҕ": 368, "ҕ": 369, "Җ": 370, "җ": 371, "Ҙ": 372, "ҙ": 373, "Қ": 374, "қ": 375, "Ҝ": 376, "ҝ": 377, "Ҟ": 378, "ҟ": 379, "Ҡ": 380, "ҡ": 381, "Ң": 382, "ң": 383, "Ҥ": 384, "ҥ": 385, "Ҧ": 386, "ҧ": 387, "Ҩ": 388, "ҩ": 389, "Ҫ": 390, "ҫ": 391, "Ҭ": 392, "ҭ": 393, "Ү": 394, "ү": 395, "Ұ": 396, "ұ": 397, "Ҳ": 398, "ҳ": 399, "Ҵ": 400, "ҵ": 401, "Ҷ": 402, "ҷ": 403, "Ҹ": 404, "ҹ": 405, "Һ": 406, "һ": 407, "Ҽ": 408, "ҽ": 409, "Ҿ": 410, "ҿ": 411, "Ӏ": 412, "Ӂ": 413, "ӂ": 414, "Ӄ": 415, "ӄ": 416, "Ӆ": 417, "ӆ": 418, "Ӈ": 419, "ӈ": 420, "Ӊ": 421, "ӊ": 422, "Ӌ": 423, "ӌ": 424, "Ӎ": 425, "ӎ": 426, "ӏ": 427, "Ӑ": 428, "ӑ": 429, "Ӓ": 430, "ӓ": 431, "Ӕ": 432, "ӕ": 433, "Ӗ": 434, "ӗ": 435, "Ә": 436, "ә": 437, "Ӛ": 438, "ӛ": 439, "Ӝ": 440, "ӝ": 441, "Ӟ": 442, "ӟ": 443, "Ӡ": 444, "ӡ": 445, "Ӣ": 446, "ӣ": 447, "Ӥ": 448, "ӥ": 449, "Ӧ": 450, "ӧ": 451, "Ө": 452, "ө": 453, "Ӫ": 454, "ӫ": 455, "Ӭ": 456, "ӭ": 457, "Ӯ": 458, "ӯ": 459, "Ӱ": 460, "ӱ": 461, "Ӳ": 462, "ӳ": 463, "Ӵ": 464, "ӵ": 465, "Ӷ": 466, "ӷ": 467, "Ӹ": 468, "ӹ": 469, "Ӻ": 470, "ӻ": 471, "Ӽ": 472, "ӽ": 473, "Ӿ": 474, "ӿ": 475, "Ԁ": 476, "ԁ": 477, "Ԃ": 478, "ԃ": 479, "Ԅ": 480, "ԅ": 481, "Ԇ": 482, "ԇ": 483, "Ԉ": 484, "ԉ": 485, "Ԋ": 486, "ԋ": 487, "Ԍ": 488, "ԍ": 489, "Ԏ": 490, "ԏ": 491, "Ԑ": 492, "ԑ": 493, "Ԓ": 494, "ԓ": 495, "Ԕ": 496, "ԕ": 497, "Ԗ": 498, "ԗ": 499, "Ԙ": 500, "ԙ": 501, "Ԛ": 502, "ԛ": 503, "Ԝ": 504, "ԝ": 505, "Ԟ": 506, "ԟ": 507, "Ԡ": 508, "ԡ": 509, "Ԣ": 510, "ԣ": 511, "Ԥ": 512, "ԥ": 513, "Ԧ": 514, "ԧ": 515, "Ԩ": 516, "ԩ": 517, "Ԫ": 518, "ԫ": 519, "Ԭ": 520, "ԭ": 521, "Ԯ": 522, "ԯ": 523, "ἀ": 524, "ἁ": 525, "ἂ": 526, "ἃ": 527, "ἄ": 528, "ἅ": 529, "ἆ": 530, "ἇ": 531, "Ἀ": 532, "Ἁ": 533, "Ἂ": 534, "Ἃ": 535, "Ἄ": 536, "Ἅ": 537, "Ἆ": 538, "Ἇ": 539, "ἐ": 540, "ἑ": 541, "ἒ": 542, "ἓ": 543, "ἔ": 544, "ἕ": 545, "Ἐ": 546, "Ἑ": 547, "Ἒ": 548, "Ἓ": 549, "Ἔ": 550, "Ἕ": 551, "ἠ": 552, "ἡ": 553, "ἢ": 554, "ἣ": 555, "ἤ": 556, "ἥ": 557, "ἦ": 558, "ἧ": 559, "Ἠ": 560, "Ἡ": 561, "Ἢ": 562, "Ἣ": 563, "Ἤ": 564, "Ἥ": 565, "Ἦ": 566, "Ἧ": 567, "ἰ": 568, "ἱ": 569, "ἲ": 570, "ἳ": 571, "ἴ": 572, "ἵ": 573, "ἶ": 574, "ἷ": 575, "Ἰ": 576, "Ἱ": 577, "Ἲ": 578, "Ἳ": 579, "Ἴ": 580, "Ἵ": 581, "Ἶ": 582, "Ἷ": 583, "ὀ": 584, "ὁ": 585, "ὂ": 586, "ὃ": 587, "ὄ": 588, "ὅ": 589, "Ὀ": 590, "Ὁ": 591, "Ὂ": 592, "Ὃ": 593, "Ὄ": 594, "Ὅ": 595, "ὐ": 596, "ὑ": 597, "ὒ": 598, "ὓ": 599, "ὔ": 600, "ὕ": 601, "ὖ": 602, "ὗ": 603, "Ὑ": 604, "Ὓ": 605, "Ὕ": 606, "Ὗ": 607, "ὠ": 608, "ὡ": 609, "ὢ": 610, "ὣ": 611, "ὤ": 612, "ὥ": 613, "ὦ": 614, "ὧ": 615, "Ὠ": 616, "Ὡ": 617, "Ὢ": 618, "Ὣ": 619, "Ὤ": 620, "Ὥ": 621, "Ὦ": 622, "Ὧ": 623, "ὰ": 624, "ά": 625, "ὲ": 626, "έ": 627, "ὴ": 628, "ή": 629, "ὶ": 630, "ί": 631, "ὸ": 632, "ό": 633, "ὺ": 634, "ύ": 635, "ὼ": 636, "ώ": 637, "ᾀ": 638, "ᾁ": 639, "ᾂ": 640, "ᾃ": 641, "ᾄ": 642, "ᾅ": 643, "ᾆ": 644, "ᾇ": 645, "ᾈ": 646, "ᾉ": 647, "ᾊ": 648, "ᾋ": 649, "ᾌ": 650, "ᾍ": 651, "ᾎ": 652, "ᾏ": 653, "ᾐ": 654, "ᾑ": 655, "ᾒ": 656, "ᾓ": 657, "ᾔ": 658, "ᾕ": 659, "ᾖ": 660, "ᾗ": 661, "ᾘ": 662, "ᾙ": 663, "ᾚ": 664, "ᾛ": 665, "ᾜ": 666, "ᾝ": 667, "ᾞ": 668, "ᾟ": 669, "ᾠ": 670, "ᾡ": 671, "ᾢ": 672, "ᾣ": 673, "ᾤ": 674, "ᾥ": 675, "ᾦ": 676, "ᾧ": 677, "ᾨ": 678, "ᾩ": 679, "ᾪ": 680, "ᾫ": 681, "ᾬ": 682, "ᾭ": 683, "ᾮ": 684, "ᾯ": 685, "ᾰ": 686, "ᾱ": 687, "ᾲ": 688, "ᾳ": 689, "ᾴ": 690, "ᾶ": 691, "ᾷ": 692, "Ᾰ": 693, "Ᾱ": 694, "Ὰ": 695, "Ά": 696, "ᾼ": 697, "ι": 698, "ῂ": 699, "ῃ": 700, "ῄ": 701, "ῆ": 702, "ῇ": 703, "Ὲ": 704, "Έ": 705, "Ὴ": 706, "Ή": 707, "ῌ": 708, "ῐ": 709, "ῑ": 710, "ῒ": 711, "ΐ": 712, "ῖ": 713, "ῗ": 714, "Ῐ": 715, "Ῑ": 716, "Ὶ": 717, "Ί": 718, "ῠ": 719, "ῡ": 720, "ῢ": 721, "ΰ": 722, "ῤ": 723, "ῥ": 724, "ῦ": 725, "ῧ": 726, "Ῠ": 727, "Ῡ": 728, "Ὺ": 729, "Ύ": 730, "Ῥ": 731, "ῲ": 732, "ῳ": 733, "ῴ": 734, "ῶ": 735, "ῷ": 736, "Ὸ": 737, "Ό": 738, "Ὼ": 739, "Ώ": 740, "ῼ": 741, "Ⲁ": 742, "ⲁ": 743, "Ⲃ": 744, "ⲃ": 745, "Ⲅ": 746, "ⲅ": 747, "Ⲇ": 748, "ⲇ": 749, "Ⲉ": 750, "ⲉ": 751, "Ⲋ": 752, "ⲋ": 753, "Ⲍ": 754, "ⲍ": 755, "Ⲏ": 756, "ⲏ": 757, "Ⲑ": 758, "ⲑ": 759, "Ⲓ": 760, "ⲓ": 761, "Ⲕ": 762, "ⲕ": 763, "Ⲗ": 764, "ⲗ": 765, "Ⲙ": 766, "ⲙ": 767, "Ⲛ": 768, "ⲛ": 769, "Ⲝ": 770, "ⲝ": 771, "Ⲟ": 772, "ⲟ": 773, "Ⲡ": 774, "ⲡ": 775, "Ⲣ": 776, "ⲣ": 777, "Ⲥ": 778, "ⲥ": 779, "Ⲧ": 780, "ⲧ": 781, "Ⲩ": 782, "ⲩ": 783, "Ⲫ": 784, "ⲫ": 785, "Ⲭ": 786, "ⲭ": 787, "Ⲯ": 788, "ⲯ": 789, "Ⲱ": 790, "ⲱ": 791, "Ⲳ": 792, "ⲳ": 793, "Ⲵ": 794, "ⲵ": 795, "Ⲷ": 796, "ⲷ": 797, "Ⲹ": 798, "ⲹ": 799, "Ⲻ": 800, "ⲻ": 801, "Ⲽ": 802, "ⲽ": 803, "Ⲿ": 804, "ⲿ": 805, "Ⳁ": 806, "ⳁ": 807, "Ⳃ": 808, "ⳃ": 809, "Ⳅ": 810, "ⳅ": 811, "Ⳇ": 812, "ⳇ": 813, "Ⳉ": 814, "ⳉ": 815, "Ⳋ": 816, "ⳋ": 817, "Ⳍ": 818, "ⳍ": 819, "Ⳏ": 820, "ⳏ": 821, "Ⳑ": 822, "ⳑ": 823, "Ⳓ": 824, "ⳓ": 825, "Ⳕ": 826, "ⳕ": 827, "Ⳗ": 828, "ⳗ": 829, "Ⳙ": 830, "ⳙ": 831, "Ⳛ": 832, "ⳛ": 833, "Ⳝ": 834, "ⳝ": 835, "Ⳟ": 836, "ⳟ": 837, "Ⳡ": 838, "ⳡ": 839, "Ⳣ": 840, "ⳣ": 841, "ⳤ": 842, "Ⳬ": 843, "ⳬ": 844, "Ⳮ": 845, "ⳮ": 846, "Ⳳ": 847, "ⳳ": 848, "Ꙁ": 849, "ꙁ": 850, "Ꙃ": 851, "ꙃ": 852, "Ꙅ": 853, "ꙅ": 854, "Ꙇ": 855, "ꙇ": 856, "Ꙉ": 857, "ꙉ": 858, "Ꙋ": 859, "ꙋ": 860, "Ꙍ": 861, "ꙍ": 862, "Ꙏ": 863, "ꙏ": 864, "Ꙑ": 865, "ꙑ": 866, "Ꙓ": 867, "ꙓ": 868, "Ꙕ": 869, "ꙕ": 870, "Ꙗ": 871, "ꙗ": 872, "Ꙙ": 873, "ꙙ": 874, "Ꙛ": 875, "ꙛ": 876, "Ꙝ": 877, "ꙝ": 878, "Ꙟ": 879, "ꙟ": 880, "Ꙡ": 881, "ꙡ": 882, "Ꙣ": 883, "ꙣ": 884, "Ꙥ": 885, "ꙥ": 886, "Ꙧ": 887, "ꙧ": 888, "Ꙩ": 889, "ꙩ": 890, "Ꙫ": 891, "ꙫ": 892, "Ꙭ": 893, "ꙭ": 894, "ꙮ": 895, "ꙿ": 896, "Ꚁ": 897, "ꚁ": 898, "Ꚃ": 899, "ꚃ": 900, "Ꚅ": 901, "ꚅ": 902, "Ꚇ": 903, "ꚇ": 904, "Ꚉ": 905, "ꚉ": 906, "Ꚋ": 907, "ꚋ": 908, "Ꚍ": 909, "ꚍ": 910, "Ꚏ": 911, "ꚏ": 912, "Ꚑ": 913, "ꚑ": 914, "Ꚓ": 915, "ꚓ": 916, "Ꚕ": 917, "ꚕ": 918, "Ꚗ": 919, "ꚗ": 920, "Ꚙ": 921, "ꚙ": 922, "Ꚛ": 923, "ꚛ": 924, "ꚜ": 925, "ꚝ": 926, "ᲀ": 927, "ᲁ": 928, "ᲂ": 929, "ᲃ": 930, "ᲄ": 931, "ᲅ": 932, "ᲆ": 933, "ᲇ": 934, "ᲈ": 935, "Ա": 936, "Բ": 937, "Գ": 938, "Դ": 939, "Ե": 940, "Զ": 941, "Է": 942, "Ը": 943, "Թ": 944, "Ժ": 945, "Ի": 946, "Լ": 947, "Խ": 948, "Ծ": 949, "Կ": 950, "Հ": 951, "Ձ": 952, "Ղ": 953, "Ճ": 954, "Մ": 955, "Յ": 956, "Ն": 957, "Շ": 958, "Ո": 959, "Չ": 960, "Պ": 961, "Ջ": 962, "Ռ": 963, "Ս": 964, "Վ": 965, "Տ": 966, "Ր": 967, "Ց": 968, "Ւ": 969, "Փ": 970, "Ք": 971, "Օ": 972, "Ֆ": 973, "ՙ": 974, "ՠ": 975, "ա": 976, "բ": 977, "գ": 978, "դ": 979, "ե": 980, "զ": 981, "է": 982, "ը": 983, "թ": 984, "ժ": 985, "ի": 986, "լ": 987, "խ": 988, "ծ": 989, "կ": 990, "հ": 991, "ձ": 992, "ղ": 993, "ճ": 994, "մ": 995, "յ": 996, "ն": 997, "շ": 998, "ո": 999, "A": 1000, "B": 1001, "C": 1002, "D": 1003, "E": 1004, "F": 1005, "G": 1006, "H": 1007, "I": 1008, "J": 1009, "K": 1010, "L": 1011, "M": 1012, "N": 1013, "O": 1014, "P": 1015, "Q": 1016, "R": 1017, "S": 1018, "T": 1019, "U": 1020, "V": 1021, "W": 1022, "X": 1023, "Y": 1024, "Z": 1025, "a": 1026, "b": 1027, "c": 1028, "d": 1029, "e": 1030, "f": 1031, "g": 1032, "h": 1033, "i": 1034, "j": 1035, "k": 1036, "l": 1037, "m": 1038, "n": 1039, "o": 1040, "p": 1041, "q": 1042, "r": 1043, "s": 1044, "t": 1045, "u": 1046, "v": 1047, "w": 1048, "x": 1049, "y": 1050, "z": 1051, "À": 1052, "È": 1053, "É": 1054, "Ì": 1055, "Ò": 1056, "Ù": 1057, "à": 1058, "è": 1059, "é": 1060, "ì": 1061, "ò": 1062, "ù": 1063, "Ä": 1064, "ä": 1065, "Ö": 1066, "ö": 1067, "Ü": 1068, "ü": 1069, "ß": 1070, "Ç": 1071, "ç": 1072, "Ë": 1073, "ë": 1074, "Á": 1075, "á": 1076, "Ñ": 1077, "ñ": 1078, "Â": 1079, "il": 1080, "lo": 1081, "la": 1082, "gli": 1083, "le": 1084, "un": 1085, "uno": 1086, "una": 1087, "l'": 1088, "un'": 1089, "ad": 1090, "di": 1091, "d'": 1092, "da": 1093, "in": 1094, "con": 1095, "su": 1096, "per": 1097, "tra": 1098, "fra": 1099, "del": 1100, "dello": 1101, "della": 1102, "dei": 1103, "degli": 1104, "delle": 1105, "dell'": 1106, "al": 1107, "allo": 1108, "alla": 1109, "ai": 1110, "agli": 1111, "alle": 1112, "all'": 1113, "dal": 1114, "dallo": 1115, "dalla": 1116, "dai": 1117, "dagli": 1118, "dalle": 1119, "dall'": 1120, "nel": 1121, "nello": 1122, "nella": 1123, "nei": 1124, "negli": 1125, "nelle": 1126, "nell'": 1127, "sul": 1128, "sullo": 1129, "sulla": 1130, "sui": 1131, "sugli": 1132, "sulle": 1133, "sull'": 1134, "ed": 1135, "oppure": 1136, "ma": 1137, "però": 1138, "bensì": 1139, "se": 1140, "che": 1141, "perché": 1142, "quando": 1143, "mentre": 1144, "quindi": 1145, "dunque": 1146, "ossia": 1147, "cioè": 1148, "né": 1149, "io": 1150, "tu": 1151, "lui": 1152, "lei": 1153, "noi": 1154, "voi": 1155, "loro": 1156, "me": 1157, "te": 1158, "sé": 1159, "mi": 1160, "ti": 1161, "ci": 1162, "vi": 1163, "si": 1164, "li": 1165, "ne": 1166, "ce": 1167, "ve": 1168, "m'": 1169, "t'": 1170, "c'": 1171, "v'": 1172, "s'": 1173, "n'": 1174, "gl'": 1175, "glielo": 1176, "gliela": 1177, "glieli": 1178, "gliele": 1179, "gliel'": 1180, "questo": 1181, "questa": 1182, "questi": 1183, "queste": 1184, "quest'": 1185, "quello": 1186, "quella": 1187, "quelli": 1188, "quelle": 1189, "quell'": 1190, "ciò": 1191, "chi": 1192, "cui": 1193, "qual": 1194, "quale": 1195, "quali": 1196, "non": 1197, "essere": 1198, "esser": 1199, "sono": 1200, "sei": 1201, "siamo": 1202, "siete": 1203, "era": 1204, "stato": 1205, "stata": 1206, "stati": 1207, "state": 1208, "avere": 1209, "aver": 1210, "ho": 1211, "hai": 1212, "ha": 1213, "abbiamo": 1214, "avete": 1215, "hanno": 1216, "avuto": 1217, "potere": 1218, "posso": 1219, "puoi": 1220, "può": 1221, "possiamo": 1222, "potete": 1223, "possono": 1224, "dovere": 1225, "devo": 1226, "devi": 1227, "deve": 1228, "dobbiamo": 1229, "dovete": 1230, "devono": 1231, "volere": 1232, "voglio": 1233, "vuoi": 1234, "vuole": 1235, "vogliamo": 1236, "volete": 1237, "vogliono": 1238, "più": 1239, "meno": 1240, "molto": 1241, "poco": 1242, "già": 1243, "ancora": 1244, "sempre": 1245, "mai": 1246, "anche": 1247, "solo": 1248, "come": 1249, "dove": 1250 }, "unk_token": "<|unk|>" }}123456789{ "model_type": "gpt2", "tokenizer_class": "PreTrainedTokenizerFast", "bos_token": "<|bos|>", "eos_token": "<|eos|>", "unk_token": "<|unk|>", "pad_token": "<|pad|>", "clean_up_tokenization_spaces": false}123version https://git-lfs.github.com/spec/v1oid sha256:7eb790115d3f743502392128e4a763277375d28f4d2af482daedec47fee0f7acsize 91310368123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971#!/usr/bin/env python3"""Vocab a stadi — pipeline SEQUENZIALE a cascata (NON encode greedy parallelo).
Flusso utente (testo → V1 → V2 → V3):
1. Vocab 1 (pezzi ~1200, goTommy2): spezzetta TUTTO il testo in token base. 2. Quei token passano a Vocab 2 (parole): crea/modifica/aggrega pezzi → parole (stesso tipo di passaggio: sequenza in → sequenza aggregata out). 3. L'uscita di V2 passa a Vocab 3 (unioni): unisce 2/3 parole se frequenti.
API encode: encode_v1(text, pezzi) → pezzi_ids pass_to_v2(pezzi_ids, bundle) → parole_ids (+ surfaces) pass_to_v3(parole_ids|surfaces, bundle) → unioni stream encode_cascade(text, bundle) = V1 → V2 → V3 align_stages_to_pezzi: ancora causale + carry-forward post-ancora (pad solo pre-prima-ancora; dopo, ultima parola/unione resta viva su spazi/pezzi)
Build: vocab2 imparato da parole ricostruite sulle sequenze di pezzi (V1); vocab3 da unioni frequenti sull'uscita di V2.
Wiring train (proposta, NON avviato): 3 stadi in SERIE emb_v1(pezzi) → mesh1 → transform → emb_v2(parole) → mesh2 → … → emb_v3(unioni). Non 3 stream paralleli “prova unioni|parole|pezzi”. Serve --confirm-stages-train.
Deprecato: encode_stages greedy “unioni poi parole poi pezzi” (ora alias di cascade)."""from __future__ import annotations
import jsonimport warningsfrom collections import Counterfrom dataclasses import dataclass, fieldfrom pathlib import Pathfrom typing import Iterable, Iterator, Optional, Sequence, Union
ROOT = Path(__file__).resolve().parentDEFAULT_OUT = ROOT / "vocab_stages"DEFAULT_PEZZI = Path("/Users/thomasseri/Desktop/columns/logs/goTommy2_vocab_by_id.txt")
SPECIALS = [ "<|end|>", "<|bos|>", "<|eos|>", "<|pad|>", "<|unk|>", "<|sep|>",]
# pezzi che rompono la parola in V2 (aggregazione pezzi → parola)_WORD_BREAK_PEZZI = frozenset( { "<spazio>", " ", "\t", "\n", ".", ",", ";", ":", "!", "?", "(", ")", "[", "]", "{", "}", '"', "'", "«", "»", "-", "—", "/", "\\", })
@dataclassclass StageVocab: name: str id_to_token: list[str] token_to_id: dict[str, int] path: Optional[Path] = None meta: dict = field(default_factory=dict)
def __len__(self) -> int: return len(self.id_to_token)
@property def unk_id(self) -> int: return int(self.token_to_id.get("<|unk|>", 4))
@property def eos_id(self) -> int: return int(self.token_to_id.get("<|eos|>", 2))
@property def pad_id(self) -> int: return int(self.token_to_id.get("<|pad|>", 3))
@dataclassclass StageBundle: """Tre vocab separati + percorsi (id-space distinti)."""
pezzi: StageVocab parole: StageVocab unioni: StageVocab root: Path
def sizes(self) -> dict[str, int]: return { "pezzi": len(self.pezzi), "parole": len(self.parole), "unioni": len(self.unioni), }
@dataclassclass V1Out: """Uscita Vocab 1: tutto il testo spezzettato in pezzi."""
pezzi_ids: list[int] surfaces: list[str]
@dataclassclass V2Out: """Uscita Vocab 2: pezzi aggregati in parole (passaggio da V1)."""
parole_ids: list[int] surfaces: list[str] # gruppi di pezzi_ids che hanno formato ciascuna parola pezzi_groups: list[list[int]] = field(default_factory=list)
@dataclassclass V3Out: """Uscita Vocab 3: unioni 2/3 parole sulle superfici di V2.
`stream` è la sequenza a cascata: ogni item è ("unione", surface, uid) oppure ("parola", surface, wid) dopo merge greedy trigram→bigram. `unioni_ids` allinea a parole V2 (uid se la parola apre un'unione, altrimenti -1). """
unioni_ids: list[int] stream: list[tuple[str, str, int]] surfaces: list[str] = field(default_factory=list)
@dataclassclass StageEncoded: """Risultato cascade V1→V2→V3 (id space distinti)."""
pezzi_ids: list[int] parole_ids: list[int] unioni_ids: list[int] # traccia: ("v1"|"v2"|"v3", surface, id_or_ids) spans: list[tuple[str, str, object]] v1: Optional[V1Out] = None v2: Optional[V2Out] = None v3: Optional[V3Out] = None
# ---------------------------------------------------------------------------# Vocab I/O# ---------------------------------------------------------------------------
def load_pezzi_vocab(path: Path | str | None = None) -> StageVocab: """Carica goTommy2 (~1251) come stadio pezzi (V1).""" p = Path(path) if path is not None else DEFAULT_PEZZI id_to_token: dict[int, str] = {} with p.open("r", encoding="utf-8") as fh: for line in fh: line = line.strip() if not line or line.startswith("#"): continue parts = line.split("\t") if len(parts) < 5: continue gid = int(parts[3]) id_to_token[gid] = parts[4] if not id_to_token: raise RuntimeError(f"pezzi vocab vuoto: {p}") n = max(id_to_token) + 1 tokens = [id_to_token.get(i, f"<unk_{i}>") for i in range(n)] return StageVocab( name="pezzi", id_to_token=tokens, token_to_id={t: i for i, t in enumerate(tokens)}, path=p, meta={"source": str(p), "note": "goTommy2-scale ~1200 (1251)"}, )
def _with_specials(tokens: Iterable[str]) -> list[str]: seen = set(SPECIALS) out = list(SPECIALS) for t in tokens: if t in seen or not t: continue seen.add(t) out.append(t) return out
def make_stage_vocab(name: str, tokens: Iterable[str], *, meta: Optional[dict] = None) -> StageVocab: id_to_token = _with_specials(tokens) return StageVocab( name=name, id_to_token=id_to_token, token_to_id={t: i for i, t in enumerate(id_to_token)}, meta=dict(meta or {}), )
def save_stage_vocab(vocab: StageVocab, path: Path) -> None: path.parent.mkdir(parents=True, exist_ok=True) with path.open("w", encoding="utf-8") as fh: fh.write(f"# stage={vocab.name} size={len(vocab)}\n") fh.write("# colonne: codice\\tscheda\\triga\\tid\\tpezzo\n") for i, tok in enumerate(vocab.id_to_token): scheda = 0 if i < 1000 else 1 riga = i if i < 1000 else (i - 1000) code = f"{scheda:02d}{riga:03d}" fh.write(f"{code}\t{scheda:02d}\t{riga:03d}\t{i}\t{tok}\n") meta_path = path.with_suffix(".meta.json") blob = { "name": vocab.name, "size": len(vocab), "path": str(path), "meta": vocab.meta, "specials": SPECIALS, } meta_path.write_text(json.dumps(blob, ensure_ascii=False, indent=2), encoding="utf-8") vocab.path = path
def load_stage_vocab(path: Path, name: Optional[str] = None) -> StageVocab: id_to_token: dict[int, str] = {} with path.open("r", encoding="utf-8") as fh: for line in fh: line = line.strip() if not line or line.startswith("#"): continue parts = line.split("\t") if len(parts) < 5: continue id_to_token[int(parts[3])] = parts[4] n = max(id_to_token) + 1 if id_to_token else 0 tokens = [id_to_token.get(i, f"<unk_{i}>") for i in range(n)] meta: dict = {} meta_path = path.with_suffix(".meta.json") if meta_path.is_file(): try: meta = json.loads(meta_path.read_text(encoding="utf-8")).get("meta", {}) except json.JSONDecodeError: meta = {} return StageVocab( name=name or path.stem, id_to_token=tokens, token_to_id={t: i for i, t in enumerate(tokens)}, path=path, meta=meta, )
def save_bundle(bundle: StageBundle, root: Optional[Path] = None) -> Path: out = Path(root) if root is not None else bundle.root out.mkdir(parents=True, exist_ok=True) pezzi_dst = out / "00_pezzi_by_id.txt" parole_path = out / "01_parole_by_id.txt" unioni_path = out / "02_unioni_by_id.txt" save_stage_vocab(bundle.pezzi, pezzi_dst) save_stage_vocab(bundle.parole, parole_path) save_stage_vocab(bundle.unioni, unioni_path) src = bundle.pezzi.meta.get("source") or str(DEFAULT_PEZZI) (out / "00_pezzi_SOURCE.txt").write_text( f"source={src}\nsize={len(bundle.pezzi)}\n", encoding="utf-8" )
manifest = { "design": "multi_vocab_stages_cascade", "note": ( "Tre id-space separati in SERIE: testo→V1 pezzi (~1200)→V2 parole→V3 unioni. " "NON encode greedy parallelo. ~1200 = scala goTommy2 (1251), non 1.2M." ), "stages": { "0_pezzi": {"path": str(pezzi_dst), "size": len(bundle.pezzi)}, "1_parole": {"path": str(parole_path), "size": len(bundle.parole)}, "2_unioni": {"path": str(unioni_path), "size": len(bundle.unioni)}, }, "encode": ( "encode_cascade = encode_v1 → pass_to_v2 → pass_to_v3. " "Wiring train: 3 stadi in serie (emb/mesh per stadio), non stream paralleli." ), "api": { "encode_v1": "text → pezzi_ids", "pass_to_v2": "pezzi_ids → parole_ids (aggrega pezzi)", "pass_to_v3": "parole surfaces → unioni (2/3 se frequenti)", "encode_cascade": "encode_v1 → pass_to_v2 → pass_to_v3", }, } (out / "manifest.json").write_text( json.dumps(manifest, ensure_ascii=False, indent=2), encoding="utf-8" ) bundle.root = out return out
def load_bundle(root: Path | str) -> StageBundle: root = Path(root) pezzi = load_stage_vocab(root / "00_pezzi_by_id.txt", "pezzi") parole = load_stage_vocab(root / "01_parole_by_id.txt", "parole") unioni = load_stage_vocab(root / "02_unioni_by_id.txt", "unioni") return StageBundle(pezzi=pezzi, parole=parole, unioni=unioni, root=root)
# ---------------------------------------------------------------------------# V1 — spezzetta tutto in pezzi# ---------------------------------------------------------------------------
def encode_pezzi_fallback(text: str, pezzi: StageVocab) -> list[int]: """Encode grezzo a pezzi: match longest token goTommy2, altrimenti char/UNK.
Case-sensitive prima (A≠a nel vocab pezzi); lower solo se manca il match. Whitespace distinto come gotommy: \\n→<riga>, \\t→<tab>, spazi→<spazio>. """ s = text ids: list[int] = [] i = 0 max_len = max((len(t) for t in pezzi.id_to_token if not t.startswith("<")), default=1) while i < len(s): ch = s[i] if ch.isspace(): # Distingue whitespace: allineato a gotommy_encode / token speciali pezzi. if ch == "\n": ws_tok = "<riga>" elif ch == "\t": ws_tok = "<tab>" elif ch == "\r": ws_tok = "<cr>" elif ch == "\xa0": ws_tok = "<nbsp>" else: ws_tok = "<spazio>" tid = pezzi.token_to_id.get(ws_tok) if tid is not None: ids.append(tid) i += 1 continue matched = False upper = min(len(s), i + max_len) for j in range(upper, i, -1): frag = s[i:j] # Lookup case-sensitive PRIMA; lower solo fallback (es. "Hello"→H non h). tid = pezzi.token_to_id.get(frag) if tid is None and frag.isalpha(): tid = pezzi.token_to_id.get(frag.lower()) if tid is not None: ids.append(tid) i = j matched = True break if matched: continue tid = pezzi.token_to_id.get(ch) if tid is None and ch.isalpha(): tid = pezzi.token_to_id.get(ch.lower()) if tid is None: tid = pezzi.unk_id ids.append(tid) i += 1 return ids
def encode_v1(text: str, pezzi: StageVocab) -> V1Out: """Vocab 1: spezzetta TUTTO il testo in pezzi/token base (~1200).
Preferisce gotommy_encode (tokenizer ufficiale goTommy2); fallback locale se gptommy non è importabile o fallisce. """ ids: list[int] | None = None try: from gptommy.encode import encode as gotommy_encode
ids = gotommy_encode(text, pezzi) except Exception: ids = None if ids is None: ids = encode_pezzi_fallback(text, pezzi) surfaces = [ pezzi.id_to_token[i] if 0 <= i < len(pezzi.id_to_token) else "<|unk|>" for i in ids ] return V1Out(pezzi_ids=ids, surfaces=surfaces)
def _is_word_break_surface(surf: str) -> bool: if not surf or surf.startswith("<|"): # specials di controllo: non rompono da soli (trattati come pezzi “vivi” # solo se non in _WORD_BREAK); <|unk|> resta nel gruppo parola return surf in _WORD_BREAK_PEZZI or surf == "<spazio>" if surf in _WORD_BREAK_PEZZI: return True # singolo char di punteggiatura if len(surf) == 1 and not surf.isalnum() and not surf.isalpha(): return True return False
def _surface_from_pezzo(surf: str) -> str: """Contributo testuale di un pezzo alla parola ricostruita (salta meta-token).""" if not surf or surf.startswith("<"): return "" return surf
# ---------------------------------------------------------------------------# V2 — aggrega pezzi → parole# ---------------------------------------------------------------------------
def reconstruct_words_from_pezzi( pezzi_ids: Sequence[int], pezzi: StageVocab,) -> tuple[list[str], list[list[int]]]: """Da sequenza pezzi → liste di superfici parola + gruppi pezzi_ids.
Split su spazio/punteggiatura; concatena le superfici dei pezzi nel gruppo. Usato sia in build (conta parole da V1) sia in pass_to_v2. """ surfaces: list[str] = [] groups: list[list[int]] = [] buf_surfs: list[str] = [] buf_ids: list[int] = []
def _flush() -> None: nonlocal buf_surfs, buf_ids if not buf_ids: buf_surfs = [] return word = "".join(buf_surfs).lower() if word: surfaces.append(word) groups.append(list(buf_ids)) buf_surfs = [] buf_ids = []
for pid in pezzi_ids: surf = pezzi.id_to_token[pid] if 0 <= pid < len(pezzi.id_to_token) else "<|unk|>" if _is_word_break_surface(surf): _flush() continue piece = _surface_from_pezzo(surf) if piece: buf_surfs.append(piece) buf_ids.append(int(pid)) else: # meta-token senza contributo testuale: chiudi la parola corrente _flush() _flush() return surfaces, groups
def pass_to_v2(pezzi_ids: Sequence[int], bundle: StageBundle) -> V2Out: """Vocab 2: prende i pezzi di V1, aggrega/modifica in parole (id space parole).""" word_surfs, groups = reconstruct_words_from_pezzi(pezzi_ids, bundle.pezzi) parole_ids: list[int] = [] for w in word_surfs: wid = bundle.parole.token_to_id.get(w) if wid is None: wid = bundle.parole.unk_id parole_ids.append(wid) return V2Out(parole_ids=parole_ids, surfaces=word_surfs, pezzi_groups=groups)
# ---------------------------------------------------------------------------# V3 — unioni 2/3 parole sull'uscita V2# ---------------------------------------------------------------------------
def pass_to_v3( v2: Union[V2Out, Sequence[str], Sequence[int]], bundle: StageBundle,) -> V3Out: """Vocab 3: sull'uscita di V2, unisce 2/3 parole se presenti in vocab unioni.
Merge greedy sinistra→destra: trigram poi bigram; altrimenti passa la parola. """ if isinstance(v2, V2Out): surfaces = list(v2.surfaces) parole_ids = list(v2.parole_ids) elif v2 and isinstance(v2[0], int): # type: ignore[index] parole_ids = [int(x) for x in v2] # type: ignore[arg-type] surfaces = [ bundle.parole.id_to_token[i] if 0 <= i < len(bundle.parole.id_to_token) else "<|unk|>" for i in parole_ids ] else: surfaces = [str(x) for x in v2] # type: ignore[arg-type] parole_ids = [ bundle.parole.token_to_id.get(s, bundle.parole.unk_id) for s in surfaces ]
unioni_ids = [-1] * len(surfaces) stream: list[tuple[str, str, int]] = [] out_surfaces: list[str] = [] i = 0 while i < len(surfaces): if i + 2 < len(surfaces): tri = f"{surfaces[i]} {surfaces[i + 1]} {surfaces[i + 2]}" uid = bundle.unioni.token_to_id.get(tri) if uid is not None: unioni_ids[i] = uid stream.append(("unione", tri, uid)) out_surfaces.append(tri) i += 3 continue if i + 1 < len(surfaces): bi = f"{surfaces[i]} {surfaces[i + 1]}" uid = bundle.unioni.token_to_id.get(bi) if uid is not None: unioni_ids[i] = uid stream.append(("unione", bi, uid)) out_surfaces.append(bi) i += 2 continue wid = parole_ids[i] if i < len(parole_ids) else bundle.parole.unk_id stream.append(("parola", surfaces[i], wid)) out_surfaces.append(surfaces[i]) i += 1
return V3Out(unioni_ids=unioni_ids, stream=stream, surfaces=out_surfaces)
# ---------------------------------------------------------------------------# Cascade + compat# ---------------------------------------------------------------------------
def encode_cascade(text: str, bundle: StageBundle) -> StageEncoded: """Pipeline ufficiale: testo → encode_v1 → pass_to_v2 → pass_to_v3.""" v1 = encode_v1(text, bundle.pezzi) v2 = pass_to_v2(v1.pezzi_ids, bundle) v3 = pass_to_v3(v2, bundle) spans: list[tuple[str, str, object]] = [] for s, pid in zip(v1.surfaces, v1.pezzi_ids): spans.append(("v1", s, pid)) for s, wid, grp in zip(v2.surfaces, v2.parole_ids, v2.pezzi_groups): spans.append(("v2", s, (wid, grp))) for kind, surf, tid in v3.stream: spans.append(("v3", f"{kind}:{surf}", tid)) return StageEncoded( pezzi_ids=v1.pezzi_ids, parole_ids=v2.parole_ids, unioni_ids=v3.unioni_ids, spans=spans, v1=v1, v2=v2, v3=v3, )
def _word_union_ids_from_v3(v3: V3Out, n_words: int) -> list[int]: """Id unione per parola V2: solo sull'ULTIMA parola di ogni unione (causale).
Non propagare l'uid sulle parole iniziali/intermedie dell'unione: sarebbe lookahead (si rivelerebbe il merge prima che le parole successive siano complete). Parole senza unione → -1. """ out = [-1] * n_words wi = 0 for kind, surf, tid in v3.stream: if kind == "unione": n = max(1, len(surf.split())) last = wi + n - 1 if 0 <= last < n_words: out[last] = int(tid) wi += n else: wi += 1 return out
def _align_anchor_for_word( pezzi: Sequence[int], pezzi_vocab: StageVocab, first_t: int, last_t: int,) -> int: """Ancora causale per una parola: spazio/break successivo, altrimenti ultimo pezzo.
Mai il primo pezzo se la parola è multi-pezzo (anti-lookahead). """ n = len(pezzi) anchor = last_t if last_t + 1 < n: nxt = ( pezzi_vocab.id_to_token[pezzi[last_t + 1]] if 0 <= pezzi[last_t + 1] < len(pezzi_vocab.id_to_token) else "<|unk|>" ) if _is_word_break_surface(nxt): anchor = last_t + 1 # sicurezza: multi-pezzo non deve mai ancorare sul primo if first_t != last_t and anchor == first_t: anchor = last_t return anchor
def _carry_forward_after_anchor(ids: list[int], pad_id: int) -> None: """In-place: dopo un id non-pad, copia l'ultimo visto sui pad successivi.
Non tocca il prefisso di soli pad (anti-lookahead pre-ancora resta valido). """ last = pad_id for i, v in enumerate(ids): if v != pad_id: last = int(v) elif last != pad_id: ids[i] = last
def _is_word_terminator(surf: str) -> bool: """Pezzo che chiude la parola in V2: break oppure pezzo senza testo (<riga>, <tab>, <|unk|>, …).""" return _is_word_break_surface(surf) or not _surface_from_pezzo(surf)
def _prefix_union_ids(surfaces: Sequence[str], bundle: StageBundle) -> list[int]: """Per ogni parola j: ultima unione di ``pass_to_v3`` sulle sole parole 0..j (-1 se nessuna).
Il merge greedy decide in i guardando le parole i+1 e i+2: le decisioni con i <= j-2 coincidono con quelle sull'intera sequenza, la coda del prefisso è al più il bigramma (j-1, j). """ uni = bundle.unioni.token_to_id n = len(surfaces) starts: list[int] = [] uids: list[int] = [] i = 0 while i < n: size, uid = 1, None if i + 2 < n: uid = uni.get(f"{surfaces[i]} {surfaces[i + 1]} {surfaces[i + 2]}") size = 3 if uid is None and i + 1 < n: uid = uni.get(f"{surfaces[i]} {surfaces[i + 1]}") size = 2 if uid is None: size = 1 starts.append(i) uids.append(-1 if uid is None else int(uid)) i += size
out = [-1] * n k = 0 last = -1 for j in range(n): while k < len(starts) and starts[k] <= j - 2: if uids[k] >= 0: last = uids[k] k += 1 cur = last if k < len(starts) and starts[k] == j - 1: uid = uni.get(f"{surfaces[j - 1]} {surfaces[j]}") if uid is not None: cur = int(uid) out[j] = cur return out
def _align_causal(enc: StageEncoded, bundle: StageBundle) -> tuple[list[int], list[int], list[int]]: """Allineamento in cui la feature in t dipende solo da pezzi[:t+1] (vedi align_stages_to_pezzi).""" pezzi = list(enc.pezzi_ids) n = len(pezzi) pad_w = bundle.parole.pad_id pad_u = bundle.unioni.pad_id parole_al = [pad_w] * n unioni_al = [pad_u] * n if n == 0: return pezzi, parole_al, unioni_al pv = bundle.pezzi word_last: list[int] = [] in_word = False for t, pid in enumerate(pezzi): surf = pv.id_to_token[pid] if 0 <= pid < len(pv.id_to_token) else "<|unk|>" if _is_word_terminator(surf): in_word = False continue if not in_word: word_last.append(t) in_word = True word_last[-1] = t if enc.v2 is not None: surfaces = list(enc.v2.surfaces) else: surfaces, _ = reconstruct_words_from_pezzi(pezzi, pv) if len(surfaces) != len(word_last) or len(enc.parole_ids) != len(word_last): raise ValueError("align causale: parole V2 e gruppi di pezzi non coincidono") word_uids = _prefix_union_ids(surfaces, bundle) for w, last_t in enumerate(word_last): anchor = last_t + 1 if anchor >= n: continue parole_al[anchor] = int(enc.parole_ids[w]) if word_uids[w] >= 0: unioni_al[anchor] = word_uids[w] _carry_forward_after_anchor(parole_al, pad_w) _carry_forward_after_anchor(unioni_al, pad_u) return pezzi, parole_al, unioni_al
def align_stages_to_pezzi( enc: StageEncoded, bundle: StageBundle, causal: bool = False,) -> tuple[list[int], list[int], list[int]]: """Allinea parole/unioni alla timeline pezzi (stessa lunghezza).
``causal=True`` (``--causal-align``): la feature in t è quella calcolabile dai soli pezzi[:t+1]. Rispetto alla policy qui sotto cambia in tre punti: - l'ancora di una parola è sempre il pezzo che la chiude in V2 (break oppure pezzo senza testo: <riga>, <tab>, <cr>, <nbsp>, <|unk|>, …), mai il suo ultimo pezzo: finché non arriva il terminatore la parola potrebbe continuare; - una parola non chiusa a fine sequenza non viene mai rivelata; - l'unione mostrata sull'ancora della parola j è l'ultima unione del merge V3 sulle sole parole 0..j (il greedy trigramma→bigramma sull'intera sequenza guarda due parole avanti).
Policy (due pass):
1) Ancora CAUSALE (anti-lookahead; coerente con gen greedy che mette pad_parole/pad_unioni sui pezzi nuovi finché la parola non è chiusa):
- Non assegnare id parola/unione al PRIMO pezzo di una parola multi-pezzo (leak: rivelerebbe l'identità prima di aver visto tutti i pezzi). - Id parola: solo sull'ultimo pezzo della parola, oppure sullo spazio/break immediatamente successivo se presente. - Id unione: solo sull'ancora dell'ultima parola coperta dall'unione (vedi `_word_union_ids_from_v3`). - Pezzi intermedi / primo pezzo (multi-pezzo) / break non-ancora → ``pad`` di parole/unioni. Non si usa ``unk`` qui: unk = superficie assente dal vocab V2/V3, non “non ancora nota”. - Parola mono-pezzo senza break successivo: ancora = quel pezzo (superficie già completa → non è lookahead).
2) Carry-forward post-ancora: una volta vista un'ancora, l'ultima parola/unione nota si propaga alle posizioni successive ancora in ``pad`` (spazi, pezzi della parola successiva, punteggiatura extra), finché non arriva una nuova ancora. Così su ``"Answer: "`` lo stadio V2 vede ``answer`` anche sullo ``<spazio>`` finale, non un reset a pad. Il prefisso pre-prima-ancora resta pad (niente leak sul primo pezzo). """ if causal: return _align_causal(enc, bundle) pezzi = list(enc.pezzi_ids) n = len(pezzi) pad_w = bundle.parole.pad_id pad_u = bundle.unioni.pad_id parole_al = [pad_w] * n unioni_al = [pad_u] * n if n == 0: return pezzi, parole_al, unioni_al
pezzi_vocab = bundle.pezzi n_words = len(enc.parole_ids) word_first = [-1] * n_words word_last = [-1] * n_words word_idx = -1 in_word = False for t, pid in enumerate(pezzi): surf = ( pezzi_vocab.id_to_token[pid] if 0 <= pid < len(pezzi_vocab.id_to_token) else "<|unk|>" ) if _is_word_break_surface(surf): in_word = False continue piece = _surface_from_pezzo(surf) if piece: if not in_word: word_idx += 1 in_word = True if 0 <= word_idx < n_words: word_first[word_idx] = t if 0 <= word_idx < n_words: word_last[word_idx] = t else: in_word = False
if enc.v3 is not None: word_uids = _word_union_ids_from_v3(enc.v3, n_words) else: word_uids = [-1] * n_words # fallback senza stream: unioni_ids è start-aligned in V3Out; # senza n-gram non possiamo spostare sull'ultima parola. for i, uid in enumerate(enc.unioni_ids): if 0 <= i < n_words and int(uid) >= 0: word_uids[i] = int(uid)
for w in range(n_words): first_t = word_first[w] last_t = word_last[w] if first_t < 0 or last_t < 0: continue anchor = _align_anchor_for_word(pezzi, pezzi_vocab, first_t, last_t) parole_al[anchor] = int(enc.parole_ids[w]) uid = word_uids[w] if w < len(word_uids) else -1 if uid >= 0: unioni_al[anchor] = int(uid)
_carry_forward_after_anchor(parole_al, pad_w) _carry_forward_after_anchor(unioni_al, pad_u) return pezzi, parole_al, unioni_al
def encode_stages(text: str, bundle: StageBundle) -> StageEncoded: """DEPRECATED: ex greedy parallelo; ora alias di encode_cascade (V1→V2→V3).""" warnings.warn( "encode_stages greedy è deprecato; usa encode_cascade / encode_v1→pass_to_v2→pass_to_v3", DeprecationWarning, stacklevel=2, ) return encode_cascade(text, bundle)
# ---------------------------------------------------------------------------# Build: vocab2 da pezzi (V1), vocab3 da uscita V2# ---------------------------------------------------------------------------
def iter_v1_word_surfaces( texts: Iterator[str], pezzi: StageVocab, *, max_chars: int = 0,) -> Iterator[list[str]]: """Per ogni testo: V1 → parole ricostruite da pezzi (senza ancora Vocab 2).""" seen = 0 for text in texts: if max_chars > 0 and seen >= max_chars: break seen += len(text) v1 = encode_v1(text, pezzi) surfs, _ = reconstruct_words_from_pezzi(v1.pezzi_ids, pezzi) if surfs: yield surfs
def count_from_cascade( texts: Iterator[str], pezzi: StageVocab, *, max_chars: int = 0,) -> tuple[dict[str, int], dict[str, int], dict[str, int]]: """Conta parole (da V1→ricostruzione) e bi/tri sulla stessa sequenza parole.
Nota build: vocab3 si impara dalle unioni sulle superfici che V2 vedrà (parole ricostruite da pezzi). Dopo aver creato Vocab 2 si può rivalidare con pass_to_v2; le superfici coincidono. """ uni: Counter[str] = Counter() bi: Counter[str] = Counter() tri: Counter[str] = Counter() for surfs in iter_v1_word_surfaces(texts, pezzi, max_chars=max_chars): uni.update(surfs) if len(surfs) >= 2: bi.update(f"{surfs[i]} {surfs[i + 1]}" for i in range(len(surfs) - 1)) if len(surfs) >= 3: tri.update( f"{surfs[i]} {surfs[i + 1]} {surfs[i + 2]}" for i in range(len(surfs) - 2) ) return dict(uni), dict(bi), dict(tri)
def count_ngrams_from_texts( texts: Iterator[str], *, max_chars: int = 0, pezzi: StageVocab | None = None,) -> tuple[dict[str, int], dict[str, int], dict[str, int]]: """Build helper: conta via cascade V1→parole ricostruite (non word-tokenize grezzo).""" if pezzi is None: pezzi = load_pezzi_vocab() return count_from_cascade(texts, pezzi, max_chars=max_chars)
def build_stages_from_counts( word_counts: dict[str, int], bigram_counts: dict[str, int], trigram_counts: dict[str, int], *, pezzi_path: Path | str | None = None, min_word_freq: int = 3, min_union_freq: int = 5, max_words: int = 50000, max_unions: int = 20000, out_dir: Path | str | None = None,) -> StageBundle: """Costruisce V1 (carica pezzi), V2 da conteggi parole-da-pezzi, V3 da unioni su V2.""" pezzi = load_pezzi_vocab(pezzi_path) ranked_words = sorted( ((w, c) for w, c in word_counts.items() if c >= min_word_freq and len(w) > 1), key=lambda x: (-x[1], x[0]), )[:max_words] parole = make_stage_vocab( "parole", (w for w, _ in ranked_words), meta={ "min_word_freq": min_word_freq, "n_candidates": len(ranked_words), "source": "reconstructed_from_v1_pezzi", "top": ranked_words[:20], }, )
union_items: list[tuple[str, int, str]] = [] for t, c in trigram_counts.items(): if c >= min_union_freq: union_items.append((t, c, "tri")) for t, c in bigram_counts.items(): if c >= min_union_freq: union_items.append((t, c, "bi")) union_items.sort(key=lambda x: (-x[1], 0 if x[2] == "tri" else 1, x[0])) union_items = union_items[:max_unions] unioni = make_stage_vocab( "unioni", (t for t, _, _ in union_items), meta={ "min_union_freq": min_union_freq, "n_candidates": len(union_items), "source": "frequent_unions_on_v2_surfaces", "n_trigram": sum(1 for _, _, k in union_items if k == "tri"), "n_bigram": sum(1 for _, _, k in union_items if k == "bi"), "top": [(t, c, k) for t, c, k in union_items[:20]], }, )
root = Path(out_dir) if out_dir is not None else DEFAULT_OUT bundle = StageBundle(pezzi=pezzi, parole=parole, unioni=unioni, root=root) save_bundle(bundle, root) counts_path = root / "counts_summary.json" counts_path.write_text( json.dumps( { "pipeline": "v1_pezzi → v2_parole(from pezzi) → v3_unioni(from v2)", "n_word_types": len(word_counts), "n_bigram_types": len(bigram_counts), "n_trigram_types": len(trigram_counts), "parole_kept": len(parole) - len(SPECIALS), "unioni_kept": len(unioni) - len(SPECIALS), "min_word_freq": min_word_freq, "min_union_freq": min_union_freq, }, ensure_ascii=False, indent=2, ), encoding="utf-8", ) return bundle1234567891011121314151617{ "name": "pezzi", "size": 1251, "path": "/Users/thomasseri/Desktop/columns/geodesic_mesh_nn/vocab_stages/00_pezzi_by_id.txt", "meta": { "source": "/Users/thomasseri/Desktop/columns/logs/goTommy2_vocab_by_id.txt", "note": "goTommy2-scale ~1200 (1251)" }, "specials": [ "<|end|>", "<|bos|>", "<|eos|>", "<|pad|>", "<|unk|>", "<|sep|>" ]}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253# stage=pezzi size=1251# colonne: codice\tscheda\triga\tid\tpezzo00000 00 000 0 <|end|>00001 00 001 1 <|bos|>00002 00 002 2 <|eos|>00003 00 003 3 <|pad|>00004 00 004 4 <|unk|>00005 00 005 5 <|sep|>00006 00 006 6 <|mask|>00007 00 007 7 <|cls|>00008 00 008 8 <|stop|>00009 00 009 9 <|break|>00010 00 010 10 <spazio>00011 00 011 11 <riga>00012 00 012 12 <tab>00013 00 013 13 <cr>00014 00 014 14 <nbsp>00015 00 015 15 <|system|>00016 00 016 16 <|user|>00017 00 017 17 <|assistant|>00018 00 018 18 <|tu|>00019 00 019 19 <|ai|>00020 00 020 20 <|tool|>00021 00 021 21 <|tool_result|>00022 00 022 22 <|im_start|>00023 00 023 23 <|im_end|>00024 00 024 24 <|db|>00025 00 025 25 <|scheda|>00026 00 026 26 <|indice|>00027 00 027 27 <|sposta|>00028 00 028 28 <|correggi|>00029 00 029 29 <|aggiungi|>00030 00 030 30 <|vuoto|>00031 00 031 31 <|think|>00032 00 032 32 <|/think|>00033 00 033 33 <|appunti|>00034 00 034 34 <|fiducia|>00035 00 035 35 <|chiedo|>00036 00 036 36 <|capito|>00037 00 037 37 <|colonna|>00038 00 038 38 <|hub|>00039 00 039 39 <|cerca|>00040 00 040 40 <|fonte|>00041 00 041 41 <|cita|>00042 00 042 42 <|no_fonte|>00043 00 043 43 <|code|>00044 00 044 44 <|/code|>00045 00 045 45 <|json|>00046 00 046 46 <|lista|>00047 00 047 47 <|tabella|>00048 00 048 48 <|math|>00049 00 049 49 <|url|>00050 00 050 50 <|non_so|>00051 00 051 51 <|esempio|>00052 00 052 52 <|attenzione|>00053 00 053 53 000054 00 054 54 100055 00 055 55 200056 00 056 56 300057 00 057 57 400058 00 058 58 500059 00 059 59 600060 00 060 60 700061 00 061 61 800062 00 062 62 900063 00 063 63 .00064 00 064 64 ,00065 00 065 65 ;00066 00 066 66 :00067 00 067 67 !00068 00 068 68 ?00069 00 069 69 …00070 00 070 70 ·00071 00 071 71 '00072 00 072 72 "00073 00 073 73 «00074 00 074 74 »00075 00 075 75 (00076 00 076 76 )00077 00 077 77 [00078 00 078 78 ]00079 00 079 79 {00080 00 080 80 }00081 00 081 81 +00082 00 082 82 -00083 00 083 83 *00084 00 084 84 /00085 00 085 85 =00086 00 086 86 <00087 00 087 87 >00088 00 088 88 @00089 00 089 89 #00090 00 090 90 %00091 00 091 91 &00092 00 092 92 _00093 00 093 93 |00094 00 094 94 \00095 00 095 95 ^00096 00 096 96 ~00097 00 097 97 `00098 00 098 98 $00099 00 099 99 Ͱ00100 00 100 100 ͱ00101 00 101 101 Ͳ00102 00 102 102 ͳ00103 00 103 103 ʹ00104 00 104 104 Ͷ00105 00 105 105 ͷ00106 00 106 106 ͺ00107 00 107 107 ͻ00108 00 108 108 ͼ00109 00 109 109 ͽ00110 00 110 110 Ϳ00111 00 111 111 Ά00112 00 112 112 Έ00113 00 113 113 Ή00114 00 114 114 Ί00115 00 115 115 Ό00116 00 116 116 Ύ00117 00 117 117 Ώ00118 00 118 118 ΐ00119 00 119 119 Α00120 00 120 120 Β00121 00 121 121 Γ00122 00 122 122 Δ00123 00 123 123 Ε00124 00 124 124 Ζ00125 00 125 125 Η00126 00 126 126 Θ00127 00 127 127 Ι00128 00 128 128 Κ00129 00 129 129 Λ00130 00 130 130 Μ00131 00 131 131 Ν00132 00 132 132 Ξ00133 00 133 133 Ο00134 00 134 134 Π00135 00 135 135 Ρ00136 00 136 136 Σ00137 00 137 137 Τ00138 00 138 138 Υ00139 00 139 139 Φ00140 00 140 140 Χ00141 00 141 141 Ψ00142 00 142 142 Ω00143 00 143 143 Ϊ00144 00 144 144 Ϋ00145 00 145 145 ά00146 00 146 146 έ00147 00 147 147 ή00148 00 148 148 ί00149 00 149 149 ΰ00150 00 150 150 α00151 00 151 151 β00152 00 152 152 γ00153 00 153 153 δ00154 00 154 154 ε00155 00 155 155 ζ00156 00 156 156 η00157 00 157 157 θ00158 00 158 158 ι00159 00 159 159 κ00160 00 160 160 λ00161 00 161 161 μ00162 00 162 162 ν00163 00 163 163 ξ00164 00 164 164 ο00165 00 165 165 π00166 00 166 166 ρ00167 00 167 167 ς00168 00 168 168 σ00169 00 169 169 τ00170 00 170 170 υ00171 00 171 171 φ00172 00 172 172 χ00173 00 173 173 ψ00174 00 174 174 ω00175 00 175 175 ϊ00176 00 176 176 ϋ00177 00 177 177 ό00178 00 178 178 ύ00179 00 179 179 ώ00180 00 180 180 Ϗ00181 00 181 181 ϐ00182 00 182 182 ϑ00183 00 183 183 ϒ00184 00 184 184 ϓ00185 00 185 185 ϔ00186 00 186 186 ϕ00187 00 187 187 ϖ00188 00 188 188 ϗ00189 00 189 189 Ϙ00190 00 190 190 ϙ00191 00 191 191 Ϛ00192 00 192 192 ϛ00193 00 193 193 Ϝ00194 00 194 194 ϝ00195 00 195 195 Ϟ00196 00 196 196 ϟ00197 00 197 197 Ϡ00198 00 198 198 ϡ00199 00 199 199 Ϣ00200 00 200 200 ϣ00201 00 201 201 Ϥ00202 00 202 202 ϥ00203 00 203 203 Ϧ00204 00 204 204 ϧ00205 00 205 205 Ϩ00206 00 206 206 ϩ00207 00 207 207 Ϫ00208 00 208 208 ϫ00209 00 209 209 Ϭ00210 00 210 210 ϭ00211 00 211 211 Ϯ00212 00 212 212 ϯ00213 00 213 213 ϰ00214 00 214 214 ϱ00215 00 215 215 ϲ00216 00 216 216 ϳ00217 00 217 217 ϴ00218 00 218 218 ϵ00219 00 219 219 Ϸ00220 00 220 220 ϸ00221 00 221 221 Ϲ00222 00 222 222 Ϻ00223 00 223 223 ϻ00224 00 224 224 ϼ00225 00 225 225 Ͻ00226 00 226 226 Ͼ00227 00 227 227 Ͽ00228 00 228 228 Ѐ00229 00 229 229 Ё00230 00 230 230 Ђ00231 00 231 231 Ѓ00232 00 232 232 Є00233 00 233 233 Ѕ00234 00 234 234 І00235 00 235 235 Ї00236 00 236 236 Ј00237 00 237 237 Љ00238 00 238 238 Њ00239 00 239 239 Ћ00240 00 240 240 Ќ00241 00 241 241 Ѝ00242 00 242 242 Ў00243 00 243 243 Џ00244 00 244 244 А00245 00 245 245 Б00246 00 246 246 В00247 00 247 247 Г00248 00 248 248 Д00249 00 249 249 Е00250 00 250 250 Ж00251 00 251 251 З00252 00 252 252 И00253 00 253 253 Й00254 00 254 254 К00255 00 255 255 Л00256 00 256 256 М00257 00 257 257 Н00258 00 258 258 О00259 00 259 259 П00260 00 260 260 Р00261 00 261 261 С00262 00 262 262 Т00263 00 263 263 У00264 00 264 264 Ф00265 00 265 265 Х00266 00 266 266 Ц00267 00 267 267 Ч00268 00 268 268 Ш00269 00 269 269 Щ00270 00 270 270 Ъ00271 00 271 271 Ы00272 00 272 272 Ь00273 00 273 273 Э00274 00 274 274 Ю00275 00 275 275 Я00276 00 276 276 а00277 00 277 277 б00278 00 278 278 в00279 00 279 279 г00280 00 280 280 д00281 00 281 281 е00282 00 282 282 ж00283 00 283 283 з00284 00 284 284 и00285 00 285 285 й00286 00 286 286 к00287 00 287 287 л00288 00 288 288 м00289 00 289 289 н00290 00 290 290 о00291 00 291 291 п00292 00 292 292 р00293 00 293 293 с00294 00 294 294 т00295 00 295 295 у00296 00 296 296 ф00297 00 297 297 х00298 00 298 298 ц00299 00 299 299 ч00300 00 300 300 ш00301 00 301 301 щ00302 00 302 302 ъ00303 00 303 303 ы00304 00 304 304 ь00305 00 305 305 э00306 00 306 306 ю00307 00 307 307 я00308 00 308 308 ѐ00309 00 309 309 ё00310 00 310 310 ђ00311 00 311 311 ѓ00312 00 312 312 є00313 00 313 313 ѕ00314 00 314 314 і00315 00 315 315 ї00316 00 316 316 ј00317 00 317 317 љ00318 00 318 318 њ00319 00 319 319 ћ00320 00 320 320 ќ00321 00 321 321 ѝ00322 00 322 322 ў00323 00 323 323 џ00324 00 324 324 Ѡ00325 00 325 325 ѡ00326 00 326 326 Ѣ00327 00 327 327 ѣ00328 00 328 328 Ѥ00329 00 329 329 ѥ00330 00 330 330 Ѧ00331 00 331 331 ѧ00332 00 332 332 Ѩ00333 00 333 333 ѩ00334 00 334 334 Ѫ00335 00 335 335 ѫ00336 00 336 336 Ѭ00337 00 337 337 ѭ00338 00 338 338 Ѯ00339 00 339 339 ѯ00340 00 340 340 Ѱ00341 00 341 341 ѱ00342 00 342 342 Ѳ00343 00 343 343 ѳ00344 00 344 344 Ѵ00345 00 345 345 ѵ00346 00 346 346 Ѷ00347 00 347 347 ѷ00348 00 348 348 Ѹ00349 00 349 349 ѹ00350 00 350 350 Ѻ00351 00 351 351 ѻ00352 00 352 352 Ѽ00353 00 353 353 ѽ00354 00 354 354 Ѿ00355 00 355 355 ѿ00356 00 356 356 Ҁ00357 00 357 357 ҁ00358 00 358 358 Ҋ00359 00 359 359 ҋ00360 00 360 360 Ҍ00361 00 361 361 ҍ00362 00 362 362 Ҏ00363 00 363 363 ҏ00364 00 364 364 Ґ00365 00 365 365 ґ00366 00 366 366 Ғ00367 00 367 367 ғ00368 00 368 368 Ҕ00369 00 369 369 ҕ00370 00 370 370 Җ00371 00 371 371 җ00372 00 372 372 Ҙ00373 00 373 373 ҙ00374 00 374 374 Қ00375 00 375 375 қ00376 00 376 376 Ҝ00377 00 377 377 ҝ00378 00 378 378 Ҟ00379 00 379 379 ҟ00380 00 380 380 Ҡ00381 00 381 381 ҡ00382 00 382 382 Ң00383 00 383 383 ң00384 00 384 384 Ҥ00385 00 385 385 ҥ00386 00 386 386 Ҧ00387 00 387 387 ҧ00388 00 388 388 Ҩ00389 00 389 389 ҩ00390 00 390 390 Ҫ00391 00 391 391 ҫ00392 00 392 392 Ҭ00393 00 393 393 ҭ00394 00 394 394 Ү00395 00 395 395 ү00396 00 396 396 Ұ00397 00 397 397 ұ00398 00 398 398 Ҳ00399 00 399 399 ҳ00400 00 400 400 Ҵ00401 00 401 401 ҵ00402 00 402 402 Ҷ00403 00 403 403 ҷ00404 00 404 404 Ҹ00405 00 405 405 ҹ00406 00 406 406 Һ00407 00 407 407 һ00408 00 408 408 Ҽ00409 00 409 409 ҽ00410 00 410 410 Ҿ00411 00 411 411 ҿ00412 00 412 412 Ӏ00413 00 413 413 Ӂ00414 00 414 414 ӂ00415 00 415 415 Ӄ00416 00 416 416 ӄ00417 00 417 417 Ӆ00418 00 418 418 ӆ00419 00 419 419 Ӈ00420 00 420 420 ӈ00421 00 421 421 Ӊ00422 00 422 422 ӊ00423 00 423 423 Ӌ00424 00 424 424 ӌ00425 00 425 425 Ӎ00426 00 426 426 ӎ00427 00 427 427 ӏ00428 00 428 428 Ӑ00429 00 429 429 ӑ00430 00 430 430 Ӓ00431 00 431 431 ӓ00432 00 432 432 Ӕ00433 00 433 433 ӕ00434 00 434 434 Ӗ00435 00 435 435 ӗ00436 00 436 436 Ә00437 00 437 437 ә00438 00 438 438 Ӛ00439 00 439 439 ӛ00440 00 440 440 Ӝ00441 00 441 441 ӝ00442 00 442 442 Ӟ00443 00 443 443 ӟ00444 00 444 444 Ӡ00445 00 445 445 ӡ00446 00 446 446 Ӣ00447 00 447 447 ӣ00448 00 448 448 Ӥ00449 00 449 449 ӥ00450 00 450 450 Ӧ00451 00 451 451 ӧ00452 00 452 452 Ө00453 00 453 453 ө00454 00 454 454 Ӫ00455 00 455 455 ӫ00456 00 456 456 Ӭ00457 00 457 457 ӭ00458 00 458 458 Ӯ00459 00 459 459 ӯ00460 00 460 460 Ӱ00461 00 461 461 ӱ00462 00 462 462 Ӳ00463 00 463 463 ӳ00464 00 464 464 Ӵ00465 00 465 465 ӵ00466 00 466 466 Ӷ00467 00 467 467 ӷ00468 00 468 468 Ӹ00469 00 469 469 ӹ00470 00 470 470 Ӻ00471 00 471 471 ӻ00472 00 472 472 Ӽ00473 00 473 473 ӽ00474 00 474 474 Ӿ00475 00 475 475 ӿ00476 00 476 476 Ԁ00477 00 477 477 ԁ00478 00 478 478 Ԃ00479 00 479 479 ԃ00480 00 480 480 Ԅ00481 00 481 481 ԅ00482 00 482 482 Ԇ00483 00 483 483 ԇ00484 00 484 484 Ԉ00485 00 485 485 ԉ00486 00 486 486 Ԋ00487 00 487 487 ԋ00488 00 488 488 Ԍ00489 00 489 489 ԍ00490 00 490 490 Ԏ00491 00 491 491 ԏ00492 00 492 492 Ԑ00493 00 493 493 ԑ00494 00 494 494 Ԓ00495 00 495 495 ԓ00496 00 496 496 Ԕ00497 00 497 497 ԕ00498 00 498 498 Ԗ00499 00 499 499 ԗ00500 00 500 500 Ԙ00501 00 501 501 ԙ00502 00 502 502 Ԛ00503 00 503 503 ԛ00504 00 504 504 Ԝ00505 00 505 505 ԝ00506 00 506 506 Ԟ00507 00 507 507 ԟ00508 00 508 508 Ԡ00509 00 509 509 ԡ00510 00 510 510 Ԣ00511 00 511 511 ԣ00512 00 512 512 Ԥ00513 00 513 513 ԥ00514 00 514 514 Ԧ00515 00 515 515 ԧ00516 00 516 516 Ԩ00517 00 517 517 ԩ00518 00 518 518 Ԫ00519 00 519 519 ԫ00520 00 520 520 Ԭ00521 00 521 521 ԭ00522 00 522 522 Ԯ00523 00 523 523 ԯ00524 00 524 524 ἀ00525 00 525 525 ἁ00526 00 526 526 ἂ00527 00 527 527 ἃ00528 00 528 528 ἄ00529 00 529 529 ἅ00530 00 530 530 ἆ00531 00 531 531 ἇ00532 00 532 532 Ἀ00533 00 533 533 Ἁ00534 00 534 534 Ἂ00535 00 535 535 Ἃ00536 00 536 536 Ἄ00537 00 537 537 Ἅ00538 00 538 538 Ἆ00539 00 539 539 Ἇ00540 00 540 540 ἐ00541 00 541 541 ἑ00542 00 542 542 ἒ00543 00 543 543 ἓ00544 00 544 544 ἔ00545 00 545 545 ἕ00546 00 546 546 Ἐ00547 00 547 547 Ἑ00548 00 548 548 Ἒ00549 00 549 549 Ἓ00550 00 550 550 Ἔ00551 00 551 551 Ἕ00552 00 552 552 ἠ00553 00 553 553 ἡ00554 00 554 554 ἢ00555 00 555 555 ἣ00556 00 556 556 ἤ00557 00 557 557 ἥ00558 00 558 558 ἦ00559 00 559 559 ἧ00560 00 560 560 Ἠ00561 00 561 561 Ἡ00562 00 562 562 Ἢ00563 00 563 563 Ἣ00564 00 564 564 Ἤ00565 00 565 565 Ἥ00566 00 566 566 Ἦ00567 00 567 567 Ἧ00568 00 568 568 ἰ00569 00 569 569 ἱ00570 00 570 570 ἲ00571 00 571 571 ἳ00572 00 572 572 ἴ00573 00 573 573 ἵ00574 00 574 574 ἶ00575 00 575 575 ἷ00576 00 576 576 Ἰ00577 00 577 577 Ἱ00578 00 578 578 Ἲ00579 00 579 579 Ἳ00580 00 580 580 Ἴ00581 00 581 581 Ἵ00582 00 582 582 Ἶ00583 00 583 583 Ἷ00584 00 584 584 ὀ00585 00 585 585 ὁ00586 00 586 586 ὂ00587 00 587 587 ὃ00588 00 588 588 ὄ00589 00 589 589 ὅ00590 00 590 590 Ὀ00591 00 591 591 Ὁ00592 00 592 592 Ὂ00593 00 593 593 Ὃ00594 00 594 594 Ὄ00595 00 595 595 Ὅ00596 00 596 596 ὐ00597 00 597 597 ὑ00598 00 598 598 ὒ00599 00 599 599 ὓ00600 00 600 600 ὔ00601 00 601 601 ὕ00602 00 602 602 ὖ00603 00 603 603 ὗ00604 00 604 604 Ὑ00605 00 605 605 Ὓ00606 00 606 606 Ὕ00607 00 607 607 Ὗ00608 00 608 608 ὠ00609 00 609 609 ὡ00610 00 610 610 ὢ00611 00 611 611 ὣ00612 00 612 612 ὤ00613 00 613 613 ὥ00614 00 614 614 ὦ00615 00 615 615 ὧ00616 00 616 616 Ὠ00617 00 617 617 Ὡ00618 00 618 618 Ὢ00619 00 619 619 Ὣ00620 00 620 620 Ὤ00621 00 621 621 Ὥ00622 00 622 622 Ὦ00623 00 623 623 Ὧ00624 00 624 624 ὰ00625 00 625 625 ά00626 00 626 626 ὲ00627 00 627 627 έ00628 00 628 628 ὴ00629 00 629 629 ή00630 00 630 630 ὶ00631 00 631 631 ί00632 00 632 632 ὸ00633 00 633 633 ό00634 00 634 634 ὺ00635 00 635 635 ύ00636 00 636 636 ὼ00637 00 637 637 ώ00638 00 638 638 ᾀ00639 00 639 639 ᾁ00640 00 640 640 ᾂ00641 00 641 641 ᾃ00642 00 642 642 ᾄ00643 00 643 643 ᾅ00644 00 644 644 ᾆ00645 00 645 645 ᾇ00646 00 646 646 ᾈ00647 00 647 647 ᾉ00648 00 648 648 ᾊ00649 00 649 649 ᾋ00650 00 650 650 ᾌ00651 00 651 651 ᾍ00652 00 652 652 ᾎ00653 00 653 653 ᾏ00654 00 654 654 ᾐ00655 00 655 655 ᾑ00656 00 656 656 ᾒ00657 00 657 657 ᾓ00658 00 658 658 ᾔ00659 00 659 659 ᾕ00660 00 660 660 ᾖ00661 00 661 661 ᾗ00662 00 662 662 ᾘ00663 00 663 663 ᾙ00664 00 664 664 ᾚ00665 00 665 665 ᾛ00666 00 666 666 ᾜ00667 00 667 667 ᾝ00668 00 668 668 ᾞ00669 00 669 669 ᾟ00670 00 670 670 ᾠ00671 00 671 671 ᾡ00672 00 672 672 ᾢ00673 00 673 673 ᾣ00674 00 674 674 ᾤ00675 00 675 675 ᾥ00676 00 676 676 ᾦ00677 00 677 677 ᾧ00678 00 678 678 ᾨ00679 00 679 679 ᾩ00680 00 680 680 ᾪ00681 00 681 681 ᾫ00682 00 682 682 ᾬ00683 00 683 683 ᾭ00684 00 684 684 ᾮ00685 00 685 685 ᾯ00686 00 686 686 ᾰ00687 00 687 687 ᾱ00688 00 688 688 ᾲ00689 00 689 689 ᾳ00690 00 690 690 ᾴ00691 00 691 691 ᾶ00692 00 692 692 ᾷ00693 00 693 693 Ᾰ00694 00 694 694 Ᾱ00695 00 695 695 Ὰ00696 00 696 696 Ά00697 00 697 697 ᾼ00698 00 698 698 ι00699 00 699 699 ῂ00700 00 700 700 ῃ00701 00 701 701 ῄ00702 00 702 702 ῆ00703 00 703 703 ῇ00704 00 704 704 Ὲ00705 00 705 705 Έ00706 00 706 706 Ὴ00707 00 707 707 Ή00708 00 708 708 ῌ00709 00 709 709 ῐ00710 00 710 710 ῑ00711 00 711 711 ῒ00712 00 712 712 ΐ00713 00 713 713 ῖ00714 00 714 714 ῗ00715 00 715 715 Ῐ00716 00 716 716 Ῑ00717 00 717 717 Ὶ00718 00 718 718 Ί00719 00 719 719 ῠ00720 00 720 720 ῡ00721 00 721 721 ῢ00722 00 722 722 ΰ00723 00 723 723 ῤ00724 00 724 724 ῥ00725 00 725 725 ῦ00726 00 726 726 ῧ00727 00 727 727 Ῠ00728 00 728 728 Ῡ00729 00 729 729 Ὺ00730 00 730 730 Ύ00731 00 731 731 Ῥ00732 00 732 732 ῲ00733 00 733 733 ῳ00734 00 734 734 ῴ00735 00 735 735 ῶ00736 00 736 736 ῷ00737 00 737 737 Ὸ00738 00 738 738 Ό00739 00 739 739 Ὼ00740 00 740 740 Ώ00741 00 741 741 ῼ00742 00 742 742 Ⲁ00743 00 743 743 ⲁ00744 00 744 744 Ⲃ00745 00 745 745 ⲃ00746 00 746 746 Ⲅ00747 00 747 747 ⲅ00748 00 748 748 Ⲇ00749 00 749 749 ⲇ00750 00 750 750 Ⲉ00751 00 751 751 ⲉ00752 00 752 752 Ⲋ00753 00 753 753 ⲋ00754 00 754 754 Ⲍ00755 00 755 755 ⲍ00756 00 756 756 Ⲏ00757 00 757 757 ⲏ00758 00 758 758 Ⲑ00759 00 759 759 ⲑ00760 00 760 760 Ⲓ00761 00 761 761 ⲓ00762 00 762 762 Ⲕ00763 00 763 763 ⲕ00764 00 764 764 Ⲗ00765 00 765 765 ⲗ00766 00 766 766 Ⲙ00767 00 767 767 ⲙ00768 00 768 768 Ⲛ00769 00 769 769 ⲛ00770 00 770 770 Ⲝ00771 00 771 771 ⲝ00772 00 772 772 Ⲟ00773 00 773 773 ⲟ00774 00 774 774 Ⲡ00775 00 775 775 ⲡ00776 00 776 776 Ⲣ00777 00 777 777 ⲣ00778 00 778 778 Ⲥ00779 00 779 779 ⲥ00780 00 780 780 Ⲧ00781 00 781 781 ⲧ00782 00 782 782 Ⲩ00783 00 783 783 ⲩ00784 00 784 784 Ⲫ00785 00 785 785 ⲫ00786 00 786 786 Ⲭ00787 00 787 787 ⲭ00788 00 788 788 Ⲯ00789 00 789 789 ⲯ00790 00 790 790 Ⲱ00791 00 791 791 ⲱ00792 00 792 792 Ⲳ00793 00 793 793 ⲳ00794 00 794 794 Ⲵ00795 00 795 795 ⲵ00796 00 796 796 Ⲷ00797 00 797 797 ⲷ00798 00 798 798 Ⲹ00799 00 799 799 ⲹ00800 00 800 800 Ⲻ00801 00 801 801 ⲻ00802 00 802 802 Ⲽ00803 00 803 803 ⲽ00804 00 804 804 Ⲿ00805 00 805 805 ⲿ00806 00 806 806 Ⳁ00807 00 807 807 ⳁ00808 00 808 808 Ⳃ00809 00 809 809 ⳃ00810 00 810 810 Ⳅ00811 00 811 811 ⳅ00812 00 812 812 Ⳇ00813 00 813 813 ⳇ00814 00 814 814 Ⳉ00815 00 815 815 ⳉ00816 00 816 816 Ⳋ00817 00 817 817 ⳋ00818 00 818 818 Ⳍ00819 00 819 819 ⳍ00820 00 820 820 Ⳏ00821 00 821 821 ⳏ00822 00 822 822 Ⳑ00823 00 823 823 ⳑ00824 00 824 824 Ⳓ00825 00 825 825 ⳓ00826 00 826 826 Ⳕ00827 00 827 827 ⳕ00828 00 828 828 Ⳗ00829 00 829 829 ⳗ00830 00 830 830 Ⳙ00831 00 831 831 ⳙ00832 00 832 832 Ⳛ00833 00 833 833 ⳛ00834 00 834 834 Ⳝ00835 00 835 835 ⳝ00836 00 836 836 Ⳟ00837 00 837 837 ⳟ00838 00 838 838 Ⳡ00839 00 839 839 ⳡ00840 00 840 840 Ⳣ00841 00 841 841 ⳣ00842 00 842 842 ⳤ00843 00 843 843 Ⳬ00844 00 844 844 ⳬ00845 00 845 845 Ⳮ00846 00 846 846 ⳮ00847 00 847 847 Ⳳ00848 00 848 848 ⳳ00849 00 849 849 Ꙁ00850 00 850 850 ꙁ00851 00 851 851 Ꙃ00852 00 852 852 ꙃ00853 00 853 853 Ꙅ00854 00 854 854 ꙅ00855 00 855 855 Ꙇ00856 00 856 856 ꙇ00857 00 857 857 Ꙉ00858 00 858 858 ꙉ00859 00 859 859 Ꙋ00860 00 860 860 ꙋ00861 00 861 861 Ꙍ00862 00 862 862 ꙍ00863 00 863 863 Ꙏ00864 00 864 864 ꙏ00865 00 865 865 Ꙑ00866 00 866 866 ꙑ00867 00 867 867 Ꙓ00868 00 868 868 ꙓ00869 00 869 869 Ꙕ00870 00 870 870 ꙕ00871 00 871 871 Ꙗ00872 00 872 872 ꙗ00873 00 873 873 Ꙙ00874 00 874 874 ꙙ00875 00 875 875 Ꙛ00876 00 876 876 ꙛ00877 00 877 877 Ꙝ00878 00 878 878 ꙝ00879 00 879 879 Ꙟ00880 00 880 880 ꙟ00881 00 881 881 Ꙡ00882 00 882 882 ꙡ00883 00 883 883 Ꙣ00884 00 884 884 ꙣ00885 00 885 885 Ꙥ00886 00 886 886 ꙥ00887 00 887 887 Ꙧ00888 00 888 888 ꙧ00889 00 889 889 Ꙩ00890 00 890 890 ꙩ00891 00 891 891 Ꙫ00892 00 892 892 ꙫ00893 00 893 893 Ꙭ00894 00 894 894 ꙭ00895 00 895 895 ꙮ00896 00 896 896 ꙿ00897 00 897 897 Ꚁ00898 00 898 898 ꚁ00899 00 899 899 Ꚃ00900 00 900 900 ꚃ00901 00 901 901 Ꚅ00902 00 902 902 ꚅ00903 00 903 903 Ꚇ00904 00 904 904 ꚇ00905 00 905 905 Ꚉ00906 00 906 906 ꚉ00907 00 907 907 Ꚋ00908 00 908 908 ꚋ00909 00 909 909 Ꚍ00910 00 910 910 ꚍ00911 00 911 911 Ꚏ00912 00 912 912 ꚏ00913 00 913 913 Ꚑ00914 00 914 914 ꚑ00915 00 915 915 Ꚓ00916 00 916 916 ꚓ00917 00 917 917 Ꚕ00918 00 918 918 ꚕ00919 00 919 919 Ꚗ00920 00 920 920 ꚗ00921 00 921 921 Ꚙ00922 00 922 922 ꚙ00923 00 923 923 Ꚛ00924 00 924 924 ꚛ00925 00 925 925 ꚜ00926 00 926 926 ꚝ00927 00 927 927 ᲀ00928 00 928 928 ᲁ00929 00 929 929 ᲂ00930 00 930 930 ᲃ00931 00 931 931 ᲄ00932 00 932 932 ᲅ00933 00 933 933 ᲆ00934 00 934 934 ᲇ00935 00 935 935 ᲈ00936 00 936 936 Ա00937 00 937 937 Բ00938 00 938 938 Գ00939 00 939 939 Դ00940 00 940 940 Ե00941 00 941 941 Զ00942 00 942 942 Է00943 00 943 943 Ը00944 00 944 944 Թ00945 00 945 945 Ժ00946 00 946 946 Ի00947 00 947 947 Լ00948 00 948 948 Խ00949 00 949 949 Ծ00950 00 950 950 Կ00951 00 951 951 Հ00952 00 952 952 Ձ00953 00 953 953 Ղ00954 00 954 954 Ճ00955 00 955 955 Մ00956 00 956 956 Յ00957 00 957 957 Ն00958 00 958 958 Շ00959 00 959 959 Ո00960 00 960 960 Չ00961 00 961 961 Պ00962 00 962 962 Ջ00963 00 963 963 Ռ00964 00 964 964 Ս00965 00 965 965 Վ00966 00 966 966 Տ00967 00 967 967 Ր00968 00 968 968 Ց00969 00 969 969 Ւ00970 00 970 970 Փ00971 00 971 971 Ք00972 00 972 972 Օ00973 00 973 973 Ֆ00974 00 974 974 ՙ00975 00 975 975 ՠ00976 00 976 976 ա00977 00 977 977 բ00978 00 978 978 գ00979 00 979 979 դ00980 00 980 980 ե00981 00 981 981 զ00982 00 982 982 է00983 00 983 983 ը00984 00 984 984 թ00985 00 985 985 ժ00986 00 986 986 ի00987 00 987 987 լ00988 00 988 988 խ00989 00 989 989 ծ00990 00 990 990 կ00991 00 991 991 հ00992 00 992 992 ձ00993 00 993 993 ղ00994 00 994 994 ճ00995 00 995 995 մ00996 00 996 996 յ00997 00 997 997 ն00998 00 998 998 շ00999 00 999 999 ո01000 01 000 1000 A01001 01 001 1001 B01002 01 002 1002 C01003 01 003 1003 D01004 01 004 1004 E01005 01 005 1005 F01006 01 006 1006 G01007 01 007 1007 H01008 01 008 1008 I01009 01 009 1009 J01010 01 010 1010 K01011 01 011 1011 L01012 01 012 1012 M01013 01 013 1013 N01014 01 014 1014 O01015 01 015 1015 P01016 01 016 1016 Q01017 01 017 1017 R01018 01 018 1018 S01019 01 019 1019 T01020 01 020 1020 U01021 01 021 1021 V01022 01 022 1022 W01023 01 023 1023 X01024 01 024 1024 Y01025 01 025 1025 Z01026 01 026 1026 a01027 01 027 1027 b01028 01 028 1028 c01029 01 029 1029 d01030 01 030 1030 e01031 01 031 1031 f01032 01 032 1032 g01033 01 033 1033 h01034 01 034 1034 i01035 01 035 1035 j01036 01 036 1036 k01037 01 037 1037 l01038 01 038 1038 m01039 01 039 1039 n01040 01 040 1040 o01041 01 041 1041 p01042 01 042 1042 q01043 01 043 1043 r01044 01 044 1044 s01045 01 045 1045 t01046 01 046 1046 u01047 01 047 1047 v01048 01 048 1048 w01049 01 049 1049 x01050 01 050 1050 y01051 01 051 1051 z01052 01 052 1052 À01053 01 053 1053 È01054 01 054 1054 É01055 01 055 1055 Ì01056 01 056 1056 Ò01057 01 057 1057 Ù01058 01 058 1058 à01059 01 059 1059 è01060 01 060 1060 é01061 01 061 1061 ì01062 01 062 1062 ò01063 01 063 1063 ù01064 01 064 1064 Ä01065 01 065 1065 ä01066 01 066 1066 Ö01067 01 067 1067 ö01068 01 068 1068 Ü01069 01 069 1069 ü01070 01 070 1070 ß01071 01 071 1071 Ç01072 01 072 1072 ç01073 01 073 1073 Ë01074 01 074 1074 ë01075 01 075 1075 Á01076 01 076 1076 á01077 01 077 1077 Ñ01078 01 078 1078 ñ01079 01 079 1079 Â01080 01 080 1080 il01081 01 081 1081 lo01082 01 082 1082 la01083 01 083 1083 gli01084 01 084 1084 le01085 01 085 1085 un01086 01 086 1086 uno01087 01 087 1087 una01088 01 088 1088 l'01089 01 089 1089 un'01090 01 090 1090 ad01091 01 091 1091 di01092 01 092 1092 d'01093 01 093 1093 da01094 01 094 1094 in01095 01 095 1095 con01096 01 096 1096 su01097 01 097 1097 per01098 01 098 1098 tra01099 01 099 1099 fra01100 01 100 1100 del01101 01 101 1101 dello01102 01 102 1102 della01103 01 103 1103 dei01104 01 104 1104 degli01105 01 105 1105 delle01106 01 106 1106 dell'01107 01 107 1107 al01108 01 108 1108 allo01109 01 109 1109 alla01110 01 110 1110 ai01111 01 111 1111 agli01112 01 112 1112 alle01113 01 113 1113 all'01114 01 114 1114 dal01115 01 115 1115 dallo01116 01 116 1116 dalla01117 01 117 1117 dai01118 01 118 1118 dagli01119 01 119 1119 dalle01120 01 120 1120 dall'01121 01 121 1121 nel01122 01 122 1122 nello01123 01 123 1123 nella01124 01 124 1124 nei01125 01 125 1125 negli01126 01 126 1126 nelle01127 01 127 1127 nell'01128 01 128 1128 sul01129 01 129 1129 sullo01130 01 130 1130 sulla01131 01 131 1131 sui01132 01 132 1132 sugli01133 01 133 1133 sulle01134 01 134 1134 sull'01135 01 135 1135 ed01136 01 136 1136 oppure01137 01 137 1137 ma01138 01 138 1138 però01139 01 139 1139 bensì01140 01 140 1140 se01141 01 141 1141 che01142 01 142 1142 perché01143 01 143 1143 quando01144 01 144 1144 mentre01145 01 145 1145 quindi01146 01 146 1146 dunque01147 01 147 1147 ossia01148 01 148 1148 cioè01149 01 149 1149 né01150 01 150 1150 io01151 01 151 1151 tu01152 01 152 1152 lui01153 01 153 1153 lei01154 01 154 1154 noi01155 01 155 1155 voi01156 01 156 1156 loro01157 01 157 1157 me01158 01 158 1158 te01159 01 159 1159 sé01160 01 160 1160 mi01161 01 161 1161 ti01162 01 162 1162 ci01163 01 163 1163 vi01164 01 164 1164 si01165 01 165 1165 li01166 01 166 1166 ne01167 01 167 1167 ce01168 01 168 1168 ve01169 01 169 1169 m'01170 01 170 1170 t'01171 01 171 1171 c'01172 01 172 1172 v'01173 01 173 1173 s'01174 01 174 1174 n'01175 01 175 1175 gl'01176 01 176 1176 glielo01177 01 177 1177 gliela01178 01 178 1178 glieli01179 01 179 1179 gliele01180 01 180 1180 gliel'01181 01 181 1181 questo01182 01 182 1182 questa01183 01 183 1183 questi01184 01 184 1184 queste01185 01 185 1185 quest'01186 01 186 1186 quello01187 01 187 1187 quella01188 01 188 1188 quelli01189 01 189 1189 quelle01190 01 190 1190 quell'01191 01 191 1191 ciò01192 01 192 1192 chi01193 01 193 1193 cui01194 01 194 1194 qual01195 01 195 1195 quale01196 01 196 1196 quali01197 01 197 1197 non01198 01 198 1198 essere01199 01 199 1199 esser01200 01 200 1200 sono01201 01 201 1201 sei01202 01 202 1202 siamo01203 01 203 1203 siete01204 01 204 1204 era01205 01 205 1205 stato01206 01 206 1206 stata01207 01 207 1207 stati01208 01 208 1208 state01209 01 209 1209 avere01210 01 210 1210 aver01211 01 211 1211 ho01212 01 212 1212 hai01213 01 213 1213 ha01214 01 214 1214 abbiamo01215 01 215 1215 avete01216 01 216 1216 hanno01217 01 217 1217 avuto01218 01 218 1218 potere01219 01 219 1219 posso01220 01 220 1220 puoi01221 01 221 1221 può01222 01 222 1222 possiamo01223 01 223 1223 potete01224 01 224 1224 possono01225 01 225 1225 dovere01226 01 226 1226 devo01227 01 227 1227 devi01228 01 228 1228 deve01229 01 229 1229 dobbiamo01230 01 230 1230 dovete01231 01 231 1231 devono01232 01 232 1232 volere01233 01 233 1233 voglio01234 01 234 1234 vuoi01235 01 235 1235 vuole01236 01 236 1236 vogliamo01237 01 237 1237 volete01238 01 238 1238 vogliono01239 01 239 1239 più01240 01 240 1240 meno01241 01 241 1241 molto01242 01 242 1242 poco01243 01 243 1243 già01244 01 244 1244 ancora01245 01 245 1245 sempre01246 01 246 1246 mai01247 01 247 1247 anche01248 01 248 1248 solo01249 01 249 1249 come01250 01 250 1250 dove123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100{ "name": "parole", "size": 17908, "path": "/Users/thomasseri/Desktop/columns/geodesic_mesh_nn/vocab_stages/01_parole_by_id.txt", "meta": { "min_word_freq": 3, "n_candidates": 17902, "source": "reconstructed_from_v1_pezzi", "top": [ [ "ingredient", 32409 ], [ "id", 22506 ], [ "the", 17636 ], [ "in", 13718 ], [ "of", 12175 ], [ "risposta", 11496 ], [ "and", 11119 ], [ "di", 10760 ], [ "is", 10074 ], [ "il", 7057 ], [ "to", 6645 ], [ "that", 6058 ], [ "la", 6018 ], [ "on", 5946 ], [ "or", 5603 ], [ "preparation", 5436 ], [ "context", 4037 ], [ "have", 3965 ], [ "as", 3952 ], [ "con", 3823 ] ] }, "specials": [ "<|end|>", "<|bos|>", "<|eos|>", "<|pad|>", "<|unk|>", "<|sep|>" ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122{ "name": "unioni", "size": 20006, "path": "/Users/thomasseri/Desktop/columns/geodesic_mesh_nn/vocab_stages/02_unioni_by_id.txt", "meta": { "min_union_freq": 5, "n_candidates": 20000, "source": "frequent_unions_on_v2_surfaces", "n_trigram": 6295, "n_bigram": 13705, "top": [ [ "id w", 20700, "bi" ], [ "ingredient id w", 16200, "tri" ], [ "ingredient ingredient id", 16200, "tri" ], [ "ingredient id", 16200, "bi" ], [ "ingredient ingredient", 16200, "bi" ], [ "id w ingredient", 15300, "tri" ], [ "w ingredient ingredient", 15300, "tri" ], [ "w ingredient", 15300, "bi" ], [ "1 1", 9522, "bi" ], [ "0 0", 8845, "bi" ], [ "1 1 1", 8760, "tri" ], [ "0 0 0", 6501, "tri" ], [ "id w preparation", 4500, "tri" ], [ "preparation id w", 4500, "tri" ], [ "w preparation id", 4500, "tri" ], [ "preparation id", 4500, "bi" ], [ "w preparation", 4500, "bi" ], [ "i don't", 3431, "bi" ], [ "on that", 3431, "bi" ], [ "a i", 3427, "bi" ] ] }, "specials": [ "<|end|>", "<|bos|>", "<|eos|>", "<|pad|>", "<|unk|>", "<|sep|>" ]}12345678910{ "pipeline": "v1_pezzi → v2_parole(from pezzi) → v3_unioni(from v2)", "n_word_types": 31186, "n_bigram_types": 190363, "n_trigram_types": 304771, "parole_kept": 17902, "unioni_kept": 20000, "min_word_freq": 3, "min_union_freq": 5}12345678910111213141516171819202122232425{ "design": "multi_vocab_stages_cascade", "note": "Tre id-space separati in SERIE: testo→V1 pezzi (~1200)→V2 parole→V3 unioni. NON encode greedy parallelo. ~1200 = scala goTommy2 (1251), non 1.2M.", "stages": { "0_pezzi": { "path": "/Users/thomasseri/Desktop/columns/geodesic_mesh_nn/vocab_stages/00_pezzi_by_id.txt", "size": 1251 }, "1_parole": { "path": "/Users/thomasseri/Desktop/columns/geodesic_mesh_nn/vocab_stages/01_parole_by_id.txt", "size": 17908 }, "2_unioni": { "path": "/Users/thomasseri/Desktop/columns/geodesic_mesh_nn/vocab_stages/02_unioni_by_id.txt", "size": 20006 } }, "encode": "encode_cascade = encode_v1 → pass_to_v2 → pass_to_v3. Wiring train: 3 stadi in serie (emb/mesh per stadio), non stream paralleli.", "api": { "encode_v1": "text → pezzi_ids", "pass_to_v2": "pezzi_ids → parole_ids (aggrega pezzi)", "pass_to_v3": "parole surfaces → unioni (2/3 se frequenti)", "encode_cascade": "encode_v1 → pass_to_v2 → pass_to_v3" }}.gitattributesDeleted-3
.gitignoreDeleted-6
LICENSE.mdDeleted-63
README.md+5-6
assets/r08_logo.jpgDeleted
config.jsonDeleted-50
model.safetensorsDeleted-3
modeling_transformer.pyDeleted-261
pezzi_tokenizer.pyDeleted-228
special_tokens_map.jsonDeleted-7
test_inference.pyDeleted-26
tokenizer.jsonDeleted-1267
tokenizer_config.jsonDeleted-9
transformer-baseline-45m-f16.ggufDeleted-3
vocab_stages.pyDeleted-971
vocab_stages/00_pezzi_by_id.meta.jsonDeleted-17
vocab_stages/00_pezzi_by_id.txtDeleted-1253
vocab_stages/01_parole_by_id.meta.jsonDeleted-100
vocab_stages/01_parole_by_id.txtDeleted
vocab_stages/02_unioni_by_id.meta.jsonDeleted-122
vocab_stages/02_unioni_by_id.txtDeleted
vocab_stages/counts_summary.jsonDeleted-10
vocab_stages/manifest.jsonDeleted-25