spacy_transformers/layers/transformer_model.py
def TransformerModel(
    name: str, get_spans: Callable, tokenizer_config: dict = {}, transformer_config: dict = {}
) -> Model[List[Doc], FullTransformerBatch]:
    """
    get_spans (Callable[[List[Doc]], List[Span]]):
        A function to extract spans from the batch of Doc objects.
        This is used to manage long documents, by cutting them into smaller
        sequences before running the transformer. The spans are allowed to
        overlap, and you can also omit sections of the Doc if they are not
        relevant.
    tokenizer_config (dict): Settings to pass to the transformers tokenizer.
    transformer_config (dict): Settings to pass to the transformers forward pass.
    """

    return Model(
        "transformer",
        forward,
        init=init,
        layers=[],
        dims={"nO": None},
        attrs={
            "tokenizer": None,
            "get_spans": get_spans,
            "name": name,
            "tokenizer_config": tokenizer_config,
            "transformer_config": transformer_config,
            "set_transformer": set_pytorch_transformer,
            "has_transformer": False,
            "flush_cache_chance": 0.0,
        },
    )

    get_spans (Callable[[List[Doc]], List[Span]]):
        A function to extract spans from the batch of Doc objects.
        This is used to manage long documents, by cutting them into smaller
        sequences before running the transformer. The spans are allowed to
        overlap, and you can also omit sections of the Doc if they are not
        relevant.
    tokenizer_config (dict): Settings to pass to the transformers tokenizer.
    transformer_config (dict): Settings to pass to the transformers forward pass.
    
get_spans (Callable[[List[Doc]], List[Span]]):
A function to extract spans from the batch of Doc objects.
This is used to manage long documents, by cutting them into smaller
sequences before running the transformer. The spans are allowed to
overlap, and you can also omit sections of the Doc if they are not
relevant.
tokenizer_config (dict): Settings to pass to the transformers tokenizer.
transformer_config (dict): Settings to pass to the transformers forward pass.
get_spans ( Callable [[ List [ Doc ]] List [ Span ]] ) : A function to extract spans from the batch of Doc objects . This is used to manage long documents by cutting them into smaller sequences before running the transformer . The spans are allowed to overlap and you can also omit sections of the Doc if they are not relevant . tokenizer_config ( dict ) : Settings to pass to the transformers tokenizer . transformer_config ( dict ) : Settings to pass to the transformers forward pass .
def TransformerModel(
    name: str, get_spans: Callable, tokenizer_config: dict = {}, transformer_config: dict = {}
) -> Model[List[Doc], FullTransformerBatch]:
    return Model(
        "transformer",
        forward,
        init=init,
        layers=[],
        dims={"nO": None},
        attrs={
            "tokenizer": None,
            "get_spans": get_spans,
            "name": name,
            "tokenizer_config": tokenizer_config,
            "transformer_config": transformer_config,
            "set_transformer": set_pytorch_transformer,
            "has_transformer": False,
            "flush_cache_chance": 0.0,
        },
    )
def TransformerModel ( name : str , get_spans : Callable , tokenizer_config : dict = { } , transformer_config : dict = { } ) -> Model [ List [ Doc ] , FullTransformerBatch ] : return Model ( "transformer" , forward , init = init , layers = [ ] , dims = { "nO" : None } , attrs = { "tokenizer" : None , "get_spans" : get_spans , "name" : name , "tokenizer_config" : tokenizer_config , "transformer_config" : transformer_config , "set_transformer" : set_pytorch_transformer , "has_transformer" : False , "flush_cache_chance" : 0.0 , } , )
get_spans (Callable[[List[Doc]], List[Span]]):
A function to extract spans from the batch of Doc objects.
get_spans ( Callable [[ List [ Doc ]] List [ Span ]] ) : A function to extract spans from the batch of Doc objects .
"""
    get_spans (Callable[[List[Doc]], List[Span]]):
        A function to extract spans from the batch of Doc objects.
        This is used to manage long documents, by cutting them into smaller
        sequences before running the transformer. The spans are allowed to
        overlap, and you can also omit sections of the Doc if they are not
        relevant.
    tokenizer_config (dict): Settings to pass to the transformers tokenizer.
    transformer_config (dict): Settings to pass to the transformers forward pass.
    """
name
str
get_spans
Callable
tokenizer_config
dict
transformer_config
dict