Views
No views yet
Task: Text-Generation
Total training time: 35 hours
Inputs: text
Outputs: text
Params: ~1.3M
Final Loss: 3.078
Important Benchmark Scores:
1. ARC Easy - 29.63%
2. BLiMP - 64.96%
3. HellaSwag - 27.27%
Framework: PyTorch, transformers
Author: Paul Courneya (Harley-ml)| Dillion (v1) | Dillionv2 | why |
|---|---|---|
| 9B token count | 24B token count | More tokens allow the model to see more patterns, improving almost everything. |
| FineWeb-edu dataset | 9-source dataset | FineWeb-edu is edu-filtered and pretty narrow in style. 9 sources allow the model to see more patterns, styles, and non-educational text, improving semantics. |
| 72 hidden size | 96 hidden size | 72 was too narrow. 96 would allow the model to capture more complex patterns. |
| 12 num layers | 9 num layers | To stay in the parameter budget. |
| 288 intermediate size | 288 intermediate size | No change. |
| 3 number of heads | 3 number of heads | No change. |
| 3076 vocab size | 2564 vocab size | To free up parameters. |
| SGD optimizer | AdamW optimizer | AdamW is the modern choice and much better than SGD. |
| Cosine scheduler | WSD scheduler | WSD gives a better final loss. |
| Qwen3.5 architecture | Qwen3.5 architecture | No change. |
| Benchmark | Dillion | Dillionv2 |
|---|---|---|
| BLiMP | 62.94% | 64.96% |
| ARC Easy (Norm) | 31.36% | 29.63% |
| PiQA (Norm) | 53.10% | 53.16% |
| SWAG (Norm) | 30.36% | 32.07% |
| HellaSwag (Norm) | 26.65% | 27.37% |
| ArithMark | 24.80% | 27.00% |
| AVG | 38.20% | 39.03% |
1#!/usr/bin/env python3
2# =============================================================================
3# Inference
4# =============================================================================
5
6MODEL_DIR = "Harley-ml/Dillionv2-1.3M"
7TOKENIZER_PATH = MODEL_DIR
8
9# --- Generation settings ---
10PROMPT = "The"
11MAX_NEW_TOKENS = 362
12TEMPERATURE = 0.6
13TOP_P = 0.95
14TOP_K = 30
15REPETITION_PENALTY = 1.2
16DO_SAMPLE = True
17
18# =============================================================================
19
20import os
21import torch
22from pathlib import Path
23from transformers import (
24 AutoModelForCausalLM,
25 AutoTokenizer,
26 PreTrainedTokenizerFast,
27 AddedToken,
28)
29
30# ---------------------------------------------------------------------------
31# Device
32# ---------------------------------------------------------------------------
33
34device = (
35 "cuda" if torch.cuda.is_available() else
36 "mps" if torch.backends.mps.is_available() else
37 "cpu"
38)
39print(f"Device : {device}")
40
41# ---------------------------------------------------------------------------
42# Tokenizer
43# ---------------------------------------------------------------------------
44
45def load_tokenizer(path_or_repo: str):
46 p = Path(path_or_repo)
47
48 # Case 1: explicit local tokenizer.json file
49 if p.exists() and p.is_file() and p.suffix.lower() == ".json":
50 tok = PreTrainedTokenizerFast(tokenizer_file=str(p.resolve()))
51 # Case 2: local directory or HF repo ID
52 else:
53 tok = AutoTokenizer.from_pretrained(path_or_repo, use_fast=True)
54
55 # Ensure required special tokens exist
56 if tok.bos_token is None:
57 tok.add_special_tokens({"bos_token": "<|bos|>"})
58 if tok.eos_token is None:
59 tok.add_special_tokens({"eos_token": "<|eos|>"})
60 if tok.unk_token is None:
61 tok.add_special_tokens({"unk_token": "<|unk|>"})
62 if tok.pad_token is None:
63 tok.pad_token = tok.eos_token if tok.eos_token is not None else "<|pad|>"
64
65 tok.padding_side = "left"
66 return tok
67
68print("Loading tokenizer...")
69tokenizer = load_tokenizer(TOKENIZER_PATH)
70print(f" Vocab size : {len(tokenizer)}")
71print(f" BOS : {tokenizer.bos_token!r}")
72print(f" EOS : {tokenizer.eos_token!r}")
73print(f" PAD : {tokenizer.pad_token!r} (id={tokenizer.pad_token_id})")
74
75# ---------------------------------------------------------------------------
76# Model
77# ---------------------------------------------------------------------------
78
79print(f"\nLoading model from {MODEL_DIR} ...")
80model = AutoModelForCausalLM.from_pretrained(
81 MODEL_DIR,
82 torch_dtype=torch.float16 if device == "cuda" else torch.float32,
83 low_cpu_mem_usage=True,
84)
85
86model.eval()
87model.to(device)
88
89# Safer inference for cache-related issues
90model.config.use_cache = False
91if hasattr(model, "generation_config") and model.generation_config is not None:
92 model.generation_config.use_cache = False
93
94total_params = sum(p.numel() for p in model.parameters())
95print(f" Parameters : {total_params:,}")
96
97# ---------------------------------------------------------------------------
98# Generation helper
99# ---------------------------------------------------------------------------
100
101def generate(
102 prompt: str = PROMPT,
103 max_new_tokens: int = MAX_NEW_TOKENS,
104 temperature: float = TEMPERATURE,
105 top_p: float = TOP_P,
106 top_k: int = TOP_K,
107 repetition_penalty: float = REPETITION_PENALTY,
108 do_sample: bool = DO_SAMPLE,
109) -> str:
110 bos = tokenizer.bos_token or ""
111 full_prompt = bos + prompt
112
113 inputs = tokenizer(
114 full_prompt,
115 return_tensors="pt",
116 add_special_tokens=False,
117 ).to(device)
118
119 inputs.pop("token_type_ids", None)
120
121 gen_kwargs = dict(
122 max_new_tokens=max_new_tokens,
123 do_sample=do_sample,
124 repetition_penalty=repetition_penalty,
125 eos_token_id=tokenizer.eos_token_id,
126 pad_token_id=tokenizer.pad_token_id,
127 use_cache=False,
128 )
129
130 if do_sample:
131 gen_kwargs["temperature"] = temperature
132 gen_kwargs["top_p"] = top_p
133 gen_kwargs["top_k"] = top_k
134
135 with torch.inference_mode():
136 output_ids = model.generate(**inputs, **gen_kwargs)
137
138 prompt_len = inputs["input_ids"].shape[-1]
139 new_ids = output_ids[0][prompt_len:]
140 return tokenizer.decode(new_ids, skip_special_tokens=True)
141
142# ---------------------------------------------------------------------------
143# Run
144# ---------------------------------------------------------------------------
145
146if __name__ == "__main__":
147 print(f"\nPrompt : {PROMPT!r}")
148 print("-" * 60)
149
150 output = generate(PROMPT)
151
152 print("Generated:")
153 print(output)