← all repositories
nikitakit/self-attentive-parser

Phrase-structure trees for eleven languages, now PyTorch-native

Pre-trained constituency parsers for 11 languages that slot into spaCy or NLTK.

911 stars Python Language ModelsData Tooling
self-attentive-parser
Not currently ranked — collecting fresh signals.
star history

What it does The Berkeley Neural Parser—benepar on PyPI—builds phrase-structure trees (constituency parses) for sentences in eleven languages. It ships as a Python library that wraps fine-tuned transformer backbones and exposes the results through spaCy extension attributes or an NLTK interface. You feed it text or pre-tokenized sentences, and it returns hierarchical bracketings like (S (NP ...) (VP ...)).

The interesting bit The project bridges decades-old treebank conventions—WSJ, CTB, SPMRL—with modern transformer architectures including T5, XLM-R, and Chinese ELECTRA. A 2021 rewrite dropped TensorFlow inference entirely for PyTorch and replaced every pre-trained model, effectively trading backward compatibility for higher F1 scores.

Key highlights

  • Eleven language models with reported test-set F1 scores up to 97.15 (Polish) and 96.29 (English large).
  • Tight spaCy integration: constituency data hangs off Span._ extensions such as parse_string, labels, and children.
  • Transformer-based models vary by language: English uses T5, most others use XLM-R, Chinese uses ELECTRA.
  • Training and evaluation scripts are included for custom treebanks, though they require cloning the repository and compiling EVALB.

Caveats

  • Raw-text support is inconsistent across languages: Arabic and Hebrew only accept pre-tokenized input via NLTK, and Basque spaCy integration is left as an exercise for the reader.
  • Because spaCy has no official constituency API, the Span._ extensions raise exceptions if you query non-constituent spans; safe traversal requires starting from doc.sents or a Token.
  • The 0.2.0 release is a hard break from earlier versions: it drops Python 2.7 and 3.5, swaps inference to PyTorch, and replaces all legacy models.

Verdict Worth a look if you need constituency parses inside a modern spaCy pipeline or want strong multilingual phrase-structure baselines. Skip it if you only need dependency syntax, or if you expect every language to handle raw text out of the box.

Frequently asked

What is nikitakit/self-attentive-parser?
Pre-trained constituency parsers for 11 languages that slot into spaCy or NLTK.
Is self-attentive-parser open source?
Yes — nikitakit/self-attentive-parser is open source, released under the MIT license.
What language is self-attentive-parser written in?
nikitakit/self-attentive-parser is primarily written in Python.
How popular is self-attentive-parser?
nikitakit/self-attentive-parser has 911 stars on GitHub.
Where can I find self-attentive-parser?
nikitakit/self-attentive-parser is on GitHub at https://github.com/nikitakit/self-attentive-parser.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.