skills/AI/AI-llm-architecture/5.-llm-architecture/SKILL.md
Build and understand LLM architecture from scratch. Use this skill whenever the user needs to create GPT models, implement transformer components (attention, feedforward, layer norm), calculate model parameters, or generate text with a trained model. Trigger for any request about LLM architecture, transformer blocks, GPT implementation, token embeddings, positional embeddings, or building neural networks for language modeling.
npx skillsauth add abelrguezr/hacktricks-skills llm-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A skill for building and understanding Large Language Model architecture from scratch, following the GPT-style transformer design.
Use this skill when the user needs to:
GELU (Gaussian Error Linear Unit) introduces non-linearity into the model. Unlike ReLU which zeroes out negative inputs, GELU smoothly maps inputs to outputs, allowing for small non-zero values for negative inputs.
Use the bundled script: scripts/gelu.py
A position-wise feedforward network that applies a two-layer fully connected network to each position:
emb_dim to 4 * emb_dimemb_dimUse the bundled script: scripts/feedforward.py
Allows the model to focus on different positions within the input sequence:
Use the bundled script: scripts/multihead_attention.py
Normalizes inputs across features for each example in a batch:
Use the bundled script: scripts/layernorm.py
Combines all components with residual connections:
Use the bundled script: scripts/transformer_block.py
The complete model that:
Use the bundled script: scripts/gpt_model.py
The default 124M parameter configuration:
GPT_CONFIG_124M = {
"vocab_size": 50257, # Vocabulary size
"context_length": 1024, # Context length
"emb_dim": 768, # Embedding dimension
"n_heads": 12, # Number of attention heads
"n_layers": 12, # Number of layers
"drop_rate": 0.1, # Dropout rate
"qkv_bias": False # Query-Key-Value bias
}
To calculate the number of parameters in your model:
Use the bundled script: scripts/calculate_params.py
This script breaks down parameters by component:
vocab_size * emb_dimcontext_length * emb_dimemb_dim * vocab_sizeTo generate text with a trained model:
Use the bundled script: scripts/generate_text.py
The generation process:
scripts/create_gpt_model.py with your configscripts/calculate_params.py to verifyscripts/generate_text.py with sample inputpython scripts/create_gpt_model.py --emb-dim 256 --n-layers 4 --n-heads 4
This creates a smaller model for testing/learning.
python scripts/calculate_params.py --config GPT_CONFIG_124M
Output shows breakdown by component and total (163,009,536 for 124M config).
python scripts/generate_text.py --model checkpoint.pt --prompt "Hello, I am" --max-tokens 10
(vocab_size, emb_dim)(context_length, emb_dim)testing
How to perform a House of Lore (small bin attack) heap exploitation. Use this skill whenever the user mentions heap exploitation, small bin attacks, fake chunks, glibc heap vulnerabilities, or needs to insert fake chunks into small bins for arbitrary read/write. Trigger for CTF challenges involving heap corruption, glibc 2.31+ exploitation, or when the user needs to bypass malloc sanity checks using fake chunk linking.
testing
How to perform House of Force heap exploitation attacks. Use this skill whenever the user mentions heap exploitation, House of Force, top chunk manipulation, arbitrary memory allocation, malloc manipulation, or wants to allocate chunks at specific addresses. Also trigger for CTF challenges involving heap overflows, top chunk size overwrites, or when the user needs to calculate evil_size for heap attacks. Make sure to use this skill for any binary exploitation task involving glibc heap manipulation, even if they don't explicitly say "House of Force".
tools
How to perform House of Einherjar heap exploitation to allocate memory at arbitrary addresses. Use this skill whenever the user mentions heap exploitation, glibc heap attacks, arbitrary memory allocation, off-by-one overflow exploitation, tcache poisoning, fast bin attacks, or any CTF challenge involving heap manipulation. This is essential for binary exploitation tasks where you need to control malloc() return addresses.
testing
How to identify, analyze, and exploit heap overflow vulnerabilities in binary exploitation challenges and real-world scenarios. Use this skill whenever the user mentions heap overflows, memory corruption, heap grooming, tcache poisoning, fast-bin attacks, or any heap-related vulnerability in CTF challenges, binary analysis, or security research. This skill covers heap overflow fundamentals, exploitation techniques, heap grooming strategies, and real-world CVE analysis.