wenmin-wu/ds-skills/batched-perplexity-scoring
Claude Code and agent skill by wenmin-wu/ds-skills
- community
Checking that the SKILL.md file is still in the repository.
Batch-compute perplexity for multiple texts using a causal LM with proper padding, shifted labels, and pad-token masking for efficient GPU utilization
Install
npx vskill@latest install wenmin-wu/ds-skills/batched-perplexity-scoringSKILL.md
Batched Perplexity Scoring
Overview
Single-sequence perplexity computation underutilizes the GPU. Batch multiple texts together with left-padding, mask out pad tokens in the loss, and compute perplexity per sequence in one forward pass. This is 4-8x faster than sequential scoring and essential when evaluating thousands of candidate orderings or generations.
Quick Start
Workflow
- Set tokenizer to left-padding with
pad_token = eos_token - Wrap each text with BOS/EOS tokens, tokenize as batch with padding
- Forward pass through causal LM to get logits
- Replace pad token IDs with -100 in labels (ignored by loss)
- Compute per-token cross-entropy, sum per sequence, divide by valid length
- Exponentiate to get perplexity
Key Decisions
- Left padding: causal LMs attend left-to-right; left-pad preserves token positions
- PAD_LABEL = -100: PyTorch CrossEntropyLoss ignores this index automatically
- BOS/EOS wrapping: manual wrapping with
add_special_tokens=Falseensures exact control - Quantization: combine with 4-bit/8-bit for larger models on limited GPU
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 repositoryCheckingskills/llm/batched-perplexity-scoring/SKILL.md
Popularity
- Repository stars
- 62
- Repository forks
- 4
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. 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/wenmin-wu/ds-skills/batched-perplexity-scoring)