From 3a193eb8f1a6da7985c8a8332ed7c005ce222f9c Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Fri, 7 Aug 2020 18:40:54 +0200 Subject: [PATCH] Fix imports, types and default configs --- spacy/ml/models/parser.py | 9 +++++---- spacy/ml/models/simple_ner.py | 4 ++-- spacy/ml/models/tagger.py | 2 +- spacy/ml/models/tok2vec.py | 10 +++++----- spacy/pipeline/dep_parser.pyx | 1 - spacy/pipeline/entity_linker.py | 1 - spacy/pipeline/multitask.pyx | 1 - spacy/pipeline/ner.pyx | 1 - spacy/pipeline/senter.pyx | 1 - spacy/pipeline/simple_ner.py | 3 +-- spacy/pipeline/tagger.pyx | 1 - spacy/pipeline/textcat.py | 1 - spacy/pipeline/tok2vec.py | 1 - spacy/tests/serialize/test_serialize_config.py | 2 -- 14 files changed, 14 insertions(+), 24 deletions(-) diff --git a/spacy/ml/models/parser.py b/spacy/ml/models/parser.py index 0d3baf0ec..868f9d6d2 100644 --- a/spacy/ml/models/parser.py +++ b/spacy/ml/models/parser.py @@ -5,6 +5,7 @@ from thinc.types import Floats2d from ...util import registry from .._precomputable_affine import PrecomputableAffine from ..tb_framework import TransitionModel +from ...tokens import Doc @registry.architectures.register("spacy.TransitionBasedParser.v1") @@ -18,7 +19,7 @@ def build_tb_parser_model( ) -> Model: """ Build a transition-based parser model. Can apply to NER or dependency-parsing. - + Transition-based parsing is an approach to structured prediction where the task of predicting the structure is mapped to a series of state transitions. You might find this tutorial helpful as background: @@ -35,7 +36,7 @@ def build_tb_parser_model( and applying the non-linearity. * upper (optional): A feed-forward network that predicts scores from the state representation. If not present, the output from the lower model is - ued as action scores directly. + used as action scores directly. tok2vec (Model[List[Doc], List[Floats2d]]): Subnetwork to map tokens into vector representations. @@ -44,10 +45,10 @@ def build_tb_parser_model( 2, 8 and 13 feature sets are designed for the parser, while the 3 and 6 feature sets are designed for the NER. The recommended feature sets are 3 for NER, and 8 for the dependency parser. - + TODO: This feature should be split into two, state_type: ["deps", "ner"] and extra_state_features: [True, False]. This would map into: - + (deps, False): 8 (deps, True): 13 (ner, False): 3 diff --git a/spacy/ml/models/simple_ner.py b/spacy/ml/models/simple_ner.py index 62f85ac07..aca58c937 100644 --- a/spacy/ml/models/simple_ner.py +++ b/spacy/ml/models/simple_ner.py @@ -10,7 +10,7 @@ from .._iob import IOB from ...util import registry -@registry.architectures.register("spacy.BiluoTagger.v1") +@registry.architectures.register("spacy.BILUOTagger.v1") def BiluoTagger( tok2vec: Model[List[Doc], List[Floats2d]] ) -> Model[List[Doc], List[Floats2d]]: @@ -59,7 +59,7 @@ def IOBTagger( token and uses greedy decoding with transition-constraints to return a valid IOB tag sequence. - A IOB tag sequence encodes a sequence of non-overlapping labelled spans + An IOB tag sequence encodes a sequence of non-overlapping labelled spans into tags assigned to each token. The first token of a span is given the tag B-LABEL, and subsequent tokens are given the tag I-LABEL. All other tokens are assigned the tag O. diff --git a/spacy/ml/models/tagger.py b/spacy/ml/models/tagger.py index d6bdb283b..09405214c 100644 --- a/spacy/ml/models/tagger.py +++ b/spacy/ml/models/tagger.py @@ -3,7 +3,7 @@ from thinc.api import zero_init, with_array, Softmax, chain, Model from thinc.types import Floats2d from ...util import registry -from ..tokens import Doc +from ...tokens import Doc @registry.architectures.register("spacy.Tagger.v1") diff --git a/spacy/ml/models/tok2vec.py b/spacy/ml/models/tok2vec.py index 5689ce50b..faa5350d4 100644 --- a/spacy/ml/models/tok2vec.py +++ b/spacy/ml/models/tok2vec.py @@ -77,7 +77,7 @@ def build_Tok2Vec_model( """Construct a tok2vec model out of embedding and encoding subnetworks. See https://explosion.ai/blog/deep-learning-formula-nlp - embed (Model[List[Doc], List[Floats2d]]): Embed tokens into context-indepdent + embed (Model[List[Doc], List[Floats2d]]): Embed tokens into context-independent word vector representations. encode (Model[List[Floats2d], List[Floats2d]]): Encode context into the embeddings, using an architecture such as a CNN, BiLSTM or transformer. @@ -187,7 +187,7 @@ def CharacterEmbed(width: int, rows: int, nM: int, nC: int): are between 16 and 64. nC (int): The number of UTF-8 bytes to embed per word. Recommended values are between 3 and 8, although it may depend on the length of words in the - language. + language. """ model = chain( concatenate( @@ -212,7 +212,7 @@ def MaxoutWindowEncoder( normalization and residual connections. width (int): The input and output width. These are required to be the same, - to allow residual connections. This value will be determined by the + to allow residual connections. This value will be determined by the width of the inputs. Recommended values are between 64 and 300. window_size (int): The number of words to concatenate around each token to construct the convolution. Recommended value is 1. @@ -244,7 +244,7 @@ def MishWindowEncoder( normalization and residual connections. width (int): The input and output width. These are required to be the same, - to allow residual connections. This value will be determined by the + to allow residual connections. This value will be determined by the width of the inputs. Recommended values are between 64 and 300. window_size (int): The number of words to concatenate around each token to construct the convolution. Recommended value is 1. @@ -266,7 +266,7 @@ def BiLSTMEncoder( """Encode context using bidirectonal LSTM layers. Requires PyTorch. width (int): The input and output width. These are required to be the same, - to allow residual connections. This value will be determined by the + to allow residual connections. This value will be determined by the width of the inputs. Recommended values are between 64 and 300. window_size (int): The number of words to concatenate around each token to construct the convolution. Recommended value is 1. diff --git a/spacy/pipeline/dep_parser.pyx b/spacy/pipeline/dep_parser.pyx index a022d04d6..f85b5626a 100644 --- a/spacy/pipeline/dep_parser.pyx +++ b/spacy/pipeline/dep_parser.pyx @@ -27,7 +27,6 @@ embed_size = 2000 window_size = 1 maxout_pieces = 3 subword_features = true -dropout = null """ DEFAULT_PARSER_MODEL = Config().from_str(default_model_config)["model"] diff --git a/spacy/pipeline/entity_linker.py b/spacy/pipeline/entity_linker.py index d922db1ad..840070c23 100644 --- a/spacy/pipeline/entity_linker.py +++ b/spacy/pipeline/entity_linker.py @@ -29,7 +29,6 @@ embed_size = 300 window_size = 1 maxout_pieces = 3 subword_features = true -dropout = null """ DEFAULT_NEL_MODEL = Config().from_str(default_model_config)["model"] diff --git a/spacy/pipeline/multitask.pyx b/spacy/pipeline/multitask.pyx index 4b582045d..84ed19b0d 100644 --- a/spacy/pipeline/multitask.pyx +++ b/spacy/pipeline/multitask.pyx @@ -29,7 +29,6 @@ embed_size = 2000 window_size = 1 maxout_pieces = 2 subword_features = true -dropout = null """ DEFAULT_MT_MODEL = Config().from_str(default_model_config)["model"] diff --git a/spacy/pipeline/ner.pyx b/spacy/pipeline/ner.pyx index 7f4fb8363..d13152a4f 100644 --- a/spacy/pipeline/ner.pyx +++ b/spacy/pipeline/ner.pyx @@ -25,7 +25,6 @@ embed_size = 2000 window_size = 1 maxout_pieces = 3 subword_features = true -dropout = null """ DEFAULT_NER_MODEL = Config().from_str(default_model_config)["model"] diff --git a/spacy/pipeline/senter.pyx b/spacy/pipeline/senter.pyx index 3147cc902..cf7479c29 100644 --- a/spacy/pipeline/senter.pyx +++ b/spacy/pipeline/senter.pyx @@ -25,7 +25,6 @@ embed_size = 2000 window_size = 1 maxout_pieces = 2 subword_features = true -dropout = null """ DEFAULT_SENTER_MODEL = Config().from_str(default_model_config)["model"] diff --git a/spacy/pipeline/simple_ner.py b/spacy/pipeline/simple_ner.py index 43a3283ca..4965b2e13 100644 --- a/spacy/pipeline/simple_ner.py +++ b/spacy/pipeline/simple_ner.py @@ -15,7 +15,7 @@ from .pipe import Pipe default_model_config = """ [model] -@architectures = "spacy.BiluoTagger.v1" +@architectures = "spacy.BILUOTagger.v1" [model.tok2vec] @architectures = "spacy.HashEmbedCNN.v1" @@ -26,7 +26,6 @@ embed_size = 7000 window_size = 1 maxout_pieces = 3 subword_features = true -dropout = null """ DEFAULT_SIMPLE_NER_MODEL = Config().from_str(default_model_config)["model"] diff --git a/spacy/pipeline/tagger.pyx b/spacy/pipeline/tagger.pyx index da1b3d3aa..db1f72fca 100644 --- a/spacy/pipeline/tagger.pyx +++ b/spacy/pipeline/tagger.pyx @@ -31,7 +31,6 @@ embed_size = 2000 window_size = 1 maxout_pieces = 3 subword_features = true -dropout = null """ DEFAULT_TAGGER_MODEL = Config().from_str(default_model_config)["model"] diff --git a/spacy/pipeline/textcat.py b/spacy/pipeline/textcat.py index a9339c021..06b72f8c7 100644 --- a/spacy/pipeline/textcat.py +++ b/spacy/pipeline/textcat.py @@ -48,7 +48,6 @@ embed_size = 2000 window_size = 1 maxout_pieces = 3 subword_features = true -dropout = null """ diff --git a/spacy/pipeline/tok2vec.py b/spacy/pipeline/tok2vec.py index 31643a7d3..db6843e8f 100644 --- a/spacy/pipeline/tok2vec.py +++ b/spacy/pipeline/tok2vec.py @@ -20,7 +20,6 @@ embed_size = 2000 window_size = 1 maxout_pieces = 3 subword_features = true -dropout = null """ DEFAULT_TOK2VEC_MODEL = Config().from_str(default_model_config)["model"] diff --git a/spacy/tests/serialize/test_serialize_config.py b/spacy/tests/serialize/test_serialize_config.py index 0d3c90c92..8e3c95823 100644 --- a/spacy/tests/serialize/test_serialize_config.py +++ b/spacy/tests/serialize/test_serialize_config.py @@ -48,7 +48,6 @@ window_size = 1 embed_size = 2000 maxout_pieces = 3 subword_features = true -dropout = null [components.tagger] factory = "tagger" @@ -78,7 +77,6 @@ embed_size = 5555 window_size = 1 maxout_pieces = 7 subword_features = false -dropout = null """