Instructions to use Patricale/Italian_GPT_mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Patricale/Italian_GPT_mlx with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("Patricale/Italian_GPT_mlx") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use Patricale/Italian_GPT_mlx with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "Patricale/Italian_GPT_mlx" --prompt "Once upon a time"
- Atomic Chat
mini-GPT italiano in MLX: pesi, tokenizer, codice di inferenza e model card
Browse files- README.md +119 -0
- config.json +21 -0
- example.py +44 -0
- minigpt/__init__.py +1 -0
- minigpt/config.py +132 -0
- minigpt/generate.py +218 -0
- minigpt/model.py +432 -0
- minigpt/tokenizer.py +253 -0
- model.safetensors +3 -0
- tokenizer.json +1 -0
README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- it
|
| 4 |
+
license: mit
|
| 5 |
+
library_name: mlx
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- mlx
|
| 9 |
+
- gpt
|
| 10 |
+
- from-scratch
|
| 11 |
+
- educational
|
| 12 |
+
- italian
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# mini-GPT italiano (MLX, 12M parametri)
|
| 16 |
+
|
| 17 |
+
Un transformer **decoder-only** scritto da zero con [MLX](https://github.com/ml-explore/mlx)
|
| 18 |
+
e addestrato su un MacBook con 29 libri italiani di pubblico dominio. È un progetto
|
| 19 |
+
**didattico**: serve a capire come funziona un language model, non a produrre testo utile.
|
| 20 |
+
|
| 21 |
+
*A small GPT-style language model written from scratch in MLX and trained on 29
|
| 22 |
+
public-domain Italian books. Educational project: it writes Italian-looking prose whose
|
| 23 |
+
meaning does not hold beyond a sentence.*
|
| 24 |
+
|
| 25 |
+
Codice, test, esperimenti e un manuale che spiega ogni componente: <https://github.com/patricale/mini-gpt-mlx>.
|
| 26 |
+
|
| 27 |
+
## Che cosa sa fare
|
| 28 |
+
|
| 29 |
+
Continua un testo in italiano letterario dell'Ottocento e del primo Novecento.
|
| 30 |
+
Ortografia, punteggiatura e dialoghi sono quasi sempre ben formati; il senso non regge
|
| 31 |
+
oltre la singola frase e ogni tanto compaiono parole inventate.
|
| 32 |
+
|
| 33 |
+
> **Quel ramo del lago di Como**domo e della Signora, che erano infatti commossi, fin
|
| 34 |
+
> dall'esser loro fatto per lui, da un tempo in cui il diletto si avrebbe fatto male.
|
| 35 |
+
|
| 36 |
+
## Architettura
|
| 37 |
+
|
| 38 |
+
| | |
|
| 39 |
+
|---|---|
|
| 40 |
+
| Tipo | decoder-only, pre-norm, weight tying tra embedding e LM head |
|
| 41 |
+
| Dimensioni | 6 layer, 6 head, `d_model` 384, contesto 256 token |
|
| 42 |
+
| Parametri | 12.194.688 |
|
| 43 |
+
| Posizioni | RoPE (Rotary Position Embedding) |
|
| 44 |
+
| Normalizzazione | RMSNorm |
|
| 45 |
+
| MLP | GELU, rapporto 4 |
|
| 46 |
+
| Tokenizer | BPE a livello di byte, vocabolario 4096, scritto da zero |
|
| 47 |
+
|
| 48 |
+
Non è un'architettura di `transformers`: per usarlo serve il codice incluso in questo
|
| 49 |
+
repository (cartella `minigpt/`, circa 1000 righe commentate).
|
| 50 |
+
|
| 51 |
+
## Come si usa
|
| 52 |
+
|
| 53 |
+
Servono un Mac con Apple Silicon e Python 3.12.
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
pip install mlx numpy pyyaml
|
| 57 |
+
python example.py --prompt "Quel ramo del lago di Como" --temperature 0.8 --top-p 0.9
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Oppure da Python, dalla cartella scaricata:
|
| 61 |
+
|
| 62 |
+
```python
|
| 63 |
+
import json
|
| 64 |
+
import mlx.core as mx
|
| 65 |
+
from minigpt.config import ModelConfig
|
| 66 |
+
from minigpt.generate import generate
|
| 67 |
+
from minigpt.model import GPT
|
| 68 |
+
from minigpt.tokenizer import BPETokenizer
|
| 69 |
+
|
| 70 |
+
model = GPT(ModelConfig(**json.load(open("config.json"))["model"]))
|
| 71 |
+
model.load_weights("model.safetensors")
|
| 72 |
+
tok = BPETokenizer.load("tokenizer.json")
|
| 73 |
+
|
| 74 |
+
ids = mx.array([tok.encode("Quel ramo del lago di Como")])
|
| 75 |
+
out = generate(model, ids, max_new_tokens=200, temperature=0.8, top_p=0.9)
|
| 76 |
+
print(tok.decode(out[0].tolist()))
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Dati
|
| 80 |
+
|
| 81 |
+
29 libri in italiano da [Project Gutenberg](https://www.gutenberg.org), tutti di pubblico
|
| 82 |
+
dominio: Manzoni, Dante, Leopardi, Collodi, Pirandello, Fogazzaro, De Amicis, Deledda,
|
| 83 |
+
Salgari, D'Annunzio, Capuana, Serao, De Roberto, Rovetta. In tutto 14,1 milioni di
|
| 84 |
+
caratteri, cioè 3,89 milioni di token di training e 0,43 milioni di validation (divisione
|
| 85 |
+
90/10 dentro ogni libro, così tutti gli autori compaiono in validation).
|
| 86 |
+
|
| 87 |
+
## Training
|
| 88 |
+
|
| 89 |
+
| | |
|
| 90 |
+
|---|---|
|
| 91 |
+
| Step | 3.000, batch 64 × 256 token (circa 12,6 passate sul corpus) |
|
| 92 |
+
| Ottimizzatore | AdamW scritto a mano, β = (0,9, 0,95), weight decay 0,1 |
|
| 93 |
+
| Learning rate | 6e-4 con 200 step di warmup, poi coseno fino a 6e-5 |
|
| 94 |
+
| Regolarizzazione | dropout 0,2, gradient clipping a 1,0 |
|
| 95 |
+
| Hardware | MacBook Pro M4 Pro, 24 GB; circa 29 minuti |
|
| 96 |
+
|
| 97 |
+
## Risultati
|
| 98 |
+
|
| 99 |
+
| Metrica | Valore |
|
| 100 |
+
|---|---|
|
| 101 |
+
| Loss di validation | **3,540** |
|
| 102 |
+
| Perplexity di validation | **34,5** |
|
| 103 |
+
|
| 104 |
+
La valutazione è su 20 batch fissi del set di validation. Senza dropout lo stesso modello
|
| 105 |
+
va in overfitting dopo 2000 step (miglior loss 3,628): il corpus è piccolo rispetto ai
|
| 106 |
+
parametri.
|
| 107 |
+
|
| 108 |
+
## Limiti
|
| 109 |
+
|
| 110 |
+
- **Non capisce e non sa nulla**: produce testo dall'aspetto plausibile, senza coerenza
|
| 111 |
+
oltre la frase e senza alcuna affidabilità sui fatti.
|
| 112 |
+
- **Solo italiano letterario d'epoca**: lessico, grafia e punteggiatura sono quelli dei
|
| 113 |
+
libri di training (per esempio i dialoghi introdotti da `--` o `—`). Su testo moderno,
|
| 114 |
+
tecnico o in altre lingue il risultato è peggiore.
|
| 115 |
+
- **I testi riflettono la loro epoca**, compresi stereotipi e linguaggio oggi
|
| 116 |
+
inaccettabili, che il modello può riprodurre.
|
| 117 |
+
- **Contesto di 256 token** (circa 800 caratteri); oltre, la generazione tiene
|
| 118 |
+
solo la parte finale del testo.
|
| 119 |
+
- Non è stato valutato per nessun uso pratico e non va usato in applicazioni reali.
|
config.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": {
|
| 3 |
+
"vocab_size": 4096,
|
| 4 |
+
"d_model": 384,
|
| 5 |
+
"n_layer": 6,
|
| 6 |
+
"n_head": 6,
|
| 7 |
+
"context_len": 256,
|
| 8 |
+
"dropout": 0.2,
|
| 9 |
+
"mlp_type": "gelu",
|
| 10 |
+
"mlp_ratio": 4,
|
| 11 |
+
"rope_base": 10000.0,
|
| 12 |
+
"norm_eps": 1e-05,
|
| 13 |
+
"norm_type": "rmsnorm",
|
| 14 |
+
"use_rope": true
|
| 15 |
+
},
|
| 16 |
+
"parameters": 12194688,
|
| 17 |
+
"metrics": {
|
| 18 |
+
"val_loss": 3.5403,
|
| 19 |
+
"val_perplexity": 34.48
|
| 20 |
+
}
|
| 21 |
+
}
|
example.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Genera testo con il modello di questa cartella.
|
| 2 |
+
|
| 3 |
+
pip install mlx numpy pyyaml
|
| 4 |
+
python example.py --prompt "Quel ramo del lago di Como" --temperature 0.8 --top-p 0.9
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import argparse
|
| 8 |
+
import json
|
| 9 |
+
import sys
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
HERE = Path(__file__).resolve().parent
|
| 13 |
+
sys.path.insert(0, str(HERE)) # il pacchetto `minigpt` è in questa cartella
|
| 14 |
+
|
| 15 |
+
import mlx.core as mx
|
| 16 |
+
|
| 17 |
+
from minigpt.config import ModelConfig
|
| 18 |
+
from minigpt.generate import generate
|
| 19 |
+
from minigpt.model import GPT
|
| 20 |
+
from minigpt.tokenizer import BPETokenizer
|
| 21 |
+
|
| 22 |
+
parser = argparse.ArgumentParser()
|
| 23 |
+
parser.add_argument("--prompt", default="Quel ramo del lago di Como")
|
| 24 |
+
parser.add_argument("--max-new-tokens", type=int, default=200)
|
| 25 |
+
parser.add_argument("--temperature", type=float, default=0.8, help="0 = greedy")
|
| 26 |
+
parser.add_argument("--top-k", type=int, default=None)
|
| 27 |
+
parser.add_argument("--top-p", type=float, default=0.9)
|
| 28 |
+
parser.add_argument("--seed", type=int, default=0)
|
| 29 |
+
args = parser.parse_args()
|
| 30 |
+
|
| 31 |
+
model = GPT(ModelConfig(**json.loads((HERE / "config.json").read_text())["model"]))
|
| 32 |
+
model.load_weights(str(HERE / "model.safetensors"))
|
| 33 |
+
tok = BPETokenizer.load(HERE / "tokenizer.json")
|
| 34 |
+
|
| 35 |
+
mx.random.seed(args.seed)
|
| 36 |
+
out = generate(
|
| 37 |
+
model,
|
| 38 |
+
mx.array([tok.encode(args.prompt)]),
|
| 39 |
+
args.max_new_tokens,
|
| 40 |
+
temperature=args.temperature,
|
| 41 |
+
top_k=args.top_k,
|
| 42 |
+
top_p=args.top_p,
|
| 43 |
+
)
|
| 44 |
+
print(tok.decode(out[0].tolist()))
|
minigpt/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""mini-GPT da zero in MLX."""
|
minigpt/config.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Configurazione del modello e del training.
|
| 2 |
+
|
| 3 |
+
Due dataclass (`ModelConfig`, `TrainConfig`) raccolte in una `Config`, caricabile da YAML:
|
| 4 |
+
|
| 5 |
+
model:
|
| 6 |
+
n_layer: 6
|
| 7 |
+
train:
|
| 8 |
+
lr: 3.0e-4
|
| 9 |
+
|
| 10 |
+
Le chiavi assenti prendono il default; le chiavi sconosciute sono un errore (un refuso in una
|
| 11 |
+
config non deve trasformarsi in un esperimento sbagliato senza che nessuno se ne accorga).
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
from dataclasses import asdict, dataclass, field, fields
|
| 17 |
+
from pathlib import Path
|
| 18 |
+
from typing import Any
|
| 19 |
+
|
| 20 |
+
import yaml
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
@dataclass(frozen=True)
|
| 24 |
+
class ModelConfig:
|
| 25 |
+
"""Iperparametri dell'architettura. I default danno ~12.2M parametri."""
|
| 26 |
+
|
| 27 |
+
vocab_size: int = 4096
|
| 28 |
+
d_model: int = 384 # dimensione del residual stream
|
| 29 |
+
n_layer: int = 6
|
| 30 |
+
n_head: int = 6
|
| 31 |
+
context_len: int = 256 # lunghezza massima della sequenza in training
|
| 32 |
+
dropout: float = 0.0
|
| 33 |
+
mlp_type: str = "gelu" # "gelu" | "swiglu"
|
| 34 |
+
mlp_ratio: int = 4 # d_hidden = mlp_ratio * d_model (per SwiGLU: 2/3 di questo)
|
| 35 |
+
rope_base: float = 10000.0 # base delle frequenze di RoPE
|
| 36 |
+
norm_eps: float = 1e-5
|
| 37 |
+
# Varianti usate nelle ablation (Fase 6)
|
| 38 |
+
norm_type: str = "rmsnorm" # "rmsnorm" | "layernorm"
|
| 39 |
+
use_rope: bool = True # False: nessuna informazione di posizione
|
| 40 |
+
|
| 41 |
+
def __post_init__(self) -> None:
|
| 42 |
+
if self.d_model % self.n_head != 0:
|
| 43 |
+
raise ValueError(
|
| 44 |
+
f"d_model ({self.d_model}) deve essere divisibile per n_head ({self.n_head})"
|
| 45 |
+
)
|
| 46 |
+
if self.head_dim % 2 != 0:
|
| 47 |
+
raise ValueError(
|
| 48 |
+
f"head_dim ({self.head_dim}) deve essere pari: RoPE ruota coppie di dimensioni"
|
| 49 |
+
)
|
| 50 |
+
if self.mlp_type not in ("gelu", "swiglu"):
|
| 51 |
+
raise ValueError(f"mlp_type sconosciuto: {self.mlp_type!r} (usa 'gelu' o 'swiglu')")
|
| 52 |
+
if self.norm_type not in ("rmsnorm", "layernorm"):
|
| 53 |
+
raise ValueError(
|
| 54 |
+
f"norm_type sconosciuto: {self.norm_type!r} (usa 'rmsnorm' o 'layernorm')"
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
@property
|
| 58 |
+
def head_dim(self) -> int:
|
| 59 |
+
return self.d_model // self.n_head
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
@dataclass(frozen=True)
|
| 63 |
+
class TrainConfig:
|
| 64 |
+
"""Iperparametri di ottimizzazione e bookkeeping di una run."""
|
| 65 |
+
|
| 66 |
+
run_name: str = "base"
|
| 67 |
+
seed: int = 1337
|
| 68 |
+
data_dir: str = "data"
|
| 69 |
+
out_dir: str = "runs"
|
| 70 |
+
|
| 71 |
+
batch_size: int = 64
|
| 72 |
+
max_steps: int = 5000
|
| 73 |
+
|
| 74 |
+
# AdamW + schedule (warmup lineare, poi cosine decay fino a min_lr)
|
| 75 |
+
lr: float = 3e-4
|
| 76 |
+
min_lr: float = 3e-5
|
| 77 |
+
warmup_steps: int = 200
|
| 78 |
+
weight_decay: float = 0.1
|
| 79 |
+
beta1: float = 0.9
|
| 80 |
+
beta2: float = 0.95
|
| 81 |
+
grad_clip: float = 1.0
|
| 82 |
+
|
| 83 |
+
log_interval: int = 50 # ogni quanti step scrivere la loss di training
|
| 84 |
+
eval_interval: int = 250
|
| 85 |
+
eval_batches: int = 20
|
| 86 |
+
ckpt_interval: int = 1000
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
@dataclass(frozen=True)
|
| 90 |
+
class Config:
|
| 91 |
+
model: ModelConfig = field(default_factory=ModelConfig)
|
| 92 |
+
train: TrainConfig = field(default_factory=TrainConfig)
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def _build(cls: type, section: str, raw: dict[str, Any] | None):
|
| 96 |
+
"""Costruisce una dataclass da un dict, con controllo delle chiavi e cast dei tipi."""
|
| 97 |
+
raw = raw or {}
|
| 98 |
+
known = {f.name: f for f in fields(cls)}
|
| 99 |
+
unknown = sorted(set(raw) - set(known))
|
| 100 |
+
if unknown:
|
| 101 |
+
raise ValueError(f"Chiavi sconosciute nella sezione '{section}': {', '.join(unknown)}")
|
| 102 |
+
|
| 103 |
+
kwargs = {}
|
| 104 |
+
for name, value in raw.items():
|
| 105 |
+
# PyYAML legge "3e-4" (senza punto) come stringa: convertiamo esplicitamente
|
| 106 |
+
# al tipo dichiarato nella dataclass, così l'errore emerge qui e non a metà training.
|
| 107 |
+
target = {"int": int, "float": float, "str": str, "bool": bool}[known[name].type]
|
| 108 |
+
if target is bool and not isinstance(value, bool):
|
| 109 |
+
raise ValueError(f"{section}.{name} deve essere true o false, trovato {value!r}")
|
| 110 |
+
if target is int and isinstance(value, float) and not value.is_integer():
|
| 111 |
+
raise ValueError(f"{section}.{name} deve essere un intero, trovato {value}")
|
| 112 |
+
kwargs[name] = target(value)
|
| 113 |
+
return cls(**kwargs)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def load_config(path: str | Path) -> Config:
|
| 117 |
+
"""Legge una config YAML con sezioni opzionali `model:` e `train:`."""
|
| 118 |
+
raw = yaml.safe_load(Path(path).read_text()) or {}
|
| 119 |
+
unknown = sorted(set(raw) - {"model", "train"})
|
| 120 |
+
if unknown:
|
| 121 |
+
raise ValueError(f"Sezioni sconosciute nella config: {', '.join(unknown)}")
|
| 122 |
+
return Config(
|
| 123 |
+
model=_build(ModelConfig, "model", raw.get("model")),
|
| 124 |
+
train=_build(TrainConfig, "train", raw.get("train")),
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def save_config(cfg: Config, path: str | Path) -> None:
|
| 129 |
+
"""Salva la config effettivamente usata (per riproducibilità: va in `runs/<nome>/`)."""
|
| 130 |
+
path = Path(path)
|
| 131 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 132 |
+
path.write_text(yaml.safe_dump(asdict(cfg), sort_keys=False))
|
minigpt/generate.py
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generazione autoregressiva: temperature, top-k, top-p e KV cache.
|
| 2 |
+
|
| 3 |
+
A ogni passo il modello produce V logit per il prossimo token; `sample_next` decide quale
|
| 4 |
+
token scegliere. I tre controlli si applicano in quest'ordine:
|
| 5 |
+
|
| 6 |
+
logit --(÷ temperature)--> --(top-k)--> --(top-p)--> softmax --> estrazione
|
| 7 |
+
|
| 8 |
+
Top-k e top-p risolvono lo stesso problema: la coda della distribuzione. Ognuno dei
|
| 9 |
+
migliaia di token improbabili ha probabilità minuscola, ma tutti insieme pesano; ogni
|
| 10 |
+
tanto ne viene estratto uno e il testo deraglia. Tagliare la coda prima di campionare
|
| 11 |
+
tiene la varietà tra i candidati sensati ed elimina gli incidenti.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
from collections.abc import Collection, Iterator
|
| 17 |
+
|
| 18 |
+
import mlx.core as mx
|
| 19 |
+
|
| 20 |
+
from minigpt.model import GPT
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def top_k_filter(logits: mx.array, k: int) -> mx.array:
|
| 24 |
+
"""Tiene i `k` logit più alti, mette gli altri a -inf (probabilità 0 dopo softmax).
|
| 25 |
+
|
| 26 |
+
Il numero di candidati è fisso: semplice, ma rigido. Se il modello è sicuro (un token
|
| 27 |
+
al 95%) k = 50 lascia passare 49 alternative quasi tutte sbagliate; se è incerto tra
|
| 28 |
+
200 parole plausibili, ne butta via 150.
|
| 29 |
+
|
| 30 |
+
In caso di pari merito sulla soglia vengono tenuti tutti i token a quel valore.
|
| 31 |
+
|
| 32 |
+
Shape: (..., V) -> (..., V)
|
| 33 |
+
"""
|
| 34 |
+
k = min(k, logits.shape[-1])
|
| 35 |
+
threshold = mx.sort(logits, axis=-1)[..., -k][..., None] # (..., 1): k-esimo più alto
|
| 36 |
+
return mx.where(logits < threshold, -mx.inf, logits)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def top_p_filter(logits: mx.array, p: float) -> mx.array:
|
| 40 |
+
"""Nucleus sampling: tiene il più piccolo insieme di token con probabilità totale >= p.
|
| 41 |
+
|
| 42 |
+
Si ordinano i token per probabilità decrescente e si prende il prefisso più corto la
|
| 43 |
+
cui somma arriva a p. A differenza di top-k il numero di candidati si adatta alla
|
| 44 |
+
forma della distribuzione: 1-2 token quando il modello è sicuro, centinaia quando è
|
| 45 |
+
incerto.
|
| 46 |
+
|
| 47 |
+
Regola usata: un token (in ordine decrescente) viene scartato se la massa di quelli
|
| 48 |
+
*prima di lui* è già >= p. Il primo non viene quindi mai scartato, e il token che fa
|
| 49 |
+
superare la soglia è tenuto.
|
| 50 |
+
|
| 51 |
+
Shape: (..., V) -> (..., V)
|
| 52 |
+
"""
|
| 53 |
+
probs = mx.softmax(logits, axis=-1)
|
| 54 |
+
order = mx.argsort(-logits, axis=-1) # (..., V): indici dal più al meno probabile
|
| 55 |
+
sorted_probs = mx.take_along_axis(probs, order, axis=-1)
|
| 56 |
+
mass_before = mx.cumsum(sorted_probs, axis=-1) - sorted_probs # massa dei precedenti
|
| 57 |
+
drop_sorted = mass_before >= p # (..., V), nell'ordine "ordinato"
|
| 58 |
+
|
| 59 |
+
# Riporta la maschera nell'ordine originale dei token: l'argsort di una permutazione
|
| 60 |
+
# è la permutazione inversa.
|
| 61 |
+
inverse = mx.argsort(order, axis=-1)
|
| 62 |
+
drop = mx.take_along_axis(drop_sorted, inverse, axis=-1)
|
| 63 |
+
return mx.where(drop, -mx.inf, logits)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def _shape_logits(
|
| 67 |
+
logits: mx.array, temperature: float, top_k: int | None, top_p: float | None
|
| 68 |
+
) -> mx.array:
|
| 69 |
+
"""Temperature, poi top-k, poi top-p: i logit da cui si campiona (temperature > 0)."""
|
| 70 |
+
logits = logits / temperature
|
| 71 |
+
if top_k is not None:
|
| 72 |
+
logits = top_k_filter(logits, top_k)
|
| 73 |
+
if top_p is not None:
|
| 74 |
+
logits = top_p_filter(logits, top_p)
|
| 75 |
+
return logits
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def sample_next(
|
| 79 |
+
logits: mx.array,
|
| 80 |
+
temperature: float = 1.0,
|
| 81 |
+
top_k: int | None = None,
|
| 82 |
+
top_p: float | None = None,
|
| 83 |
+
) -> mx.array:
|
| 84 |
+
"""Sceglie il prossimo token dai logit dell'ultima posizione.
|
| 85 |
+
|
| 86 |
+
La temperature T riscala i logit prima della softmax: p_i ∝ exp(logit_i / T).
|
| 87 |
+
T < 1 rende la distribuzione più appuntita (testo più prevedibile), T > 1 più piatta
|
| 88 |
+
(più vario, più errori); T -> 0 tende all'argmax, che qui è il caso `temperature == 0`.
|
| 89 |
+
|
| 90 |
+
La temperature viene applicata *prima* dei filtri: top-p ragiona sulle probabilità,
|
| 91 |
+
e quelle dipendono da T (top-k no: riscalare non cambia l'ordine dei logit).
|
| 92 |
+
|
| 93 |
+
Args:
|
| 94 |
+
logits: (B, V)
|
| 95 |
+
Returns:
|
| 96 |
+
(B,) id dei token scelti
|
| 97 |
+
"""
|
| 98 |
+
if temperature == 0.0:
|
| 99 |
+
return mx.argmax(logits, axis=-1)
|
| 100 |
+
logits = _shape_logits(logits, temperature, top_k, top_p)
|
| 101 |
+
return mx.random.categorical(logits, axis=-1) # estrae da softmax(logits)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def next_token_probs(
|
| 105 |
+
logits: mx.array,
|
| 106 |
+
temperature: float = 1.0,
|
| 107 |
+
top_k: int | None = None,
|
| 108 |
+
top_p: float | None = None,
|
| 109 |
+
) -> mx.array:
|
| 110 |
+
"""La distribuzione da cui `sample_next` estrae, resa esplicita.
|
| 111 |
+
|
| 112 |
+
Serve a *guardare* l'effetto dei tre controlli (lo fa l'interfaccia web): i token
|
| 113 |
+
tagliati da top-k o top-p hanno probabilità 0, e con `temperature == 0` tutta la
|
| 114 |
+
massa sta sull'argmax.
|
| 115 |
+
|
| 116 |
+
Shape: (B, V) -> (B, V), ogni riga somma a 1
|
| 117 |
+
"""
|
| 118 |
+
if temperature == 0.0:
|
| 119 |
+
best = mx.argmax(logits, axis=-1)[..., None] # (B, 1)
|
| 120 |
+
return (mx.arange(logits.shape[-1]) == best).astype(mx.float32)
|
| 121 |
+
return mx.softmax(_shape_logits(logits, temperature, top_k, top_p), axis=-1)
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def generate_stream(
|
| 125 |
+
model: GPT,
|
| 126 |
+
idx: mx.array,
|
| 127 |
+
max_new_tokens: int,
|
| 128 |
+
temperature: float = 1.0,
|
| 129 |
+
top_k: int | None = None,
|
| 130 |
+
top_p: float | None = None,
|
| 131 |
+
use_cache: bool = True,
|
| 132 |
+
stop_ids: Collection[int] = (),
|
| 133 |
+
) -> Iterator[tuple[mx.array, mx.array]]:
|
| 134 |
+
"""Genera un token alla volta e lo restituisce subito, insieme ai suoi logit.
|
| 135 |
+
|
| 136 |
+
È il cuore della generazione; `generate` si limita a raccoglierne i token. Restituire
|
| 137 |
+
i passi uno a uno serve a mostrare il testo mentre viene scritto e a ispezionare la
|
| 138 |
+
distribuzione da cui ogni token è stato scelto.
|
| 139 |
+
|
| 140 |
+
- `use_cache=False`: a ogni passo si rifà il forward su tutta la finestra e si usa
|
| 141 |
+
solo l'ultima posizione.
|
| 142 |
+
- `use_cache=True`: il primo forward elabora il prompt e riempie la KV cache; poi a
|
| 143 |
+
ogni passo entra nel modello solo l'ultimo token generato.
|
| 144 |
+
|
| 145 |
+
Le due modalità producono gli stessi logit (a meno dell'arrotondamento float), quindi
|
| 146 |
+
lo stesso testo a parità di seed.
|
| 147 |
+
|
| 148 |
+
Finestra di contesto. Il modello è allenato su al più `context_len` token. Quando la
|
| 149 |
+
finestra è piena la si accorcia alla sua seconda metà e si riparte da lì. Con la cache
|
| 150 |
+
questo significa svuotarla e ricalcolarla sui token rimasti: non basterebbe buttare le
|
| 151 |
+
key/value più vecchie, perché quelle rimaste sono state calcolate "vedendo" i token
|
| 152 |
+
scartati e non coinciderebbero con un forward sulla sola finestra accorciata. Il
|
| 153 |
+
ricalcolo avviene una volta ogni context_len / 2 token, quindi costa poco.
|
| 154 |
+
|
| 155 |
+
Args:
|
| 156 |
+
idx: (B, T) prompt
|
| 157 |
+
stop_ids: la generazione si ferma dopo un passo in cui tutte le sequenze del batch
|
| 158 |
+
hanno prodotto uno di questi token (es. <EOS>); quel passo viene restituito.
|
| 159 |
+
Yields:
|
| 160 |
+
(next_id, logits): (B,) i token scelti e (B, V) i logit grezzi (prima di
|
| 161 |
+
temperature e filtri) da cui sono stati scelti.
|
| 162 |
+
"""
|
| 163 |
+
was_training = model.training
|
| 164 |
+
model.eval() # dropout spento in generazione
|
| 165 |
+
context_len = model.cfg.context_len
|
| 166 |
+
|
| 167 |
+
start = max(0, idx.shape[1] - context_len) # inizio della finestra dentro idx
|
| 168 |
+
cache = None # None = da (ri)costruire
|
| 169 |
+
|
| 170 |
+
# try/finally: chi consuma lo stream può abbandonarlo a metà (pulsante Stop); il
|
| 171 |
+
# modello deve comunque tornare nello stato in cui era.
|
| 172 |
+
try:
|
| 173 |
+
for _ in range(max_new_tokens):
|
| 174 |
+
if idx.shape[1] - start >= context_len: # finestra piena: tieni la seconda metà
|
| 175 |
+
start = idx.shape[1] - context_len // 2
|
| 176 |
+
cache = None
|
| 177 |
+
|
| 178 |
+
if not use_cache:
|
| 179 |
+
logits = model(idx[:, start:])[:, -1, :] # (B, V): forward su tutta la finestra
|
| 180 |
+
elif cache is None:
|
| 181 |
+
cache = model.make_cache()
|
| 182 |
+
logits = model(idx[:, start:], cache=cache)[:, -1, :] # riempie la cache
|
| 183 |
+
else:
|
| 184 |
+
logits = model(idx[:, -1:], cache=cache)[:, -1, :] # solo il token nuovo
|
| 185 |
+
|
| 186 |
+
next_id = sample_next(logits, temperature, top_k, top_p) # (B,)
|
| 187 |
+
idx = mx.concatenate([idx, next_id[:, None].astype(idx.dtype)], axis=1)
|
| 188 |
+
# MLX è lazy: senza eval il grafo (e la cache) crescerebbero senza mai essere
|
| 189 |
+
# calcolati, e i tempi misurati sarebbero falsi.
|
| 190 |
+
mx.eval(idx, logits, *([c.k for c in cache] + [c.v for c in cache] if cache else []))
|
| 191 |
+
|
| 192 |
+
yield next_id, logits
|
| 193 |
+
if stop_ids and all(t in stop_ids for t in next_id.tolist()):
|
| 194 |
+
break
|
| 195 |
+
finally:
|
| 196 |
+
model.train(was_training)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
def generate(
|
| 200 |
+
model: GPT,
|
| 201 |
+
idx: mx.array,
|
| 202 |
+
max_new_tokens: int,
|
| 203 |
+
temperature: float = 1.0,
|
| 204 |
+
top_k: int | None = None,
|
| 205 |
+
top_p: float | None = None,
|
| 206 |
+
use_cache: bool = True,
|
| 207 |
+
) -> mx.array:
|
| 208 |
+
"""Estende `idx` di `max_new_tokens` token, uno alla volta (vedi `generate_stream`).
|
| 209 |
+
|
| 210 |
+
Args:
|
| 211 |
+
idx: (B, T) prompt
|
| 212 |
+
Returns:
|
| 213 |
+
(B, T + max_new_tokens)
|
| 214 |
+
"""
|
| 215 |
+
stream = generate_stream(model, idx, max_new_tokens, temperature, top_k, top_p, use_cache)
|
| 216 |
+
for next_id, _ in stream:
|
| 217 |
+
idx = mx.concatenate([idx, next_id[:, None].astype(idx.dtype)], axis=1)
|
| 218 |
+
return idx
|
minigpt/model.py
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Il modello: transformer decoder-only in stile GPT, scritto con primitive MLX.
|
| 2 |
+
|
| 3 |
+
Schema (pre-norm):
|
| 4 |
+
|
| 5 |
+
token ids (B, T)
|
| 6 |
+
│ embedding -> (B, T, C)
|
| 7 |
+
▼
|
| 8 |
+
┌─ Block × n_layer ───────────────────────────┐
|
| 9 |
+
│ x = x + Attention(RMSNorm(x)) ← RoPE qui │
|
| 10 |
+
│ x = x + MLP(RMSNorm(x)) │
|
| 11 |
+
└─────────────────────────────────────────────┘
|
| 12 |
+
│ RMSNorm finale
|
| 13 |
+
│ LM head = embedding trasposto (weight tying) -> logits (B, T, V)
|
| 14 |
+
|
| 15 |
+
Convenzioni sulle shape: B = batch, T = lunghezza sequenza, C = d_model, H = n_head,
|
| 16 |
+
D = head_dim = C / H, V = vocab_size.
|
| 17 |
+
|
| 18 |
+
Non c'è un embedding posizionale sommato all'ingresso: l'informazione di posizione entra
|
| 19 |
+
solo dentro l'attention, tramite RoPE.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
from __future__ import annotations
|
| 23 |
+
|
| 24 |
+
import math
|
| 25 |
+
|
| 26 |
+
import mlx.core as mx
|
| 27 |
+
import mlx.nn as nn
|
| 28 |
+
import numpy as np
|
| 29 |
+
from mlx.utils import tree_flatten, tree_unflatten
|
| 30 |
+
|
| 31 |
+
from minigpt.config import ModelConfig
|
| 32 |
+
|
| 33 |
+
# --------------------------------------------------------------------------------------
|
| 34 |
+
# RMSNorm
|
| 35 |
+
# --------------------------------------------------------------------------------------
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class RMSNorm(nn.Module):
|
| 39 |
+
"""Root Mean Square normalization.
|
| 40 |
+
|
| 41 |
+
RMS(x) = sqrt( mean_i(x_i²) + eps )
|
| 42 |
+
y = g * x / RMS(x)
|
| 43 |
+
|
| 44 |
+
Rispetto a LayerNorm toglie due cose: la sottrazione della media e il bias. L'idea
|
| 45 |
+
(Zhang & Sennrich, 2019) è che il beneficio di LayerNorm venga quasi tutto dal
|
| 46 |
+
*riscalare* le attivazioni, non dal ricentrarle: resta un vettore di norma fissa
|
| 47 |
+
(RMS = 1, cioè norma L2 = sqrt(C)) con un guadagno `g` appreso per dimensione, a
|
| 48 |
+
costo minore. L'output è invariante alla scala dell'input: RMSNorm(a·x) = RMSNorm(x).
|
| 49 |
+
|
| 50 |
+
Shape: (..., C) -> (..., C)
|
| 51 |
+
"""
|
| 52 |
+
|
| 53 |
+
def __init__(self, dims: int, eps: float = 1e-5) -> None:
|
| 54 |
+
super().__init__()
|
| 55 |
+
self.weight = mx.ones((dims,)) # guadagno g, parte da 1
|
| 56 |
+
self.eps = eps
|
| 57 |
+
|
| 58 |
+
def __call__(self, x: mx.array) -> mx.array:
|
| 59 |
+
rms = mx.sqrt(mx.mean(mx.square(x), axis=-1, keepdims=True) + self.eps) # (..., 1)
|
| 60 |
+
return self.weight * (x / rms)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
class LayerNorm(nn.Module):
|
| 64 |
+
"""Layer normalization classica (Ba et al., 2016), per il confronto con RMSNorm.
|
| 65 |
+
|
| 66 |
+
y = g * (x - media(x)) / sqrt(var(x) + eps) + b
|
| 67 |
+
|
| 68 |
+
Rispetto a RMSNorm in più sottrae la media e ha un bias `b`: 2·C parametri invece di C.
|
| 69 |
+
|
| 70 |
+
Shape: (..., C) -> (..., C)
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
def __init__(self, dims: int, eps: float = 1e-5) -> None:
|
| 74 |
+
super().__init__()
|
| 75 |
+
self.weight = mx.ones((dims,))
|
| 76 |
+
self.bias = mx.zeros((dims,))
|
| 77 |
+
self.eps = eps
|
| 78 |
+
|
| 79 |
+
def __call__(self, x: mx.array) -> mx.array:
|
| 80 |
+
mean = mx.mean(x, axis=-1, keepdims=True)
|
| 81 |
+
var = mx.var(x, axis=-1, keepdims=True)
|
| 82 |
+
return self.weight * (x - mean) / mx.sqrt(var + self.eps) + self.bias
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def make_norm(cfg: ModelConfig) -> nn.Module:
|
| 86 |
+
"""La normalizzazione scelta in `cfg.norm_type`."""
|
| 87 |
+
cls = LayerNorm if cfg.norm_type == "layernorm" else RMSNorm
|
| 88 |
+
return cls(cfg.d_model, cfg.norm_eps)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
# --------------------------------------------------------------------------------------
|
| 92 |
+
# RoPE
|
| 93 |
+
# --------------------------------------------------------------------------------------
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def apply_rope(x: mx.array, offset: int = 0, base: float = 10000.0, scale: float = 1.0) -> mx.array:
|
| 97 |
+
"""Rotary Position Embedding (Su et al., 2021).
|
| 98 |
+
|
| 99 |
+
Invece di *sommare* un vettore di posizione all'embedding, RoPE *ruota* query e key
|
| 100 |
+
di un angolo proporzionale alla loro posizione. Le D dimensioni sono viste come D/2
|
| 101 |
+
coppie (x_{2i}, x_{2i+1}), cioè D/2 punti nel piano; la coppia i del token in
|
| 102 |
+
posizione m viene ruotata dell'angolo m·θ_i, con
|
| 103 |
+
|
| 104 |
+
θ_i = base^(-2i / D), i = 0 .. D/2 - 1
|
| 105 |
+
|
| 106 |
+
[x'_{2i} ] [cos mθ_i -sin mθ_i] [x_{2i} ]
|
| 107 |
+
[x'_{2i+1}] = [sin mθ_i cos mθ_i] [x_{2i+1}]
|
| 108 |
+
|
| 109 |
+
Perché funziona: il prodotto scalare tra due vettori ruotati di m·θ e n·θ dipende
|
| 110 |
+
solo dalla differenza degli angoli, quindi
|
| 111 |
+
|
| 112 |
+
<RoPE(q, m), RoPE(k, n)> = f(q, k, m - n)
|
| 113 |
+
|
| 114 |
+
e lo score di attention vede direttamente la posizione *relativa*. Le frequenze θ_i
|
| 115 |
+
vanno da 1 (i = 0: un giro ogni ~6 token, distingue posizioni vicine) a ~1/base
|
| 116 |
+
(lunghezza d'onda di decine di migliaia di token, distingue quelle lontane), come
|
| 117 |
+
nelle sinusoidi del Transformer originale. Essendo una rotazione non cambia la norma
|
| 118 |
+
dei vettori, e si applica solo a q e k (non a v).
|
| 119 |
+
|
| 120 |
+
Args:
|
| 121 |
+
x: (..., T, D) con D pari; tipicamente (B, H, T, D).
|
| 122 |
+
offset: posizione assoluta del primo token di `x`. È 0 in training; con la KV
|
| 123 |
+
cache si elabora un token per volta e l'offset dice dove si trova.
|
| 124 |
+
base: base delle frequenze (10000 di default).
|
| 125 |
+
scale: fattore applicato alle posizioni (m -> scale·m). Con scale < 1 si fa
|
| 126 |
+
"position interpolation": un contesto più lungo di quello di training viene
|
| 127 |
+
compresso nell'intervallo di posizioni già visto. Vedi Fase 6.
|
| 128 |
+
|
| 129 |
+
Returns:
|
| 130 |
+
Tensore ruotato, stessa shape di `x`.
|
| 131 |
+
"""
|
| 132 |
+
T, D = x.shape[-2], x.shape[-1]
|
| 133 |
+
half = D // 2
|
| 134 |
+
|
| 135 |
+
theta = base ** (-mx.arange(half, dtype=mx.float32) / half) # (D/2,) = base^(-2i/D)
|
| 136 |
+
positions = scale * mx.arange(offset, offset + T, dtype=mx.float32) # (T,)
|
| 137 |
+
angles = positions[:, None] * theta[None, :] # (T, D/2): angolo m·θ_i
|
| 138 |
+
cos, sin = mx.cos(angles), mx.sin(angles) # (T, D/2), broadcast su (..., T, D/2)
|
| 139 |
+
|
| 140 |
+
x_even = x[..., 0::2] # (..., T, D/2): prima coordinata di ogni coppia
|
| 141 |
+
x_odd = x[..., 1::2] # (..., T, D/2): seconda coordinata
|
| 142 |
+
rot_even = x_even * cos - x_odd * sin
|
| 143 |
+
rot_odd = x_even * sin + x_odd * cos
|
| 144 |
+
|
| 145 |
+
# Rimette le coppie nell'ordine originale: (..., T, D/2, 2) -> (..., T, D)
|
| 146 |
+
return mx.stack([rot_even, rot_odd], axis=-1).reshape(x.shape)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
# --------------------------------------------------------------------------------------
|
| 150 |
+
# Attention
|
| 151 |
+
# --------------------------------------------------------------------------------------
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def causal_mask(T: int) -> mx.array:
|
| 155 |
+
"""Maschera additiva (T, T): 0 dove j <= i, -inf dove j > i (il futuro).
|
| 156 |
+
|
| 157 |
+
Sommata agli score prima della softmax, porta a zero il peso di attention sulle
|
| 158 |
+
posizioni future: exp(-inf) = 0.
|
| 159 |
+
"""
|
| 160 |
+
return mx.triu(mx.full((T, T), -math.inf), k=1)
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
class KVCache:
|
| 164 |
+
"""Key e value già calcolate per i token passati, per *un* layer di attention.
|
| 165 |
+
|
| 166 |
+
Perché si può fare. In generazione si aggiunge un token alla volta. Grazie alla
|
| 167 |
+
maschera causale, tutto ciò che un layer calcola per le posizioni 0..t-1 non dipende
|
| 168 |
+
dal token t: rifare il forward sull'intera sequenza ricalcola ogni volta gli stessi
|
| 169 |
+
numeri. In particolare non cambiano le key e le value dei token passati, che sono
|
| 170 |
+
tutto ciò che serve al token nuovo per fare attention su di loro. Le si salva qui e a
|
| 171 |
+
ogni passo si elabora solo il token nuovo:
|
| 172 |
+
|
| 173 |
+
senza cache: passo t = forward su t token -> O(t²) per token (attention)
|
| 174 |
+
con cache: passo t = forward su 1 token,
|
| 175 |
+
che fa attention su t key salvate -> O(t) per token
|
| 176 |
+
|
| 177 |
+
Le key sono salvate *già ruotate* da RoPE con la loro posizione assoluta: non vanno
|
| 178 |
+
più toccate. Al token nuovo basta ruotare la propria query e la propria key con
|
| 179 |
+
offset = numero di token già in cache.
|
| 180 |
+
|
| 181 |
+
Shape: k, v: (B, H, T_passati, D), oppure None se la cache è vuota.
|
| 182 |
+
"""
|
| 183 |
+
|
| 184 |
+
def __init__(self) -> None:
|
| 185 |
+
self.k: mx.array | None = None
|
| 186 |
+
self.v: mx.array | None = None
|
| 187 |
+
|
| 188 |
+
@property
|
| 189 |
+
def length(self) -> int:
|
| 190 |
+
"""Numero di posizioni già in cache."""
|
| 191 |
+
return 0 if self.k is None else self.k.shape[2]
|
| 192 |
+
|
| 193 |
+
def append(self, k: mx.array, v: mx.array) -> tuple[mx.array, mx.array]:
|
| 194 |
+
"""Accoda le key/value dei token nuovi e restituisce quelle di tutta la sequenza."""
|
| 195 |
+
if self.k is not None:
|
| 196 |
+
k = mx.concatenate([self.k, k], axis=2) # (B, H, T_passati + T_nuovi, D)
|
| 197 |
+
v = mx.concatenate([self.v, v], axis=2)
|
| 198 |
+
self.k, self.v = k, v
|
| 199 |
+
return k, v
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class Attention(nn.Module):
|
| 203 |
+
"""Self-attention causale multi-head con RoPE.
|
| 204 |
+
|
| 205 |
+
Per ogni head: score = (q · kᵀ) / sqrt(D) + maschera causale
|
| 206 |
+
out = softmax(score) · v
|
| 207 |
+
|
| 208 |
+
Ogni posizione t costruisce una query ("cosa cerco"), ogni posizione s <= t espone
|
| 209 |
+
una key ("cosa offro") e un value ("cosa consegno"); l'output in t è la media dei
|
| 210 |
+
value pesata dalla compatibilità query-key. La divisione per sqrt(D) tiene la
|
| 211 |
+
varianza degli score ~1 indipendentemente da D, così la softmax non satura.
|
| 212 |
+
|
| 213 |
+
Le quattro proiezioni sono `nn.Linear` separate e senza bias: tenerle distinte
|
| 214 |
+
(invece di un'unica matrice qkv) rende banale applicare LoRA solo a q e v.
|
| 215 |
+
|
| 216 |
+
Con `cache` (generazione): `x` contiene solo i token *nuovi*, che fanno attention
|
| 217 |
+
sulle key/value in cache più le proprie. Vedi `KVCache`.
|
| 218 |
+
|
| 219 |
+
Shape: (B, T, C) -> (B, T, C)
|
| 220 |
+
"""
|
| 221 |
+
|
| 222 |
+
def __init__(self, cfg: ModelConfig) -> None:
|
| 223 |
+
super().__init__()
|
| 224 |
+
self.n_head = cfg.n_head
|
| 225 |
+
self.head_dim = cfg.head_dim
|
| 226 |
+
self.rope_base = cfg.rope_base
|
| 227 |
+
self.use_rope = cfg.use_rope
|
| 228 |
+
self.rope_scale = 1.0 # vedi `apply_rope(scale=...)`
|
| 229 |
+
# Se True, i pesi di attention dell'ultimo forward restano in `_last_attention`
|
| 230 |
+
# (il prefisso "_" evita che MLX li scambi per parametri del modello).
|
| 231 |
+
self.record_attention = False
|
| 232 |
+
self._last_attention = None
|
| 233 |
+
self.q_proj = nn.Linear(cfg.d_model, cfg.d_model, bias=False)
|
| 234 |
+
self.k_proj = nn.Linear(cfg.d_model, cfg.d_model, bias=False)
|
| 235 |
+
self.v_proj = nn.Linear(cfg.d_model, cfg.d_model, bias=False)
|
| 236 |
+
self.o_proj = nn.Linear(cfg.d_model, cfg.d_model, bias=False)
|
| 237 |
+
self.attn_dropout = nn.Dropout(cfg.dropout)
|
| 238 |
+
self.resid_dropout = nn.Dropout(cfg.dropout)
|
| 239 |
+
|
| 240 |
+
def _split_heads(self, x: mx.array) -> mx.array:
|
| 241 |
+
"""(B, T, C) -> (B, H, T, D): ogni head lavora su una fetta di D dimensioni."""
|
| 242 |
+
B, T, _ = x.shape
|
| 243 |
+
return x.reshape(B, T, self.n_head, self.head_dim).transpose(0, 2, 1, 3)
|
| 244 |
+
|
| 245 |
+
def __call__(self, x: mx.array, cache: KVCache | None = None) -> mx.array:
|
| 246 |
+
B, T, C = x.shape # T = token in ingresso (tutti, oppure solo i nuovi con la cache)
|
| 247 |
+
|
| 248 |
+
q = self._split_heads(self.q_proj(x)) # (B, H, T, D)
|
| 249 |
+
k = self._split_heads(self.k_proj(x)) # (B, H, T, D)
|
| 250 |
+
v = self._split_heads(self.v_proj(x)) # (B, H, T, D)
|
| 251 |
+
|
| 252 |
+
# La posizione entra qui: q e k vengono ruotate, v no. Con la cache i token in
|
| 253 |
+
# ingresso non partono dalla posizione 0 ma da `past`.
|
| 254 |
+
past = cache.length if cache is not None else 0
|
| 255 |
+
if self.use_rope:
|
| 256 |
+
q = apply_rope(q, offset=past, base=self.rope_base, scale=self.rope_scale)
|
| 257 |
+
k = apply_rope(k, offset=past, base=self.rope_base, scale=self.rope_scale)
|
| 258 |
+
|
| 259 |
+
if cache is not None:
|
| 260 |
+
k, v = cache.append(k, v) # (B, H, S, D) con S = past + T: tutta la sequenza
|
| 261 |
+
|
| 262 |
+
# Senza cache S = T. Con la cache le query sono solo quelle dei T token nuovi.
|
| 263 |
+
scores = (q @ k.transpose(0, 1, 3, 2)) / math.sqrt(self.head_dim) # (B, H, T, S)
|
| 264 |
+
# Maschera: le ultime T righe di quella (S, S). Il token nuovo vede tutto il
|
| 265 |
+
# passato; se i nuovi sono più d'uno (prompt iniziale) restano causali tra loro.
|
| 266 |
+
scores = scores + causal_mask(past + T)[past:] # (T, S), broadcast su (B, H)
|
| 267 |
+
weights = mx.softmax(scores, axis=-1) # (B, H, T, S), ogni riga somma a 1
|
| 268 |
+
if self.record_attention:
|
| 269 |
+
self._last_attention = weights
|
| 270 |
+
weights = self.attn_dropout(weights)
|
| 271 |
+
|
| 272 |
+
out = weights @ v # (B, H, T, D)
|
| 273 |
+
out = out.transpose(0, 2, 1, 3).reshape(B, T, C) # riunisce le head: (B, T, C)
|
| 274 |
+
return self.resid_dropout(self.o_proj(out))
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
# --------------------------------------------------------------------------------------
|
| 278 |
+
# MLP
|
| 279 |
+
# --------------------------------------------------------------------------------------
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
class MLP(nn.Module):
|
| 283 |
+
"""Feed-forward applicata a ogni posizione in modo indipendente.
|
| 284 |
+
|
| 285 |
+
Due varianti, scelte da `cfg.mlp_type`:
|
| 286 |
+
|
| 287 |
+
- "gelu": y = W_proj · GELU(W_fc · x) d_hidden = 4·C
|
| 288 |
+
- "swiglu": y = W_proj · (SiLU(W_gate · x) ⊙ W_fc · x) d_hidden = 2/3 · 4·C
|
| 289 |
+
|
| 290 |
+
SwiGLU (usata in LLaMA) sostituisce l'attivazione con un *gate* moltiplicativo: un
|
| 291 |
+
ramo decide quanto far passare dell'altro. Ha tre matrici invece di due, per cui
|
| 292 |
+
d_hidden viene ridotto a 2/3 e il numero di parametri resta lo stesso.
|
| 293 |
+
|
| 294 |
+
Shape: (B, T, C) -> (B, T, C)
|
| 295 |
+
"""
|
| 296 |
+
|
| 297 |
+
def __init__(self, cfg: ModelConfig) -> None:
|
| 298 |
+
super().__init__()
|
| 299 |
+
self.mlp_type = cfg.mlp_type
|
| 300 |
+
hidden = cfg.mlp_ratio * cfg.d_model
|
| 301 |
+
if self.mlp_type == "swiglu":
|
| 302 |
+
hidden = int(2 * hidden / 3)
|
| 303 |
+
self.gate = nn.Linear(cfg.d_model, hidden, bias=False)
|
| 304 |
+
self.fc = nn.Linear(cfg.d_model, hidden, bias=False)
|
| 305 |
+
self.proj = nn.Linear(hidden, cfg.d_model, bias=False)
|
| 306 |
+
self.dropout = nn.Dropout(cfg.dropout)
|
| 307 |
+
|
| 308 |
+
def __call__(self, x: mx.array) -> mx.array:
|
| 309 |
+
if self.mlp_type == "swiglu":
|
| 310 |
+
h = nn.silu(self.gate(x)) * self.fc(x) # (B, T, hidden)
|
| 311 |
+
else:
|
| 312 |
+
h = nn.gelu(self.fc(x)) # (B, T, hidden)
|
| 313 |
+
return self.dropout(self.proj(h))
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
# --------------------------------------------------------------------------------------
|
| 317 |
+
# Block e GPT
|
| 318 |
+
# --------------------------------------------------------------------------------------
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
class Block(nn.Module):
|
| 322 |
+
"""Blocco transformer pre-norm.
|
| 323 |
+
|
| 324 |
+
x = x + Attention(RMSNorm(x))
|
| 325 |
+
x = x + MLP(RMSNorm(x))
|
| 326 |
+
|
| 327 |
+
"Pre-norm": la normalizzazione sta sul ramo, non sul percorso residuo. Il residual
|
| 328 |
+
stream `x` attraversa tutta la rete senza mai essere normalizzato, e i gradienti
|
| 329 |
+
hanno un percorso diretto (identità) dall'uscita fino all'embedding: il training è
|
| 330 |
+
più stabile rispetto al post-norm del Transformer originale.
|
| 331 |
+
|
| 332 |
+
Shape: (B, T, C) -> (B, T, C)
|
| 333 |
+
"""
|
| 334 |
+
|
| 335 |
+
def __init__(self, cfg: ModelConfig) -> None:
|
| 336 |
+
super().__init__()
|
| 337 |
+
self.norm1 = make_norm(cfg)
|
| 338 |
+
self.attn = Attention(cfg)
|
| 339 |
+
self.norm2 = make_norm(cfg)
|
| 340 |
+
self.mlp = MLP(cfg)
|
| 341 |
+
|
| 342 |
+
def __call__(self, x: mx.array, cache: KVCache | None = None) -> mx.array:
|
| 343 |
+
x = x + self.attn(self.norm1(x), cache=cache)
|
| 344 |
+
x = x + self.mlp(self.norm2(x))
|
| 345 |
+
return x
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
class GPT(nn.Module):
|
| 349 |
+
"""Transformer decoder-only.
|
| 350 |
+
|
| 351 |
+
Weight tying: la LM head non ha pesi propri, riusa la matrice di embedding E (V, C):
|
| 352 |
+
|
| 353 |
+
ingresso: x_t = E[token_t] (riga di E)
|
| 354 |
+
uscita: logits = h · Eᵀ (prodotto scalare con ogni riga di E)
|
| 355 |
+
|
| 356 |
+
Il logit del token w è quindi la similarità tra lo stato finale h e l'embedding di w.
|
| 357 |
+
Si risparmiano V·C parametri (1.57M su 12.2M nella config di default) e ogni token
|
| 358 |
+
riceve gradiente sia quando è in ingresso sia quando è un candidato in uscita.
|
| 359 |
+
|
| 360 |
+
Shape: idx (B, T) int -> logits (B, T, V)
|
| 361 |
+
"""
|
| 362 |
+
|
| 363 |
+
def __init__(self, cfg: ModelConfig) -> None:
|
| 364 |
+
super().__init__()
|
| 365 |
+
self.cfg = cfg
|
| 366 |
+
self.tok_emb = nn.Embedding(cfg.vocab_size, cfg.d_model)
|
| 367 |
+
self.emb_dropout = nn.Dropout(cfg.dropout)
|
| 368 |
+
self.blocks = [Block(cfg) for _ in range(cfg.n_layer)]
|
| 369 |
+
self.norm_f = make_norm(cfg)
|
| 370 |
+
init_weights(self)
|
| 371 |
+
|
| 372 |
+
def make_cache(self) -> list[KVCache]:
|
| 373 |
+
"""Una cache vuota per layer, da passare a `__call__` durante la generazione."""
|
| 374 |
+
return [KVCache() for _ in self.blocks]
|
| 375 |
+
|
| 376 |
+
def __call__(self, idx: mx.array, cache: list[KVCache] | None = None) -> mx.array:
|
| 377 |
+
"""Con `cache`, `idx` contiene solo i token nuovi e i logit restituiti sono
|
| 378 |
+
solo i loro; la cache viene aggiornata in place."""
|
| 379 |
+
x = self.emb_dropout(self.tok_emb(idx)) # (B, T, C)
|
| 380 |
+
for i, block in enumerate(self.blocks):
|
| 381 |
+
x = block(x, cache=cache[i] if cache is not None else None) # (B, T, C)
|
| 382 |
+
x = self.norm_f(x) # (B, T, C)
|
| 383 |
+
return x @ self.tok_emb.weight.T # (B, T, V): LM head = embedding trasposto
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
def init_weights(model: GPT) -> None:
|
| 387 |
+
"""Inizializzazione in stile GPT-2.
|
| 388 |
+
|
| 389 |
+
- Tutte le matrici (embedding e Linear): N(0, 0.02²). Valori piccoli → logit iniziali
|
| 390 |
+
vicini a zero → distribuzione quasi uniforme → loss iniziale ≈ ln(V).
|
| 391 |
+
- Le proiezioni che *scrivono* nel residual stream (`attn.o_proj`, `mlp.proj`):
|
| 392 |
+
N(0, (0.02 / sqrt(2·n_layer))²). Il residual stream è la somma di 2·n_layer
|
| 393 |
+
contributi; se ognuno ha varianza σ² la somma ha varianza 2L·σ². Dividere σ per
|
| 394 |
+
sqrt(2L) rende la varianza dell'uscita indipendente dalla profondità.
|
| 395 |
+
- I guadagni delle RMSNorm restano a 1 (sono vettori 1-D: non vengono toccati).
|
| 396 |
+
"""
|
| 397 |
+
std = 0.02
|
| 398 |
+
resid_std = std / math.sqrt(2 * model.cfg.n_layer)
|
| 399 |
+
|
| 400 |
+
new_params = []
|
| 401 |
+
for name, p in tree_flatten(model.parameters()):
|
| 402 |
+
if p.ndim == 2:
|
| 403 |
+
is_residual_proj = name.endswith(("attn.o_proj.weight", "mlp.proj.weight"))
|
| 404 |
+
p = (resid_std if is_residual_proj else std) * mx.random.normal(p.shape)
|
| 405 |
+
new_params.append((name, p))
|
| 406 |
+
model.update(tree_unflatten(new_params))
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
def count_parameters(module: nn.Module) -> int:
|
| 410 |
+
"""Numero totale di parametri (scalari) del modulo."""
|
| 411 |
+
return sum(p.size for _, p in tree_flatten(module.parameters()))
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
def attention_maps(model: GPT, idx: mx.array) -> list:
|
| 415 |
+
"""Pesi di attention di ogni layer per la sequenza `idx` (1, T).
|
| 416 |
+
|
| 417 |
+
Returns:
|
| 418 |
+
lista di n_layer array numpy (H, T, T): l'elemento [h, i, j] è quanto la head h,
|
| 419 |
+
dalla posizione i (query), guarda la posizione j (key). Ogni riga somma a 1 e
|
| 420 |
+
per j > i vale 0 (maschera causale).
|
| 421 |
+
"""
|
| 422 |
+
was_training = model.training
|
| 423 |
+
model.eval()
|
| 424 |
+
for block in model.blocks:
|
| 425 |
+
block.attn.record_attention = True
|
| 426 |
+
mx.eval(model(idx))
|
| 427 |
+
maps = [np.array(block.attn._last_attention[0]) for block in model.blocks]
|
| 428 |
+
for block in model.blocks:
|
| 429 |
+
block.attn.record_attention = False
|
| 430 |
+
block.attn._last_attention = None
|
| 431 |
+
model.train(was_training)
|
| 432 |
+
return maps
|
minigpt/tokenizer.py
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tokenizer BPE (Byte Pair Encoding) a livello di byte, scritto da zero.
|
| 2 |
+
|
| 3 |
+
Idea
|
| 4 |
+
----
|
| 5 |
+
Si parte dall'alfabeto più semplice possibile: i 256 valori di un byte. Qualsiasi stringa,
|
| 6 |
+
codificata in UTF-8, è una sequenza di questi simboli, quindi non esistono mai token
|
| 7 |
+
"sconosciuti". Poi si ripete N volte:
|
| 8 |
+
|
| 9 |
+
1. conta tutte le coppie di simboli adiacenti nel corpus;
|
| 10 |
+
2. prendi la coppia più frequente (a, b);
|
| 11 |
+
3. crea un nuovo simbolo `ab` e sostituiscilo ovunque compaia la coppia.
|
| 12 |
+
|
| 13 |
+
Ogni iterazione ("merge") aggiunge un token al vocabolario. Le sequenze frequenti
|
| 14 |
+
("che", " della", "zione") diventano un token solo, quelle rare restano spezzate in pezzi
|
| 15 |
+
più piccoli. La lista ordinata dei merge È il tokenizer: per codificare un testo nuovo si
|
| 16 |
+
riapplicano gli stessi merge, nello stesso ordine di priorità.
|
| 17 |
+
|
| 18 |
+
Layout degli id
|
| 19 |
+
---------------
|
| 20 |
+
0 .. 255 byte grezzi
|
| 21 |
+
256 .. 256+M-1 token creati dai merge (M = numero di merge)
|
| 22 |
+
256+M .. 256+M+2 token speciali <SEP>, <EOS>, <PAD>
|
| 23 |
+
|
| 24 |
+
Con vocab_size=4096 si hanno quindi M = 4096 - 256 - 3 = 3837 merge.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
from __future__ import annotations
|
| 28 |
+
|
| 29 |
+
import json
|
| 30 |
+
import re
|
| 31 |
+
from collections import Counter, defaultdict
|
| 32 |
+
from pathlib import Path
|
| 33 |
+
|
| 34 |
+
SPECIAL_TOKENS = ("<SEP>", "<EOS>", "<PAD>")
|
| 35 |
+
|
| 36 |
+
# Pre-tokenizzazione: prima di applicare BPE il testo viene spezzato in "pezzi"
|
| 37 |
+
# (parola con eventuale spazio davanti | punteggiatura | spazi bianchi) e i merge non
|
| 38 |
+
# attraversano mai il confine tra due pezzi. Serve a due cose:
|
| 39 |
+
# - efficienza: BPE lavora sulle parole *distinte* pesate per frequenza (~10^5) invece
|
| 40 |
+
# che sull'intero corpus (~10^7 byte), e in encode ogni parola si può mettere in cache;
|
| 41 |
+
# - qualità: evita token che incollano la fine di una parola all'inizio della successiva.
|
| 42 |
+
# Le tre alternative coprono ogni carattere, quindi "".join(pezzi) == testo (lossless).
|
| 43 |
+
_PRETOKENIZE = re.compile(r" ?\w+| ?[^\w\s]+|\s+")
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def _merge(ids: list[int], pair: tuple[int, int], new_id: int) -> list[int]:
|
| 47 |
+
"""Sostituisce, da sinistra a destra, ogni occorrenza di `pair` con `new_id`.
|
| 48 |
+
|
| 49 |
+
Esempio: _merge([1, 2, 3, 1, 2], (1, 2), 9) -> [9, 3, 9]
|
| 50 |
+
"""
|
| 51 |
+
a, b = pair
|
| 52 |
+
out = []
|
| 53 |
+
i = 0
|
| 54 |
+
n = len(ids)
|
| 55 |
+
while i < n:
|
| 56 |
+
if i < n - 1 and ids[i] == a and ids[i + 1] == b:
|
| 57 |
+
out.append(new_id)
|
| 58 |
+
i += 2
|
| 59 |
+
else:
|
| 60 |
+
out.append(ids[i])
|
| 61 |
+
i += 1
|
| 62 |
+
return out
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class BPETokenizer:
|
| 66 |
+
def __init__(
|
| 67 |
+
self,
|
| 68 |
+
merges: list[tuple[int, int]],
|
| 69 |
+
special_tokens: tuple[str, ...] = SPECIAL_TOKENS,
|
| 70 |
+
) -> None:
|
| 71 |
+
self.merges = [tuple(m) for m in merges]
|
| 72 |
+
self.special_tokens = tuple(special_tokens)
|
| 73 |
+
|
| 74 |
+
# rango del merge: più è basso, prima è stato imparato, prima va applicato
|
| 75 |
+
self._rank = {pair: i for i, pair in enumerate(self.merges)}
|
| 76 |
+
|
| 77 |
+
# vocab[id] -> bytes del token; i merge si espandono ricorsivamente nei loro byte
|
| 78 |
+
self.vocab: list[bytes] = [bytes([i]) for i in range(256)]
|
| 79 |
+
for a, b in self.merges:
|
| 80 |
+
self.vocab.append(self.vocab[a] + self.vocab[b])
|
| 81 |
+
|
| 82 |
+
first_special = len(self.vocab)
|
| 83 |
+
self.special_to_id = {tok: first_special + i for i, tok in enumerate(self.special_tokens)}
|
| 84 |
+
for tok in self.special_tokens:
|
| 85 |
+
self.vocab.append(tok.encode("utf-8"))
|
| 86 |
+
|
| 87 |
+
self._special_re = re.compile("(" + "|".join(map(re.escape, self.special_tokens)) + ")")
|
| 88 |
+
self._cache: dict[str, list[int]] = {} # pezzo -> id, riempita da encode
|
| 89 |
+
|
| 90 |
+
# ------------------------------------------------------------------ proprietà
|
| 91 |
+
|
| 92 |
+
@property
|
| 93 |
+
def vocab_size(self) -> int:
|
| 94 |
+
return len(self.vocab)
|
| 95 |
+
|
| 96 |
+
@property
|
| 97 |
+
def sep_id(self) -> int:
|
| 98 |
+
return self.special_to_id["<SEP>"]
|
| 99 |
+
|
| 100 |
+
@property
|
| 101 |
+
def eos_id(self) -> int:
|
| 102 |
+
return self.special_to_id["<EOS>"]
|
| 103 |
+
|
| 104 |
+
@property
|
| 105 |
+
def pad_id(self) -> int:
|
| 106 |
+
return self.special_to_id["<PAD>"]
|
| 107 |
+
|
| 108 |
+
# ------------------------------------------------------------------ training
|
| 109 |
+
|
| 110 |
+
@classmethod
|
| 111 |
+
def train(cls, text: str, vocab_size: int, verbose: bool = False) -> BPETokenizer:
|
| 112 |
+
"""Impara i merge da `text` fino a raggiungere `vocab_size` (speciali inclusi).
|
| 113 |
+
|
| 114 |
+
Versione efficiente dell'algoritmo descritto in cima al file. L'algoritmo ingenuo
|
| 115 |
+
riconta tutte le coppie del corpus a ogni merge: O(M · |corpus|), ore in Python.
|
| 116 |
+
Qui invece:
|
| 117 |
+
|
| 118 |
+
- si lavora sulle parole distinte, ciascuna con la sua frequenza `freq`: una coppia
|
| 119 |
+
dentro una parola che compare 5000 volte conta 5000;
|
| 120 |
+
- `pair_counts[(a, b)]` tiene il conteggio globale di ogni coppia e viene
|
| 121 |
+
*aggiornato in modo incrementale*: fondere (a, b) cambia le coppie solo nelle
|
| 122 |
+
parole che la contengono;
|
| 123 |
+
- `where[(a, b)]` è l'indice inverso coppia -> parole che la contengono, così
|
| 124 |
+
quelle parole si trovano senza scorrere tutto.
|
| 125 |
+
|
| 126 |
+
Può fermarsi prima di `vocab_size` se nessuna coppia compare almeno 2 volte.
|
| 127 |
+
"""
|
| 128 |
+
n_merges = vocab_size - 256 - len(SPECIAL_TOKENS)
|
| 129 |
+
if n_merges < 0:
|
| 130 |
+
raise ValueError(f"vocab_size troppo piccolo: minimo {256 + len(SPECIAL_TOKENS)}")
|
| 131 |
+
|
| 132 |
+
# parole distinte e loro frequenza; ogni parola è la lista dei suoi byte
|
| 133 |
+
word_freq = Counter(_PRETOKENIZE.findall(text))
|
| 134 |
+
words = [list(w.encode("utf-8")) for w in word_freq]
|
| 135 |
+
freqs = list(word_freq.values())
|
| 136 |
+
|
| 137 |
+
pair_counts: dict[tuple[int, int], int] = defaultdict(int)
|
| 138 |
+
where: dict[tuple[int, int], set[int]] = defaultdict(set)
|
| 139 |
+
for i, (word, freq) in enumerate(zip(words, freqs, strict=True)):
|
| 140 |
+
for pair in zip(word, word[1:], strict=False):
|
| 141 |
+
pair_counts[pair] += freq
|
| 142 |
+
where[pair].add(i)
|
| 143 |
+
|
| 144 |
+
merges: list[tuple[int, int]] = []
|
| 145 |
+
for step in range(n_merges):
|
| 146 |
+
if not pair_counts:
|
| 147 |
+
break
|
| 148 |
+
# Coppia più frequente. A parità di conteggio vince la prima inserita nel dict:
|
| 149 |
+
# una regola arbitraria ma deterministica (stesso testo -> stessi merge).
|
| 150 |
+
pair = max(pair_counts, key=pair_counts.get)
|
| 151 |
+
count = pair_counts[pair]
|
| 152 |
+
if count < 2:
|
| 153 |
+
break # fondere una coppia che compare una volta sola non comprime nulla
|
| 154 |
+
|
| 155 |
+
new_id = 256 + len(merges)
|
| 156 |
+
merges.append(pair)
|
| 157 |
+
|
| 158 |
+
# Aggiorna solo le parole che contengono la coppia: si tolgono dal conteggio
|
| 159 |
+
# tutte le loro vecchie coppie e si aggiungono quelle della parola dopo il merge.
|
| 160 |
+
for i in sorted(where.pop(pair)):
|
| 161 |
+
word, freq = words[i], freqs[i]
|
| 162 |
+
for p in zip(word, word[1:], strict=False):
|
| 163 |
+
pair_counts[p] -= freq
|
| 164 |
+
if pair_counts[p] == 0:
|
| 165 |
+
del pair_counts[p]
|
| 166 |
+
word = _merge(word, pair, new_id)
|
| 167 |
+
for p in zip(word, word[1:], strict=False):
|
| 168 |
+
pair_counts[p] += freq
|
| 169 |
+
where[p].add(i)
|
| 170 |
+
words[i] = word
|
| 171 |
+
|
| 172 |
+
if verbose and (step + 1) % 500 == 0:
|
| 173 |
+
tok = cls(merges).vocab[new_id]
|
| 174 |
+
print(f" merge {step + 1:>5}/{n_merges}: {tok!r} (freq {count})")
|
| 175 |
+
|
| 176 |
+
return cls(merges)
|
| 177 |
+
|
| 178 |
+
# ------------------------------------------------------------------ encode / decode
|
| 179 |
+
|
| 180 |
+
def _encode_chunk(self, chunk: str) -> list[int]:
|
| 181 |
+
"""Applica i merge a un singolo pezzo pre-tokenizzato.
|
| 182 |
+
|
| 183 |
+
Si parte dai byte e si fonde ripetutamente la coppia presente con il rango più
|
| 184 |
+
basso (cioè imparata per prima): è lo stesso ordine seguito in training, quindi
|
| 185 |
+
il risultato è coerente con il modo in cui il vocabolario è stato costruito.
|
| 186 |
+
"""
|
| 187 |
+
ids = list(chunk.encode("utf-8"))
|
| 188 |
+
rank = self._rank
|
| 189 |
+
while len(ids) >= 2:
|
| 190 |
+
pair = min(zip(ids, ids[1:], strict=False), key=lambda p: rank.get(p, float("inf")))
|
| 191 |
+
if pair not in rank:
|
| 192 |
+
break # nessuna coppia rimasta è un merge noto
|
| 193 |
+
ids = _merge(ids, pair, 256 + rank[pair])
|
| 194 |
+
return ids
|
| 195 |
+
|
| 196 |
+
def _encode_ordinary(self, text: str) -> list[int]:
|
| 197 |
+
ids: list[int] = []
|
| 198 |
+
cache = self._cache
|
| 199 |
+
for chunk in _PRETOKENIZE.findall(text):
|
| 200 |
+
chunk_ids = cache.get(chunk)
|
| 201 |
+
if chunk_ids is None:
|
| 202 |
+
chunk_ids = cache[chunk] = self._encode_chunk(chunk)
|
| 203 |
+
ids.extend(chunk_ids)
|
| 204 |
+
return ids
|
| 205 |
+
|
| 206 |
+
def encode(self, text: str, allow_special: bool = False) -> list[int]:
|
| 207 |
+
"""Testo -> lista di id.
|
| 208 |
+
|
| 209 |
+
Con `allow_special=False` (default) le stringhe "<SEP>", "<EOS>", "<PAD>" presenti
|
| 210 |
+
nel testo sono trattate come testo qualunque. Con `allow_special=True` vengono
|
| 211 |
+
convertite nei token di controllo: va usato solo su testo che costruiamo noi
|
| 212 |
+
(es. i task sintetici `input <SEP> output <EOS>`), mai su testo arbitrario.
|
| 213 |
+
"""
|
| 214 |
+
if not allow_special:
|
| 215 |
+
return self._encode_ordinary(text)
|
| 216 |
+
ids: list[int] = []
|
| 217 |
+
for part in self._special_re.split(text):
|
| 218 |
+
if part in self.special_to_id:
|
| 219 |
+
ids.append(self.special_to_id[part])
|
| 220 |
+
elif part:
|
| 221 |
+
ids.extend(self._encode_ordinary(part))
|
| 222 |
+
return ids
|
| 223 |
+
|
| 224 |
+
def decode(self, ids) -> str:
|
| 225 |
+
"""Lista di id -> testo.
|
| 226 |
+
|
| 227 |
+
Si concatenano i byte dei token e si decodifica in UTF-8 una volta sola alla fine:
|
| 228 |
+
un carattere multi-byte può essere spezzato tra due token. `errors="replace"`
|
| 229 |
+
perché una sequenza generata dal modello può non essere UTF-8 valido.
|
| 230 |
+
"""
|
| 231 |
+
data = b"".join(self.vocab[i] for i in ids)
|
| 232 |
+
return data.decode("utf-8", errors="replace")
|
| 233 |
+
|
| 234 |
+
# ------------------------------------------------------------------ persistenza
|
| 235 |
+
|
| 236 |
+
def save(self, path: str | Path) -> None:
|
| 237 |
+
"""Salva in JSON. Bastano i merge: il vocabolario si ricostruisce da quelli."""
|
| 238 |
+
path = Path(path)
|
| 239 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 240 |
+
payload = {
|
| 241 |
+
"version": 1,
|
| 242 |
+
"special_tokens": list(self.special_tokens),
|
| 243 |
+
"merges": [list(m) for m in self.merges],
|
| 244 |
+
}
|
| 245 |
+
path.write_text(json.dumps(payload))
|
| 246 |
+
|
| 247 |
+
@classmethod
|
| 248 |
+
def load(cls, path: str | Path) -> BPETokenizer:
|
| 249 |
+
payload = json.loads(Path(path).read_text())
|
| 250 |
+
return cls(
|
| 251 |
+
merges=[tuple(m) for m in payload["merges"]],
|
| 252 |
+
special_tokens=tuple(payload["special_tokens"]),
|
| 253 |
+
)
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2e3510fc87132359e1664c44c73d7388cea5bcfdf1b4db9b555e27eff8a7259f
|
| 3 |
+
size 48783514
|
tokenizer.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version": 1, "special_tokens": ["<SEP>", "<EOS>", "<PAD>"], "merges": [[32, 100], [32, 115], [32, 99], [101, 114], [97, 110], [32, 112], [111, 110], [32, 97], [32, 108], [101, 110], [116, 111], [114, 101], [105, 110], [108, 108], [116, 97], [256, 105], [32, 109], [114, 105], [114, 97], [116, 101], [32, 101], [117, 110], [116, 105], [104, 101], [32, 110], [118, 97], [32, 102], [108, 105], [115, 115], [32, 105], [10, 10], [32, 118], [32, 32], [111, 114], [111, 108], [113, 117], [105, 97], [101, 269], [32, 277], [97, 114], [32, 103], [258, 279], [111, 115], [32, 291], [264, 97], [32, 116], [99, 99], [114, 111], [32, 268], [111, 109], [97, 108], [100, 111], [46, 46], [226, 128], [285, 108], [101, 108], [105, 111], [32, 98], [257, 117], [101, 115], [264, 101], [258, 262], [261, 259], [257, 105], [116, 266], [100, 105], [260, 111], [103, 283], [309, 148], [195, 178], [118, 101], [115, 105], [280, 262], [259, 97], [32, 273], [293, 97], [269, 97], [99, 105], [109, 97], [109, 265], [103, 110], [259, 101], [195, 168], [122, 97], [100, 97], [261, 105], [256, 97], [100, 101], [99, 101], [99, 97], [99, 111], [104, 105], [32, 111], [261, 111], [258, 97], [257, 101], [45, 45], [109, 111], [263, 108], [195, 160], [122, 105], [101, 116], [272, 97], [109, 112], [258, 305], [288, 288], [109, 105], [301, 117], [294, 97], [262, 101], [108, 101], [284, 101], [115, 111], [99, 279], [287, 105], [32, 260], [195, 185], [98, 98], [261, 97], [103, 103], [260, 307], [112, 112], [282, 97], [116, 274], [272, 105], [118, 322], [115, 101], [10, 288], [108, 97], [284, 105], [256, 101], [115, 99], [256, 311], [195, 172], [118, 105], [115, 97], [259, 111], [262, 111], [115, 112], [335, 275], [116, 117], [98, 105], [32, 324], [341, 372], [110, 111], [257, 111], [116, 303], [268, 97], [112, 105], [32, 69], [296, 105], [269, 101], [296, 283], [293, 101], [256, 331], [117, 105], [32, 67], [32, 83], [116, 278], [102, 102], [117, 111], [118, 111], [112, 111], [258, 298], [360, 101], [32, 329], [114, 260], [284, 97], [261, 295], [110, 97], [308, 46], [268, 111], [263, 326], [112, 97], [99, 104], [109, 101], [32, 65], [116, 270], [284, 111], [32, 77], [259, 105], [265, 278], [264, 111], [272, 101], [290, 111], [256, 111], [309, 153], [122, 122], [116, 116], [257, 99], [290, 97], [280, 101], [290, 101], [32, 338], [32, 117], [32, 76], [116, 260], [103, 97], [265, 339], [268, 105], [314, 111], [32, 80], [265, 275], [32, 274], [261, 303], [103, 105], [356, 365], [261, 267], [260, 105], [263, 118], [257, 97], [32, 275], [258, 105], [287, 101], [258, 111], [299, 315], [306, 101], [116, 275], [265, 307], [262, 105], [336, 111], [122, 339], [115, 270], [257, 112], [116, 355], [256, 117], [32, 78], [302, 347], [32, 73], [361, 361], [287, 290], [265, 101], [116, 267], [301, 274], [99, 262], [269, 111], [103, 117], [32, 95], [117, 266], [108, 111], [32, 267], [260, 100], [280, 111], [287, 111], [194, 171], [263, 332], [282, 105], [32, 68], [116, 273], [194, 187], [260, 266], [257, 270], [428, 281], [268, 101], [308, 308], [298, 105], [112, 259], [114, 117], [32, 104], [314, 97], [265, 100], [313, 97], [289, 111], [266, 114], [99, 292], [282, 289], [373, 101], [282, 117], [302, 104], [118, 259], [103, 111], [273, 97], [258, 290], [32, 71], [109, 98], [262, 97], [265, 266], [375, 105], [258, 104], [258, 347], [296, 117], [299, 311], [116, 259], [264, 105], [298, 97], [386, 105], [272, 111], [299, 97], [293, 111], [286, 288], [430, 338], [280, 311], [32, 84], [302, 292], [285, 111], [435, 97], [323, 97], [336, 105], [110, 105], [256, 409], [336, 97], [261, 265], [110, 101], [260, 275], [261, 273], [32, 86], [299, 331], [277, 97], [260, 278], [302, 97], [32, 270], [282, 111], [115, 266], [81, 117], [481, 101], [100, 117], [349, 105], [258, 289], [313, 105], [98, 97], [263, 100], [299, 306], [357, 270], [261, 117], [443, 111], [265, 105], [263, 114], [296, 422], [301, 303], [102, 105], [115, 116], [406, 289], [258, 259], [32, 278], [115, 333], [265, 270], [112, 101], [289, 270], [359, 267], [32, 70], [271, 367], [101, 105], [335, 266], [419, 389], [115, 278], [298, 101], [33, 426], [263, 302], [100, 337], [282, 101], [99, 347], [265, 97], [313, 117], [397, 366], [363, 320], [359, 111], [32, 82], [267, 522], [371, 369], [282, 274], [263, 269], [280, 331], [323, 111], [264, 518], [287, 259], [256, 293], [122, 292], [263, 377], [273, 111], [363, 414], [330, 394], [536, 295], [441, 326], [256, 262], [451, 97], [305, 101], [346, 274], [343, 281], [348, 483], [115, 117], [258, 267], [282, 295], [272, 312], [114, 262], [100, 259], [299, 376], [114, 268], [315, 101], [291, 101], [257, 454], [101, 320], [118, 260], [269, 105], [32, 66], [103, 101], [32, 281], [482, 262], [257, 437], [256, 306], [314, 108], [117, 274], [264, 411], [260, 270], [260, 400], [514, 97], [351, 594], [118, 290], [396, 274], [102, 97], [298, 111], [257, 275], [272, 292], [344, 281], [293, 105], [112, 267], [117, 270], [285, 359], [258, 411], [419, 97], [302, 111], [280, 97], [296, 312], [342, 332], [265, 116], [32, 259], [305, 111], [471, 266], [32, 500], [302, 105], [276, 100], [32, 303], [577, 369], [277, 111], [276, 284], [371, 632], [301, 259], [257, 289], [115, 275], [99, 289], [375, 312], [316, 105], [524, 312], [100, 267], [73, 108], [257, 306], [276, 323], [280, 117], [257, 393], [272, 290], [32, 519], [258, 295], [122, 312], [292, 353], [315, 278], [318, 546], [357, 303], [313, 487], [560, 334], [315, 105], [263, 415], [263, 407], [301, 267], [294, 111], [262, 307], [272, 289], [375, 292], [374, 267], [263, 105], [109, 334], [499, 344], [32, 79], [276, 332], [358, 105], [387, 292], [257, 259], [105, 108], [484, 108], [263, 373], [287, 292], [260, 97], [32, 569], [109, 109], [441, 418], [272, 322], [97, 118], [319, 476], [265, 111], [295, 327], [485, 485], [348, 553], [114, 393], [272, 464], [257, 290], [114, 325], [301, 506], [76, 97], [378, 320], [349, 346], [350, 391], [256, 305], [356, 475], [543, 327], [257, 429], [291, 105], [401, 320], [114, 327], [486, 270], [117, 108], [467, 611], [260, 340], [491, 274], [103, 312], [287, 265], [77, 97], [397, 266], [282, 268], [370, 270], [534, 292], [296, 273], [357, 116], [117, 114], [97, 326], [260, 356], [264, 117], [313, 274], [122, 111], [46, 352], [63, 426], [406, 355], [587, 400], [306, 379], [257, 116], [102, 289], [348, 274], [257, 379], [271, 267], [261, 593], [111, 274], [264, 277], [371, 340], [101, 321], [377, 111], [103, 274], [296, 274], [100, 325], [277, 644], [335, 278], [349, 275], [416, 267], [460, 112], [680, 322], [353, 267], [99, 117], [118, 337], [306, 402], [456, 105], [299, 472], [301, 265], [471, 270], [32, 85], [524, 292], [109, 289], [284, 392], [354, 402], [112, 274], [299, 105], [363, 433], [415, 105], [317, 116], [282, 267], [260, 103], [298, 379], [315, 270], [567, 367], [195, 136], [302, 312], [32, 289], [102, 117], [584, 281], [110, 262], [514, 111], [112, 295], [354, 504], [357, 278], [314, 332], [260, 339], [306, 97], [311, 111], [260, 101], [299, 409], [378, 267], [291, 97], [98, 111], [286, 10], [363, 473], [195, 169], [78, 262], [99, 305], [357, 275], [280, 416], [258, 117], [277, 266], [323, 101], [32, 266], [111, 105], [620, 368], [102, 101], [498, 105], [112, 273], [100, 292], [350, 418], [336, 289], [492, 295], [103, 347], [305, 532], [313, 111], [282, 259], [424, 384], [258, 804], [277, 105], [452, 266], [439, 580], [314, 101], [116, 265], [261, 292], [264, 355], [261, 114], [257, 346], [122, 101], [271, 115], [271, 394], [397, 283], [287, 448], [479, 101], [109, 295], [385, 365], [626, 601], [268, 117], [299, 544], [100, 312], [424, 275], [507, 266], [377, 97], [280, 293], [374, 423], [105, 359], [299, 293], [257, 404], [385, 353], [287, 581], [109, 325], [116, 325], [341, 302], [118, 392], [268, 103], [100, 474], [386, 323], [100, 295], [274, 281], [32, 265], [413, 105], [257, 298], [273, 266], [497, 511], [457, 259], [689, 337], [257, 262], [282, 416], [350, 404], [298, 266], [33, 352], [629, 425], [345, 266], [97, 302], [300, 729], [99, 259], [101, 323], [315, 266], [314, 770], [583, 343], [605, 344], [272, 295], [272, 265], [445, 273], [412, 97], [118, 448], [280, 338], [304, 321], [301, 273], [270, 267], [499, 105], [108, 265], [32, 72], [256, 290], [112, 114], [115, 379], [692, 273], [257, 440], [529, 105], [539, 98], [97, 105], [702, 332], [280, 409], [258, 306], [557, 391], [263, 394], [261, 101], [262, 340], [257, 389], [272, 870], [298, 270], [627, 340], [370, 368], [489, 320], [401, 820], [99, 440], [412, 279], [260, 425], [516, 337], [108, 117], [261, 289], [100, 494], [359, 105], [299, 597], [116, 322], [256, 315], [521, 382], [305, 105], [263, 362], [283, 97], [100, 509], [704, 266], [452, 339], [271, 387], [118, 265], [273, 281], [311, 101], [270, 395], [574, 368], [557, 327], [122, 356], [360, 429], [519, 400], [32, 114], [319, 867], [465, 613], [465, 259], [424, 448], [101, 284], [350, 281], [257, 396], [406, 117], [73, 110], [561, 105], [272, 260], [266, 267], [257, 338], [262, 452], [548, 117], [413, 101], [32, 442], [99, 290], [32, 513], [722, 281], [360, 268], [263, 766], [280, 298], [484, 111], [484, 110], [99, 273], [46, 505], [432, 110], [109, 353], [318, 115], [311, 97], [305, 98], [435, 105], [419, 101], [327, 365], [115, 259], [467, 478], [272, 117], [447, 284], [354, 99], [443, 101], [112, 303], [103, 411], [32, 830], [461, 365], [345, 281], [574, 260], [533, 277], [342, 407], [432, 108], [333, 325], [296, 97], [359, 97], [108, 395], [451, 101], [315, 97], [691, 274], [305, 455], [343, 381], [378, 549], [97, 415], [424, 278], [466, 613], [287, 392], [357, 355], [320, 267], [268, 321], [345, 267], [313, 265], [401, 415], [100, 331], [114, 355], [117, 681], [118, 329], [99, 295], [317, 402], [267, 105], [358, 698], [584, 797], [341, 796], [117, 267], [271, 118], [270, 281], [114, 384], [296, 458], [102, 259], [666, 434], [97, 273], [342, 269], [257, 265], [257, 292], [271, 711], [194, 160], [99, 337], [102, 111], [459, 453], [99, 312], [109, 335], [741, 267], [296, 292], [278, 345], [316, 375], [516, 511], [100, 311], [260, 116], [299, 506], [274, 266], [109, 362], [330, 694], [503, 312], [270, 266], [257, 345], [115, 345], [466, 592], [274, 267], [276, 387], [505, 46], [257, 329], [579, 325], [378, 668], [115, 346], [272, 472], [115, 306], [317, 298], [101, 343], [330, 112], [503, 105], [938, 488], [262, 343], [272, 719], [97, 99], [265, 402], [257, 295], [370, 99], [118, 390], [492, 101], [612, 105], [103, 279], [587, 554], [424, 446], [468, 325], [460, 102], [280, 105], [360, 112], [650, 281], [385, 334], [777, 281], [748, 340], [103, 292], [268, 778], [542, 307], [486, 275], [543, 283], [401, 283], [114, 495], [521, 275], [117, 391], [516, 259], [326, 281], [471, 278], [482, 111], [272, 306], [295, 393], [350, 112], [342, 105], [116, 114], [104, 97], [80, 259], [117, 278], [263, 334], [741, 274], [99, 631], [405, 274], [642, 333], [304, 538], [374, 698], [803, 281], [98, 101], [118, 325], [44, 352], [815, 110], [535, 643], [351, 105], [386, 320], [99, 474], [441, 118], [257, 868], [371, 554], [595, 97], [1115, 384], [428, 381], [371, 105], [450, 590], [416, 105], [101, 431], [272, 262], [497, 325], [67, 279], [304, 327], [394, 105], [112, 329], [318, 325], [99, 267], [266, 273], [326, 344], [115, 290], [261, 857], [32, 642], [314, 407], [459, 302], [923, 273], [805, 624], [103, 267], [315, 275], [100, 114], [263, 423], [97, 527], [780, 549], [282, 312], [470, 332], [115, 392], [444, 265], [689, 259], [677, 118], [46, 34], [302, 101], [450, 1057], [452, 275], [560, 353], [313, 295], [304, 116], [430, 292], [317, 275], [263, 320], [258, 260], [316, 320], [498, 473], [432, 104], [282, 455], [99, 298], [457, 97], [44, 505], [330, 334], [639, 275], [269, 117], [257, 446], [257, 260], [264, 389], [258, 268], [469, 604], [280, 631], [373, 274], [628, 281], [271, 344], [301, 422], [915, 379], [98, 117], [316, 444], [794, 526], [118, 581], [115, 344], [450, 681], [461, 289], [350, 109], [540, 395], [763, 278], [464, 334], [83, 105], [109, 262], [396, 266], [463, 115], [354, 488], [103, 273], [313, 331], [871, 565], [283, 344], [10, 361], [100, 458], [855, 417], [824, 893], [115, 292], [502, 323], [349, 116], [470, 407], [273, 267], [32, 298], [276, 394], [457, 105], [579, 267], [447, 105], [319, 947], [268, 99], [469, 640], [63, 352], [521, 339], [260, 333], [101, 270], [334, 105], [471, 275], [283, 345], [466, 112], [256, 1149], [116, 402], [110, 778], [373, 105], [277, 101], [282, 427], [888, 281], [58, 352], [444, 355], [117, 590], [97, 269], [306, 395], [296, 303], [647, 101], [118, 292], [529, 312], [274, 105], [116, 376], [271, 114], [272, 742], [588, 266], [261, 1173], [101, 100], [313, 306], [440, 267], [270, 114], [405, 332], [535, 117], [404, 372], [261, 306], [271, 668], [99, 268], [305, 97], [608, 262], [313, 101], [623, 607], [428, 367], [109, 260], [507, 281], [517, 530], [304, 998], [112, 265], [662, 270], [377, 101], [287, 709], [97, 320], [256, 1131], [68, 105], [348, 267], [114, 322], [378, 344], [387, 290], [109, 403], [373, 392], [296, 111], [101, 453], [100, 455], [566, 108], [676, 387], [296, 265], [257, 448], [387, 104], [302, 295], [514, 659], [342, 118], [450, 321], [260, 554], [995, 392], [284, 259], [363, 111], [289, 267], [116, 379], [380, 597], [343, 434], [304, 102], [115, 446], [333, 101], [63, 505], [470, 105], [274, 278], [282, 1243], [1186, 307], [356, 101], [103, 403], [257, 679], [444, 403], [343, 97], [315, 379], [65, 110], [98, 273], [720, 275], [949, 344], [677, 1314], [507, 270], [295, 495], [469, 697], [787, 642], [111, 267], [282, 292], [525, 368], [351, 490], [730, 390], [954, 117], [653, 281], [790, 340], [103, 337], [100, 376], [405, 323], [313, 513], [256, 801], [116, 427], [97, 807], [705, 425], [263, 323], [304, 1204], [99, 403], [103, 509], [351, 1042], [73, 111], [100, 293], [317, 379], [406, 277], [303, 1134], [608, 531], [385, 609], [313, 311], [370, 281], [283, 333], [97, 377], [530, 101], [666, 423], [363, 114], [948, 111], [301, 487], [84, 117], [261, 315], [961, 578], [363, 97], [256, 714], [99, 656], [773, 334], [350, 274], [97, 100], [1130, 847], [275, 491], [263, 284], [302, 279], [97, 373], [1038, 688], [412, 347], [470, 269], [1029, 531], [295, 278], [99, 446], [1020, 520], [387, 312], [579, 114], [101, 266], [257, 278], [583, 321], [1246, 1135], [304, 103], [265, 343], [374, 284], [374, 385], [288, 32], [1189, 906], [406, 372], [439, 618], [492, 97], [273, 394], [374, 1214], [98, 267], [122, 325], [257, 488], [349, 909], [262, 980], [259, 266], [273, 101], [257, 452], [304, 490], [357, 538], [274, 270], [263, 99], [378, 362], [289, 382], [340, 395], [268, 278], [706, 303], [101, 275], [32, 309], [304, 1303], [78, 111], [459, 404], [287, 117], [263, 512], [374, 656], [85, 110], [260, 369], [1316, 647], [825, 100], [1198, 1194], [396, 986], [32, 40], [97, 394], [412, 631], [285, 114], [257, 333], [263, 444], [543, 1302], [370, 327], [676, 663], [83, 101], [424, 108], [349, 1269], [116, 104], [300, 1251], [265, 633], [303, 267], [115, 353], [99, 325], [571, 270], [336, 101], [413, 260], [469, 343], [273, 480], [525, 391], [1031, 274], [1290, 707], [460, 281], [299, 669], [660, 105], [287, 298], [490, 298], [317, 327], [116, 403], [261, 646], [256, 289], [377, 105], [97, 407], [468, 843], [396, 267], [453, 267], [314, 105], [256, 295], [826, 292], [470, 491], [466, 283], [780, 831], [109, 397], [873, 267], [118, 436], [774, 340], [704, 278], [112, 117], [503, 111], [468, 1309], [374, 434], [758, 407], [258, 101], [1132, 355], [114, 362], [629, 558], [1295, 117], [374, 643], [97, 332], [32, 34], [465, 390], [272, 458], [994, 476], [117, 431], [73, 73], [100, 403], [282, 719], [97, 284], [377, 1080], [412, 298], [649, 97], [350, 737], [278, 346], [445, 289], [577, 99], [635, 97], [265, 781], [261, 277], [313, 273], [994, 556], [109, 322], [264, 1477], [557, 115], [1163, 669], [63, 34], [329, 395], [335, 111], [65, 108], [302, 117], [1257, 329], [69, 332], [305, 429], [566, 114], [1215, 105], [908, 440], [117, 321], [626, 262], [468, 114], [479, 259], [330, 519], [705, 110], [582, 991], [445, 262], [264, 295], [118, 446], [459, 1044], [351, 530], [587, 425], [115, 402], [521, 334], [265, 884], [97, 274], [795, 267], [97, 362], [1022, 402], [76, 101], [779, 344], [413, 389], [105, 114], [295, 362], [627, 800], [283, 111], [391, 395], [520, 366], [257, 988], [273, 346], [256, 1325], [313, 260], [263, 565], [1081, 591], [630, 332], [748, 876], [300, 590], [350, 368], [118, 268], [261, 290], [99, 376], [104, 111], [264, 416], [755, 765], [808, 303], [1147, 278], [115, 437], [815, 425], [309, 158], [349, 606], [542, 858], [262, 425], [1516, 334], [380, 382], [432, 98], [726, 104], [259, 327], [358, 918], [97, 267], [573, 418], [318, 105], [100, 329], [259, 322], [385, 362], [445, 347], [463, 568], [1047, 382], [315, 99], [33, 505], [314, 512], [117, 275], [101, 333], [71, 105], [353, 273], [457, 111], [853, 268], [370, 343], [984, 333], [32, 75], [108, 278], [114, 376], [775, 337], [109, 464], [114, 400], [486, 494], [282, 1564], [272, 298], [333, 366], [267, 477], [430, 851], [276, 423], [653, 598], [79, 104], [1281, 117], [259, 274], [97, 525], [115, 504], [1363, 307], [257, 266], [313, 409], [463, 434], [375, 101], [412, 105], [109, 844], [262, 100], [259, 355], [451, 111], [427, 697], [636, 97], [272, 593], [499, 618], [451, 117], [283, 480], [1365, 564], [100, 389], [315, 488], [82, 105], [798, 622], [572, 546], [77, 105], [262, 275], [100, 305], [350, 377], [280, 827], [263, 397], [1218, 273], [340, 281], [551, 527], [908, 446], [285, 115], [334, 281], [83, 389], [415, 259], [744, 744], [261, 925], [457, 860], [330, 1310], [109, 117], [989, 289], [69, 274], [463, 382], [267, 478], [944, 693], [889, 1377], [304, 99], [341, 260], [436, 109], [116, 563], [282, 513], [103, 559], [67, 631], [736, 376], [114, 607], [115, 289], [118, 311], [316, 281], [1491, 156], [591, 395], [755, 1196], [270, 270], [117, 273], [114, 337], [445, 292], [358, 1386], [276, 366], [795, 281], [774, 800], [461, 475], [586, 268], [984, 346], [10, 32], [377, 267], [295, 384], [573, 267], [264, 1013], [100, 273], [380, 101], [109, 268], [291, 306], [952, 368], [321, 333], [496, 478], [612, 111], [263, 1372], [282, 509], [923, 346], [118, 315], [373, 292], [548, 97], [905, 281], [261, 639], [100, 714], [603, 506], [281, 105], [276, 327], [273, 609], [469, 633], [295, 111], [259, 325], [349, 538], [102, 274], [453, 266], [272, 854], [502, 492], [1113, 281], [1142, 458], [263, 1374], [455, 951], [1191, 334], [733, 497], [267, 1354], [856, 273], [330, 344], [393, 267], [109, 735], [1485, 552], [436, 480], [486, 266], [794, 453], [967, 281], [102, 455], [471, 116], [920, 546], [1133, 427], [528, 418], [263, 807], [317, 833], [354, 98], [263, 414], [272, 842], [321, 266], [263, 385], [441, 1065], [370, 290], [118, 532], [263, 461], [283, 735], [307, 267], [371, 356], [401, 267], [412, 262], [481, 345], [349, 488], [371, 800], [271, 273], [103, 422], [268, 538], [1007, 321], [117, 97], [428, 417], [349, 284], [115, 488], [530, 97], [588, 275], [256, 544], [65, 104], [312, 267], [116, 396], [282, 658], [463, 333], [672, 97], [330, 102], [109, 559], [86, 105], [387, 389], [465, 494], [32, 74], [341, 322], [424, 326], [445, 117], [670, 382], [592, 320], [530, 111], [603, 289], [358, 724], [98, 306], [342, 266], [349, 1073], [1279, 97], [371, 913], [296, 267], [401, 407], [470, 512], [569, 376], [75, 1750], [374, 648], [304, 275], [476, 267], [450, 1683], [386, 283], [470, 274], [111, 553], [1263, 329], [1500, 425], [261, 311], [349, 112], [463, 368], [294, 105], [263, 1352], [1136, 1701], [100, 393], [855, 281], [257, 305], [345, 270], [349, 434], [291, 331], [274, 462], [368, 556], [1188, 1656], [103, 303], [373, 283], [100, 409], [529, 283], [774, 307], [1646, 526], [370, 478], [483, 101], [1401, 307], [317, 571], [1004, 337], [374, 367], [378, 433], [259, 292], [404, 266], [314, 269], [287, 1193], [1020, 1050], [110, 472], [1039, 875], [97, 115], [258, 265], [117, 295], [362, 366], [452, 100], [272, 827], [373, 111], [464, 353], [943, 711], [100, 708], [787, 422], [334, 266], [447, 323], [295, 275], [1254, 759], [68, 111], [439, 353], [301, 559], [32, 392], [100, 454], [535, 101], [571, 101], [373, 487], [108, 260], [272, 531], [482, 793], [377, 292], [452, 278], [937, 403], [276, 522], [271, 102], [321, 115], [413, 393], [348, 415], [301, 591], [886, 329], [1097, 111], [298, 278], [575, 274], [115, 95], [268, 116], [417, 283], [539, 267], [706, 111], [350, 611], [418, 275], [330, 1534], [271, 1675], [444, 427], [450, 114], [1089, 368], [1248, 644], [1596, 429], [287, 268], [109, 431], [525, 278], [566, 366], [111, 973], [771, 1388], [44, 34], [370, 568], [98, 274], [102, 292], [292, 99], [465, 337], [503, 97], [270, 278], [517, 444], [649, 105], [262, 480], [1209, 262], [1538, 362], [612, 1584], [330, 662], [1125, 357], [342, 281], [720, 266], [1265, 334], [1390, 122], [100, 289], [260, 346], [265, 379], [403, 266], [380, 407], [111, 697], [720, 817], [304, 879], [117, 1456], [489, 387], [917, 404], [1049, 98], [285, 1244], [330, 1205], [1360, 259], [272, 1546], [76, 111], [334, 267], [323, 337], [270, 366], [371, 694], [101, 103], [298, 275], [100, 427], [313, 267], [1262, 767], [1434, 281], [636, 343], [105, 1387], [396, 105], [272, 403], [287, 437], [623, 295], [299, 932], [69, 323], [103, 393], [257, 504], [903, 918], [109, 337], [504, 344], [799, 326], [396, 320], [100, 268], [97, 283], [260, 345], [301, 564], [677, 292], [32, 49], [99, 393], [340, 267], [354, 266], [114, 742], [775, 325], [315, 116], [422, 275], [560, 362], [257, 910], [110, 117], [262, 321], [340, 266], [32, 622], [378, 414], [536, 97], [469, 816], [257, 708], [342, 267], [371, 430], [565, 266], [258, 656], [733, 292], [1147, 266], [1600, 321], [387, 347], [32, 1128], [1022, 504], [1472, 365], [103, 259], [511, 480], [525, 327], [627, 913], [300, 118], [67, 347], [358, 267], [99, 458], [390, 552], [1385, 389], [195, 175], [263, 117], [272, 1482], [304, 876], [321, 270], [351, 476], [351, 1212], [281, 267], [367, 268], [257, 788], [282, 659], [271, 802], [115, 329], [290, 488], [272, 268], [1029, 365], [291, 311], [118, 591], [664, 414], [287, 1820], [109, 329], [317, 102], [435, 295], [1300, 337], [436, 101], [263, 491], [588, 278], [343, 105], [291, 376], [282, 436], [289, 767], [917, 112], [350, 1052], [1233, 1687], [270, 283], [370, 321], [1322, 592], [612, 1333], [360, 353], [117, 382], [635, 108], [1141, 963], [109, 259], [115, 416], [401, 476], [111, 483], [567, 332], [567, 818], [271, 346], [116, 372], [276, 385], [271, 385], [307, 434], [880, 1093], [374, 344], [306, 111], [768, 558], [100, 315], [321, 367], [103, 474], [553, 585], [502, 1571], [102, 267], [286, 361], [386, 112], [265, 391], [363, 444], [588, 345], [962, 580], [274, 114], [431, 434], [498, 278], [538, 292], [873, 281], [1046, 346], [1489, 477], [287, 827], [1870, 1990], [104, 312], [1099, 114], [1223, 509], [542, 1284], [354, 1594], [109, 292], [104, 295], [330, 326], [330, 281], [268, 490], [675, 283], [32, 89], [287, 289], [317, 270], [530, 292], [731, 322], [615, 1445], [268, 275], [267, 353], [422, 99], [285, 724], [65, 766], [111, 1200], [80, 105], [430, 259], [103, 458], [679, 749], [285, 1028], [428, 275], [258, 273], [274, 275], [97, 423], [296, 513], [109, 376], [270, 985], [1051, 1430], [432, 766], [260, 110], [306, 98], [893, 278], [348, 1369], [273, 345], [100, 437], [296, 437], [586, 392], [1439, 640], [315, 111], [405, 110], [1122, 1971], [32, 46], [299, 101], [403, 267], [300, 417], [453, 281], [264, 509], [341, 607], [905, 267], [1671, 384], [371, 103], [466, 105], [99, 532], [300, 1025], [397, 1053], [67, 298], [370, 417], [271, 823], [270, 275], [306, 266], [112, 312], [10, 485], [548, 105], [97, 95], [258, 292], [321, 267], [304, 390], [385, 431], [533, 289], [496, 1199], [521, 1751], [97, 117], [336, 292], [290, 357], [287, 532], [272, 671], [1004, 259], [341, 1064], [1239, 389], [281, 266], [258, 303], [105, 724], [1428, 480], [349, 283], [450, 823], [1060, 97], [280, 544], [299, 1066], [1606, 841], [111, 320], [97, 353], [348, 377], [314, 377], [270, 381], [418, 267], [446, 267], [503, 101], [505, 44], [341, 826], [261, 844], [110, 331], [115, 389], [418, 105], [275, 477], [114, 267], [415, 97], [658, 327], [704, 275], [981, 379], [354, 122], [413, 117], [1495, 290], [1894, 695], [680, 260], [272, 765], [342, 323], [450, 684], [117, 823], [378, 1184], [1533, 402], [447, 1969], [1792, 2011], [115, 262], [346, 283], [370, 114], [586, 325], [664, 320], [1524, 2037], [112, 108], [340, 275], [556, 266], [531, 266], [117, 115], [299, 295], [357, 273], [270, 462], [726, 274], [317, 862], [2290, 1756], [261, 312], [354, 339], [386, 326], [465, 564], [587, 1931], [80, 111], [67, 262], [110, 311], [370, 332], [467, 359], [301, 658], [1104, 801], [1615, 283], [278, 281], [1398, 697], [1843, 332], [116, 262], [278, 115], [112, 289], [273, 334], [405, 100], [479, 295], [358, 695], [997, 553], [1174, 303], [319, 1490], [286, 1737], [274, 381], [429, 267], [1254, 1797], [960, 267], [98, 295], [306, 339], [263, 737], [460, 862], [469, 977], [1505, 578], [396, 97], [341, 742], [1046, 345], [1265, 353], [1831, 436], [2092, 518], [327, 345], [517, 478], [290, 266], [389, 111], [482, 97], [1108, 307], [636, 307], [1432, 575], [473, 111], [489, 433], [32, 707], [263, 864], [949, 289], [439, 1795], [114, 427], [439, 434], [900, 266], [672, 1423], [447, 344], [451, 260], [496, 103], [523, 533], [350, 549], [740, 390], [768, 494], [313, 289], [282, 306], [257, 344], [275, 362], [384, 267], [280, 392], [315, 402], [2130, 556], [334, 278], [520, 283], [556, 281], [640, 327], [276, 675], [374, 891], [286, 383], [401, 118], [416, 283], [481, 369], [516, 474], [605, 343], [939, 320], [1095, 580], [469, 100], [999, 601], [1715, 520], [354, 270], [523, 289], [499, 552], [960, 281], [1949, 527], [1005, 283], [1351, 381], [289, 1573], [257, 1811], [1582, 688], [1501, 307], [374, 274], [470, 323], [263, 527], [637, 327], [465, 1076], [605, 1275], [1782, 369], [32, 2111], [435, 2191], [354, 1474], [72, 111], [298, 333], [813, 337], [882, 974], [901, 1423], [1775, 115], [102, 295], [256, 437], [503, 262], [573, 275], [859, 565], [349, 1296], [1658, 100], [940, 2224], [413, 97], [586, 454], [285, 594], [341, 658], [271, 1124], [348, 1200], [271, 109], [422, 400], [85, 425], [450, 362], [115, 454], [623, 111], [889, 434], [271, 284], [311, 281], [276, 391], [81, 411], [444, 325], [582, 278], [1259, 267], [1961, 312], [301, 114], [357, 117], [114, 366], [425, 266], [333, 454], [463, 275], [272, 714], [771, 1312], [102, 268], [315, 346], [445, 305], [356, 454], [490, 116], [479, 578], [721, 267], [80, 860], [265, 340], [350, 382], [109, 854], [103, 289], [258, 532], [955, 303], [1403, 1840], [99, 322], [277, 622], [1679, 520], [2018, 325], [259, 267], [110, 293], [463, 429], [115, 487], [740, 613], [116, 487], [1287, 711], [103, 325], [373, 312], [715, 259], [755, 464], [1697, 440], [733, 708], [261, 409], [103, 455], [460, 275], [298, 520], [650, 381], [788, 334], [2385, 259], [117, 101], [396, 414], [272, 455], [1101, 101], [1005, 648], [1362, 292], [1141, 719], [457, 1711], [345, 395], [116, 663], [2237, 431], [278, 417], [305, 437], [443, 776], [997, 2256], [285, 343], [451, 411], [595, 259], [523, 746], [264, 268], [271, 270], [396, 114], [415, 338], [98, 448], [1433, 2106], [88, 88], [291, 293], [272, 416], [499, 333], [382, 594], [686, 434], [427, 816], [264, 289], [360, 404], [390, 598], [623, 97], [805, 527], [263, 817], [691, 1799], [112, 292], [296, 108], [359, 312], [301, 639], [803, 367], [298, 112], [296, 311], [287, 416], [432, 373], [479, 268], [929, 289], [271, 1184], [1005, 491], [623, 857], [1664, 971], [825, 433], [2221, 312], [483, 337], [497, 440], [872, 334], [1223, 464], [317, 344], [306, 431], [573, 391], [799, 622], [260, 884], [900, 267], [343, 433], [744, 485], [528, 411], [603, 1599], [450, 1868], [582, 273], [924, 980], [115, 396], [620, 526], [880, 477], [1095, 477], [272, 2215], [67, 105], [117, 320], [431, 423], [351, 492], [679, 325], [775, 376], [318, 102], [276, 382], [440, 273], [341, 506], [592, 275], [954, 2128], [257, 2200], [109, 392], [97, 402], [405, 675], [1608, 325], [101, 278], [256, 355], [351, 359], [271, 390], [447, 362], [451, 597], [653, 267], [1242, 382], [577, 801], [122, 117], [272, 329], [337, 353], [439, 321], [586, 436], [1495, 448], [321, 480], [116, 513], [548, 289], [794, 1137], [317, 266], [274, 366], [402, 281], [422, 100], [351, 473], [502, 618], [263, 1107], [349, 1425], [100, 343], [403, 281], [296, 411], [287, 487], [258, 506], [348, 533], [258, 658], [692, 670], [257, 833], [627, 1407], [295, 103], [272, 497], [2023, 464], [290, 278], [330, 368], [387, 273], [512, 546], [600, 622], [330, 1874], [418, 283], [321, 462], [469, 483], [285, 530], [287, 1593], [1937, 511], [258, 312], [496, 568], [535, 1055], [576, 2150], [32, 2202], [100, 290], [330, 391], [461, 117], [343, 473], [362, 480], [595, 274], [636, 604], [370, 809], [261, 842], [794, 869], [1185, 494], [401, 1670], [68, 97], [264, 260], [327, 475], [571, 278], [1286, 267], [264, 1761], [2182, 338], [341, 2186], [111, 273], [304, 115], [263, 307], [1027, 369], [2580, 2247], [263, 375], [573, 114], [260, 632], [952, 911], [885, 1721], [348, 1985], [70, 97], [118, 376], [511, 266], [561, 97], [882, 1157], [1167, 546], [304, 1168], [447, 1576], [371, 278], [313, 709], [1031, 267], [319, 1648], [1758, 403], [1640, 325], [417, 344], [496, 327], [1703, 477], [268, 325], [380, 274], [344, 381], [316, 476], [258, 513], [734, 695], [611, 1425], [566, 1612], [2248, 387], [307, 326], [779, 431], [922, 400], [995, 436], [1268, 312], [2036, 326], [358, 2252], [84, 79], [280, 259], [258, 384], [824, 268], [626, 966], [285, 1097], [608, 393], [1585, 270], [412, 2322], [329, 266], [333, 266], [1807, 274], [105, 101], [110, 325], [366, 320], [357, 396], [423, 266], [390, 480], [557, 97], [573, 382], [586, 337], [1038, 277], [715, 1346], [108, 411], [306, 488], [499, 407], [706, 558], [432, 1158], [1702, 527], [100, 306], [117, 362], [1607, 425], [271, 1772], [430, 312], [415, 646], [887, 480], [360, 950], [903, 1356], [2308, 2147], [2349, 1466], [259, 260], [307, 118], [333, 283], [350, 414], [264, 563], [595, 117], [314, 289], [883, 512], [2026, 472], [2239, 389], [32, 262], [359, 101], [373, 273], [261, 422], [102, 436], [445, 295], [306, 480], [273, 568], [469, 911], [1069, 111], [2230, 97], [459, 2442], [299, 2334], [32, 90], [348, 326], [538, 425], [620, 343], [605, 737], [304, 759], [441, 809], [268, 879], [67, 97], [362, 384], [109, 472], [507, 278], [108, 518], [552, 281], [627, 100], [706, 270], [834, 266], [1165, 411], [517, 1939], [103, 104], [307, 320], [321, 387], [401, 414], [482, 101], [517, 423], [528, 429], [888, 275], [967, 267], [1815, 2089], [2223, 1633], [257, 2465], [834, 267], [419, 2476], [99, 454], [466, 512], [99, 540], [330, 604], [741, 273], [1232, 423], [1313, 434], [536, 1698], [1238, 266], [306, 260], [490, 340], [502, 284], [721, 281], [834, 281], [900, 281], [872, 906], [1153, 266], [330, 1707], [502, 2013], [71, 283], [296, 101], [289, 368], [272, 436], [517, 473], [262, 781], [340, 332], [1464, 325], [69, 100], [114, 278], [531, 270], [552, 267], [552, 266], [586, 513], [588, 270], [671, 266], [720, 278], [460, 833], [962, 695], [95, 2695], [296, 933], [65, 98], [304, 278], [313, 544], [285, 737], [1101, 337], [771, 1719], [2598, 568], [306, 99], [98, 487], [1358, 1343], [350, 2541], [561, 2689], [103, 268], [109, 312], [371, 400], [272, 643], [684, 325], [950, 389], [1095, 996], [257, 1231], [406, 1753], [323, 325], [265, 327], [368, 320], [428, 97], [302, 440], [495, 284], [528, 404], [268, 998], [272, 259], [321, 278], [330, 98], [516, 440], [524, 338], [575, 444], [296, 578], [595, 105], [615, 275], [258, 776], [1025, 585], [1257, 337], [452, 1411], [315, 292], [816, 270], [859, 108], [262, 895], [1018, 807], [1340, 427], [1577, 389], [32, 339], [362, 266], [390, 270], [378, 431], [453, 270], [465, 474], [374, 504], [560, 431], [315, 670], [726, 890], [955, 259], [1494, 1487], [917, 1875], [2408, 423], [350, 267], [700, 97], [726, 114], [730, 312], [257, 851], [864, 334], [304, 1085], [676, 368], [2112, 494], [2441, 368], [273, 98], [285, 334], [330, 345], [112, 357], [443, 295], [457, 267], [479, 289], [531, 267], [556, 270], [268, 1085], [314, 1225], [1712, 663], [481, 2507], [282, 392], [412, 303], [603, 265], [700, 281], [2538, 1470], [283, 266], [423, 281], [291, 506], [510, 505], [689, 474], [1022, 488], [1733, 1227], [567, 858], [98, 259], [370, 101], [715, 97], [777, 367], [104, 956], [1039, 1305], [702, 2610], [101, 97], [112, 290], [317, 100], [358, 274], [460, 344], [306, 504], [792, 281], [1240, 440], [832, 1297], [1806, 281], [1899, 440], [257, 326], [287, 329], [278, 366], [511, 462], [459, 675], [677, 381], [901, 97], [459, 1047], [363, 860], [103, 95], [330, 278], [358, 283], [434, 267], [385, 475], [502, 552], [671, 395], [1160, 2340], [551, 2374], [313, 114], [350, 359], [97, 444], [287, 843], [939, 809], [1471, 601], [595, 1486], [486, 2002], [108, 277], [103, 295], [304, 343], [429, 344], [432, 118], [446, 462], [313, 669], [118, 1030], [1229, 575], [1342, 391], [1009, 2257], [83, 117], [99, 306], [318, 100], [329, 105], [345, 278], [99, 392], [115, 452], [469, 307], [582, 303], [1038, 563], [1682, 2897], [79, 114], [107, 97], [340, 278], [380, 283], [497, 446], [412, 540], [265, 558], [114, 558], [291, 933], [944, 98], [955, 273], [356, 262], [425, 353], [99, 427], [100, 1964], [276, 367], [299, 564], [304, 571], [97, 898], [350, 604], [1863, 404], [1582, 540], [386, 333], [477, 267], [612, 101], [649, 289], [99, 743], [103, 1102], [1619, 848], [1037, 2366], [100, 274], [345, 462], [548, 306], [721, 270], [1454, 267], [2233, 906], [2384, 423], [32, 422], [608, 433], [626, 646], [795, 266], [257, 890], [955, 329], [1568, 1332], [1726, 544], [1481, 402], [319, 1936], [263, 473], [482, 105], [536, 260], [479, 540], [937, 369], [467, 978], [1345, 266], [2203, 609], [296, 262], [280, 329], [265, 368], [406, 303], [103, 437], [317, 585], [788, 275], [1014, 414], [1604, 604], [114, 333], [335, 307], [350, 273], [379, 320], [478, 266], [517, 433], [651, 108], [282, 411], [263, 433], [486, 259], [837, 278], [1262, 400], [1300, 494], [1689, 332], [529, 1935], [605, 2266], [386, 2542], [445, 312], [525, 115], [528, 262], [548, 101], [589, 362], [271, 740], [1046, 606], [354, 379], [1242, 568], [285, 1387], [412, 1395], [579, 1914], [257, 1956], [2068, 2176], [272, 2531], [263, 2532], [257, 102], [256, 274], [313, 298], [348, 320], [517, 520], [529, 292], [539, 101], [608, 274], [356, 665], [116, 749], [1359, 262], [1481, 379], [1514, 295], [341, 559], [1817, 941], [1611, 526], [273, 270], [321, 394], [109, 564], [930, 266], [317, 1035], [382, 1042], [349, 1552], [584, 1178], [257, 268], [263, 340], [343, 320], [115, 369], [97, 414], [497, 303], [561, 259], [105, 594], [600, 345], [263, 724], [97, 817], [990, 663], [340, 269], [1365, 909], [1439, 1665], [523, 527], [1934, 400], [2485, 971], [271, 97], [281, 281], [108, 325], [278, 333], [32, 356], [394, 101], [97, 397], [282, 422], [118, 544], [384, 729], [118, 763], [666, 898], [1123, 333], [1442, 444], [1403, 985], [260, 122], [101, 346], [341, 357], [371, 110], [412, 295], [432, 114], [110, 544], [636, 387], [990, 558], [1039, 277], [1590, 376], [1007, 2658], [2566, 2916], [260, 321], [370, 390], [267, 433], [280, 436], [489, 321], [521, 884], [493, 1177], [1282, 338], [1475, 433], [100, 1655], [1742, 368], [341, 1124], [1049, 2855], [271, 382], [424, 116], [461, 277], [497, 295], [316, 533], [257, 1291], [1401, 340], [349, 423], [298, 402], [457, 114], [479, 292], [662, 266], [847, 327], [960, 266], [973, 266], [616, 1013], [330, 109], [356, 322], [116, 365], [366, 105], [430, 427], [289, 431], [561, 860], [623, 1087], [1195, 270], [2738, 416], [104, 292], [260, 343], [108, 376], [101, 423], [431, 281], [463, 391], [496, 112], [777, 381], [873, 266], [1000, 403], [1621, 346], [103, 322], [257, 532], [103, 564], [1153, 270], [1255, 267], [73, 2210], [2269, 992], [97, 270], [334, 270], [109, 436], [99, 437], [496, 283], [556, 267], [1362, 312], [2177, 2035], [573, 368], [3122, 440], [335, 270], [117, 462], [489, 394], [542, 266], [582, 362], [880, 344], [1041, 112], [263, 1221], [318, 1583], [2345, 267], [496, 2791], [341, 2877], [103, 108], [268, 327], [370, 326], [380, 284], [445, 306], [358, 504], [1006, 404], [1556, 326], [1846, 522], [1948, 418], [1996, 681], [595, 2195], [1279, 325], [265, 321], [336, 322], [416, 273], [97, 512], [261, 513], [321, 711], [349, 809], [853, 429], [653, 266], [1270, 591], [1455, 281], [1496, 270], [1556, 418], [1505, 646], [117, 368], [114, 390], [412, 267], [525, 425], [670, 368], [1322, 2244], [285, 2725], [467, 2611], [116, 329], [373, 267], [525, 400], [261, 540], [639, 266], [679, 403], [573, 1765], [2928, 891], [3209, 2997], [109, 298], [261, 384], [463, 327], [296, 495], [672, 593], [282, 828], [871, 473], [944, 262], [1230, 337], [691, 1519], [2282, 337], [358, 2397], [105, 115], [257, 343], [448, 320], [479, 329], [798, 307], [328, 400], [318, 977], [507, 381], [362, 283], [469, 321], [109, 475], [296, 446], [272, 1685], [805, 2704], [1882, 281], [289, 266], [312, 273], [371, 327], [330, 404], [549, 266], [257, 575], [684, 101], [733, 274], [672, 796], [627, 865], [1006, 895], [351, 604], [1614, 914], [1889, 307], [1186, 321], [2666, 338], [262, 270], [276, 115], [99, 303], [386, 417], [419, 266], [307, 433], [529, 97], [775, 474], [813, 259], [105, 1244], [1604, 633], [295, 1764], [813, 340], [380, 2627], [2796, 591], [1328, 368], [97, 281], [290, 270], [114, 323], [336, 325], [351, 414], [257, 585], [837, 326], [258, 844], [330, 911], [603, 532], [1854, 393], [287, 427], [612, 3259], [66, 97], [431, 100], [103, 454], [531, 281], [109, 763], [417, 928], [1006, 865], [1448, 497], [318, 1693], [1873, 446], [2001, 1911], [466, 2910], [1577, 2912], [302, 293], [348, 273], [481, 274], [507, 267], [700, 671], [289, 986], [300, 1272], [105, 1376], [370, 487], [84, 101], [261, 298], [315, 345], [278, 369], [349, 369], [418, 116], [118, 458], [257, 519], [566, 662], [330, 868], [265, 1058], [360, 1305], [1500, 554], [1943, 97], [1947, 332], [1957, 345], [2563, 392], [2788, 781], [704, 270], [443, 325], [114, 455], [457, 303], [275, 611], [336, 643], [1010, 345], [257, 1094], [1397, 382], [2104, 266], [2616, 1275], [947, 3037], [1746, 477], [103, 265], [345, 391], [103, 427], [459, 362], [498, 270], [380, 552], [686, 423], [975, 898], [276, 1035], [520, 1053], [787, 1350], [306, 1474], [1507, 267], [1511, 270], [916, 1891], [2457, 827], [100, 262], [314, 393], [765, 267], [853, 112], [1472, 531], [1507, 273], [67, 65], [107, 95], [259, 270], [114, 283], [306, 122], [390, 323], [276, 390], [118, 393], [413, 111], [521, 278], [346, 522], [530, 274], [557, 357], [768, 671], [908, 448], [949, 333], [888, 367], [1046, 369], [361, 1466], [1572, 73], [1679, 1050], [405, 1955], [275, 390], [507, 114], [516, 446], [445, 607], [99, 644], [765, 281], [1366, 266], [722, 381], [104, 659], [2379, 353], [281, 108], [280, 295], [320, 114], [99, 411], [461, 262], [285, 476], [503, 331], [523, 114], [356, 540], [368, 820], [872, 303], [959, 307], [99, 975], [1192, 267], [2439, 477], [1270, 454], [70, 117], [272, 315], [330, 429], [517, 333], [337, 522], [97, 565], [779, 333], [100, 895], [924, 266], [1451, 329], [109, 1685], [700, 2273], [2276, 283], [2214, 392], [330, 359], [343, 477], [489, 115], [526, 618], [855, 326], [961, 646], [257, 983], [650, 1299], [1392, 477], [301, 393], [1113, 275], [273, 278], [269, 376], [100, 392], [477, 266], [478, 281], [317, 635], [930, 281], [1232, 359], [459, 1771], [758, 1838], [283, 98], [332, 267], [259, 353], [115, 393], [259, 427], [445, 472], [523, 273], [267, 600], [808, 273], [489, 1221], [736, 933], [2649, 533], [76, 79], [112, 268], [273, 105], [79, 274], [291, 658], [664, 267], [118, 709], [109, 743], [360, 875], [565, 1034], [1108, 321], [78, 793], [588, 1644], [1933, 988], [2169, 622], [569, 933], [1014, 320], [605, 3030], [350, 1526], [2107, 781], [103, 262], [268, 102], [112, 337], [316, 453], [521, 362], [561, 101], [394, 578], [623, 303], [375, 646], [317, 788], [931, 266], [445, 1488], [1848, 320], [1884, 346], [2027, 267], [2993, 320], [1281, 2407], [41, 44], [68, 262], [278, 97], [302, 325], [470, 340], [333, 480], [561, 292], [377, 607], [721, 266], [905, 381], [100, 992], [2534, 101], [885, 988], [33, 34], [321, 101], [108, 355], [361, 32], [390, 307], [412, 305], [533, 372], [542, 367], [276, 586], [533, 598], [1332, 644], [1590, 325], [2042, 549], [561, 1540], [330, 115], [423, 267], [435, 101], [118, 440], [439, 477], [460, 571], [582, 103], [257, 759], [952, 382], [997, 476], [691, 2063], [790, 2423], [736, 311], [405, 2714], [321, 345], [348, 302], [387, 262], [432, 326], [548, 111], [351, 565], [636, 633], [747, 102], [523, 353], [100, 841], [1017, 480], [1089, 327], [1865, 366], [2074, 340], [2958, 344], [3140, 1981], [332, 281], [380, 115], [291, 409], [112, 436], [528, 289], [260, 606], [271, 693], [348, 1221], [1323, 436], [1413, 281], [1496, 266], [469, 1058], [588, 1067], [350, 2190], [2196, 1384], [2219, 366], [65, 114], [287, 311], [305, 334], [354, 278], [349, 367], [257, 402], [380, 635], [636, 321], [424, 437], [758, 332], [937, 520], [497, 983], [317, 1376], [2208, 797], [73, 2735], [465, 1814], [295, 355], [109, 355], [384, 266], [496, 333], [1816, 118], [2253, 303], [330, 2607], [2648, 391], [84, 105], [432, 269], [326, 604], [380, 618], [747, 329], [588, 1045], [481, 2066], [291, 828], [263, 283], [100, 303], [257, 372], [482, 311], [527, 395], [582, 1745], [1757, 273], [2059, 56], [2267, 1100], [2301, 1631], [2679, 580], [3139, 326], [65, 78], [350, 340], [281, 353], [360, 105], [378, 105], [256, 389], [117, 478], [428, 385], [1349, 483], [1484, 644], [1615, 270], [401, 3050], [317, 3185], [304, 101], [117, 332], [304, 345], [438, 433], [510, 352], [538, 400], [267, 693], [706, 275], [99, 804], [826, 411], [486, 907], [1039, 563], [386, 1299], [330, 1338], [1435, 414], [1778, 97], [1061, 266], [2357, 3000], [257, 103], [315, 259], [97, 334], [357, 259], [375, 337], [345, 404], [416, 275], [759, 478], [773, 303], [883, 864], [330, 950], [1335, 571], [1484, 847], [278, 1503], [751, 332], [1892, 362], [1862, 1280], [3128, 346], [605, 3318], [110, 392], [109, 509], [517, 434], [567, 385], [341, 568], [637, 362], [272, 656], [672, 105], [463, 869], [862, 1275], [268, 1312], [358, 2170], [412, 2792], [1587, 281], [59, 352], [271, 417], [109, 455], [475, 345], [265, 488], [503, 305], [516, 448], [520, 266], [590, 355], [600, 346], [330, 606], [905, 114], [1123, 344], [1218, 267], [1512, 366], [2593, 556], [2187, 3380], [105, 274], [323, 295], [97, 327], [439, 423], [118, 464], [271, 525], [313, 581], [391, 592], [637, 355], [542, 580], [813, 343], [513, 1344], [363, 101], [66, 105], [276, 108], [330, 321], [345, 275], [304, 382], [403, 270], [111, 415], [118, 437], [723, 671], [803, 381], [1037, 303], [1389, 369], [1605, 1239], [117, 1677], [330, 3021], [3287, 2732], [304, 281], [502, 384], [571, 275], [319, 1052], [1340, 403], [299, 559], [2004, 267], [1436, 111], [2624, 2096], [2708, 366], [1785, 281], [101, 385], [389, 97], [304, 400], [117, 440], [443, 376], [291, 472], [266, 495], [574, 114], [1061, 267], [1779, 526], [319, 2158], [2187, 1790], [32, 2712], [2007, 338], [82, 73], [270, 108], [259, 273], [307, 418], [439, 443], [459, 367], [384, 462], [523, 108], [579, 373], [112, 593], [824, 532], [1089, 122], [378, 1100], [342, 491], [341, 1356], [579, 476], [97, 385], [413, 275], [459, 100], [463, 344], [498, 326], [507, 275], [349, 525], [99, 564], [620, 327], [32, 639], [664, 549], [467, 693], [879, 337], [990, 494], [330, 998], [257, 458], [1270, 458], [1324, 98], [450, 1818], [350, 2641], [466, 1814], [296, 2550], [276, 434], [317, 382], [362, 382], [502, 108], [274, 761], [97, 1107], [1533, 504], [97, 266], [117, 327], [378, 275], [271, 415], [521, 431], [529, 117], [561, 111], [564, 345], [628, 381], [516, 983], [350, 1156], [428, 818], [380, 2110], [1328, 382], [32, 2467], [1658, 597], [268, 110], [340, 105], [271, 345], [397, 108], [396, 433], [461, 355], [529, 259], [330, 585], [616, 277], [672, 289], [705, 266], [948, 956], [380, 1035], [523, 1691], [943, 1736], [1924, 533], [672, 1458], [3068, 3695], [340, 270], [97, 473], [635, 332], [637, 495], [1548, 267], [1725, 464], [432, 2475], [2820, 366], [304, 3048], [588, 3183], [3535, 303], [68, 312], [103, 376], [450, 302], [103, 464], [358, 524], [528, 518], [530, 267], [824, 591], [351, 977], [350, 978], [1340, 455], [1429, 295], [1413, 267], [1579, 427], [832, 986], [2245, 288], [374, 2483], [3225, 3436], [101, 111], [281, 270], [342, 270], [512, 115], [542, 100], [608, 114], [649, 117], [637, 325], [720, 353], [450, 1083], [1165, 531], [1169, 266], [1313, 423], [560, 1771], [1786, 675], [736, 828], [296, 2064], [3459, 333], [380, 1220], [80, 267], [108, 268], [348, 336], [314, 397], [112, 403], [257, 418], [493, 67], [792, 266], [825, 291], [287, 1030], [822, 1315], [1399, 724], [566, 1112], [1943, 105], [758, 2115], [2312, 259], [1192, 281], [542, 2553], [2980, 2096], [306, 3558], [374, 3794], [277, 270], [296, 295], [100, 322], [118, 331], [366, 284], [390, 321], [319, 322], [378, 417], [263, 494], [497, 448], [341, 581], [581, 346], [650, 476], [885, 379], [628, 367], [258, 1325], [1442, 98], [1851, 344], [287, 659], [2473, 986], [349, 2913], [1697, 446], [306, 270], [118, 312], [83, 393], [257, 427], [97, 461], [468, 334], [486, 117], [486, 382], [534, 338], [291, 544], [99, 559], [976, 278], [1069, 259], [73, 1244], [700, 1674], [450, 1718], [1778, 105], [715, 646], [2957, 344], [405, 3449], [80, 97], [195, 173], [368, 283], [298, 404], [416, 346], [110, 416], [99, 544], [330, 817], [1240, 267], [1286, 273], [1351, 367], [1353, 266], [450, 1677], [1359, 925], [2736, 118], [1161, 3342], [3417, 431], [889, 3460], [1786, 3852], [256, 273], [412, 259], [542, 407], [97, 766], [837, 275], [445, 842], [901, 105], [261, 1193], [1402, 707], [1446, 290], [1614, 274], [419, 2041], [2484, 893], [529, 3292], [2604, 2560], [282, 277], [109, 306], [258, 315], [116, 337], [268, 376], [345, 381], [412, 290], [418, 346], [477, 270], [519, 425], [530, 303], [459, 533]]}
|