Downloads · 30 days
15
8% of all-time downloads
shibatch/tinyqwen2m
tinyqwen2m is a machine learning model from shibatch. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
This repository provides ultra-lightweight Qwen2 model files across both GGUF and Hugging Face / Safetensors formats, trained to 100% convergence on the TinyStories dataset and optimized for inference engine testing a…
Downloads · 30 days
15
8% of all-time downloads
All-time downloads
184
Public
Repo size
16.3 MB
Likes
0
Public
Click a slice to open those files.
.gguf8.2 MB · 50%
From the Hugging Face model README
This repository provides ultra-lightweight Qwen2 model files across both GGUF and Hugging Face / Safetensors formats, trained to 100% convergence on the TinyStories dataset and optimized for inference engine testing and validation.
When developing a custom LLM inference engine, debugging with a full-sized model is slow. This suite offers a true 2M parameter scale Qwen2 model (~4.0MB), allowing developers to validate their loaders, namespace parsing, compact tokenization matrices, and Grouped-Query Attention (GQA) logic step-by-step with maximum efficiency and verifiable natural language outputs.
This model is designed to expose architectural layout bugs that standard Llama files cannot trigger:
qwen2. namespace (e.g., qwen2.attention.head_count) instead of the traditional llama. identifier. This forces your GGUF loader to resolve string lookup configurations dynamically based on general.architecture rather than falling back onto hardcoded defaults.1024 to eliminate index select out-of-bounds risks (indexSelectSmallIndex errors) on private hardware setups. Configured with "tie_word_embeddings": true to validate shared memory layouts across projection surfaces.0.1) injected into the q_proj, k_proj, and v_proj surfaces during training. If an inference engine fails to process or omits these projection biases, the numerical discrepancy accumulates rapidly across the 8 sequential layers, causing text generation to break completely into random garbage within a few tokens..
├── tinyqwen2m.gguf
├── README.md
└── hf/
├── config.json
├── generation_config.json
├── model.safetensors
├── tokenizer_config.json
├── special_tokens_map.json
└── tokenizer.json
A validation binary converted for custom engines and native runtimes. The tokenizer vocabulary and special tokens are fully embedded within the GGUF file.
tinyqwen2m.gguf (~4.0 MB)
Validates dynamic qwen2. GGUF namespace parsing, attention bias handling, RoPE operations, 16-bit floating point matrix layouts, type casting, and SwiGLU activation pipelines../hf/)This directory contains the standard files required to load the model using the PyTorch transformers library:
hf/model.safetensors: The raw, unquantized model weights stored securely in Safetensors format.hf/config.json: The architectural configuration file defining hyperparameters (8 layers, attention biases, weight-tying, standard dimensions).hf/generation_config.json: Default parameters optimized for text generation.hf/tokenizer_config.json: Tokenizer behavior layout specifying the custom ChatML/Qwen2 fast tokenizer setup.hf/special_tokens_map.json: Architectural mappings tying special characters to the token blocks.hf/tokenizer.json: The custom Byte-Level BPE tokenization descriptor layout.To verify your local loader setup or validate dynamic key parsing via native completions:
./llama-completion -m tinyqwen2m.gguf -p "Once upon" -n 100 --temp 0.0 --repeat-penalty 1.0 --top-p 1.0
Expected Golden Output:
Once upon a time, there was a little girl named Lily. Lily loved to play with her toys and her friends. One day, Lily's friend came over to play. She showed her how to make a tall tower. Lily was so happy and proud of her tall tower. She showed it to her friend and they both laughed together. From that day on, Lily and her friend played together every day. They would pretend they
To get identical token alignment and generation results as GGUF, use PreTrainedTokenizerFast to load the subfolder configurations, and manually prepend the BOS token ID (1000) to replicate the exact dataset layout used during training.
import torch
from transformers import PreTrainedTokenizerFast, AutoModelForCausalLM
repo_id = "shibatch/tinyqwen2m"
# Load via PreTrainedTokenizerFast to preserve the vocabulary configuration safely
tokenizer = PreTrainedTokenizerFast.from_pretrained(repo_id, subfolder="hf")
model = AutoModelForCausalLM.from_pretrained(repo_id, subfolder="hf")
prompt = "Once upon"
# Tokenize without injecting automatic special tokens
input_ids = tokenizer.encode(prompt, add_special_tokens=False)
# Manually prepend the exact BOS token ID (1000) to match the training pipeline
input_ids = [tokenizer.bos_token_id] + input_ids
inputs = {"input_ids": torch.tensor([input_ids])}
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=100,
do_sample=False, # Matches --temp 0
repetition_penalty=1.0,
top_p=1.0,
bos_token_id=tokenizer.bos_token_id,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
The network architecture features an active weight-tying matrix (tie_word_embeddings), perfectly aligned power-of-two shapes, and explicit Attention QKV bias vectors matching full-scale Qwen2 profiles.
Qwen2ForCausalLM)hidden_size): 128head_dim): 32 (128 / 4, satisfies hardware SDPA and RoPE alignment constraints)num_hidden_layers): 8 (Deep vertical structure to accelerate bias omission errors)num_attention_heads): 4num_key_value_heads): 1 (Standard GQA 4:1 topology)intermediate_size): 512 (Standard power-of-two dimension)max_position_embeddings): 256 (Standard power-of-two context length)attention_bias): True (Explicitly fixed at 0.1 for q_proj, k_proj, and v_proj)rope_theta): 1,000,000.0