mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-31 16:07:41 +03:00 
			
		
		
		
	TransitionBasedParser.v1 to legacy (#8586)
* TransitionBasedParser.v1 to legacy * register sublayers * bump spacy-legacy to 3.0.7
This commit is contained in:
		
							parent
							
								
									04a9ade40f
								
							
						
					
					
						commit
						e7d747e3ee
					
				|  | @ -1,5 +1,5 @@ | |||
| # Our libraries | ||||
| spacy-legacy>=3.0.6,<3.1.0 | ||||
| spacy-legacy>=3.0.7,<3.1.0 | ||||
| cymem>=2.0.2,<2.1.0 | ||||
| preshed>=3.0.2,<3.1.0 | ||||
| thinc>=8.0.7,<8.1.0 | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ setup_requires = | |||
|     thinc>=8.0.7,<8.1.0 | ||||
| install_requires = | ||||
|     # Our libraries | ||||
|     spacy-legacy>=3.0.6,<3.1.0 | ||||
|     spacy-legacy>=3.0.7,<3.1.0 | ||||
|     murmurhash>=0.28.0,<1.1.0 | ||||
|     cymem>=2.0.2,<2.1.0 | ||||
|     preshed>=3.0.2,<3.1.0 | ||||
|  |  | |||
|  | @ -1,6 +1,9 @@ | |||
| from thinc.api import Model, normal_init | ||||
| 
 | ||||
| from ..util import registry | ||||
| 
 | ||||
| 
 | ||||
| @registry.layers("spacy.PrecomputableAffine.v1") | ||||
| def PrecomputableAffine(nO, nI, nF, nP, dropout=0.1): | ||||
|     model = Model( | ||||
|         "precomputable_affine", | ||||
|  |  | |||
|  | @ -10,48 +10,7 @@ from ..tb_framework import TransitionModel | |||
| from ...tokens import Doc | ||||
| 
 | ||||
| 
 | ||||
| @registry.architectures("spacy.TransitionBasedParser.v1") | ||||
| def transition_parser_v1( | ||||
|     tok2vec: Model[List[Doc], List[Floats2d]], | ||||
|     state_type: Literal["parser", "ner"], | ||||
|     extra_state_tokens: bool, | ||||
|     hidden_width: int, | ||||
|     maxout_pieces: int, | ||||
|     use_upper: bool = True, | ||||
|     nO: Optional[int] = None, | ||||
| ) -> Model: | ||||
|     return build_tb_parser_model( | ||||
|         tok2vec, | ||||
|         state_type, | ||||
|         extra_state_tokens, | ||||
|         hidden_width, | ||||
|         maxout_pieces, | ||||
|         use_upper, | ||||
|         nO, | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| @registry.architectures("spacy.TransitionBasedParser.v2") | ||||
| def transition_parser_v2( | ||||
|     tok2vec: Model[List[Doc], List[Floats2d]], | ||||
|     state_type: Literal["parser", "ner"], | ||||
|     extra_state_tokens: bool, | ||||
|     hidden_width: int, | ||||
|     maxout_pieces: int, | ||||
|     use_upper: bool, | ||||
|     nO: Optional[int] = None, | ||||
| ) -> Model: | ||||
|     return build_tb_parser_model( | ||||
|         tok2vec, | ||||
|         state_type, | ||||
|         extra_state_tokens, | ||||
|         hidden_width, | ||||
|         maxout_pieces, | ||||
|         use_upper, | ||||
|         nO, | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| def build_tb_parser_model( | ||||
|     tok2vec: Model[List[Doc], List[Floats2d]], | ||||
|     state_type: Literal["parser", "ner"], | ||||
|  |  | |||
|  | @ -1,7 +1,9 @@ | |||
| from thinc.api import Model, noop | ||||
| from .parser_model import ParserStepModel | ||||
| from ..util import registry | ||||
| 
 | ||||
| 
 | ||||
| @registry.layers("spacy.TransitionModel.v1") | ||||
| def TransitionModel( | ||||
|     tok2vec, lower, upper, resize_output, dropout=0.2, unseen_classes=set() | ||||
| ): | ||||
|  |  | |||
|  | @ -553,6 +553,13 @@ consists of either two or three subnetworks: | |||
| | `nO`                 | The number of actions the model will predict between. Usually inferred from data at the beginning of training, or loaded from disk. ~~int~~                                                                                                                                                                                                                             | | ||||
| | **CREATES**          | The model using the architecture. ~~Model[List[Docs], List[List[Floats2d]]]~~                                                                                                                                                                                                                                                                                           | | ||||
| 
 | ||||
| <Accordion title="spacy.TransitionBasedParser.v1 definition" spaced> | ||||
| 
 | ||||
| [TransitionBasedParser.v1](/api/legacy#TransitionBasedParser_v1) had the exact same signature,  | ||||
| but the `use_upper` argument was `True` by default. | ||||
| 
 | ||||
| </Accordion> | ||||
| 
 | ||||
| ## Tagging architectures {#tagger source="spacy/ml/models/tagger.py"} | ||||
| 
 | ||||
| ### spacy.Tagger.v1 {#Tagger} | ||||
|  |  | |||
|  | @ -103,6 +103,11 @@ and residual connections. | |||
| | `depth`       | The number of convolutional layers. Recommended value is `4`. ~~int~~                                                                                                                                          | | ||||
| | **CREATES**   | The model using the architecture. ~~Model[Floats2d, Floats2d]~~                                                                                                                                                | | ||||
| 
 | ||||
| ### spacy.TransitionBasedParser.v1 {#TransitionBasedParser_v1} | ||||
| 
 | ||||
| Identical to [`spacy.TransitionBasedParser.v2`](/api/architectures#TransitionBasedParser) | ||||
| except the `use_upper` was set to `True` by default. | ||||
| 
 | ||||
| ### spacy.TextCatEnsemble.v1 {#TextCatEnsemble_v1} | ||||
| 
 | ||||
| The `spacy.TextCatEnsemble.v1` architecture built an internal `tok2vec` and | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user