Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Index your code
hub
/
github.com/explosion/spacy-transformers
/ functions
Functions
214 in github.com/explosion/spacy-transformers
⨍
Functions
214
◇
Types & classes
13
↳
Endpoints
3
↓ 30 callers
Method
initialize
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 callers
Method
predict
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 callers
Method
update
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 callers
Method
from_dict
(self, msg: Dict[str, Any])
spacy_transformers/data_classes.py:130
↓ 18 callers
Function
make_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 callers
Method
to_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 callers
Function
nlp
()
spacy_transformers/tests/test_model_wrapper.py:17
↓ 15 callers
Method
to_bytes
(self)
spacy_transformers/layers/hf_shim.py:50
↓ 15 callers
Method
zeros
(cls, lengths: List[int], xp=numpy)
spacy_transformers/data_classes.py:84
↓ 11 callers
Method
from_bytes
(self, bytes_data)
spacy_transformers/layers/hf_shim.py:86
↓ 9 callers
Function
_assert_equal_tensors
(tensors1, tensors2)
spacy_transformers/tests/util.py:16
↓ 9 callers
Method
empty
(cls, *, xp=numpy)
spacy_transformers/data_classes.py:74
↓ 9 callers
Method
pipe
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 callers
Function
_assert_empty
(trf_data)
spacy_transformers/tests/test_pipeline_component.py:330
↓ 5 callers
Method
from_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 callers
Function
log_gpu_memory
(logger, context)
spacy_transformers/util.py:131
↓ 5 callers
Method
to_dict
(self)
spacy_transformers/data_classes.py:121
↓ 4 callers
Method
_get_shim
(self)
spacy_transformers/layers/transformer_model.py:70
↓ 4 callers
Method
from_batch_encoding
(cls, token_data: BatchEncoding)
spacy_transformers/data_classes.py:94
↓ 4 callers
Function
get_spans
(word_seqs)
spacy_transformers/tests/test_alignment.py:17
↓ 4 callers
Function
huggingface_tokenize
Apply a Huggingface tokenizer to a batch of texts.
spacy_transformers/layers/transformer_model.py:288
↓ 4 callers
Method
set_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 callers
Function
split_trf_batch
()
spacy_transformers/layers/split_trf.py:6
↓ 4 callers
Function
trfs2arrays
Pool transformer data into token-aligned tensors.
spacy_transformers/layers/trfs2arrays.py:12
↓ 3 callers
Method
copy
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 callers
Function
filter_array
(data: ArrayT)
spacy_transformers/truncate.py:71
↓ 3 callers
Function
install_extensions
()
spacy_transformers/pipeline_component.py:83
↓ 3 callers
Function
simple_nlp
()
spacy_transformers/tests/test_pipeline_component.py:43
↓ 2 callers
Function
HFWrapper
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 callers
Function
_truncate_alignment
(align: Ragged, mask: numpy.ndarray)
spacy_transformers/truncate.py:88
↓ 2 callers
Function
_truncate_tokens
(wordpieces: WordpieceBatch, mask: numpy.ndarray)
spacy_transformers/truncate.py:59
↓ 2 callers
Method
convert_ids_to_tokens
(self, ids: Union[List[int], torch.Tensor])
spacy_transformers/tests/util.py:88
↓ 2 callers
Method
get_batch_id
(cls, inputs: List[Doc])
spacy_transformers/layers/listener.py:27
↓ 2 callers
Function
get_sent_spans
(docs: Iterable[Doc])
spacy_transformers/span_getters.py:41
↓ 2 callers
Function
huggingface_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 callers
Function
huggingface_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 callers
Method
receive
(self, batch_id, outputs, backprop)
spacy_transformers/layers/listener.py:30
↓ 2 callers
Method
to_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 callers
Function
truncate_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 callers
Method
unsplit_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 callers
Method
verify_inputs
(self, inputs)
spacy_transformers/layers/listener.py:49
↓ 1 callers
Function
DummyTransformer
Create a test model that produces a FullTransformerBatch object.
spacy_transformers/tests/util.py:143
↓ 1 callers
Function
DummyTransformerModel
(width: int, depth: int)
spacy_transformers/tests/util.py:128
↓ 1 callers
Method
_encode_words
(self, words)
spacy_transformers/tests/util.py:118
↓ 1 callers
Function
_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 callers
Function
_is_safetensors
Check whether bytes are in safetensors format (vs torch pickle).
spacy_transformers/layers/hf_shim.py:145
↓ 1 callers
Method
_pad
(self, batch)
spacy_transformers/tests/util.py:91
↓ 1 callers
Method
_tokenize
(self, text)
spacy_transformers/tests/util.py:102
↓ 1 callers
Method
add_listener
Add a listener for a downstream component. Usually internals.
spacy_transformers/pipeline_component.py:142
↓ 1 callers
Function
batch_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 callers
Method
build_options
(self)
setup.py:28
↓ 1 callers
Function
concat_pooling_forward
( pooling: Model[Ragged, Floats2d], X: List[Ragged], is_train: bool )
spacy_transformers/layers/trfs2arrays.py:128
↓ 1 callers
Function
configure_custom_sent_spans
(max_length: int)
spacy_transformers/tests/test_spanners.py:35
↓ 1 callers
Function
configure_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 callers
Function
configure_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 callers
Method
find_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 callers
Function
flatten_strings
(words1, words2)
spacy_transformers/tests/test_alignment.py:23
↓ 1 callers
Method
from_dict
(self, msg: Dict[str, Any])
spacy_transformers/data_classes.py:215
↓ 1 callers
Function
get_ragged
(ops, nested: List[List[int]])
spacy_transformers/tests/test_alignment.py:12
↓ 1 callers
Function
huggingface_tokenize
Apply a Huggingface tokenizer to a batch of texts.
spacy_transformers/util.py:49
↓ 1 callers
Function
log_batch_size
(logger, token_data, is_train)
spacy_transformers/util.py:136
↓ 1 callers
Function
maybe_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 callers
Function
setup_package
()
setup.py:45
↓ 1 callers
Method
split_by_doc
Split a TransformerData that represents a batch into a list with one TransformerData per Doc.
spacy_transformers/data_classes.py:326
↓ 1 callers
Method
to_dict
(self)
spacy_transformers/data_classes.py:208
↓ 1 callers
Function
transpose_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
Method
accumulate_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
Function
align
(sequences)
spacy_transformers/tests/test_truncation.py:51
Method
all_special_tokens
(self)
spacy_transformers/tests/util.py:41
Function
backprop
(dY)
spacy_transformers/layers/trfs2arrays.py:145
Function
backprop
(d_trf_datas)
spacy_transformers/layers/split_trf.py:11
Function
backprop
(d_model_output: ModelOutput)
spacy_transformers/layers/transformer_model.py:244
Method
backprop
Callback to actually do the backprop. Passed to last listener.
spacy_transformers/pipeline_component.py:311
Method
backprop_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
Function
backprop_transformer
(d_output: FullTransformerBatch)
spacy_transformers/layers/transformer_model.py:217
Function
backprop_trf_to_tensor
(d_outputs: List[Floats2d])
spacy_transformers/layers/trfs2arrays.py:83
Method
build_extensions
(self)
setup.py:40
Function
component
(vocab)
spacy_transformers/tests/test_pipeline_component.py:38
Function
configure_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
Function
configure_null_annotation_setter
()
spacy_transformers/annotation_setters.py:14
Method
copy
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
Function
create_TransformerModel_v1
( name: str, get_spans: Callable, tokenizer_config: dict = {}, )
spacy_transformers/architectures.py:180
next →
1–100 of 214, ranked by callers