Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

perf: skip dependency parser during POS tagging#4409

Draft
KRRT7 wants to merge 6 commits into
Unstructured-IO:mainUnstructured-IO/unstructured:mainfrom
KRRT7:perf-parser-free-pos-stackedKRRT7/unstructured:perf-parser-free-pos-stackedCopy head branch name to clipboard
Draft

perf: skip dependency parser during POS tagging#4409
KRRT7 wants to merge 6 commits into
Unstructured-IO:mainUnstructured-IO/unstructured:mainfrom
KRRT7:perf-parser-free-pos-stackedKRRT7/unstructured:perf-parser-free-pos-stackedCopy head branch name to clipboard

Conversation

@KRRT7

@KRRT7 KRRT7 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Stack dependency

This draft is stacked on #4408 and should be reviewed and merged after that PR. Once #4408 lands, this branch will be rebased onto main so the final diff contains only the parser-free POS change.

Summary

Skip spaCy's dependency parser in pos_tag() while retaining the tok2vec and tagger components that produce token.tag_.

The dependency parser runs after the tagger, and pos_tag() immediately discards its output. Disabling it removes unnecessary statistical work without changing returned POS tags.

Performance

Benchmarked against the tokenizer-only parent branch on an 8-vCPU AMD EPYC host with 15 GiB RAM and Python 3.12. The spaCy model was warmed, NLP result caches were cleared before every iteration, and each full-matrix result is the median of three runs.

Document Tokenizer-only parent This PR Incremental change
1,225-page War and Peace TXT 48.986s 47.237s 3.6% faster
230-page 10-K HTML 1.038s 1.048s effectively neutral
872-page handbook DOCX 20.582s 20.128s 2.2% faster
369-page science presentation PPTX 2.327s 2.586s noisy short workload
Aggregate median 72.932s 70.998s 2.7% faster / 1.03x

A seven-iteration follow-up on the short workloads measured HTML 1.5% faster and PPTX 1.6% slower, confirming both are effectively neutral. The repeatable gains are in the text-heavy TXT and DOCX paths.

Compared with upstream/main, the combined tokenizer-only and parser-free-POS stack improves the representative aggregate from 85.801s to 70.998s: approximately 17.3% faster / 1.21x.

Output parity was exact for all four documents.

Testing

  • 128 focused NLP, text-classification, and benchmark tests pass.
  • POS tags are compared with and without the dependency parser across six representative inputs.
  • A regression test verifies that pos_tag() disables the parser.
  • Existing tokenizer parity, truncation, caching, and benchmark tests continue to pass.
  • Ruff lint and formatting checks pass.

Review in cubic

@KRRT7
KRRT7 force-pushed the perf-parser-free-pos-stacked branch from 35d48a9 to 11d518e Compare July 17, 2026 03:39
@cragwolfe

Copy link
Copy Markdown
Contributor

LGTM. will wait for #4408 to land before formal approval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.