skills/AI/AI-llm-architecture/AI-llm-architecture/SKILL.md
Guide for building and training large language models from scratch. Use this skill whenever the user wants to understand LLM training concepts, implement tokenization, data sampling, embeddings, attention mechanisms, model architecture, pre-training, or fine-tuning workflows. Trigger on mentions of LLM training, building models from scratch, tokenization, embeddings, attention, pre-training, fine-tuning, LoRA, or any LLM development task.
npx skillsauth add abelrguezr/hacktricks-skills llm-training-guideInstall 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 comprehensive guide for building and training large language models from scratch, based on the Manning book "Build a Large Language Model from Scratch".
This skill covers the complete LLM training pipeline:
Goal: Divide input text into tokens (IDs) in a meaningful way.
<pad>, <unk>, <bos>, <eos>Goal: Sample input data and prepare it for training by separating into sequences of specific length and generating expected responses.
Goal: Assign each token a vector representation of desired dimensions. Each word becomes a point in X-dimensional space.
Goal: Apply attention layers to capture relationships between words in the sentence.
Attention(Q, K, V) = softmax(QK^T / sqrt(d_k))V
Goal: Develop the full LLM architecture by combining all components.
Input → Token Embedding → Position Embedding → [N × (Attention → MLP)] → Output Projection → Logits
Goal: Train the model from scratch using the defined architecture, loss functions, and optimizer.
for epoch in epochs:
for batch in dataloader:
# Forward pass
logits = model(input_tokens)
# Compute loss
loss = cross_entropy(logits, target_tokens)
# Backward pass
loss.backward()
# Update weights
optimizer.step()
optimizer.zero_grad()
Goal: Reduce computation needed for fine-tuning by training only small adapter matrices.
Goal: Adapt pre-trained model to classify text into categories.
Goal: Adapt pre-trained model to follow instructions (chat, tasks, etc.).
<instruction> {instruction} <input> {input} <output> {output}
| Issue | Solution | |-------|----------| | Training loss not decreasing | Check learning rate, batch size, data quality | | Model generates repetitive text | Adjust temperature, use top-k/top-p sampling | | Out of memory | Reduce batch size, use gradient checkpointing | | Slow training | Use mixed precision, flash attention | | Poor generalization | More data, regularization, better architecture |
After completing these phases, you can:
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.