⚠️This version of spaCy requires downloading new models. You can use the
spacy validatecommand to find out which models need updating, and print update instructions. If you've been training your own models, you'll need to retrain them with the new version.
✨ New features and improvements
Tagger, Parser, NER and Text Categorizer
- NEW: Experimental ULMFit/BERT/Elmo-like pretraining (see #2931) via the new
spacy pretraincommand. This pre-trains the CNN using BERT's cloze task. A new trick we're calling Language Modelling with Approximate Outputs is used to apply the pre-training to smaller models. The pre-training outputs CNN and embedding weights that can be used in
spacy train, using the new
- NEW: Allow parser to do joint word segmentation and parsing. If you pass in data where the tokenizer over-segments, the parser now learns to merge the tokens.
- Make parser, tagger and NER faster, through better hyperparameters.
- Add simpler, GPU-friendly option to
TextCategorizer, and allow setting
architecturearguments on initialization.
- Remove document length limit during training, by implementing faster Levenshtein alignment.
- Use Thinc v7.0, which defaults to single-thread with fast
bliskernel for matrix multiplication. Parallelisation should be performed at the task level, e.g. by running more containers.
Models & Language Data
- NEW: 2-3 times faster tokenization across all languages at the same accuracy!
- NEW: Small accuracy improvements for parsing, tagging and NER for 6+ languages.
- NEW: The English and German models are now available under the MIT license.
- NEW: Statistical models for Greek.
- NEW: Alpha support for Tamil, Ukrainian and Kannada, and base language classes for Afrikaans, Bulgarian, Czech, Icelandic, Lithuanian, Latvian, Slovak, Slovenian and Albanian.
- Improve loading time of
Vocab.writing_system(populated via the language data) to expose settings like writing direction.
pretraincommand for ULMFit/BERT/Elmo-like pretraining (see #2931).
- NEW: New
ud-traincommand, to train and evaluate using the CoNLL 2017 shared task data.
- Check if model is already installed before downloading it via
- Pass additional arguments of
pipto customise installation.
traincommand by letting
GoldCorpusstream data, instead of loading into memory.
init-modelcommand, including support for lexical attributes and word-vectors, using a variety of formats. This replaces the
spacy vocabcommand, which is now deprecated.
- Add support for multi-task objectives to
- Add support for data-augmentation to
- NEW: Enhanced pattern API for rule-based
Doc.retokenizecontext manager for merging and splitting tokens more efficiently.
- NEW: Add support for custom pipeline component factories via entry points (#2348).
- NEW: Implement fastText vectors with subword features.
- NEW: Built-in rule-based NER component to add entities based on match patterns (see #2513).
- NEW: Allow
PhraseMatcherto match on token attributes other than
LOWER(for case-insensitive matching) or even
- NEW: Replace
dillwith our own package
srslyto centralise dependencies and allow binary wheels.
Doc.to_json()method which outputs data in spaCy's training format. This will be the only place where the format is hard-coded (see #2932).
- NEW: Built-in
EntityRulercomponent to make it easier to build rule-based NER and combinations of statistical and rule-based systems.
gold.spans_from_biluo_tagshelper that returns
Spanobjects, e.g. to overwrite the
- Add warnings if
.similaritymethod is called with empty vectors or without word vectors.
- Improve rule-based
return_matcheskeyword argument to
(doc, matches)tuples instead of only
as_tuplesto add context to the
- Make stop words via
"TEXT"as an alternative to
.pysource and optimse codebase using
flake8. You can now run
flake8 spacyand it should return no errors or warnings. See
🔴 Bug fixes
- Fix issue #795: Fix behaviour of
- Fix issue #1487: Add
- Fix issue #1537: Make
Span.as_docreturn a copy, not a view.
- Fix issue #1574: Make sure stop words are available in medium and large English models.
- Fix issue #1585: Prevent parser from predicting unseen classes.
- Fix issue #1642: Replace
reand speed up tokenization.
- Fix issue #1665: Correct typos in symbol
- Fix issue #1748, #1798, #2756, #2934: Add simpler GPU-friendly option to
- Fix issue #1773: Prevent tokenizer exceptions from setting
- Fix issue #1782, #2343: Fix training on GPU.
- Fix issue #1816: Allow custom
Languagesubclasses via entry points.
- Fix issue #1865: Correct licensing of
- Fix issue #1889: Make stop words case-insensitive.
- Fix issue #1903: Add
relcldependency label to symbols.
- Fix issue #1963: Resize
Doc.tensorwhen merging spans.
- Fix issue #1971: Update
Matcherengine to support regex, extension attributes and rich comparison.
- Fix issue #2014: Make
- Fix issue #2091: Fix
displacysupport for RTL languages.
- Fix issue #2203, #3268: Prevent bad interaction of lemmatizer and tokenizer exceptions.
- Fix issue #2329: Correct
- Fix issue #2369: Respect pre-defined warning filters.
- Fix issue #2390: Support setting lexical attributes during retokenization.
- Fix issue #2396: Fix
- Fix issue #2464, #3009: Fix behaviour of
- Fix issue #2482: Fix serialization when parser model is empty.
- Fix issue #2512, #2153: Fix issue with deserialization into non-empty vocab.
- Fix issue #2603: Improve handling of missing NER tags.
- Fix issue #2644: Add table explaining training metrics to docs.
- Fix issue #2648: Fix
- Fix issue #2671, #2675: Fix incorrect match ID on some patterns.
- Fix issue #2693: Only use
'sentencizer'as built-in sentence boundary component name.
- Fix issue #2728: Fix HTML escaping in
displacyNER visualization and correct API docs.
- Fix issue #2740: Add ability to pass additional arguments to pipeline components.
- Fix issue #2754, #3028: Make
Tokenattribute instead of a
Lexemeattribute to allow setting context-specific norms in tokenizer exceptions.
- Fix issue #2769: Fix issue that'd cause segmentation fault when calling
- Fix issue #2772: Fix bug in sentence starts for non-projective parses.
- Fix issue #2779: Fix handling of pre-set entities.
- Fix issue #2782: Make
like_numwork with prefixed numbers.
- Fix issue #2833: Raise better error if
- Fix issue #2838: Add
Retokenizer.splitmethod to split one token into several.
- Fix issue #2869: Make
doc.is_sent_start == True.
- Fix issue #2870: Make it illegal for the entity recognizer to predict whitespace tokens as
- Fix issue #2871: Fix vectors for reserved words.
- Fix issue #2901: Fix issue with first call of
nlpin Japanese (MeCab).
- Fix issue #2924: Make IDs of displaCy arcs more unique to avoid clashes.
- Fix issue #3012: Fix clobber of
- Fix issue #3027: Allow
Spanto take unicode value for
- Fix issue #3036: Support mutable default arguments in extension attributes.
- Fix issue #3048: Raise better errors for uninitialized pipeline components.
- Fix issue #3064: Allow single string attributes in
- Fix issue #3093, #3067: Set
vectors.namecorrectly when exporting model via CLI.
- Fix issue #3112: Make sure entity types are added correctly on GPU.
- Fix issue #3191: Fix pickling of
- Fix issue #3122: Correct docs of
- Fix issue #3128: Improve error handling in converters.
- Fix issue #3248: Fix
PhraseMatcherpickling and make
- Fix issue #3274: Make
Token.sentwork as expected without the parser.
- Fix issue #3277: Add en/em dash to tokenizer prefixes and suffixes.
- Fix issue #3346: Expose Japanese stop words in language class.
- Fix issue #3357: Update displaCy examples in docs to correctly show
- Fix issue #3345: Fix NER when preset entities cross-sentence boundaries.
- Fix issue #3348: Don't use
numpydirectly for similarity.
- Fix issue #3366: Improve converters, training data formats and docs.
- Fix issue #3369: Fix
#eggfragments in direct downloads.
- Fix issue #3382: Make
- Fix issue #3398: Don't set extension attributes in language classes.
- Fix issue #3373: Merge and improve
- Fix serialization of custom tokenizer if not all functions are defined.
- Fix bugs in beam-search training objective.
- Fix problems with model pickling.
⚠️ Backwards incompatibilities
- This version of spaCy requires downloading new models. You can use the
spacy validatecommand to find out which models need updating, and print update instructions.
- If you've been training your own models, you'll need to retrain them with the new version.
- Due to difficulties linking our new
blisfor faster platform-independent matrix multiplication, v2.1.x currently doesn't work on Python 2.7 on Windows. We expect this to be corrected in the future.
- While the
MatcherAPI is fully backwards compatible, its algorithm has changed to fix a number of bugs and performance issues. This means that the
v2.1.xmay produce different results compared to the
- The deprecated
Span.mergemethods still work, but you may notice that they now run slower when merging many objects in a row. That's because the merging engine was rewritten to be more reliable and to support more efficient merging in bulk. To take advantage of this, you should rewrite your logic to use the
Doc.retokenizecontext manager and perform as many merges as possible together in the
- doc[1:5].merge() - doc[6:8].merge() + with doc.retokenize() as retokenizer: + retokenizer.merge(doc[1:5]) + retokenizer.merge(doc[6:8])
- The serialization methods
from_bytesnow support a single
excludeargument to provide a list of string names to exclude. The docs have been updated to list the available serialization fields for each class. The
disableargument on the
Languageserialization methods has been renamed to
- nlp.to_disk("/path", disable=["parser", "ner"]) + nlp.to_disk("/path", exclude=["parser", "ner"]) - data = nlp.tokenizer.to_bytes(vocab=False) + data = nlp.tokenizer.to_bytes(exclude=["vocab"])
.posvalue for several common English words has changed, due to corrections to long-standing mistakes in the English tag map (see #593, #3311).
- For better compatibility with the Universal Dependencies data, the lemmatizer now preserves capitalization, e.g. for proper nouns (see #3256).
- The keyword argument
.pipemethods is now deprecated, as the v2.x models cannot release the global interpreter lock. (Future versions may introduce a
n_processargument for parallel inference via multiprocessing.)
Doc.print_treemethod is not deprecated in favour of a unified
Doc.to_jsonmethod, which outputs data in the same format as the expected JSON training data.
- The built-in rule-based sentence boundary detector is now only called
'sentencizer'– the name
- sentence_splitter = nlp.create_pipe('sbd') + sentence_splitter = nlp.create_pipe('sentencizer')
is_sent_startattribute of the first token in a
Docnow correctly defaults to
True. It previously defaulted to
spacy traincommand now lets you specify a comma-separated list of pipeline component names, instead of separate flags like
--no-parserto disable components. This is more flexible and also handles custom components out-of-the-box.
- $ spacy train en /output train_data.json dev_data.json --no-parser + $ spacy train en /output train_data.json dev_data.json --pipeline tagger,ner
spacy init-modelcommand now uses a
--jsonl-locargument to pass in a a newline-delimited JSON (JSONL) file containing one lexical entry per line instead of a separate
- $ spacy init-model en ./model --freqs-loc ./freqs.txt --clusters-loc ./clusters.txt + $ spacy init-model en ./model --jsonl-loc ./vocab.jsonl
- Also note that some of the model licenses have changed:
it_core_news_smis now correctly licensed under CC BY-NC-SA 3.0, and all English and German models are now published under the MIT license.
💬UAS: Unlabelled dependencies (parser). LAS: Labelled dependencies (parser). POS: Part-of-speech tags (fine-grained tags, i.e.
Token.tag_). NER F: Named entities (F-score). Vec: Model contains word vectors. Size: Model file size (zipped archive).
📖 Documentation and examples
Although it looks pretty much the same, we've rebuilt the entire documentation using Gatsby and MDX. It's now an even faster progressive web app and allows us to write all content entirely in Markdown, without having to compromise on easy-to-use custom UI components. We're hoping that the Markdown source will make it even easier to contribute to the documentation. For more details, check out the styleguide and source.
While converting the pages to Markdown, we've also fixed a bunch of typos, improved the existing pages and added some new content:
- Usage Guide: Rule-based Matching. How to use the
PhraseMatcherand the new
EntityRuler, and write powerful components to combine statistical models and rules.
- Usage Guide: Saving and Loading. Everything you need to know about serialization, and how to save and load pipeline components, package your spaCy models as Python modules and use entry points.
- Usage Guide: Merging and Splitting. How to retokenize a
Docusing the new
retokenizecontext manager and merge spans into single tokens and split single tokens into multiple.
- Universe: Videos and Podcasts
- API: Pipeline functions
Thanks to @DuyguA, @giannisdaras, @mgogoulos, @louridas, @skrcode, @gavrieltal, @svlandeg, @jarib, @alvaroabascar, @kbulygin, @moreymat, @mirfan899, @ozcankasal, @willprice, @alvations, @amperinet, @retnuh, @Loghijiaha, @DeNeutoy, @gavrieltal, @boena, @BramVanroy, @pganssle, @foufaster, @adrianeboyd, @maknotavailable, @pierremonico, @lauraBaakman, @juliamakogon, @Gizzio, @Abhijit-2592, @akki2825, @grivaz, @roshni-b, @mpuig, @mikelibg, @danielkingai2, @adrienball and @Poluglottos for the pull requests and contributions.