Files
INTUIA/Programa final/spacy/ml/models/__pycache__/parser.cpython-312.pyc
T

74 lines
8.6 KiB
Plaintext
Raw Normal View History

2026-03-15 13:27:50 +00:00
Ë
>û g ãó"ddlmZmZmZddlmZmZmZmZm Z m
Z
ddl m Z ddl
mZddlmZddlmZddlmZd d
lmZd d lmZej2d « ddeeeee fdeddededededeedefd«ZdZdZdZdZ dZ!y
)é)ÚListÚOptionalÚcast)ÚLinearÚModelÚchainÚ
list2arrayÚuse_opsÚ zero_init)ÚFloats2dé)ÚLiteral)ÚErrors)ÚDoc)Úregistryé©ÚPrecomputableAffine)ÚTransitionModelzspacy.TransitionBasedParser.v2NÚtok2vecÚ
state_type)ÚparserÚnerÚextra_state_tokensÚ hidden_widthÚ
maxout_piecesÚ use_upperÚnOÚreturncóø|dk(r|rdnd}n5|dk(r|rdnd}n)ttjj|¬««|j d«r|j d«nd }t
|t«t||««}|jd|«t|r|n|||j d«|¬
«} d }
|r!td «5t|d ¬ «}
d d d «t|| |
t«S#1swYŒxYw)
a
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:
https://explosion.ai/blog/parsing-english-in-python
The neural network state prediction model consists of either two or three
subnetworks:
* tok2vec: Map each token into a vector representations. This subnetwork
is run once for each batch.
* lower: Construct a feature-specific vector for each (token, feature) pair.
This is also run once for each batch. Constructing the state
representation is then simply a matter of summing the component features
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
used as action scores directly.
tok2vec (Model[List[Doc], List[Floats2d]]):
Subnetwork to map tokens into vector representations.
state_type (str):
String value denoting the type of parser model: "parser" or "ner"
extra_state_tokens (bool): Whether or not to use additional tokens in the context
to construct the state vector. Defaults to `False`, which means 3 and 8
for the NER and parser respectively. When set to `True`, this would become 6
feature sets (for the NER) or 13 (for the parser).
hidden_width (int): The width of the hidden layer.
maxout_pieces (int): How many pieces to use in the state prediction layer.
Recommended values are 1, 2 or 3. If 1, the maxout non-linearity
is replaced with a ReLu non-linearity if use_upper=True, and no
non-linearity if use_upper=False.
use_upper (bool): Whether to use an additional hidden layer after the state
vector in order to predict the action scores. It is recommended to set
this to False for large pretrained models such as transformers, and True
for smaller networks. The upper layer is computed on CPU, which becomes
a bottleneck on larger GPU-based models, where it's also less necessary.
nO (int or None): The number of actions the model will predict between.
Usually inferred from data at the beginning of training, or loaded from
disk.
ré
érér
)ÚvaluerrÚnFÚnIÚnPÚcpu©rr')Ú
ValueErrorrÚE917ÚformatÚhas_dimÚget_dimrr rÚset_dimÚ
_define_lowerr
Ú
_define_upperrÚ
resize_output) rrrrrrrÚnr_feature_tokensÚ t2v_widthÚlowerÚuppers úWC:\Users\garci\AppData\Roaming\Python\Python312\site-packages\spacy/ml/models/parser.pyÚbuild_tb_parser_modelr9ðjÙ"4™B¸Ø Ù!3™A¸Ñ䜟×+°*Ð>Ø)0¯©¸Ô)> Ô%ÀD€IÜØÜ Üˆ|˜YÓ€Gð
 ‡OOD˜ Ù$‰<¨"Ø Ø ?‰?˜ Ø ô 
€Eð
€EÙÜ
U! R¨DÔ1ˆô ˜7 E¨5´-Ó ˆ^ús ÃC0Ã0C9có&t||t¬«S)N)rr'Úinit_W)rr r*s r8r2r2^sÜ R˜B¤yÔ có t||||¬«S)Nr%rr%s r8r1r1bsÜ  °°rÔ :r<cóP|jdr t||«St||«S)NÚ has_upper)ÚattrsÚ
_resize_upperÚ
_resize_lower)ÚmodelÚnew_nOs r8r3r3fs(Ø ‡{{ܘU FÓ ˜ Ó 'r<có4|jd«}|jd«|jd|«|S||jd«k(r|S|}|j d«}t d«5t
||¬«}ddd«|jd«jj||«}|jj|«}|jd«}|jd«} |jd«rJ|jd«}
||d|
| |d|