MCPcopy Index your code

hub / github.com/explosion/spacy-transformers / functions

Functions214 in github.com/explosion/spacy-transformers

↓ 30 callersMethodinitialize
Initialize the pipe for training, using data examples if available. get_examples (Callable[[], Iterable[Example]]): Optional function that
spacy_transformers/pipeline_component.py:335
↓ 26 callersMethodpredict
Apply the pipeline's model to a batch of docs, without modifying them. Returns the extracted features as the FullTransformerBatch dataclass.
spacy_transformers/pipeline_component.py:216
↓ 19 callersMethodupdate
Prepare for an update to the transformer. Like the `Tok2Vec` component, the `Transformer` component is unusual in that it does not re
spacy_transformers/pipeline_component.py:250
↓ 18 callersMethodfrom_dict
(self, msg: Dict[str, Any])
spacy_transformers/data_classes.py:130
↓ 18 callersFunctionmake_tempdir
Execute a block in a temporary directory and remove the directory and its contents at the end of the with block. YIELDS (Path): The path of t
spacy_transformers/util.py:148
↓ 18 callersMethodto_disk
Serialize the pipe to disk. path (str / Path): Path to a directory. exclude (Iterable[str]): String names of serialization fields to
spacy_transformers/pipeline_component.py:358
↓ 17 callersFunctionnlp
()
spacy_transformers/tests/test_model_wrapper.py:17
↓ 15 callersMethodto_bytes
(self)
spacy_transformers/layers/hf_shim.py:50
↓ 15 callersMethodzeros
(cls, lengths: List[int], xp=numpy)
spacy_transformers/data_classes.py:84
↓ 11 callersMethodfrom_bytes
(self, bytes_data)
spacy_transformers/layers/hf_shim.py:86
↓ 9 callersFunction_assert_equal_tensors
(tensors1, tensors2)
spacy_transformers/tests/util.py:16
↓ 9 callersMethodempty
(cls, *, xp=numpy)
spacy_transformers/data_classes.py:74
↓ 9 callersMethodpipe
Apply the pipe to a stream of documents. This usually happens under the hood when the nlp object is called on a text and all components are
spacy_transformers/pipeline_component.py:197
↓ 5 callersFunction_assert_empty
(trf_data)
spacy_transformers/tests/test_pipeline_component.py:330
↓ 5 callersMethodfrom_disk
Load the pipe from disk. path (str / Path): Path to a directory. exclude (Iterable[str]): String names of serialization fields to exc
spacy_transformers/pipeline_component.py:374
↓ 5 callersFunctionlog_gpu_memory
(logger, context)
spacy_transformers/util.py:131
↓ 5 callersMethodto_dict
(self)
spacy_transformers/data_classes.py:121
↓ 4 callersMethod_get_shim
(self)
spacy_transformers/layers/transformer_model.py:70
↓ 4 callersMethodfrom_batch_encoding
(cls, token_data: BatchEncoding)
spacy_transformers/data_classes.py:94
↓ 4 callersFunctionget_spans
(word_seqs)
spacy_transformers/tests/test_alignment.py:17
↓ 4 callersFunctionhuggingface_tokenize
Apply a Huggingface tokenizer to a batch of texts.
spacy_transformers/layers/transformer_model.py:288
↓ 4 callersMethodset_annotations
Assign the extracted features to the Doc objects. By default, the TransformerData object is written to the doc._.trf_data attribute. Your
spacy_transformers/pipeline_component.py:233
↓ 4 callersFunctionsplit_trf_batch
()
spacy_transformers/layers/split_trf.py:6
↓ 4 callersFunctiontrfs2arrays
Pool transformer data into token-aligned tensors.
spacy_transformers/layers/trfs2arrays.py:12
↓ 3 callersMethodcopy
Create a copy of the model, its attributes, and its parameters. Any child layers will also be deep-copied. The copy will receive a di
spacy_transformers/layers/transformer_model.py:89
↓ 3 callersFunctionfilter_array
(data: ArrayT)
spacy_transformers/truncate.py:71
↓ 3 callersFunctioninstall_extensions
()
spacy_transformers/pipeline_component.py:83
↓ 3 callersFunctionsimple_nlp
()
spacy_transformers/tests/test_pipeline_component.py:43
↓ 2 callersFunctionHFWrapper
Wrap a PyTorch HF model, so that it has the same API as Thinc models. To optimize the model, you'll need to create a PyTorch optimizer and call
spacy_transformers/layers/hf_wrapper.py:14
↓ 2 callersFunction_truncate_alignment
(align: Ragged, mask: numpy.ndarray)
spacy_transformers/truncate.py:88
↓ 2 callersFunction_truncate_tokens
(wordpieces: WordpieceBatch, mask: numpy.ndarray)
spacy_transformers/truncate.py:59
↓ 2 callersMethodconvert_ids_to_tokens
(self, ids: Union[List[int], torch.Tensor])
spacy_transformers/tests/util.py:88
↓ 2 callersMethodget_batch_id
(cls, inputs: List[Doc])
spacy_transformers/layers/listener.py:27
↓ 2 callersFunctionget_sent_spans
(docs: Iterable[Doc])
spacy_transformers/span_getters.py:41
↓ 2 callersFunctionhuggingface_from_pretrained
Create a Huggingface transformer model from pretrained weights. Will download the model if it is not already downloaded. source (Union[str, P
spacy_transformers/util.py:23
↓ 2 callersFunctionhuggingface_from_pretrained
Create a Huggingface transformer model from pretrained weights. Will download the model if it is not already downloaded. source (Union[str, P
spacy_transformers/layers/transformer_model.py:253
↓ 2 callersMethodreceive
(self, batch_id, outputs, backprop)
spacy_transformers/layers/listener.py:30
↓ 2 callersMethodto_hf_dict
Return a dict similar to the format produced by the Huggingface tokenizer, converting arrays to pytorch tensors as well.
spacy_transformers/data_classes.py:60
↓ 2 callersFunctiontruncate_oversize_splits
Drop wordpieces from inputs that are too long. This can happen because the splitter is based on linguistic tokens, and the number of wordpieces
spacy_transformers/truncate.py:9
↓ 2 callersMethodunsplit_by_doc
Return a new FullTransformerBatch from a split batch of activations, using the current object's spans, wordpieces and alignment. This
spacy_transformers/data_classes.py:307
↓ 2 callersMethodverify_inputs
(self, inputs)
spacy_transformers/layers/listener.py:49
↓ 1 callersFunctionDummyTransformer
Create a test model that produces a FullTransformerBatch object.
spacy_transformers/tests/util.py:143
↓ 1 callersFunctionDummyTransformerModel
(width: int, depth: int)
spacy_transformers/tests/util.py:128
↓ 1 callersMethod_encode_words
(self, words)
spacy_transformers/tests/util.py:118
↓ 1 callersFunction_get_truncation_mask_drop_from_end
Return a two-dimensional boolean mask, indicating whether wordpieces are dropped from their sequences. Drop wordpieces from the end of the se
spacy_transformers/truncate.py:46
↓ 1 callersFunction_is_safetensors
Check whether bytes are in safetensors format (vs torch pickle).
spacy_transformers/layers/hf_shim.py:145
↓ 1 callersMethod_pad
(self, batch)
spacy_transformers/tests/util.py:91
↓ 1 callersMethod_tokenize
(self, text)
spacy_transformers/tests/util.py:102
↓ 1 callersMethodadd_listener
Add a listener for a downstream component. Usually internals.
spacy_transformers/pipeline_component.py:142
↓ 1 callersFunctionbatch_by_length
Given a list of sequences, return a batched list of indices into the list, where the batches are grouped by length, in descending order. Batc
spacy_transformers/util.py:98
↓ 1 callersMethodbuild_options
(self)
setup.py:28
↓ 1 callersFunctionconcat_pooling_forward
( pooling: Model[Ragged, Floats2d], X: List[Ragged], is_train: bool )
spacy_transformers/layers/trfs2arrays.py:128
↓ 1 callersFunctionconfigure_custom_sent_spans
(max_length: int)
spacy_transformers/tests/test_spanners.py:35
↓ 1 callersFunctionconfigure_get_sent_spans
Create a `span_getter` that uses sentence boundary markers to extract the spans. This requires sentence boundaries to be set, and may result
spacy_transformers/span_getters.py:46
↓ 1 callersFunctionconfigure_strided_spans
Set the 'window' and 'stride' options for getting strided spans. If you set the window and stride to the same value, the spans will cover
spacy_transformers/span_getters.py:29
↓ 1 callersMethodfind_listeners
Walk over a model of a processing component, looking for layers that are TransformerListener subclasses that have an upstream_name that
spacy_transformers/pipeline_component.py:163
↓ 1 callersFunctionflatten_strings
(words1, words2)
spacy_transformers/tests/test_alignment.py:23
↓ 1 callersMethodfrom_dict
(self, msg: Dict[str, Any])
spacy_transformers/data_classes.py:215
↓ 1 callersFunctionget_ragged
(ops, nested: List[List[int]])
spacy_transformers/tests/test_alignment.py:12
↓ 1 callersFunctionhuggingface_tokenize
Apply a Huggingface tokenizer to a batch of texts.
spacy_transformers/util.py:49
↓ 1 callersFunctionlog_batch_size
(logger, token_data, is_train)
spacy_transformers/util.py:136
↓ 1 callersFunctionmaybe_flush_pytorch_cache
Flip a coin and decide whether to flush PyTorch's cache. This allows the cache to be flushed periodically without maintaining a counter. I'm
spacy_transformers/util.py:77
↓ 1 callersFunctionsetup_package
()
setup.py:45
↓ 1 callersMethodsplit_by_doc
Split a TransformerData that represents a batch into a list with one TransformerData per Doc.
spacy_transformers/data_classes.py:326
↓ 1 callersMethodto_dict
(self)
spacy_transformers/data_classes.py:208
↓ 1 callersFunctiontranspose_list
(nested_list)
spacy_transformers/util.py:88
Method__call__
Apply the pipe to one document. The document is modified in place, and returned. This usually happens under the hood when the nlp object
spacy_transformers/pipeline_component.py:182
Method__call__
( self, texts, add_special_tokens=True, max_length=None, stride: int =
spacy_transformers/tests/util.py:44
Method__getitem__
(self, index)
spacy_transformers/data_classes.py:45
Method__init__
Initialize the transformer component.
spacy_transformers/pipeline_component.py:108
Method__init__
(self, upstream_name: str)
spacy_transformers/layers/listener.py:19
Method__init__
get_spans (Callable[[List[Doc]], List[Span]]): A function to extract spans from the batch of Doc objects. This is use
spacy_transformers/layers/transformer_model.py:26
Method__init__
( self, model: HFObjects, config=None, optimizer: Any = None, mixed_pr
spacy_transformers/layers/hf_shim.py:21
Method__init__
( self, name: str, get_spans: Callable, tokenizer_config: dict
spacy_transformers/tests/test_model_sequence_classification.py:29
Method__init__
(self)
spacy_transformers/tests/util.py:32
Method__len__
(self)
spacy_transformers/data_classes.py:42
Function_convert_transformer_inputs
(model, wps: WordpieceBatch, is_train)
spacy_transformers/layers/transformer_model.py:228
Function_convert_transformer_outputs
(model, inputs_outputs, is_train)
spacy_transformers/layers/transformer_model.py:241
Function_empty_backprop
(dX)
spacy_transformers/layers/listener.py:86
Function_forward
(model, tokens, is_train)
spacy_transformers/tests/util.py:129
Method_init_tokenizer_config
(self)
spacy_transformers/layers/transformer_model.py:82
Method_init_tokenizer_config
(self)
spacy_transformers/tests/test_model_sequence_classification.py:71
Method_init_transformer_config
(self)
spacy_transformers/layers/transformer_model.py:86
Method_init_transformer_config
(self)
spacy_transformers/tests/test_model_sequence_classification.py:75
Methodaccumulate_gradient
Accumulate tok2vec loss and gradient. This is passed as a callback to all but the last listener. Only the last one does the backprop.
spacy_transformers/pipeline_component.py:297
Functionalign
(sequences)
spacy_transformers/tests/test_truncation.py:51
Methodall_special_tokens
(self)
spacy_transformers/tests/util.py:41
Functionbackprop
(dY)
spacy_transformers/layers/trfs2arrays.py:145
Functionbackprop
(d_trf_datas)
spacy_transformers/layers/split_trf.py:11
Functionbackprop
(d_model_output: ModelOutput)
spacy_transformers/layers/transformer_model.py:244
Methodbackprop
Callback to actually do the backprop. Passed to last listener.
spacy_transformers/pipeline_component.py:311
Methodbackprop_and_clear
Call the stored _backprop callback, and then clears it. This saves memory, as otherwise we hold onto that callback until the next batc
spacy_transformers/layers/listener.py:35
Functionbackprop_transformer
(d_output: FullTransformerBatch)
spacy_transformers/layers/transformer_model.py:217
Functionbackprop_trf_to_tensor
(d_outputs: List[Floats2d])
spacy_transformers/layers/trfs2arrays.py:83
Methodbuild_extensions
(self)
setup.py:40
Functioncomponent
(vocab)
spacy_transformers/tests/test_pipeline_component.py:38
Functionconfigure_get_doc_spans
Create a `span_getter` that uses the whole document as its spans. This is the best approach if your `Doc` objects already refer to relatively
spacy_transformers/span_getters.py:61
Functionconfigure_null_annotation_setter
()
spacy_transformers/annotation_setters.py:14
Methodcopy
Create a copy of the model, its attributes, and its parameters. Any child layers will also be deep-copied. The copy will rece
spacy_transformers/tests/test_model_sequence_classification.py:78
Functioncreate_TransformerModel_v1
( name: str, get_spans: Callable, tokenizer_config: dict = {}, )
spacy_transformers/architectures.py:180
next →1–100 of 214, ranked by callers