Text Generation
Transformers
Safetensors
tinyqwen3_novelty
qwen3
causal-lm
tiny-language-model
novelty-gated-attention
trust-remote-code
custom_code
Instructions to use User01110/tinyLM-8M-exp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use User01110/tinyLM-8M-exp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="User01110/tinyLM-8M-exp", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("User01110/tinyLM-8M-exp", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use User01110/tinyLM-8M-exp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "User01110/tinyLM-8M-exp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "User01110/tinyLM-8M-exp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/User01110/tinyLM-8M-exp
- SGLang
How to use User01110/tinyLM-8M-exp with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "User01110/tinyLM-8M-exp" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "User01110/tinyLM-8M-exp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "User01110/tinyLM-8M-exp" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "User01110/tinyLM-8M-exp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use User01110/tinyLM-8M-exp with Docker Model Runner:
docker model run hf.co/User01110/tinyLM-8M-exp
Upload tinyLM-8M-exp final novelty-gated Qwen3 checkpoint
Browse files- README.md +90 -0
- config.json +29 -0
- model.safetensors +3 -0
- modeling_tinyqwen3_novelty.py +159 -0
- tokenizer.json +0 -0
- tokenizer_config.json +18 -0
README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
base_model: Qwen/Qwen3-0.6B
|
| 4 |
+
tags:
|
| 5 |
+
- qwen3
|
| 6 |
+
- causal-lm
|
| 7 |
+
- tiny-language-model
|
| 8 |
+
- novelty-gated-attention
|
| 9 |
+
- trust-remote-code
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# tinyLM-8M-exp
|
| 13 |
+
|
| 14 |
+
Tiny 5M-class parameter Qwen3-config causal LM with math-only novelty-gated GQA.
|
| 15 |
+
|
| 16 |
+
## Architecture
|
| 17 |
+
|
| 18 |
+
| Item | Value |
|
| 19 |
+
| --- | ---: |
|
| 20 |
+
| Config type | `qwen3` |
|
| 21 |
+
| Parameters | 8.919M |
|
| 22 |
+
| Layers | 10 |
|
| 23 |
+
| Hidden size | 256 |
|
| 24 |
+
| MLP size | 768 |
|
| 25 |
+
| Query heads | 8 |
|
| 26 |
+
| KV heads | 4 |
|
| 27 |
+
| Head dim | 32 |
|
| 28 |
+
| RoPE theta | 2500 |
|
| 29 |
+
| Tied embeddings | yes |
|
| 30 |
+
|
| 31 |
+
| Attention | Value |
|
| 32 |
+
| --- | --- |
|
| 33 |
+
| Type | GQA |
|
| 34 |
+
| Novelty gate | math-only element-wise RMS-normalized abs-delta |
|
| 35 |
+
| Gate floor | 0.05 |
|
| 36 |
+
|
| 37 |
+
## Training
|
| 38 |
+
|
| 39 |
+
| Item | Value |
|
| 40 |
+
| --- | --- |
|
| 41 |
+
| Tokenizer | `AxiomicLabs/GPT-S2-5M` |
|
| 42 |
+
| Sequence length | 512 |
|
| 43 |
+
| Microbatch size | 512 |
|
| 44 |
+
| Gradient accumulation | 4 |
|
| 45 |
+
| Effective batch size | 2048 |
|
| 46 |
+
| Steps | 20,000 |
|
| 47 |
+
| Validation cadence | every 1,000 steps |
|
| 48 |
+
| Raw MC eval cadence | every 2,000 steps on ARC-Easy, ARC-Challenge, PIQA, HellaSwag |
|
| 49 |
+
| LR schedule | warmup, cosine to min by 10,000, hold min to 15,000, cosine tail to zero by 20,000 |
|
| 50 |
+
| Optimizer | Muon for middle 2D weights, AdamW for the rest |
|
| 51 |
+
| Special-token policy | BOS/EOS are document-level; `<|im_start|>`/`<|im_end|>` are sequence-level |
|
| 52 |
+
|
| 53 |
+
| Dataset | Share | Config |
|
| 54 |
+
| --- | ---: | --- |
|
| 55 |
+
| `HuggingFaceFW/fineweb-edu` | 60.0% | `sample-100BT` |
|
| 56 |
+
| `HuggingFaceTB/smollm-corpus` | 30.0% | `cosmopedia-v2` only |
|
| 57 |
+
| `epfml/FineWeb-HQ` | 10.0% | `default` |
|
| 58 |
+
|
| 59 |
+
## Validation
|
| 60 |
+
|
| 61 |
+
| Metric | Value |
|
| 62 |
+
| --- | ---: |
|
| 63 |
+
| Dataset | `Salesforce/wikitext`, `wikitext-103-raw-v1`, validation |
|
| 64 |
+
| Context / stride | 512 / 256 |
|
| 65 |
+
| Loss | 3.1546 |
|
| 66 |
+
| Perplexity | 23.44 |
|
| 67 |
+
| UTF-8 BPB | 1.4433 |
|
| 68 |
+
| Scored tokens | 365,258 |
|
| 69 |
+
| UTF-8 bytes | 1,151,766 |
|
| 70 |
+
|
| 71 |
+
## Load And Generate
|
| 72 |
+
|
| 73 |
+
```python
|
| 74 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 75 |
+
import torch
|
| 76 |
+
|
| 77 |
+
repo = "User01110/tinyLM-8M-exp"
|
| 78 |
+
tokenizer = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
|
| 79 |
+
model = AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True)
|
| 80 |
+
|
| 81 |
+
inputs = tokenizer("Once upon a time", return_tensors="pt").to(model.device)
|
| 82 |
+
print(inputs.input_ids[0][:2].tolist()) # [<|im_start|>, <|bos|>]
|
| 83 |
+
|
| 84 |
+
with torch.no_grad():
|
| 85 |
+
output = model.generate(**inputs, max_new_tokens=128, do_sample=True, temperature=0.7, top_k=40)
|
| 86 |
+
|
| 87 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
This repo uses a native `Qwen3Config` plus remote model code for the math-only novelty-gated attention block.
|
config.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "qwen3",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"TinyQwen3NoveltyForCausalLM"
|
| 5 |
+
],
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoModelForCausalLM": "modeling_tinyqwen3_novelty.TinyQwen3NoveltyForCausalLM"
|
| 8 |
+
},
|
| 9 |
+
"vocab_size": 4098,
|
| 10 |
+
"hidden_size": 256,
|
| 11 |
+
"intermediate_size": 768,
|
| 12 |
+
"num_hidden_layers": 10,
|
| 13 |
+
"num_attention_heads": 8,
|
| 14 |
+
"num_key_value_heads": 4,
|
| 15 |
+
"head_dim": 32,
|
| 16 |
+
"rms_norm_eps": 1e-06,
|
| 17 |
+
"rope_theta": 2500.0,
|
| 18 |
+
"max_position_embeddings": 512,
|
| 19 |
+
"tie_word_embeddings": true,
|
| 20 |
+
"initializer_range": 0.02,
|
| 21 |
+
"torch_dtype": "float32",
|
| 22 |
+
"bos_token_id": 1,
|
| 23 |
+
"eos_token_id": 2,
|
| 24 |
+
"pad_token_id": 2,
|
| 25 |
+
"novelty_gate_floor": 0.05,
|
| 26 |
+
"novelty_gate_type": "math_rms_abs_delta",
|
| 27 |
+
"im_start_token_id": 4096,
|
| 28 |
+
"im_end_token_id": 4097
|
| 29 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ef0aff6c3442e38c986a8c47f88e9e06b7bb37ac884a3e5595228e8b97b17ec
|
| 3 |
+
size 35688600
|
modeling_tinyqwen3_novelty.py
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
import torch.nn.functional as F
|
| 4 |
+
from transformers import PreTrainedModel
|
| 5 |
+
from transformers.generation import GenerationMixin
|
| 6 |
+
from transformers.modeling_outputs import CausalLMOutput
|
| 7 |
+
from transformers.models.qwen3.configuration_qwen3 import Qwen3Config
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class RMSNorm(nn.Module):
|
| 11 |
+
def __init__(self, dim, eps=1e-6):
|
| 12 |
+
super().__init__()
|
| 13 |
+
self.weight = nn.Parameter(torch.ones(dim))
|
| 14 |
+
self.eps = eps
|
| 15 |
+
|
| 16 |
+
def forward(self, x):
|
| 17 |
+
return self.weight.to(dtype=x.dtype) * x * torch.rsqrt(x.pow(2).mean(dim=-1, keepdim=True) + self.eps)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def rotate_half(x):
|
| 21 |
+
x1, x2 = x.chunk(2, dim=-1)
|
| 22 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class RotaryEmbedding(nn.Module):
|
| 26 |
+
def __init__(self, head_dim, theta):
|
| 27 |
+
super().__init__()
|
| 28 |
+
inv_freq = 1.0 / (theta ** (torch.arange(0, head_dim, 2).float() / head_dim))
|
| 29 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 30 |
+
|
| 31 |
+
def forward(self, seq_len, device):
|
| 32 |
+
pos = torch.arange(seq_len, device=device, dtype=self.inv_freq.dtype)
|
| 33 |
+
freqs = torch.outer(pos, self.inv_freq.to(device))
|
| 34 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 35 |
+
return emb.cos()[None, None, :, :], emb.sin()[None, None, :, :]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def apply_rope(x, cos, sin):
|
| 39 |
+
return (x * cos.to(dtype=x.dtype)) + (rotate_half(x) * sin.to(dtype=x.dtype))
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class MathNoveltyGate(nn.Module):
|
| 43 |
+
def __init__(self, head_dim, floor=0.05):
|
| 44 |
+
super().__init__()
|
| 45 |
+
del head_dim
|
| 46 |
+
self.floor = floor
|
| 47 |
+
self.last_gate = None
|
| 48 |
+
|
| 49 |
+
def forward(self, heads):
|
| 50 |
+
context = (heads.sum(dim=1, keepdim=True) - heads) / (heads.size(1) - 1)
|
| 51 |
+
scale = heads.pow(2).mean(dim=-1, keepdim=True).sqrt() + context.pow(2).mean(dim=-1, keepdim=True).sqrt() + 1e-6
|
| 52 |
+
score = (heads - context).abs() / scale
|
| 53 |
+
gate = self.floor + (1.0 - self.floor) * score.clamp(0.0, 1.0)
|
| 54 |
+
compiler = getattr(torch, "compiler", None)
|
| 55 |
+
if compiler is None or not compiler.is_compiling():
|
| 56 |
+
self.last_gate = gate.detach()
|
| 57 |
+
return heads * gate
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class NoveltyGQA(nn.Module):
|
| 61 |
+
def __init__(self, config):
|
| 62 |
+
super().__init__()
|
| 63 |
+
dim = config.hidden_size
|
| 64 |
+
n_heads = config.num_attention_heads
|
| 65 |
+
n_kv_heads = config.num_key_value_heads
|
| 66 |
+
self.dim = dim
|
| 67 |
+
self.n_heads = n_heads
|
| 68 |
+
self.n_kv_heads = n_kv_heads
|
| 69 |
+
self.head_dim = dim // n_heads
|
| 70 |
+
self.kv_dim = n_kv_heads * self.head_dim
|
| 71 |
+
self.kv_repeat = n_heads // n_kv_heads
|
| 72 |
+
self.q_proj = nn.Linear(dim, dim, bias=False)
|
| 73 |
+
self.k_proj = nn.Linear(dim, self.kv_dim, bias=False)
|
| 74 |
+
self.v_proj = nn.Linear(dim, self.kv_dim, bias=False)
|
| 75 |
+
self.o_proj = nn.Linear(dim, dim, bias=False)
|
| 76 |
+
self.q_norm = RMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
| 77 |
+
self.k_norm = RMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
| 78 |
+
rope_theta = getattr(config, "rope_theta", 1000000.0)
|
| 79 |
+
self.rope = RotaryEmbedding(self.head_dim, rope_theta)
|
| 80 |
+
self.novelty = MathNoveltyGate(self.head_dim, floor=getattr(config, "novelty_gate_floor", 0.05))
|
| 81 |
+
|
| 82 |
+
def forward(self, x):
|
| 83 |
+
bsz, seq_len, _ = x.shape
|
| 84 |
+
q = self.q_proj(x).view(bsz, seq_len, self.n_heads, self.head_dim).transpose(1, 2)
|
| 85 |
+
k = self.k_proj(x).view(bsz, seq_len, self.n_kv_heads, self.head_dim).transpose(1, 2)
|
| 86 |
+
v = self.v_proj(x).view(bsz, seq_len, self.n_kv_heads, self.head_dim).transpose(1, 2)
|
| 87 |
+
q = self.q_norm(q)
|
| 88 |
+
k = self.k_norm(k)
|
| 89 |
+
cos, sin = self.rope(seq_len, x.device)
|
| 90 |
+
q = apply_rope(q, cos, sin)
|
| 91 |
+
k = apply_rope(k, cos, sin)
|
| 92 |
+
k = k.repeat_interleave(self.kv_repeat, dim=1)
|
| 93 |
+
v = v.repeat_interleave(self.kv_repeat, dim=1)
|
| 94 |
+
heads = F.scaled_dot_product_attention(q, k, v, is_causal=True)
|
| 95 |
+
heads = self.novelty(heads)
|
| 96 |
+
out = heads.transpose(1, 2).contiguous().view(bsz, seq_len, self.dim)
|
| 97 |
+
return self.o_proj(out)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
class SwiGLU(nn.Module):
|
| 101 |
+
def __init__(self, dim, hidden_dim):
|
| 102 |
+
super().__init__()
|
| 103 |
+
self.gate_proj = nn.Linear(dim, hidden_dim, bias=False)
|
| 104 |
+
self.up_proj = nn.Linear(dim, hidden_dim, bias=False)
|
| 105 |
+
self.down_proj = nn.Linear(hidden_dim, dim, bias=False)
|
| 106 |
+
|
| 107 |
+
def forward(self, x):
|
| 108 |
+
return self.down_proj(F.silu(self.gate_proj(x)) * self.up_proj(x))
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
class TinyQwen3NoveltyBlock(nn.Module):
|
| 112 |
+
def __init__(self, config):
|
| 113 |
+
super().__init__()
|
| 114 |
+
self.input_norm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 115 |
+
self.attn = NoveltyGQA(config)
|
| 116 |
+
self.post_attn_norm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 117 |
+
self.mlp = SwiGLU(config.hidden_size, config.intermediate_size)
|
| 118 |
+
|
| 119 |
+
def forward(self, x):
|
| 120 |
+
x = x + self.attn(self.input_norm(x))
|
| 121 |
+
x = x + self.mlp(self.post_attn_norm(x))
|
| 122 |
+
return x
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
class TinyQwen3NoveltyForCausalLM(PreTrainedModel, GenerationMixin):
|
| 126 |
+
config_class = Qwen3Config
|
| 127 |
+
base_model_prefix = ""
|
| 128 |
+
_no_split_modules = ["TinyQwen3NoveltyBlock"]
|
| 129 |
+
_tied_weights_keys = ["embed_tokens.weight"]
|
| 130 |
+
|
| 131 |
+
def __init__(self, config):
|
| 132 |
+
super().__init__(config)
|
| 133 |
+
self.all_tied_weights_keys = {}
|
| 134 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size)
|
| 135 |
+
self.layers = nn.ModuleList(TinyQwen3NoveltyBlock(config) for _ in range(config.num_hidden_layers))
|
| 136 |
+
self.norm = RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 137 |
+
|
| 138 |
+
def get_input_embeddings(self):
|
| 139 |
+
return self.embed_tokens
|
| 140 |
+
|
| 141 |
+
def set_input_embeddings(self, value):
|
| 142 |
+
self.embed_tokens = value
|
| 143 |
+
|
| 144 |
+
def forward(self, input_ids=None, attention_mask=None, labels=None, return_dict=True, **kwargs):
|
| 145 |
+
del attention_mask, kwargs
|
| 146 |
+
x = self.embed_tokens(input_ids)
|
| 147 |
+
for layer in self.layers:
|
| 148 |
+
x = layer(x)
|
| 149 |
+
x = self.norm(x)
|
| 150 |
+
logits = x @ self.embed_tokens.weight.t()
|
| 151 |
+
loss = None
|
| 152 |
+
if labels is not None:
|
| 153 |
+
loss = F.cross_entropy(logits[:, :-1, :].contiguous().view(-1, self.config.vocab_size), labels[:, 1:].contiguous().view(-1))
|
| 154 |
+
if not return_dict:
|
| 155 |
+
return (loss, logits) if loss is not None else (logits,)
|
| 156 |
+
return CausalLMOutput(loss=loss, logits=logits)
|
| 157 |
+
|
| 158 |
+
def prepare_inputs_for_generation(self, input_ids, **kwargs):
|
| 159 |
+
return {"input_ids": input_ids}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": true,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<bos>",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<eos>",
|
| 7 |
+
"extra_special_tokens": [
|
| 8 |
+
"<|im_start|>",
|
| 9 |
+
"<|im_end|>"
|
| 10 |
+
],
|
| 11 |
+
"is_local": false,
|
| 12 |
+
"local_files_only": false,
|
| 13 |
+
"model_max_length": 1000000000,
|
| 14 |
+
"pad_token": "<eos>",
|
| 15 |
+
"tokenizer_class": "TokenizersBackend",
|
| 16 |
+
"unk_token": "<unk>",
|
| 17 |
+
"vocab_size": 4096
|
| 18 |
+
}
|