Skip to content
Back to skills

Stopword Priority Sorting

ASecurity

Initialize text ordering by placing stopwords first then content words, producing low-perplexity starting points for combinatorial search over word permutations

  • 61 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 12, 2026
toolspython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill stopword-priority-sorting --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Stopword Priority Sorting?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Stopword Priority Sorting
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-stopword-priority-sorting/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-stopword-priority-sorting)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: llm-stopword-priority-sorting
description: Initialize text ordering by placing stopwords first then content words, producing low-perplexity starting points for combinatorial search over word permutations
---

# Stopword Priority Sorting

## Overview

When minimizing LLM perplexity over word permutations, the initial ordering matters for local search convergence. Sorting stopwords (the, a, is, of) first and content words second produces a surprisingly low starting perplexity because LLMs assign high probability to function words at sequence starts. This simple heuristic gives a 20-40% perplexity reduction over alphabetical sorting as a starting point.

## Quick Start

```python
from nltk.corpus import stopwords

STOP_WORDS = set(stopwords.words('english'))

def stopword_priority_sort(words):
    stops = sorted([w for w in words if w.lower() in STOP_WORDS])
    content = sorted([w for w in words if w.lower() not in STOP_WORDS])
    return stops + content

initial_order = stopword_priority_sort(text.split())
initial_text = ' '.join(initial_order)
```

## Workflow

1. Split text into words
2. Partition into stopwords and content words
3. Sort each partition alphabetically (or by frequency)
4. Concatenate: stopwords first, then content words
5. Use as initialization for SA, sliding window, or greedy reinsert search

## Key Decisions

- **Why it works**: LLMs model P(w_i | w_{<i}); function words have high conditional probability after other function words
- **Alphabetical within groups**: provides deterministic tie-breaking; frequency-based may be slightly better
- **vs random**: 2-5x lower starting perplexity than random shuffle
- **Limitations**: only useful as initialization — follow with local search for final optimization

## References

- [To Winning - Sort Off](https://www.kaggle.com/code/jazivxt/to-winning-sort-off)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.