cstrien/skills_dior/3-token-embeddings
Claude Code and agent skill by cstrien/skills_dior
- community
Checking that the SKILL.md file is still in the repository.
Create and work with token embeddings for LLMs. Use this skill whenever you need to understand token embeddings, create embedding layers in PyTorch, add positional embeddings (absolute, relative, or RoPE), or debug embedding-related issues in your language model. This skill covers vocabulary setup, embedding initialization, positional encoding strategies, and context window extension techniques. Make sure to use this skill when working with any LLM architecture, training pipelines, or when you…
Install
npx vskill@latest install cstrien/skills_dior/3-token-embeddingsSKILL.md
The same SKILL.md was published earlier as cstrien/skills_dior/3-token-embeddings.
Token Embeddings Skill
This skill helps you create, understand, and work with token embeddings for large language models.
What This Skill Does
- Explains token embedding concepts and initialization
- Creates PyTorch embedding layers for your vocabulary
- Adds positional embeddings (absolute, relative, RoPE)
- Helps debug embedding-related issues
- Provides code templates for common embedding tasks
When to Use This Skill
Use this skill when you:
- Need to create token embeddings for a new vocabulary
- Want to understand how embeddings work in your model
- Need to add positional information to your embeddings
- Are debugging embedding dimension mismatches
- Want to extend context windows in RoPE-based models
- Need to implement or understand different positional encoding strategies
Core Concepts
Token Embeddings
Token embeddings convert discrete tokens into continuous vectors. Each token in your vocabulary gets a unique vector of fixed dimensions.
Key parameters:
vocab_size: Number of unique tokens (e.g., 50257 for BPE)embedding_dim: Vector dimensions (e.g., 256, 512, 768)
Example:
Positional Embeddings
Positional embeddings encode token positions in sequences. Without them, the model treats tokens as a "bag of words."
Types:
- Absolute: Fixed position vectors (GPT-style)
- Relative: Distance-based encoding (Transformer-XL, BERT variants)
- RoPE: Rotary embeddings (modern decoder-only LLMs)
Quick Start
Create Basic Token Embeddings
Add Absolute Positional Embeddings
RoPE (Rotary Positional Embeddings)
For modern LLMs, RoPE is preferred:
Common Tasks
Task 1: Initialize Embedding Layer
Task 2: Create Positional Embeddings
Task 3: Combine Token and Positional Embeddings
Task 4: Position Interpolation for Extended Context
Debugging Checklist
When embeddings aren't working correctly, check:
- Dimension Mismatches
``python # Verify shapes match assert token_emb.shape == pos_emb.shape, "Embedding dimensions must match" ``
- Vocabulary Size
``python # Ensure vocab_size matches your tokenizer max_token_id = token_ids.max() assert max_token_id < vocab_size, f"Token {max_token_id} exceeds vocab_size {vocab_size}" ``
- Context Length
``python # Ensure sequence doesn't exceed context length seq_len = token_ids.shape[1] assert seq_len <= context_length, f"Sequence {seq_len} exceeds context {context_length}" ``
- Gradient Flow
``python # Verify embeddings are trainable assert token_embedding.weight.requires_grad, "Embeddings should be trainable" ``
Best Practices
- Embedding Dimensions: Use powers of 2 (256, 512, 768, 1024) for efficiency
- Initialization: PyTorch's default Xavier initialization works well
- Positional Encoding: Use RoPE for decoder-only models, absolute for encoder-only
- Context Extension: Use position interpolation before fine-tuning for longer contexts
- Batch Processing: Always process in batches for efficiency
Example: Complete Embedding Setup
References
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingAI/AI-llm-architecture/3.-token-embeddings/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cstrien/skills_dior/3-token-embeddings)