gt4sd.algorithms.generation.hugging_face.core module¶
HuggingFace generation algorithm.
Summary¶
Classes:
Configuration to generate text using CTRL. |
|
Basic configuration for an hugging face algorithm. |
|
Configuration to generate text using GPT2. |
|
Configuration to generate text using OpenAIGPT. |
|
Configuration to generate text using Seq2Seq LMs. |
|
Configuration to generate text using TransfoXL. |
|
Configuration to generate text using XLM. |
|
Configuration to generate text using XLNet. |
Reference¶
- class HuggingFaceGenerationAlgorithm(configuration, target=None)[source]¶
Bases:
GeneratorAlgorithm
[S
,None
]- __init__(configuration, target=None)[source]¶
HuggingFace generation algorithm.
- Parameters
configuration (
AlgorithmConfiguration
) – domain and application specification, defining types and validations.target (
None
) – unused since it is not a conditional generator.
Example
An example for using a generative algorithm from HuggingFace:
configuration = HuggingFaceXLMGenerator() algorithm = HuggingFaceGenerationAlgorithm(configuration=configuration) items = list(algorithm.sample(1)) print(items)
- get_generator(configuration, target)[source]¶
Get the function to sample batches.
- Parameters
configuration (
AlgorithmConfiguration
[~S,None
]) – helps to set up the application.target (
None
) – context or condition for the generation. Unused in the algorithm.
- Return type
Callable
[[],Iterable
[Any
]]- Returns
callable generating a batch of items.
- validate_configuration(configuration)[source]¶
Overload to validate the a configuration for the algorithm.
- Parameters
configuration (
AlgorithmConfiguration
) – the algorithm configuration.- Raises
InvalidAlgorithmConfiguration – in case the configuration for the algorithm is invalid.
- Return type
- Returns
the validated configuration.
- __abstractmethods__ = frozenset({})¶
- __annotations__ = {'generate': 'Untargeted', 'generator': 'Union[Untargeted, Targeted[T]]', 'max_runtime': 'int', 'max_samples': 'int', 'target': 'Optional[T]'}¶
- __doc__ = None¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __orig_bases__ = (gt4sd.algorithms.core.GeneratorAlgorithm[~S, NoneType],)¶
- __parameters__ = (~S,)¶
- _abc_impl = <_abc._abc_data object>¶
- class HuggingFaceConfiguration(*args, **kwargs)[source]¶
Bases:
HuggingFaceConfiguration
,Generic
[T
]Basic configuration for an hugging face algorithm.
- algorithm_type: ClassVar[str] = 'generation'¶
General type of generative algorithm.
- domain: ClassVar[str] = 'nlp'¶
General application domain. Hints at input/output types.
- model_type: str = ''¶
- prompt: str = "I'm a stochastic parrot."¶
- length: int = 20¶
- stop_token: str = ''¶
- num_beams: int = 1¶
- do_sample: bool = True¶
- temperature: float = 1.0¶
- repetition_penalty: float = 1.0¶
- k: int = 50¶
- p: float = 1.0¶
- prefix: str = ''¶
- number_of_sequences: int = 8¶
- get_target_description()[source]¶
Get description of the target for generation.
- Return type
Optional
[Dict
[str
,str
],None
]- Returns
target description, returns None in case no target is used.
- __annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': typing.ClassVar[str], 'algorithm_version': 'str', 'do_sample': <class 'bool'>, 'domain': typing.ClassVar[str], 'k': <class 'int'>, 'length': <class 'int'>, 'model_type': <class 'str'>, 'num_beams': <class 'int'>, 'number_of_sequences': <class 'int'>, 'p': <class 'float'>, 'prefix': <class 'str'>, 'prompt': <class 'str'>, 'repetition_penalty': <class 'float'>, 'stop_token': <class 'str'>, 'temperature': <class 'float'>}¶
- __dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='HuggingFaceConfiguration',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='HuggingFaceGenerationAlgorithm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type='str',default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'do_sample': Field(name='do_sample',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Whether or not to use sampling; use greedy decoding otherwise.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='nlp',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'k': Field(name='k',type=<class 'int'>,default=50,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of top-k probability tokens to keep.'}),kw_only=False,_field_type=_FIELD), 'length': Field(name='length',type=<class 'int'>,default=20,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Length of the generated text.'}),kw_only=False,_field_type=_FIELD), 'model_type': Field(name='model_type',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Type of the model. Supported: gpt2, ctrl, openai-gpt, xlnet, transfo-xl, xlm, auto-seq2seq-lm'}),kw_only=False,_field_type=_FIELD), 'num_beams': Field(name='num_beams',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of beams for beam search.'}),kw_only=False,_field_type=_FIELD), 'number_of_sequences': Field(name='number_of_sequences',type=<class 'int'>,default=8,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of text sequences to generate.'}),kw_only=False,_field_type=_FIELD), 'p': Field(name='p',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Only tokens with cumulative probabilities summing up to this value are kept.'}),kw_only=False,_field_type=_FIELD), 'prefix': Field(name='prefix',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Text defining context provided prior to the prompt.'}),kw_only=False,_field_type=_FIELD), 'prompt': Field(name='prompt',type=<class 'str'>,default="I'm a stochastic parrot.",default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Prompt for text generation.'}),kw_only=False,_field_type=_FIELD), 'repetition_penalty': Field(name='repetition_penalty',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Primarily useful for CTRL model, where 1.2 should be used.'}),kw_only=False,_field_type=_FIELD), 'stop_token': Field(name='stop_token',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Stop token for text generation.'}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Temperature for sampling, the lower the greedier the sampling.'}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __doc__ = 'Basic configuration for an hugging face algorithm.'¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __match_args__ = ('algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences')¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __orig_bases__ = (<class 'types.HuggingFaceConfiguration'>, typing.Generic[~T])¶
- __parameters__ = (~T,)¶
- __pydantic_complete__ = True¶
- __pydantic_config__ = {}¶
- __pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceConfiguration'>, 'config': {'title': 'HuggingFaceConfiguration'}, 'fields': ['algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceConfiguration'>, title=None)]}, 'post_init': False, 'ref': 'types.HuggingFaceConfiguration:94662825867168', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'HuggingFaceConfiguration', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'model_type', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prompt', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': "I'm a stochastic parrot."}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 20}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'stop_token', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'num_beams', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 1}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'do_sample', 'schema': {'type': 'default', 'schema': {'type': 'bool'}, 'default': True}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'temperature', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'repetition_penalty', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'k', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 50}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'p', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prefix', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'number_of_sequences', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 8}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}¶
- __pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- __pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='', init=True, init_var=False, kw_only=False), 'do_sample': FieldInfo(annotation=bool, required=False, default=True, description='Whether or not to use sampling; use greedy decoding otherwise.', init=True, init_var=False, kw_only=False), 'k': FieldInfo(annotation=int, required=False, default=50, description='Number of top-k probability tokens to keep.', init=True, init_var=False, kw_only=False), 'length': FieldInfo(annotation=int, required=False, default=20, description='Length of the generated text.', init=True, init_var=False, kw_only=False), 'model_type': FieldInfo(annotation=str, required=False, default='', description='Type of the model. Supported: gpt2, ctrl, openai-gpt, xlnet, transfo-xl, xlm, auto-seq2seq-lm', init=True, init_var=False, kw_only=False), 'num_beams': FieldInfo(annotation=int, required=False, default=1, description='Number of beams for beam search.', init=True, init_var=False, kw_only=False), 'number_of_sequences': FieldInfo(annotation=int, required=False, default=8, description='Number of text sequences to generate.', init=True, init_var=False, kw_only=False), 'p': FieldInfo(annotation=float, required=False, default=1.0, description='Only tokens with cumulative probabilities summing up to this value are kept.', init=True, init_var=False, kw_only=False), 'prefix': FieldInfo(annotation=str, required=False, default='', description='Text defining context provided prior to the prompt.', init=True, init_var=False, kw_only=False), 'prompt': FieldInfo(annotation=str, required=False, default="I'm a stochastic parrot.", description='Prompt for text generation.', init=True, init_var=False, kw_only=False), 'repetition_penalty': FieldInfo(annotation=float, required=False, default=1.0, description='Primarily useful for CTRL model, where 1.2 should be used.', init=True, init_var=False, kw_only=False), 'stop_token': FieldInfo(annotation=str, required=False, default='', description='Stop token for text generation.', init=True, init_var=False, kw_only=False), 'temperature': FieldInfo(annotation=float, required=False, default=1.0, description='Temperature for sampling, the lower the greedier the sampling.', init=True, init_var=False, kw_only=False)}¶
- __pydantic_serializer__ = SchemaSerializer(serializer=Dataclass( DataclassSerializer { class: Py( 0x00005618681bf7a0, ), serializer: Fields( GeneralFieldsSerializer { fields: { "prompt": SerField { key_py: Py( 0x00007f1dc5101cf0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9e100, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "num_beams": SerField { key_py: Py( 0x00007f1dc5101db0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94680f0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "do_sample": SerField { key_py: Py( 0x00007f1dc5101df0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x000056185a4635a0, ), ), serializer: Bool( BoolSerializer, ), }, ), ), required: true, }, "temperature": SerField { key_py: Py( 0x00007f1dc5101e30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "p": SerField { key_py: Py( 0x00007f1ea9534670, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "k": SerField { key_py: Py( 0x00007f1ea9129030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468710, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "number_of_sequences": SerField { key_py: Py( 0x00007f1dc510f780, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94681d0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "length": SerField { key_py: Py( 0x00007f1dc5101d30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468350, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "prefix": SerField { key_py: Py( 0x00007f1dc5101e70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "algorithm_version": SerField { key_py: Py( 0x00007f1dc510f6e0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "model_type": SerField { key_py: Py( 0x00007f1dc5101cb0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "stop_token": SerField { key_py: Py( 0x00007f1dc5101d70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "repetition_penalty": SerField { key_py: Py( 0x00007f1dc510f730, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 13, }, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], name: "HuggingFaceConfiguration", }, ), definitions=[])¶
- __pydantic_validator__ = SchemaValidator(title="HuggingFaceConfiguration", validator=Dataclass( DataclassValidator { strict: false, validator: DataclassArgs( DataclassArgsValidator { fields: [ Field { kw_only: false, name: "algorithm_version", py_name: Py( 0x00007f1ea52ed250, ), init: true, init_only: false, lookup_key: Simple { key: "algorithm_version", py_key: Py( 0x00007f1dc510f550, ), path: LookupPath( [ S( "algorithm_version", Py( 0x00007f1dc510f5a0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "model_type", py_name: Py( 0x00007f1ea6163a30, ), init: true, init_only: false, lookup_key: Simple { key: "model_type", py_key: Py( 0x00007f1dc51017b0, ), path: LookupPath( [ S( "model_type", Py( 0x00007f1dc5101730, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prompt", py_name: Py( 0x00007f1ea914d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "prompt", py_key: Py( 0x00007f1dc51016b0, ), path: LookupPath( [ S( "prompt", Py( 0x00007f1dc5101630, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9e100, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "length", py_name: Py( 0x00007f1ea8b3f9f0, ), init: true, init_only: false, lookup_key: Simple { key: "length", py_key: Py( 0x00007f1dc5101830, ), path: LookupPath( [ S( "length", Py( 0x00007f1dc51018b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468350, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "stop_token", py_name: Py( 0x00007f1e981a5670, ), init: true, init_only: false, lookup_key: Simple { key: "stop_token", py_key: Py( 0x00007f1dc5101930, ), path: LookupPath( [ S( "stop_token", Py( 0x00007f1dc51019b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "num_beams", py_name: Py( 0x00007f1de45c9570, ), init: true, init_only: false, lookup_key: Simple { key: "num_beams", py_key: Py( 0x00007f1dc5101a30, ), path: LookupPath( [ S( "num_beams", Py( 0x00007f1dc5101ab0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94680f0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "do_sample", py_name: Py( 0x00007f1de45a75b0, ), init: true, init_only: false, lookup_key: Simple { key: "do_sample", py_key: Py( 0x00007f1dc5101b30, ), path: LookupPath( [ S( "do_sample", Py( 0x00007f1dc5101b70, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x000056185a4635a0, ), ), on_error: Raise, validator: Bool( BoolValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[bool]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "temperature", py_name: Py( 0x00007f1e33d8d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "temperature", py_key: Py( 0x00007f1dc5101bb0, ), path: LookupPath( [ S( "temperature", Py( 0x00007f1dc5101bf0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "repetition_penalty", py_name: Py( 0x00007f1de459fb40, ), init: true, init_only: false, lookup_key: Simple { key: "repetition_penalty", py_key: Py( 0x00007f1dc510f500, ), path: LookupPath( [ S( "repetition_penalty", Py( 0x00007f1dc510f5f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "k", py_name: Py( 0x00007f1ea9129030, ), init: true, init_only: false, lookup_key: Simple { key: "k", py_key: Py( 0x00007f1ea9129030, ), path: LookupPath( [ S( "k", Py( 0x00007f1ea9129030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468710, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "p", py_name: Py( 0x00007f1ea9534670, ), init: true, init_only: false, lookup_key: Simple { key: "p", py_key: Py( 0x00007f1ea9534670, ), path: LookupPath( [ S( "p", Py( 0x00007f1ea9534670, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prefix", py_name: Py( 0x00007f1ea951f5f0, ), init: true, init_only: false, lookup_key: Simple { key: "prefix", py_key: Py( 0x00007f1dc5101c30, ), path: LookupPath( [ S( "prefix", Py( 0x00007f1dc5101c70, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "number_of_sequences", py_name: Py( 0x00007f1dcab9ece0, ), init: true, init_only: false, lookup_key: Simple { key: "number_of_sequences", py_key: Py( 0x00007f1dc510f640, ), path: LookupPath( [ S( "number_of_sequences", Py( 0x00007f1dc510f690, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94681d0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, ], positional_count: 13, init_only_count: None, dataclass_name: "HuggingFaceConfiguration", validator_name: "dataclass-args[HuggingFaceConfiguration]", extra_behavior: Ignore, extras_validator: None, loc_by_alias: true, }, ), class: Py( 0x00005618681bf7a0, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], post_init: None, revalidate: Never, name: "HuggingFaceConfiguration", frozen: false, slots: true, }, ), definitions=[], cache_strings=True)¶
- __repr__()¶
Return repr(self).
- __signature__ = <Signature (algorithm_version: 'str' = '', model_type: str = '', prompt: str = "I'm a stochastic parrot.", length: int = 20, stop_token: str = '', num_beams: int = 1, do_sample: bool = True, temperature: float = 1.0, repetition_penalty: float = 1.0, k: int = 50, p: float = 1.0, prefix: str = '', number_of_sequences: int = 8) -> None>¶
- __wrapped__¶
alias of
HuggingFaceConfiguration
- class HuggingFaceXLMGenerator(*args, **kwargs)[source]¶
Bases:
HuggingFaceXLMGenerator
Configuration to generate text using XLM.
- algorithm_version: str = 'xlm-mlm-en-2048'¶
To differentiate between different versions of an application.
There is no imposed naming convention.
- model_type: str = 'xlm'¶
- classmethod list_versions()[source]¶
Get possible algorithm versions.
Standard S3 and cache search adding the version used in the configuration.
- Return type
Set
[str
]- Returns
viable values as
algorithm_version
for the environment.
- __annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': 'ClassVar[str]', 'algorithm_version': <class 'str'>, 'do_sample': 'bool', 'domain': 'ClassVar[str]', 'k': 'int', 'length': 'int', 'model_type': <class 'str'>, 'num_beams': 'int', 'number_of_sequences': 'int', 'p': 'float', 'prefix': 'str', 'prompt': 'str', 'repetition_penalty': 'float', 'stop_token': 'str', 'temperature': 'float'}¶
- __dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='HuggingFaceXLMGenerator',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='HuggingFaceGenerationAlgorithm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type=<class 'str'>,default='xlm-mlm-en-2048',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'do_sample': Field(name='do_sample',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Whether or not to use sampling; use greedy decoding otherwise.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='nlp',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'k': Field(name='k',type=<class 'int'>,default=50,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of top-k probability tokens to keep.'}),kw_only=False,_field_type=_FIELD), 'length': Field(name='length',type=<class 'int'>,default=20,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Length of the generated text.'}),kw_only=False,_field_type=_FIELD), 'model_type': Field(name='model_type',type=<class 'str'>,default='xlm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'num_beams': Field(name='num_beams',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of beams for beam search.'}),kw_only=False,_field_type=_FIELD), 'number_of_sequences': Field(name='number_of_sequences',type=<class 'int'>,default=8,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of text sequences to generate.'}),kw_only=False,_field_type=_FIELD), 'p': Field(name='p',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Only tokens with cumulative probabilities summing up to this value are kept.'}),kw_only=False,_field_type=_FIELD), 'prefix': Field(name='prefix',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Text defining context provided prior to the prompt.'}),kw_only=False,_field_type=_FIELD), 'prompt': Field(name='prompt',type=<class 'str'>,default="I'm a stochastic parrot.",default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Prompt for text generation.'}),kw_only=False,_field_type=_FIELD), 'repetition_penalty': Field(name='repetition_penalty',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Primarily useful for CTRL model, where 1.2 should be used.'}),kw_only=False,_field_type=_FIELD), 'stop_token': Field(name='stop_token',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Stop token for text generation.'}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Temperature for sampling, the lower the greedier the sampling.'}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __doc__ = 'Configuration to generate text using XLM.'¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __match_args__ = ('algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences')¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __parameters__ = (~T,)¶
- __pydantic_complete__ = True¶
- __pydantic_config__ = {}¶
- __pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceXLMGenerator'>, 'config': {'title': 'HuggingFaceXLMGenerator'}, 'fields': ['algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceXLMGenerator'>, title=None)]}, 'post_init': False, 'ref': 'types.HuggingFaceXLMGenerator:94662825888400', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'HuggingFaceXLMGenerator', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'xlm-mlm-en-2048'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'model_type', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'xlm'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prompt', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': "I'm a stochastic parrot."}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 20}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'stop_token', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'num_beams', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 1}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'do_sample', 'schema': {'type': 'default', 'schema': {'type': 'bool'}, 'default': True}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'temperature', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'repetition_penalty', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'k', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 50}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'p', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prefix', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'number_of_sequences', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 8}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}¶
- __pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- __pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='xlm-mlm-en-2048', init=True, init_var=False, kw_only=False), 'do_sample': FieldInfo(annotation=bool, required=False, default=True, description='Whether or not to use sampling; use greedy decoding otherwise.', init=True, init_var=False, kw_only=False), 'k': FieldInfo(annotation=int, required=False, default=50, description='Number of top-k probability tokens to keep.', init=True, init_var=False, kw_only=False), 'length': FieldInfo(annotation=int, required=False, default=20, description='Length of the generated text.', init=True, init_var=False, kw_only=False), 'model_type': FieldInfo(annotation=str, required=False, default='xlm', init=True, init_var=False, kw_only=False), 'num_beams': FieldInfo(annotation=int, required=False, default=1, description='Number of beams for beam search.', init=True, init_var=False, kw_only=False), 'number_of_sequences': FieldInfo(annotation=int, required=False, default=8, description='Number of text sequences to generate.', init=True, init_var=False, kw_only=False), 'p': FieldInfo(annotation=float, required=False, default=1.0, description='Only tokens with cumulative probabilities summing up to this value are kept.', init=True, init_var=False, kw_only=False), 'prefix': FieldInfo(annotation=str, required=False, default='', description='Text defining context provided prior to the prompt.', init=True, init_var=False, kw_only=False), 'prompt': FieldInfo(annotation=str, required=False, default="I'm a stochastic parrot.", description='Prompt for text generation.', init=True, init_var=False, kw_only=False), 'repetition_penalty': FieldInfo(annotation=float, required=False, default=1.0, description='Primarily useful for CTRL model, where 1.2 should be used.', init=True, init_var=False, kw_only=False), 'stop_token': FieldInfo(annotation=str, required=False, default='', description='Stop token for text generation.', init=True, init_var=False, kw_only=False), 'temperature': FieldInfo(annotation=float, required=False, default=1.0, description='Temperature for sampling, the lower the greedier the sampling.', init=True, init_var=False, kw_only=False)}¶
- __pydantic_serializer__ = SchemaSerializer(serializer=Dataclass( DataclassSerializer { class: Py( 0x00005618681c4a90, ), serializer: Fields( GeneralFieldsSerializer { fields: { "do_sample": SerField { key_py: Py( 0x00007f1dc50309b0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x000056185a4635a0, ), ), serializer: Bool( BoolSerializer, ), }, ), ), required: true, }, "prefix": SerField { key_py: Py( 0x00007f1dc5030930, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "algorithm_version": SerField { key_py: Py( 0x00007f1dc5125840, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc5256830, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "model_type": SerField { key_py: Py( 0x00007f1dc5030af0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1de4362df0, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "temperature": SerField { key_py: Py( 0x00007f1dc5030970, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "repetition_penalty": SerField { key_py: Py( 0x00007f1dc51257f0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "p": SerField { key_py: Py( 0x00007f1ea9534670, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "length": SerField { key_py: Py( 0x00007f1dc5030a70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468350, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "stop_token": SerField { key_py: Py( 0x00007f1dc5030a30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "num_beams": SerField { key_py: Py( 0x00007f1dc50309f0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94680f0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "prompt": SerField { key_py: Py( 0x00007f1dc5030ab0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9e100, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "k": SerField { key_py: Py( 0x00007f1ea9129030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468710, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "number_of_sequences": SerField { key_py: Py( 0x00007f1dc51257a0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94681d0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 13, }, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], name: "HuggingFaceXLMGenerator", }, ), definitions=[])¶
- __pydantic_validator__ = SchemaValidator(title="HuggingFaceXLMGenerator", validator=Dataclass( DataclassValidator { strict: false, validator: DataclassArgs( DataclassArgsValidator { fields: [ Field { kw_only: false, name: "algorithm_version", py_name: Py( 0x00007f1ea52ed250, ), init: true, init_only: false, lookup_key: Simple { key: "algorithm_version", py_key: Py( 0x00007f1dc5125f20, ), path: LookupPath( [ S( "algorithm_version", Py( 0x00007f1dc51256b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc5256830, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "model_type", py_name: Py( 0x00007f1ea6163a30, ), init: true, init_only: false, lookup_key: Simple { key: "model_type", py_key: Py( 0x00007f1dc5033bb0, ), path: LookupPath( [ S( "model_type", Py( 0x00007f1dc5033b70, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1de4362df0, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prompt", py_name: Py( 0x00007f1ea914d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "prompt", py_key: Py( 0x00007f1dc5033b30, ), path: LookupPath( [ S( "prompt", Py( 0x00007f1dc5033af0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9e100, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "length", py_name: Py( 0x00007f1ea8b3f9f0, ), init: true, init_only: false, lookup_key: Simple { key: "length", py_key: Py( 0x00007f1dc5033bf0, ), path: LookupPath( [ S( "length", Py( 0x00007f1dc5033c30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468350, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "stop_token", py_name: Py( 0x00007f1e981a5670, ), init: true, init_only: false, lookup_key: Simple { key: "stop_token", py_key: Py( 0x00007f1dc5033c70, ), path: LookupPath( [ S( "stop_token", Py( 0x00007f1dc5033cb0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "num_beams", py_name: Py( 0x00007f1de45c9570, ), init: true, init_only: false, lookup_key: Simple { key: "num_beams", py_key: Py( 0x00007f1dc5033cf0, ), path: LookupPath( [ S( "num_beams", Py( 0x00007f1dc5033d30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94680f0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "do_sample", py_name: Py( 0x00007f1de45a75b0, ), init: true, init_only: false, lookup_key: Simple { key: "do_sample", py_key: Py( 0x00007f1dc5033d70, ), path: LookupPath( [ S( "do_sample", Py( 0x00007f1dc5033db0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x000056185a4635a0, ), ), on_error: Raise, validator: Bool( BoolValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[bool]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "temperature", py_name: Py( 0x00007f1e33d8d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "temperature", py_key: Py( 0x00007f1dc5033df0, ), path: LookupPath( [ S( "temperature", Py( 0x00007f1dc5033e30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "repetition_penalty", py_name: Py( 0x00007f1de459fb40, ), init: true, init_only: false, lookup_key: Simple { key: "repetition_penalty", py_key: Py( 0x00007f1dc5125ed0, ), path: LookupPath( [ S( "repetition_penalty", Py( 0x00007f1dc5125610, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "k", py_name: Py( 0x00007f1ea9129030, ), init: true, init_only: false, lookup_key: Simple { key: "k", py_key: Py( 0x00007f1ea9129030, ), path: LookupPath( [ S( "k", Py( 0x00007f1ea9129030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468710, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "p", py_name: Py( 0x00007f1ea9534670, ), init: true, init_only: false, lookup_key: Simple { key: "p", py_key: Py( 0x00007f1ea9534670, ), path: LookupPath( [ S( "p", Py( 0x00007f1ea9534670, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prefix", py_name: Py( 0x00007f1ea951f5f0, ), init: true, init_only: false, lookup_key: Simple { key: "prefix", py_key: Py( 0x00007f1dc5033e70, ), path: LookupPath( [ S( "prefix", Py( 0x00007f1dc5033eb0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "number_of_sequences", py_name: Py( 0x00007f1dcab9ece0, ), init: true, init_only: false, lookup_key: Simple { key: "number_of_sequences", py_key: Py( 0x00007f1dc5125c50, ), path: LookupPath( [ S( "number_of_sequences", Py( 0x00007f1dc5125ca0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94681d0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, ], positional_count: 13, init_only_count: None, dataclass_name: "HuggingFaceXLMGenerator", validator_name: "dataclass-args[HuggingFaceXLMGenerator]", extra_behavior: Ignore, extras_validator: None, loc_by_alias: true, }, ), class: Py( 0x00005618681c4a90, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], post_init: None, revalidate: Never, name: "HuggingFaceXLMGenerator", frozen: false, slots: true, }, ), definitions=[], cache_strings=True)¶
- __repr__()¶
Return repr(self).
- __signature__ = <Signature (*args: Any, algorithm_version: str = 'xlm-mlm-en-2048', model_type: str = 'xlm', prompt: str = "I'm a stochastic parrot.", length: int = 20, stop_token: str = '', num_beams: int = 1, do_sample: bool = True, temperature: float = 1.0, repetition_penalty: float = 1.0, k: int = 50, p: float = 1.0, prefix: str = '', number_of_sequences: int = 8) -> None>¶
- __wrapped__¶
alias of
HuggingFaceXLMGenerator
- algorithm_application: ClassVar[str] = 'HuggingFaceXLMGenerator'¶
Unique name for the application that is the use of this configuration together with a specific algorithm.
Will be set when registering to
ApplicationsRegistry
, but can be given by direct registration (Seeregister_algorithm_application
)
- algorithm_name: ClassVar[str] = 'HuggingFaceGenerationAlgorithm'¶
Name of the algorithm to use with this configuration.
Will be set when registering to
ApplicationsRegistry
- class HuggingFaceCTRLGenerator(*args, **kwargs)[source]¶
Bases:
HuggingFaceCTRLGenerator
Configuration to generate text using CTRL.
- algorithm_version: str = 'ctrl'¶
To differentiate between different versions of an application.
There is no imposed naming convention.
- model_type: str = 'ctrl'¶
- classmethod list_versions()[source]¶
Get possible algorithm versions.
Standard S3 and cache search adding the version used in the configuration.
- Return type
Set
[str
]- Returns
viable values as
algorithm_version
for the environment.
- __annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': 'ClassVar[str]', 'algorithm_version': <class 'str'>, 'do_sample': 'bool', 'domain': 'ClassVar[str]', 'k': 'int', 'length': 'int', 'model_type': <class 'str'>, 'num_beams': 'int', 'number_of_sequences': 'int', 'p': 'float', 'prefix': 'str', 'prompt': 'str', 'repetition_penalty': 'float', 'stop_token': 'str', 'temperature': 'float'}¶
- __dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='HuggingFaceCTRLGenerator',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='HuggingFaceGenerationAlgorithm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type=<class 'str'>,default='ctrl',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'do_sample': Field(name='do_sample',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Whether or not to use sampling; use greedy decoding otherwise.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='nlp',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'k': Field(name='k',type=<class 'int'>,default=50,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of top-k probability tokens to keep.'}),kw_only=False,_field_type=_FIELD), 'length': Field(name='length',type=<class 'int'>,default=20,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Length of the generated text.'}),kw_only=False,_field_type=_FIELD), 'model_type': Field(name='model_type',type=<class 'str'>,default='ctrl',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'num_beams': Field(name='num_beams',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of beams for beam search.'}),kw_only=False,_field_type=_FIELD), 'number_of_sequences': Field(name='number_of_sequences',type=<class 'int'>,default=8,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of text sequences to generate.'}),kw_only=False,_field_type=_FIELD), 'p': Field(name='p',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Only tokens with cumulative probabilities summing up to this value are kept.'}),kw_only=False,_field_type=_FIELD), 'prefix': Field(name='prefix',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Text defining context provided prior to the prompt.'}),kw_only=False,_field_type=_FIELD), 'prompt': Field(name='prompt',type=<class 'str'>,default="I'm a stochastic parrot.",default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Prompt for text generation.'}),kw_only=False,_field_type=_FIELD), 'repetition_penalty': Field(name='repetition_penalty',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Primarily useful for CTRL model, where 1.2 should be used.'}),kw_only=False,_field_type=_FIELD), 'stop_token': Field(name='stop_token',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Stop token for text generation.'}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Temperature for sampling, the lower the greedier the sampling.'}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __doc__ = 'Configuration to generate text using CTRL.'¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __match_args__ = ('algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences')¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __parameters__ = (~T,)¶
- __pydantic_complete__ = True¶
- __pydantic_config__ = {}¶
- __pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceCTRLGenerator'>, 'config': {'title': 'HuggingFaceCTRLGenerator'}, 'fields': ['algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceCTRLGenerator'>, title=None)]}, 'post_init': False, 'ref': 'types.HuggingFaceCTRLGenerator:94662825995040', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'HuggingFaceCTRLGenerator', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'ctrl'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'model_type', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'ctrl'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prompt', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': "I'm a stochastic parrot."}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 20}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'stop_token', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'num_beams', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 1}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'do_sample', 'schema': {'type': 'default', 'schema': {'type': 'bool'}, 'default': True}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'temperature', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'repetition_penalty', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'k', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 50}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'p', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prefix', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'number_of_sequences', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 8}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}¶
- __pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- __pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='ctrl', init=True, init_var=False, kw_only=False), 'do_sample': FieldInfo(annotation=bool, required=False, default=True, description='Whether or not to use sampling; use greedy decoding otherwise.', init=True, init_var=False, kw_only=False), 'k': FieldInfo(annotation=int, required=False, default=50, description='Number of top-k probability tokens to keep.', init=True, init_var=False, kw_only=False), 'length': FieldInfo(annotation=int, required=False, default=20, description='Length of the generated text.', init=True, init_var=False, kw_only=False), 'model_type': FieldInfo(annotation=str, required=False, default='ctrl', init=True, init_var=False, kw_only=False), 'num_beams': FieldInfo(annotation=int, required=False, default=1, description='Number of beams for beam search.', init=True, init_var=False, kw_only=False), 'number_of_sequences': FieldInfo(annotation=int, required=False, default=8, description='Number of text sequences to generate.', init=True, init_var=False, kw_only=False), 'p': FieldInfo(annotation=float, required=False, default=1.0, description='Only tokens with cumulative probabilities summing up to this value are kept.', init=True, init_var=False, kw_only=False), 'prefix': FieldInfo(annotation=str, required=False, default='', description='Text defining context provided prior to the prompt.', init=True, init_var=False, kw_only=False), 'prompt': FieldInfo(annotation=str, required=False, default="I'm a stochastic parrot.", description='Prompt for text generation.', init=True, init_var=False, kw_only=False), 'repetition_penalty': FieldInfo(annotation=float, required=False, default=1.0, description='Primarily useful for CTRL model, where 1.2 should be used.', init=True, init_var=False, kw_only=False), 'stop_token': FieldInfo(annotation=str, required=False, default='', description='Stop token for text generation.', init=True, init_var=False, kw_only=False), 'temperature': FieldInfo(annotation=float, required=False, default=1.0, description='Temperature for sampling, the lower the greedier the sampling.', init=True, init_var=False, kw_only=False)}¶
- __pydantic_serializer__ = SchemaSerializer(serializer=Dataclass( DataclassSerializer { class: Py( 0x00005618681deb20, ), serializer: Fields( GeneralFieldsSerializer { fields: { "prefix": SerField { key_py: Py( 0x00007f1dc5048f70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "number_of_sequences": SerField { key_py: Py( 0x00007f1dc5127a00, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94681d0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "stop_token": SerField { key_py: Py( 0x00007f1dc5049070, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "p": SerField { key_py: Py( 0x00007f1ea9534670, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "do_sample": SerField { key_py: Py( 0x00007f1dc5048ff0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x000056185a4635a0, ), ), serializer: Bool( BoolSerializer, ), }, ), ), required: true, }, "model_type": SerField { key_py: Py( 0x00007f1dc5049130, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1de93b4130, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "algorithm_version": SerField { key_py: Py( 0x00007f1dc510fc30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1de93b4130, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "length": SerField { key_py: Py( 0x00007f1dc50490b0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468350, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "prompt": SerField { key_py: Py( 0x00007f1dc50490f0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9e100, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "temperature": SerField { key_py: Py( 0x00007f1dc5048fb0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "repetition_penalty": SerField { key_py: Py( 0x00007f1dc5127a50, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "num_beams": SerField { key_py: Py( 0x00007f1dc5049030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94680f0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "k": SerField { key_py: Py( 0x00007f1ea9129030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468710, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 13, }, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], name: "HuggingFaceCTRLGenerator", }, ), definitions=[])¶
- __pydantic_validator__ = SchemaValidator(title="HuggingFaceCTRLGenerator", validator=Dataclass( DataclassValidator { strict: false, validator: DataclassArgs( DataclassArgsValidator { fields: [ Field { kw_only: false, name: "algorithm_version", py_name: Py( 0x00007f1ea52ed250, ), init: true, init_only: false, lookup_key: Simple { key: "algorithm_version", py_key: Py( 0x00007f1dc51277d0, ), path: LookupPath( [ S( "algorithm_version", Py( 0x00007f1dc5125d40, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1de93b4130, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "model_type", py_name: Py( 0x00007f1ea6163a30, ), init: true, init_only: false, lookup_key: Simple { key: "model_type", py_key: Py( 0x00007f1dc504a370, ), path: LookupPath( [ S( "model_type", Py( 0x00007f1dc504a2f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1de93b4130, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prompt", py_name: Py( 0x00007f1ea914d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "prompt", py_key: Py( 0x00007f1dc504a270, ), path: LookupPath( [ S( "prompt", Py( 0x00007f1dc504a1f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9e100, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "length", py_name: Py( 0x00007f1ea8b3f9f0, ), init: true, init_only: false, lookup_key: Simple { key: "length", py_key: Py( 0x00007f1dc504a3f0, ), path: LookupPath( [ S( "length", Py( 0x00007f1dc504a470, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468350, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "stop_token", py_name: Py( 0x00007f1e981a5670, ), init: true, init_only: false, lookup_key: Simple { key: "stop_token", py_key: Py( 0x00007f1dc504a4f0, ), path: LookupPath( [ S( "stop_token", Py( 0x00007f1dc504a5f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "num_beams", py_name: Py( 0x00007f1de45c9570, ), init: true, init_only: false, lookup_key: Simple { key: "num_beams", py_key: Py( 0x00007f1dc504a6f0, ), path: LookupPath( [ S( "num_beams", Py( 0x00007f1dc504af70, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94680f0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "do_sample", py_name: Py( 0x00007f1de45a75b0, ), init: true, init_only: false, lookup_key: Simple { key: "do_sample", py_key: Py( 0x00007f1dc504bd70, ), path: LookupPath( [ S( "do_sample", Py( 0x00007f1dc4eff3b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x000056185a4635a0, ), ), on_error: Raise, validator: Bool( BoolValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[bool]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "temperature", py_name: Py( 0x00007f1e33d8d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "temperature", py_key: Py( 0x00007f1dc4efe270, ), path: LookupPath( [ S( "temperature", Py( 0x00007f1dc4eff530, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "repetition_penalty", py_name: Py( 0x00007f1de459fb40, ), init: true, init_only: false, lookup_key: Simple { key: "repetition_penalty", py_key: Py( 0x00007f1dc5127870, ), path: LookupPath( [ S( "repetition_penalty", Py( 0x00007f1dc5127f00, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "k", py_name: Py( 0x00007f1ea9129030, ), init: true, init_only: false, lookup_key: Simple { key: "k", py_key: Py( 0x00007f1ea9129030, ), path: LookupPath( [ S( "k", Py( 0x00007f1ea9129030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468710, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "p", py_name: Py( 0x00007f1ea9534670, ), init: true, init_only: false, lookup_key: Simple { key: "p", py_key: Py( 0x00007f1ea9534670, ), path: LookupPath( [ S( "p", Py( 0x00007f1ea9534670, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prefix", py_name: Py( 0x00007f1ea951f5f0, ), init: true, init_only: false, lookup_key: Simple { key: "prefix", py_key: Py( 0x00007f1dc4efc070, ), path: LookupPath( [ S( "prefix", Py( 0x00007f1dc4efc0f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "number_of_sequences", py_name: Py( 0x00007f1dcab9ece0, ), init: true, init_only: false, lookup_key: Simple { key: "number_of_sequences", py_key: Py( 0x00007f1dc5127fa0, ), path: LookupPath( [ S( "number_of_sequences", Py( 0x00007f1dc5127f50, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94681d0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, ], positional_count: 13, init_only_count: None, dataclass_name: "HuggingFaceCTRLGenerator", validator_name: "dataclass-args[HuggingFaceCTRLGenerator]", extra_behavior: Ignore, extras_validator: None, loc_by_alias: true, }, ), class: Py( 0x00005618681deb20, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], post_init: None, revalidate: Never, name: "HuggingFaceCTRLGenerator", frozen: false, slots: true, }, ), definitions=[], cache_strings=True)¶
- __repr__()¶
Return repr(self).
- __signature__ = <Signature (*args: Any, algorithm_version: str = 'ctrl', model_type: str = 'ctrl', prompt: str = "I'm a stochastic parrot.", length: int = 20, stop_token: str = '', num_beams: int = 1, do_sample: bool = True, temperature: float = 1.0, repetition_penalty: float = 1.0, k: int = 50, p: float = 1.0, prefix: str = '', number_of_sequences: int = 8) -> None>¶
- __wrapped__¶
alias of
HuggingFaceCTRLGenerator
- algorithm_application: ClassVar[str] = 'HuggingFaceCTRLGenerator'¶
Unique name for the application that is the use of this configuration together with a specific algorithm.
Will be set when registering to
ApplicationsRegistry
, but can be given by direct registration (Seeregister_algorithm_application
)
- algorithm_name: ClassVar[str] = 'HuggingFaceGenerationAlgorithm'¶
Name of the algorithm to use with this configuration.
Will be set when registering to
ApplicationsRegistry
- class HuggingFaceGPT2Generator(*args, **kwargs)[source]¶
Bases:
HuggingFaceGPT2Generator
Configuration to generate text using GPT2.
- algorithm_version: str = 'gpt2'¶
To differentiate between different versions of an application.
There is no imposed naming convention.
- model_type: str = 'gpt2'¶
- classmethod list_versions()[source]¶
Get possible algorithm versions.
Standard S3 and cache search adding the version used in the configuration.
- Return type
Set
[str
]- Returns
viable values as
algorithm_version
for the environment.
- __annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': 'ClassVar[str]', 'algorithm_version': <class 'str'>, 'do_sample': 'bool', 'domain': 'ClassVar[str]', 'k': 'int', 'length': 'int', 'model_type': <class 'str'>, 'num_beams': 'int', 'number_of_sequences': 'int', 'p': 'float', 'prefix': 'str', 'prompt': 'str', 'repetition_penalty': 'float', 'stop_token': 'str', 'temperature': 'float'}¶
- __dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='HuggingFaceGPT2Generator',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='HuggingFaceGenerationAlgorithm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type=<class 'str'>,default='gpt2',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'do_sample': Field(name='do_sample',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Whether or not to use sampling; use greedy decoding otherwise.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='nlp',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'k': Field(name='k',type=<class 'int'>,default=50,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of top-k probability tokens to keep.'}),kw_only=False,_field_type=_FIELD), 'length': Field(name='length',type=<class 'int'>,default=20,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Length of the generated text.'}),kw_only=False,_field_type=_FIELD), 'model_type': Field(name='model_type',type=<class 'str'>,default='gpt2',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'num_beams': Field(name='num_beams',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of beams for beam search.'}),kw_only=False,_field_type=_FIELD), 'number_of_sequences': Field(name='number_of_sequences',type=<class 'int'>,default=8,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of text sequences to generate.'}),kw_only=False,_field_type=_FIELD), 'p': Field(name='p',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Only tokens with cumulative probabilities summing up to this value are kept.'}),kw_only=False,_field_type=_FIELD), 'prefix': Field(name='prefix',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Text defining context provided prior to the prompt.'}),kw_only=False,_field_type=_FIELD), 'prompt': Field(name='prompt',type=<class 'str'>,default="I'm a stochastic parrot.",default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Prompt for text generation.'}),kw_only=False,_field_type=_FIELD), 'repetition_penalty': Field(name='repetition_penalty',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Primarily useful for CTRL model, where 1.2 should be used.'}),kw_only=False,_field_type=_FIELD), 'stop_token': Field(name='stop_token',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Stop token for text generation.'}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Temperature for sampling, the lower the greedier the sampling.'}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __doc__ = 'Configuration to generate text using GPT2.'¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __match_args__ = ('algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences')¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __parameters__ = (~T,)¶
- __pydantic_complete__ = True¶
- __pydantic_config__ = {}¶
- __pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceGPT2Generator'>, 'config': {'title': 'HuggingFaceGPT2Generator'}, 'fields': ['algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceGPT2Generator'>, title=None)]}, 'post_init': False, 'ref': 'types.HuggingFaceGPT2Generator:94662826065152', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'HuggingFaceGPT2Generator', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'gpt2'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'model_type', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'gpt2'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prompt', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': "I'm a stochastic parrot."}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 20}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'stop_token', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'num_beams', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 1}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'do_sample', 'schema': {'type': 'default', 'schema': {'type': 'bool'}, 'default': True}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'temperature', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'repetition_penalty', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'k', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 50}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'p', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prefix', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'number_of_sequences', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 8}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}¶
- __pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- __pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='gpt2', init=True, init_var=False, kw_only=False), 'do_sample': FieldInfo(annotation=bool, required=False, default=True, description='Whether or not to use sampling; use greedy decoding otherwise.', init=True, init_var=False, kw_only=False), 'k': FieldInfo(annotation=int, required=False, default=50, description='Number of top-k probability tokens to keep.', init=True, init_var=False, kw_only=False), 'length': FieldInfo(annotation=int, required=False, default=20, description='Length of the generated text.', init=True, init_var=False, kw_only=False), 'model_type': FieldInfo(annotation=str, required=False, default='gpt2', init=True, init_var=False, kw_only=False), 'num_beams': FieldInfo(annotation=int, required=False, default=1, description='Number of beams for beam search.', init=True, init_var=False, kw_only=False), 'number_of_sequences': FieldInfo(annotation=int, required=False, default=8, description='Number of text sequences to generate.', init=True, init_var=False, kw_only=False), 'p': FieldInfo(annotation=float, required=False, default=1.0, description='Only tokens with cumulative probabilities summing up to this value are kept.', init=True, init_var=False, kw_only=False), 'prefix': FieldInfo(annotation=str, required=False, default='', description='Text defining context provided prior to the prompt.', init=True, init_var=False, kw_only=False), 'prompt': FieldInfo(annotation=str, required=False, default="I'm a stochastic parrot.", description='Prompt for text generation.', init=True, init_var=False, kw_only=False), 'repetition_penalty': FieldInfo(annotation=float, required=False, default=1.0, description='Primarily useful for CTRL model, where 1.2 should be used.', init=True, init_var=False, kw_only=False), 'stop_token': FieldInfo(annotation=str, required=False, default='', description='Stop token for text generation.', init=True, init_var=False, kw_only=False), 'temperature': FieldInfo(annotation=float, required=False, default=1.0, description='Temperature for sampling, the lower the greedier the sampling.', init=True, init_var=False, kw_only=False)}¶
- __pydantic_serializer__ = SchemaSerializer(serializer=Dataclass( DataclassSerializer { class: Py( 0x00005618681efd00, ), serializer: Fields( GeneralFieldsSerializer { fields: { "model_type": SerField { key_py: Py( 0x00007f1dc4efdd70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1de495ce30, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "num_beams": SerField { key_py: Py( 0x00007f1dc4efdaf0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94680f0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "do_sample": SerField { key_py: Py( 0x00007f1dc4efda70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x000056185a4635a0, ), ), serializer: Bool( BoolSerializer, ), }, ), ), required: true, }, "temperature": SerField { key_py: Py( 0x00007f1dc4efda30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "length": SerField { key_py: Py( 0x00007f1dc4efdc70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468350, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "k": SerField { key_py: Py( 0x00007f1ea9129030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468710, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "p": SerField { key_py: Py( 0x00007f1ea9534670, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "prefix": SerField { key_py: Py( 0x00007f1dc4efd9f0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "repetition_penalty": SerField { key_py: Py( 0x00007f1dc510f4b0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "number_of_sequences": SerField { key_py: Py( 0x00007f1dc4fedf20, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94681d0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "algorithm_version": SerField { key_py: Py( 0x00007f1dc510d570, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1de495ce30, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "stop_token": SerField { key_py: Py( 0x00007f1dc4efdbf0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "prompt": SerField { key_py: Py( 0x00007f1dc4efdcf0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9e100, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 13, }, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], name: "HuggingFaceGPT2Generator", }, ), definitions=[])¶
- __pydantic_validator__ = SchemaValidator(title="HuggingFaceGPT2Generator", validator=Dataclass( DataclassValidator { strict: false, validator: DataclassArgs( DataclassArgsValidator { fields: [ Field { kw_only: false, name: "algorithm_version", py_name: Py( 0x00007f1ea52ed250, ), init: true, init_only: false, lookup_key: Simple { key: "algorithm_version", py_key: Py( 0x00007f1dc4fedc50, ), path: LookupPath( [ S( "algorithm_version", Py( 0x00007f1dc4fedb10, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1de495ce30, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "model_type", py_name: Py( 0x00007f1ea6163a30, ), init: true, init_only: false, lookup_key: Simple { key: "model_type", py_key: Py( 0x00007f1dc501d070, ), path: LookupPath( [ S( "model_type", Py( 0x00007f1dc501d030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1de495ce30, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prompt", py_name: Py( 0x00007f1ea914d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "prompt", py_key: Py( 0x00007f1dc501cfb0, ), path: LookupPath( [ S( "prompt", Py( 0x00007f1dc501cf30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9e100, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "length", py_name: Py( 0x00007f1ea8b3f9f0, ), init: true, init_only: false, lookup_key: Simple { key: "length", py_key: Py( 0x00007f1dc501d0b0, ), path: LookupPath( [ S( "length", Py( 0x00007f1dc501d130, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468350, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "stop_token", py_name: Py( 0x00007f1e981a5670, ), init: true, init_only: false, lookup_key: Simple { key: "stop_token", py_key: Py( 0x00007f1dc501d1b0, ), path: LookupPath( [ S( "stop_token", Py( 0x00007f1dc501d230, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "num_beams", py_name: Py( 0x00007f1de45c9570, ), init: true, init_only: false, lookup_key: Simple { key: "num_beams", py_key: Py( 0x00007f1dc501d2b0, ), path: LookupPath( [ S( "num_beams", Py( 0x00007f1dc501d330, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94680f0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "do_sample", py_name: Py( 0x00007f1de45a75b0, ), init: true, init_only: false, lookup_key: Simple { key: "do_sample", py_key: Py( 0x00007f1dc501d3b0, ), path: LookupPath( [ S( "do_sample", Py( 0x00007f1dc501d3f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x000056185a4635a0, ), ), on_error: Raise, validator: Bool( BoolValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[bool]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "temperature", py_name: Py( 0x00007f1e33d8d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "temperature", py_key: Py( 0x00007f1dc501d430, ), path: LookupPath( [ S( "temperature", Py( 0x00007f1dc501d4b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "repetition_penalty", py_name: Py( 0x00007f1de459fb40, ), init: true, init_only: false, lookup_key: Simple { key: "repetition_penalty", py_key: Py( 0x00007f1dc4fee150, ), path: LookupPath( [ S( "repetition_penalty", Py( 0x00007f1dc4feda20, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "k", py_name: Py( 0x00007f1ea9129030, ), init: true, init_only: false, lookup_key: Simple { key: "k", py_key: Py( 0x00007f1ea9129030, ), path: LookupPath( [ S( "k", Py( 0x00007f1ea9129030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468710, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "p", py_name: Py( 0x00007f1ea9534670, ), init: true, init_only: false, lookup_key: Simple { key: "p", py_key: Py( 0x00007f1ea9534670, ), path: LookupPath( [ S( "p", Py( 0x00007f1ea9534670, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prefix", py_name: Py( 0x00007f1ea951f5f0, ), init: true, init_only: false, lookup_key: Simple { key: "prefix", py_key: Py( 0x00007f1dc501d530, ), path: LookupPath( [ S( "prefix", Py( 0x00007f1dc501d570, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "number_of_sequences", py_name: Py( 0x00007f1dcab9ece0, ), init: true, init_only: false, lookup_key: Simple { key: "number_of_sequences", py_key: Py( 0x00007f1dc4fed9d0, ), path: LookupPath( [ S( "number_of_sequences", Py( 0x00007f1dc4fed980, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94681d0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, ], positional_count: 13, init_only_count: None, dataclass_name: "HuggingFaceGPT2Generator", validator_name: "dataclass-args[HuggingFaceGPT2Generator]", extra_behavior: Ignore, extras_validator: None, loc_by_alias: true, }, ), class: Py( 0x00005618681efd00, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], post_init: None, revalidate: Never, name: "HuggingFaceGPT2Generator", frozen: false, slots: true, }, ), definitions=[], cache_strings=True)¶
- __repr__()¶
Return repr(self).
- __signature__ = <Signature (*args: Any, algorithm_version: str = 'gpt2', model_type: str = 'gpt2', prompt: str = "I'm a stochastic parrot.", length: int = 20, stop_token: str = '', num_beams: int = 1, do_sample: bool = True, temperature: float = 1.0, repetition_penalty: float = 1.0, k: int = 50, p: float = 1.0, prefix: str = '', number_of_sequences: int = 8) -> None>¶
- __wrapped__¶
alias of
HuggingFaceGPT2Generator
- algorithm_application: ClassVar[str] = 'HuggingFaceGPT2Generator'¶
Unique name for the application that is the use of this configuration together with a specific algorithm.
Will be set when registering to
ApplicationsRegistry
, but can be given by direct registration (Seeregister_algorithm_application
)
- algorithm_name: ClassVar[str] = 'HuggingFaceGenerationAlgorithm'¶
Name of the algorithm to use with this configuration.
Will be set when registering to
ApplicationsRegistry
- class HuggingFaceOpenAIGPTGenerator(*args, **kwargs)[source]¶
Bases:
HuggingFaceOpenAIGPTGenerator
Configuration to generate text using OpenAIGPT.
- algorithm_version: str = 'openai-gpt'¶
To differentiate between different versions of an application.
There is no imposed naming convention.
- model_type: str = 'openai-gpt'¶
- classmethod list_versions()[source]¶
Get possible algorithm versions.
Standard S3 and cache search adding the version used in the configuration.
- Return type
Set
[str
]- Returns
viable values as
algorithm_version
for the environment.
- __annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': 'ClassVar[str]', 'algorithm_version': <class 'str'>, 'do_sample': 'bool', 'domain': 'ClassVar[str]', 'k': 'int', 'length': 'int', 'model_type': <class 'str'>, 'num_beams': 'int', 'number_of_sequences': 'int', 'p': 'float', 'prefix': 'str', 'prompt': 'str', 'repetition_penalty': 'float', 'stop_token': 'str', 'temperature': 'float'}¶
- __dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='HuggingFaceOpenAIGPTGenerator',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='HuggingFaceGenerationAlgorithm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type=<class 'str'>,default='openai-gpt',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'do_sample': Field(name='do_sample',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Whether or not to use sampling; use greedy decoding otherwise.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='nlp',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'k': Field(name='k',type=<class 'int'>,default=50,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of top-k probability tokens to keep.'}),kw_only=False,_field_type=_FIELD), 'length': Field(name='length',type=<class 'int'>,default=20,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Length of the generated text.'}),kw_only=False,_field_type=_FIELD), 'model_type': Field(name='model_type',type=<class 'str'>,default='openai-gpt',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'num_beams': Field(name='num_beams',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of beams for beam search.'}),kw_only=False,_field_type=_FIELD), 'number_of_sequences': Field(name='number_of_sequences',type=<class 'int'>,default=8,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of text sequences to generate.'}),kw_only=False,_field_type=_FIELD), 'p': Field(name='p',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Only tokens with cumulative probabilities summing up to this value are kept.'}),kw_only=False,_field_type=_FIELD), 'prefix': Field(name='prefix',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Text defining context provided prior to the prompt.'}),kw_only=False,_field_type=_FIELD), 'prompt': Field(name='prompt',type=<class 'str'>,default="I'm a stochastic parrot.",default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Prompt for text generation.'}),kw_only=False,_field_type=_FIELD), 'repetition_penalty': Field(name='repetition_penalty',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Primarily useful for CTRL model, where 1.2 should be used.'}),kw_only=False,_field_type=_FIELD), 'stop_token': Field(name='stop_token',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Stop token for text generation.'}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Temperature for sampling, the lower the greedier the sampling.'}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __doc__ = 'Configuration to generate text using OpenAIGPT.'¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __match_args__ = ('algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences')¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __parameters__ = (~T,)¶
- __pydantic_complete__ = True¶
- __pydantic_config__ = {}¶
- __pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceOpenAIGPTGenerator'>, 'config': {'title': 'HuggingFaceOpenAIGPTGenerator'}, 'fields': ['algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceOpenAIGPTGenerator'>, title=None)]}, 'post_init': False, 'ref': 'types.HuggingFaceOpenAIGPTGenerator:94662826058336', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'HuggingFaceOpenAIGPTGenerator', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'openai-gpt'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'model_type', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'openai-gpt'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prompt', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': "I'm a stochastic parrot."}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 20}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'stop_token', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'num_beams', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 1}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'do_sample', 'schema': {'type': 'default', 'schema': {'type': 'bool'}, 'default': True}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'temperature', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'repetition_penalty', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'k', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 50}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'p', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prefix', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'number_of_sequences', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 8}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}¶
- __pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- __pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='openai-gpt', init=True, init_var=False, kw_only=False), 'do_sample': FieldInfo(annotation=bool, required=False, default=True, description='Whether or not to use sampling; use greedy decoding otherwise.', init=True, init_var=False, kw_only=False), 'k': FieldInfo(annotation=int, required=False, default=50, description='Number of top-k probability tokens to keep.', init=True, init_var=False, kw_only=False), 'length': FieldInfo(annotation=int, required=False, default=20, description='Length of the generated text.', init=True, init_var=False, kw_only=False), 'model_type': FieldInfo(annotation=str, required=False, default='openai-gpt', init=True, init_var=False, kw_only=False), 'num_beams': FieldInfo(annotation=int, required=False, default=1, description='Number of beams for beam search.', init=True, init_var=False, kw_only=False), 'number_of_sequences': FieldInfo(annotation=int, required=False, default=8, description='Number of text sequences to generate.', init=True, init_var=False, kw_only=False), 'p': FieldInfo(annotation=float, required=False, default=1.0, description='Only tokens with cumulative probabilities summing up to this value are kept.', init=True, init_var=False, kw_only=False), 'prefix': FieldInfo(annotation=str, required=False, default='', description='Text defining context provided prior to the prompt.', init=True, init_var=False, kw_only=False), 'prompt': FieldInfo(annotation=str, required=False, default="I'm a stochastic parrot.", description='Prompt for text generation.', init=True, init_var=False, kw_only=False), 'repetition_penalty': FieldInfo(annotation=float, required=False, default=1.0, description='Primarily useful for CTRL model, where 1.2 should be used.', init=True, init_var=False, kw_only=False), 'stop_token': FieldInfo(annotation=str, required=False, default='', description='Stop token for text generation.', init=True, init_var=False, kw_only=False), 'temperature': FieldInfo(annotation=float, required=False, default=1.0, description='Temperature for sampling, the lower the greedier the sampling.', init=True, init_var=False, kw_only=False)}¶
- __pydantic_serializer__ = SchemaSerializer(serializer=Dataclass( DataclassSerializer { class: Py( 0x00005618681ee260, ), serializer: Fields( GeneralFieldsSerializer { fields: { "do_sample": SerField { key_py: Py( 0x00007f1dc501fc70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x000056185a4635a0, ), ), serializer: Bool( BoolSerializer, ), }, ), ), required: true, }, "num_beams": SerField { key_py: Py( 0x00007f1dc501fcf0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94680f0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "temperature": SerField { key_py: Py( 0x00007f1dc501fb30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "p": SerField { key_py: Py( 0x00007f1ea9534670, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "prefix": SerField { key_py: Py( 0x00007f1dc501fc30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "length": SerField { key_py: Py( 0x00007f1dc501fd70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468350, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "algorithm_version": SerField { key_py: Py( 0x00007f1dc5127e60, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51c01f0, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "stop_token": SerField { key_py: Py( 0x00007f1dc501fbf0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "k": SerField { key_py: Py( 0x00007f1ea9129030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468710, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "number_of_sequences": SerField { key_py: Py( 0x00007f1dc510f410, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94681d0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "model_type": SerField { key_py: Py( 0x00007f1dc501fcb0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51c01f0, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "prompt": SerField { key_py: Py( 0x00007f1dc501fe70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9e100, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "repetition_penalty": SerField { key_py: Py( 0x00007f1dc5127910, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 13, }, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], name: "HuggingFaceOpenAIGPTGenerator", }, ), definitions=[])¶
- __pydantic_validator__ = SchemaValidator(title="HuggingFaceOpenAIGPTGenerator", validator=Dataclass( DataclassValidator { strict: false, validator: DataclassArgs( DataclassArgsValidator { fields: [ Field { kw_only: false, name: "algorithm_version", py_name: Py( 0x00007f1ea52ed250, ), init: true, init_only: false, lookup_key: Simple { key: "algorithm_version", py_key: Py( 0x00007f1dc4fefa50, ), path: LookupPath( [ S( "algorithm_version", Py( 0x00007f1dc4fefa00, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51c01f0, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "model_type", py_name: Py( 0x00007f1ea6163a30, ), init: true, init_only: false, lookup_key: Simple { key: "model_type", py_key: Py( 0x00007f1dc4fc6df0, ), path: LookupPath( [ S( "model_type", Py( 0x00007f1dc4fc6630, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51c01f0, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prompt", py_name: Py( 0x00007f1ea914d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "prompt", py_key: Py( 0x00007f1dc4fc63f0, ), path: LookupPath( [ S( "prompt", Py( 0x00007f1dc4fc6370, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9e100, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "length", py_name: Py( 0x00007f1ea8b3f9f0, ), init: true, init_only: false, lookup_key: Simple { key: "length", py_key: Py( 0x00007f1dc4fc6f30, ), path: LookupPath( [ S( "length", Py( 0x00007f1dc4fc6fb0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468350, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "stop_token", py_name: Py( 0x00007f1e981a5670, ), init: true, init_only: false, lookup_key: Simple { key: "stop_token", py_key: Py( 0x00007f1dc4fc7070, ), path: LookupPath( [ S( "stop_token", Py( 0x00007f1dc4fc70f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "num_beams", py_name: Py( 0x00007f1de45c9570, ), init: true, init_only: false, lookup_key: Simple { key: "num_beams", py_key: Py( 0x00007f1dc4fc7170, ), path: LookupPath( [ S( "num_beams", Py( 0x00007f1dc4fc7270, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94680f0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "do_sample", py_name: Py( 0x00007f1de45a75b0, ), init: true, init_only: false, lookup_key: Simple { key: "do_sample", py_key: Py( 0x00007f1dc4fc72f0, ), path: LookupPath( [ S( "do_sample", Py( 0x00007f1dc4fc75b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x000056185a4635a0, ), ), on_error: Raise, validator: Bool( BoolValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[bool]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "temperature", py_name: Py( 0x00007f1e33d8d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "temperature", py_key: Py( 0x00007f1dc4fc7230, ), path: LookupPath( [ S( "temperature", Py( 0x00007f1dc4fc4030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "repetition_penalty", py_name: Py( 0x00007f1de459fb40, ), init: true, init_only: false, lookup_key: Simple { key: "repetition_penalty", py_key: Py( 0x00007f1dc4fefaf0, ), path: LookupPath( [ S( "repetition_penalty", Py( 0x00007f1dc4fed930, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "k", py_name: Py( 0x00007f1ea9129030, ), init: true, init_only: false, lookup_key: Simple { key: "k", py_key: Py( 0x00007f1ea9129030, ), path: LookupPath( [ S( "k", Py( 0x00007f1ea9129030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468710, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "p", py_name: Py( 0x00007f1ea9534670, ), init: true, init_only: false, lookup_key: Simple { key: "p", py_key: Py( 0x00007f1ea9534670, ), path: LookupPath( [ S( "p", Py( 0x00007f1ea9534670, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prefix", py_name: Py( 0x00007f1ea951f5f0, ), init: true, init_only: false, lookup_key: Simple { key: "prefix", py_key: Py( 0x00007f1dc4fc4070, ), path: LookupPath( [ S( "prefix", Py( 0x00007f1dc4fc40b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "number_of_sequences", py_name: Py( 0x00007f1dcab9ece0, ), init: true, init_only: false, lookup_key: Simple { key: "number_of_sequences", py_key: Py( 0x00007f1dc4fef960, ), path: LookupPath( [ S( "number_of_sequences", Py( 0x00007f1dc4fefaa0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94681d0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, ], positional_count: 13, init_only_count: None, dataclass_name: "HuggingFaceOpenAIGPTGenerator", validator_name: "dataclass-args[HuggingFaceOpenAIGPTGenerator]", extra_behavior: Ignore, extras_validator: None, loc_by_alias: true, }, ), class: Py( 0x00005618681ee260, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], post_init: None, revalidate: Never, name: "HuggingFaceOpenAIGPTGenerator", frozen: false, slots: true, }, ), definitions=[], cache_strings=True)¶
- __repr__()¶
Return repr(self).
- __signature__ = <Signature (*args: Any, algorithm_version: str = 'openai-gpt', model_type: str = 'openai-gpt', prompt: str = "I'm a stochastic parrot.", length: int = 20, stop_token: str = '', num_beams: int = 1, do_sample: bool = True, temperature: float = 1.0, repetition_penalty: float = 1.0, k: int = 50, p: float = 1.0, prefix: str = '', number_of_sequences: int = 8) -> None>¶
- __wrapped__¶
alias of
HuggingFaceOpenAIGPTGenerator
- algorithm_application: ClassVar[str] = 'HuggingFaceOpenAIGPTGenerator'¶
Unique name for the application that is the use of this configuration together with a specific algorithm.
Will be set when registering to
ApplicationsRegistry
, but can be given by direct registration (Seeregister_algorithm_application
)
- algorithm_name: ClassVar[str] = 'HuggingFaceGenerationAlgorithm'¶
Name of the algorithm to use with this configuration.
Will be set when registering to
ApplicationsRegistry
- class HuggingFaceXLNetGenerator(*args, **kwargs)[source]¶
Bases:
HuggingFaceXLNetGenerator
Configuration to generate text using XLNet.
- algorithm_version: str = 'xlnet-large-cased'¶
To differentiate between different versions of an application.
There is no imposed naming convention.
- model_type: str = 'xlnet'¶
- classmethod list_versions()[source]¶
Get possible algorithm versions.
Standard S3 and cache search adding the version used in the configuration.
- Return type
Set
[str
]- Returns
viable values as
algorithm_version
for the environment.
- __annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': 'ClassVar[str]', 'algorithm_version': <class 'str'>, 'do_sample': 'bool', 'domain': 'ClassVar[str]', 'k': 'int', 'length': 'int', 'model_type': <class 'str'>, 'num_beams': 'int', 'number_of_sequences': 'int', 'p': 'float', 'prefix': 'str', 'prompt': 'str', 'repetition_penalty': 'float', 'stop_token': 'str', 'temperature': 'float'}¶
- __dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='HuggingFaceXLNetGenerator',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='HuggingFaceGenerationAlgorithm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type=<class 'str'>,default='xlnet-large-cased',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'do_sample': Field(name='do_sample',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Whether or not to use sampling; use greedy decoding otherwise.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='nlp',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'k': Field(name='k',type=<class 'int'>,default=50,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of top-k probability tokens to keep.'}),kw_only=False,_field_type=_FIELD), 'length': Field(name='length',type=<class 'int'>,default=20,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Length of the generated text.'}),kw_only=False,_field_type=_FIELD), 'model_type': Field(name='model_type',type=<class 'str'>,default='xlnet',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'num_beams': Field(name='num_beams',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of beams for beam search.'}),kw_only=False,_field_type=_FIELD), 'number_of_sequences': Field(name='number_of_sequences',type=<class 'int'>,default=8,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of text sequences to generate.'}),kw_only=False,_field_type=_FIELD), 'p': Field(name='p',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Only tokens with cumulative probabilities summing up to this value are kept.'}),kw_only=False,_field_type=_FIELD), 'prefix': Field(name='prefix',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Text defining context provided prior to the prompt.'}),kw_only=False,_field_type=_FIELD), 'prompt': Field(name='prompt',type=<class 'str'>,default="I'm a stochastic parrot.",default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Prompt for text generation.'}),kw_only=False,_field_type=_FIELD), 'repetition_penalty': Field(name='repetition_penalty',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Primarily useful for CTRL model, where 1.2 should be used.'}),kw_only=False,_field_type=_FIELD), 'stop_token': Field(name='stop_token',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Stop token for text generation.'}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Temperature for sampling, the lower the greedier the sampling.'}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __doc__ = 'Configuration to generate text using XLNet.'¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __match_args__ = ('algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences')¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __parameters__ = (~T,)¶
- __pydantic_complete__ = True¶
- __pydantic_config__ = {}¶
- __pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceXLNetGenerator'>, 'config': {'title': 'HuggingFaceXLNetGenerator'}, 'fields': ['algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceXLNetGenerator'>, title=None)]}, 'post_init': False, 'ref': 'types.HuggingFaceXLNetGenerator:94662826134512', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'HuggingFaceXLNetGenerator', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'xlnet-large-cased'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'model_type', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'xlnet'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prompt', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': "I'm a stochastic parrot."}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 20}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'stop_token', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'num_beams', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 1}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'do_sample', 'schema': {'type': 'default', 'schema': {'type': 'bool'}, 'default': True}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'temperature', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'repetition_penalty', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'k', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 50}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'p', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prefix', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'number_of_sequences', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 8}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}¶
- __pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- __pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='xlnet-large-cased', init=True, init_var=False, kw_only=False), 'do_sample': FieldInfo(annotation=bool, required=False, default=True, description='Whether or not to use sampling; use greedy decoding otherwise.', init=True, init_var=False, kw_only=False), 'k': FieldInfo(annotation=int, required=False, default=50, description='Number of top-k probability tokens to keep.', init=True, init_var=False, kw_only=False), 'length': FieldInfo(annotation=int, required=False, default=20, description='Length of the generated text.', init=True, init_var=False, kw_only=False), 'model_type': FieldInfo(annotation=str, required=False, default='xlnet', init=True, init_var=False, kw_only=False), 'num_beams': FieldInfo(annotation=int, required=False, default=1, description='Number of beams for beam search.', init=True, init_var=False, kw_only=False), 'number_of_sequences': FieldInfo(annotation=int, required=False, default=8, description='Number of text sequences to generate.', init=True, init_var=False, kw_only=False), 'p': FieldInfo(annotation=float, required=False, default=1.0, description='Only tokens with cumulative probabilities summing up to this value are kept.', init=True, init_var=False, kw_only=False), 'prefix': FieldInfo(annotation=str, required=False, default='', description='Text defining context provided prior to the prompt.', init=True, init_var=False, kw_only=False), 'prompt': FieldInfo(annotation=str, required=False, default="I'm a stochastic parrot.", description='Prompt for text generation.', init=True, init_var=False, kw_only=False), 'repetition_penalty': FieldInfo(annotation=float, required=False, default=1.0, description='Primarily useful for CTRL model, where 1.2 should be used.', init=True, init_var=False, kw_only=False), 'stop_token': FieldInfo(annotation=str, required=False, default='', description='Stop token for text generation.', init=True, init_var=False, kw_only=False), 'temperature': FieldInfo(annotation=float, required=False, default=1.0, description='Temperature for sampling, the lower the greedier the sampling.', init=True, init_var=False, kw_only=False)}¶
- __pydantic_serializer__ = SchemaSerializer(serializer=Dataclass( DataclassSerializer { class: Py( 0x0000561868200bf0, ), serializer: Fields( GeneralFieldsSerializer { fields: { "do_sample": SerField { key_py: Py( 0x00007f1dc4fc73f0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x000056185a4635a0, ), ), serializer: Bool( BoolSerializer, ), }, ), ), required: true, }, "number_of_sequences": SerField { key_py: Py( 0x00007f1dc5001bb0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94681d0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "model_type": SerField { key_py: Py( 0x00007f1dc4fc7530, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1de4362ef0, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "temperature": SerField { key_py: Py( 0x00007f1dc4fc73b0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "stop_token": SerField { key_py: Py( 0x00007f1dc4fc7470, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "prompt": SerField { key_py: Py( 0x00007f1dc4fc74f0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9e100, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "algorithm_version": SerField { key_py: Py( 0x00007f1dc5001ca0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9f190, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "num_beams": SerField { key_py: Py( 0x00007f1dc4fc7430, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94680f0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "length": SerField { key_py: Py( 0x00007f1dc4fc74b0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468350, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "repetition_penalty": SerField { key_py: Py( 0x00007f1dc5001c50, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "k": SerField { key_py: Py( 0x00007f1ea9129030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468710, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "p": SerField { key_py: Py( 0x00007f1ea9534670, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "prefix": SerField { key_py: Py( 0x00007f1dc4fc7330, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 13, }, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], name: "HuggingFaceXLNetGenerator", }, ), definitions=[])¶
- __pydantic_validator__ = SchemaValidator(title="HuggingFaceXLNetGenerator", validator=Dataclass( DataclassValidator { strict: false, validator: DataclassArgs( DataclassArgsValidator { fields: [ Field { kw_only: false, name: "algorithm_version", py_name: Py( 0x00007f1ea52ed250, ), init: true, init_only: false, lookup_key: Simple { key: "algorithm_version", py_key: Py( 0x00007f1dc50023d0, ), path: LookupPath( [ S( "algorithm_version", Py( 0x00007f1dc5001b60, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9f190, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "model_type", py_name: Py( 0x00007f1ea6163a30, ), init: true, init_only: false, lookup_key: Simple { key: "model_type", py_key: Py( 0x00007f1dc4fc7ef0, ), path: LookupPath( [ S( "model_type", Py( 0x00007f1dc4fc7e70, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1de4362ef0, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prompt", py_name: Py( 0x00007f1ea914d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "prompt", py_key: Py( 0x00007f1dc4fc7e30, ), path: LookupPath( [ S( "prompt", Py( 0x00007f1dc4fc7df0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9e100, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "length", py_name: Py( 0x00007f1ea8b3f9f0, ), init: true, init_only: false, lookup_key: Simple { key: "length", py_key: Py( 0x00007f1dc4fc7eb0, ), path: LookupPath( [ S( "length", Py( 0x00007f1dc4fc58b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468350, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "stop_token", py_name: Py( 0x00007f1e981a5670, ), init: true, init_only: false, lookup_key: Simple { key: "stop_token", py_key: Py( 0x00007f1dc4fc6ff0, ), path: LookupPath( [ S( "stop_token", Py( 0x00007f1dc5009e70, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "num_beams", py_name: Py( 0x00007f1de45c9570, ), init: true, init_only: false, lookup_key: Simple { key: "num_beams", py_key: Py( 0x00007f1dc500a5b0, ), path: LookupPath( [ S( "num_beams", Py( 0x00007f1dc500a7b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94680f0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "do_sample", py_name: Py( 0x00007f1de45a75b0, ), init: true, init_only: false, lookup_key: Simple { key: "do_sample", py_key: Py( 0x00007f1dc50081b0, ), path: LookupPath( [ S( "do_sample", Py( 0x00007f1dc50082b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x000056185a4635a0, ), ), on_error: Raise, validator: Bool( BoolValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[bool]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "temperature", py_name: Py( 0x00007f1e33d8d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "temperature", py_key: Py( 0x00007f1dc50083b0, ), path: LookupPath( [ S( "temperature", Py( 0x00007f1dc50084b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "repetition_penalty", py_name: Py( 0x00007f1de459fb40, ), init: true, init_only: false, lookup_key: Simple { key: "repetition_penalty", py_key: Py( 0x00007f1dc5002240, ), path: LookupPath( [ S( "repetition_penalty", Py( 0x00007f1dc5002790, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "k", py_name: Py( 0x00007f1ea9129030, ), init: true, init_only: false, lookup_key: Simple { key: "k", py_key: Py( 0x00007f1ea9129030, ), path: LookupPath( [ S( "k", Py( 0x00007f1ea9129030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468710, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "p", py_name: Py( 0x00007f1ea9534670, ), init: true, init_only: false, lookup_key: Simple { key: "p", py_key: Py( 0x00007f1ea9534670, ), path: LookupPath( [ S( "p", Py( 0x00007f1ea9534670, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prefix", py_name: Py( 0x00007f1ea951f5f0, ), init: true, init_only: false, lookup_key: Simple { key: "prefix", py_key: Py( 0x00007f1dc50085b0, ), path: LookupPath( [ S( "prefix", Py( 0x00007f1dc50086b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "number_of_sequences", py_name: Py( 0x00007f1dcab9ece0, ), init: true, init_only: false, lookup_key: Simple { key: "number_of_sequences", py_key: Py( 0x00007f1dc5002290, ), path: LookupPath( [ S( "number_of_sequences", Py( 0x00007f1dc5001980, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94681d0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, ], positional_count: 13, init_only_count: None, dataclass_name: "HuggingFaceXLNetGenerator", validator_name: "dataclass-args[HuggingFaceXLNetGenerator]", extra_behavior: Ignore, extras_validator: None, loc_by_alias: true, }, ), class: Py( 0x0000561868200bf0, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], post_init: None, revalidate: Never, name: "HuggingFaceXLNetGenerator", frozen: false, slots: true, }, ), definitions=[], cache_strings=True)¶
- __repr__()¶
Return repr(self).
- __signature__ = <Signature (*args: Any, algorithm_version: str = 'xlnet-large-cased', model_type: str = 'xlnet', prompt: str = "I'm a stochastic parrot.", length: int = 20, stop_token: str = '', num_beams: int = 1, do_sample: bool = True, temperature: float = 1.0, repetition_penalty: float = 1.0, k: int = 50, p: float = 1.0, prefix: str = '', number_of_sequences: int = 8) -> None>¶
- __wrapped__¶
alias of
HuggingFaceXLNetGenerator
- algorithm_application: ClassVar[str] = 'HuggingFaceXLNetGenerator'¶
Unique name for the application that is the use of this configuration together with a specific algorithm.
Will be set when registering to
ApplicationsRegistry
, but can be given by direct registration (Seeregister_algorithm_application
)
- algorithm_name: ClassVar[str] = 'HuggingFaceGenerationAlgorithm'¶
Name of the algorithm to use with this configuration.
Will be set when registering to
ApplicationsRegistry
- class HuggingFaceTransfoXLGenerator(*args, **kwargs)[source]¶
Bases:
HuggingFaceTransfoXLGenerator
Configuration to generate text using TransfoXL.
- algorithm_version: str = 'transfo-xl-wt103'¶
To differentiate between different versions of an application.
There is no imposed naming convention.
- model_type: str = 'transfo-xl'¶
- classmethod list_versions()[source]¶
Get possible algorithm versions.
Standard S3 and cache search adding the version used in the configuration.
- Return type
Set
[str
]- Returns
viable values as
algorithm_version
for the environment.
- __annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': 'ClassVar[str]', 'algorithm_version': <class 'str'>, 'do_sample': 'bool', 'domain': 'ClassVar[str]', 'k': 'int', 'length': 'int', 'model_type': <class 'str'>, 'num_beams': 'int', 'number_of_sequences': 'int', 'p': 'float', 'prefix': 'str', 'prompt': 'str', 'repetition_penalty': 'float', 'stop_token': 'str', 'temperature': 'float'}¶
- __dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='HuggingFaceTransfoXLGenerator',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='HuggingFaceGenerationAlgorithm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type=<class 'str'>,default='transfo-xl-wt103',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'do_sample': Field(name='do_sample',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Whether or not to use sampling; use greedy decoding otherwise.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='nlp',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'k': Field(name='k',type=<class 'int'>,default=50,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of top-k probability tokens to keep.'}),kw_only=False,_field_type=_FIELD), 'length': Field(name='length',type=<class 'int'>,default=20,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Length of the generated text.'}),kw_only=False,_field_type=_FIELD), 'model_type': Field(name='model_type',type=<class 'str'>,default='transfo-xl',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'num_beams': Field(name='num_beams',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of beams for beam search.'}),kw_only=False,_field_type=_FIELD), 'number_of_sequences': Field(name='number_of_sequences',type=<class 'int'>,default=8,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of text sequences to generate.'}),kw_only=False,_field_type=_FIELD), 'p': Field(name='p',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Only tokens with cumulative probabilities summing up to this value are kept.'}),kw_only=False,_field_type=_FIELD), 'prefix': Field(name='prefix',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Text defining context provided prior to the prompt.'}),kw_only=False,_field_type=_FIELD), 'prompt': Field(name='prompt',type=<class 'str'>,default="I'm a stochastic parrot.",default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Prompt for text generation.'}),kw_only=False,_field_type=_FIELD), 'repetition_penalty': Field(name='repetition_penalty',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Primarily useful for CTRL model, where 1.2 should be used.'}),kw_only=False,_field_type=_FIELD), 'stop_token': Field(name='stop_token',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Stop token for text generation.'}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Temperature for sampling, the lower the greedier the sampling.'}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __doc__ = 'Configuration to generate text using TransfoXL.'¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __match_args__ = ('algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences')¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __parameters__ = (~T,)¶
- __pydantic_complete__ = True¶
- __pydantic_config__ = {}¶
- __pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceTransfoXLGenerator'>, 'config': {'title': 'HuggingFaceTransfoXLGenerator'}, 'fields': ['algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceTransfoXLGenerator'>, title=None)]}, 'post_init': False, 'ref': 'types.HuggingFaceTransfoXLGenerator:94662826178496', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'HuggingFaceTransfoXLGenerator', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'transfo-xl-wt103'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'model_type', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'transfo-xl'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prompt', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': "I'm a stochastic parrot."}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 20}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'stop_token', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'num_beams', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 1}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'do_sample', 'schema': {'type': 'default', 'schema': {'type': 'bool'}, 'default': True}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'temperature', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'repetition_penalty', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'k', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 50}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'p', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prefix', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'number_of_sequences', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 8}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}¶
- __pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- __pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='transfo-xl-wt103', init=True, init_var=False, kw_only=False), 'do_sample': FieldInfo(annotation=bool, required=False, default=True, description='Whether or not to use sampling; use greedy decoding otherwise.', init=True, init_var=False, kw_only=False), 'k': FieldInfo(annotation=int, required=False, default=50, description='Number of top-k probability tokens to keep.', init=True, init_var=False, kw_only=False), 'length': FieldInfo(annotation=int, required=False, default=20, description='Length of the generated text.', init=True, init_var=False, kw_only=False), 'model_type': FieldInfo(annotation=str, required=False, default='transfo-xl', init=True, init_var=False, kw_only=False), 'num_beams': FieldInfo(annotation=int, required=False, default=1, description='Number of beams for beam search.', init=True, init_var=False, kw_only=False), 'number_of_sequences': FieldInfo(annotation=int, required=False, default=8, description='Number of text sequences to generate.', init=True, init_var=False, kw_only=False), 'p': FieldInfo(annotation=float, required=False, default=1.0, description='Only tokens with cumulative probabilities summing up to this value are kept.', init=True, init_var=False, kw_only=False), 'prefix': FieldInfo(annotation=str, required=False, default='', description='Text defining context provided prior to the prompt.', init=True, init_var=False, kw_only=False), 'prompt': FieldInfo(annotation=str, required=False, default="I'm a stochastic parrot.", description='Prompt for text generation.', init=True, init_var=False, kw_only=False), 'repetition_penalty': FieldInfo(annotation=float, required=False, default=1.0, description='Primarily useful for CTRL model, where 1.2 should be used.', init=True, init_var=False, kw_only=False), 'stop_token': FieldInfo(annotation=str, required=False, default='', description='Stop token for text generation.', init=True, init_var=False, kw_only=False), 'temperature': FieldInfo(annotation=float, required=False, default=1.0, description='Temperature for sampling, the lower the greedier the sampling.', init=True, init_var=False, kw_only=False)}¶
- __pydantic_serializer__ = SchemaSerializer(serializer=Dataclass( DataclassSerializer { class: Py( 0x000056186820b7c0, ), serializer: Fields( GeneralFieldsSerializer { fields: { "p": SerField { key_py: Py( 0x00007f1ea9534670, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "prompt": SerField { key_py: Py( 0x00007f1dc5008c70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9e100, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "stop_token": SerField { key_py: Py( 0x00007f1dc5008b70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "repetition_penalty": SerField { key_py: Py( 0x00007f1dc510d5c0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "prefix": SerField { key_py: Py( 0x00007f1dc50089f0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "k": SerField { key_py: Py( 0x00007f1ea9129030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468710, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "number_of_sequences": SerField { key_py: Py( 0x00007f1dc510d660, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94681d0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "algorithm_version": SerField { key_py: Py( 0x00007f1dc510d6b0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9ee70, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "length": SerField { key_py: Py( 0x00007f1dc5008bf0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468350, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "num_beams": SerField { key_py: Py( 0x00007f1dc5008af0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94680f0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "do_sample": SerField { key_py: Py( 0x00007f1dc5008a70, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x000056185a4635a0, ), ), serializer: Bool( BoolSerializer, ), }, ), ), required: true, }, "temperature": SerField { key_py: Py( 0x00007f1dc5008a30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "model_type": SerField { key_py: Py( 0x00007f1dc5008cf0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51c2db0, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 13, }, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], name: "HuggingFaceTransfoXLGenerator", }, ), definitions=[])¶
- __pydantic_validator__ = SchemaValidator(title="HuggingFaceTransfoXLGenerator", validator=Dataclass( DataclassValidator { strict: false, validator: DataclassArgs( DataclassArgsValidator { fields: [ Field { kw_only: false, name: "algorithm_version", py_name: Py( 0x00007f1ea52ed250, ), init: true, init_only: false, lookup_key: Simple { key: "algorithm_version", py_key: Py( 0x00007f1dc4fefc80, ), path: LookupPath( [ S( "algorithm_version", Py( 0x00007f1dc510d7a0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9ee70, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "model_type", py_name: Py( 0x00007f1ea6163a30, ), init: true, init_only: false, lookup_key: Simple { key: "model_type", py_key: Py( 0x00007f1dc5009ff0, ), path: LookupPath( [ S( "model_type", Py( 0x00007f1dc500aef0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51c2db0, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prompt", py_name: Py( 0x00007f1ea914d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "prompt", py_key: Py( 0x00007f1dc500b070, ), path: LookupPath( [ S( "prompt", Py( 0x00007f1dc500b1f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9e100, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "length", py_name: Py( 0x00007f1ea8b3f9f0, ), init: true, init_only: false, lookup_key: Simple { key: "length", py_key: Py( 0x00007f1dc500adf0, ), path: LookupPath( [ S( "length", Py( 0x00007f1dc500aab0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468350, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "stop_token", py_name: Py( 0x00007f1e981a5670, ), init: true, init_only: false, lookup_key: Simple { key: "stop_token", py_key: Py( 0x00007f1dc500abb0, ), path: LookupPath( [ S( "stop_token", Py( 0x00007f1dc50093b0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "num_beams", py_name: Py( 0x00007f1de45c9570, ), init: true, init_only: false, lookup_key: Simple { key: "num_beams", py_key: Py( 0x00007f1dc5009f30, ), path: LookupPath( [ S( "num_beams", Py( 0x00007f1dc5009b30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94680f0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "do_sample", py_name: Py( 0x00007f1de45a75b0, ), init: true, init_only: false, lookup_key: Simple { key: "do_sample", py_key: Py( 0x00007f1dc500ad30, ), path: LookupPath( [ S( "do_sample", Py( 0x00007f1dc5008c30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x000056185a4635a0, ), ), on_error: Raise, validator: Bool( BoolValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[bool]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "temperature", py_name: Py( 0x00007f1e33d8d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "temperature", py_key: Py( 0x00007f1dc500b330, ), path: LookupPath( [ S( "temperature", Py( 0x00007f1dc5009af0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "repetition_penalty", py_name: Py( 0x00007f1de459fb40, ), init: true, init_only: false, lookup_key: Simple { key: "repetition_penalty", py_key: Py( 0x00007f1dc510d7f0, ), path: LookupPath( [ S( "repetition_penalty", Py( 0x00007f1dc510d840, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "k", py_name: Py( 0x00007f1ea9129030, ), init: true, init_only: false, lookup_key: Simple { key: "k", py_key: Py( 0x00007f1ea9129030, ), path: LookupPath( [ S( "k", Py( 0x00007f1ea9129030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468710, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "p", py_name: Py( 0x00007f1ea9534670, ), init: true, init_only: false, lookup_key: Simple { key: "p", py_key: Py( 0x00007f1ea9534670, ), path: LookupPath( [ S( "p", Py( 0x00007f1ea9534670, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prefix", py_name: Py( 0x00007f1ea951f5f0, ), init: true, init_only: false, lookup_key: Simple { key: "prefix", py_key: Py( 0x00007f1dc5008b30, ), path: LookupPath( [ S( "prefix", Py( 0x00007f1dc500b430, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "number_of_sequences", py_name: Py( 0x00007f1dcab9ece0, ), init: true, init_only: false, lookup_key: Simple { key: "number_of_sequences", py_key: Py( 0x00007f1dc510d750, ), path: LookupPath( [ S( "number_of_sequences", Py( 0x00007f1dc510d700, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94681d0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, ], positional_count: 13, init_only_count: None, dataclass_name: "HuggingFaceTransfoXLGenerator", validator_name: "dataclass-args[HuggingFaceTransfoXLGenerator]", extra_behavior: Ignore, extras_validator: None, loc_by_alias: true, }, ), class: Py( 0x000056186820b7c0, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], post_init: None, revalidate: Never, name: "HuggingFaceTransfoXLGenerator", frozen: false, slots: true, }, ), definitions=[], cache_strings=True)¶
- __repr__()¶
Return repr(self).
- __signature__ = <Signature (*args: Any, algorithm_version: str = 'transfo-xl-wt103', model_type: str = 'transfo-xl', prompt: str = "I'm a stochastic parrot.", length: int = 20, stop_token: str = '', num_beams: int = 1, do_sample: bool = True, temperature: float = 1.0, repetition_penalty: float = 1.0, k: int = 50, p: float = 1.0, prefix: str = '', number_of_sequences: int = 8) -> None>¶
- __wrapped__¶
alias of
HuggingFaceTransfoXLGenerator
- algorithm_application: ClassVar[str] = 'HuggingFaceTransfoXLGenerator'¶
Unique name for the application that is the use of this configuration together with a specific algorithm.
Will be set when registering to
ApplicationsRegistry
, but can be given by direct registration (Seeregister_algorithm_application
)
- algorithm_name: ClassVar[str] = 'HuggingFaceGenerationAlgorithm'¶
Name of the algorithm to use with this configuration.
Will be set when registering to
ApplicationsRegistry
- class HuggingFaceSeq2SeqGenerator(*args, **kwargs)[source]¶
Bases:
HuggingFaceSeq2SeqGenerator
Configuration to generate text using Seq2Seq LMs.
- algorithm_version: str = 't5-small'¶
To differentiate between different versions of an application.
There is no imposed naming convention.
- model_type: str = 'auto-seq2seq-lm'¶
- classmethod list_versions()[source]¶
Get possible algorithm versions.
Standard S3 and cache search adding the version used in the configuration.
- Return type
Set
[str
]- Returns
viable values as
algorithm_version
for the environment.
- __annotations__ = {'algorithm_application': 'ClassVar[str]', 'algorithm_name': 'ClassVar[str]', 'algorithm_type': 'ClassVar[str]', 'algorithm_version': <class 'str'>, 'do_sample': 'bool', 'domain': 'ClassVar[str]', 'k': 'int', 'length': 'int', 'model_type': <class 'str'>, 'num_beams': 'int', 'number_of_sequences': 'int', 'p': 'float', 'prefix': 'str', 'prompt': 'str', 'repetition_penalty': 'float', 'stop_token': 'str', 'temperature': 'float'}¶
- __dataclass_fields__ = {'algorithm_application': Field(name='algorithm_application',type=typing.ClassVar[str],default='HuggingFaceSeq2SeqGenerator',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_name': Field(name='algorithm_name',type=typing.ClassVar[str],default='HuggingFaceGenerationAlgorithm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_type': Field(name='algorithm_type',type=typing.ClassVar[str],default='generation',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'algorithm_version': Field(name='algorithm_version',type=<class 'str'>,default='t5-small',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'do_sample': Field(name='do_sample',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Whether or not to use sampling; use greedy decoding otherwise.'}),kw_only=False,_field_type=_FIELD), 'domain': Field(name='domain',type=typing.ClassVar[str],default='nlp',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=_FIELD_CLASSVAR), 'k': Field(name='k',type=<class 'int'>,default=50,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of top-k probability tokens to keep.'}),kw_only=False,_field_type=_FIELD), 'length': Field(name='length',type=<class 'int'>,default=20,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Length of the generated text.'}),kw_only=False,_field_type=_FIELD), 'model_type': Field(name='model_type',type=<class 'str'>,default='auto-seq2seq-lm',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'num_beams': Field(name='num_beams',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of beams for beam search.'}),kw_only=False,_field_type=_FIELD), 'number_of_sequences': Field(name='number_of_sequences',type=<class 'int'>,default=8,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Number of text sequences to generate.'}),kw_only=False,_field_type=_FIELD), 'p': Field(name='p',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Only tokens with cumulative probabilities summing up to this value are kept.'}),kw_only=False,_field_type=_FIELD), 'prefix': Field(name='prefix',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Text defining context provided prior to the prompt.'}),kw_only=False,_field_type=_FIELD), 'prompt': Field(name='prompt',type=<class 'str'>,default="I'm a stochastic parrot.",default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Prompt for text generation.'}),kw_only=False,_field_type=_FIELD), 'repetition_penalty': Field(name='repetition_penalty',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Primarily useful for CTRL model, where 1.2 should be used.'}),kw_only=False,_field_type=_FIELD), 'stop_token': Field(name='stop_token',type=<class 'str'>,default='',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Stop token for text generation.'}),kw_only=False,_field_type=_FIELD), 'temperature': Field(name='temperature',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'Temperature for sampling, the lower the greedier the sampling.'}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __doc__ = 'Configuration to generate text using Seq2Seq LMs.'¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(*args, **kwargs)¶
- __match_args__ = ('algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences')¶
- __module__ = 'gt4sd.algorithms.generation.hugging_face.core'¶
- __parameters__ = (~T,)¶
- __pydantic_complete__ = True¶
- __pydantic_config__ = {}¶
- __pydantic_core_schema__ = {'cls': <class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceSeq2SeqGenerator'>, 'config': {'title': 'HuggingFaceSeq2SeqGenerator'}, 'fields': ['algorithm_version', 'model_type', 'prompt', 'length', 'stop_token', 'num_beams', 'do_sample', 'temperature', 'repetition_penalty', 'k', 'p', 'prefix', 'number_of_sequences'], 'frozen': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'gt4sd.algorithms.generation.hugging_face.core.HuggingFaceSeq2SeqGenerator'>, title=None)]}, 'post_init': False, 'ref': 'types.HuggingFaceSeq2SeqGenerator:94662826181920', 'schema': {'collect_init_only': False, 'computed_fields': [], 'dataclass_name': 'HuggingFaceSeq2SeqGenerator', 'fields': [{'type': 'dataclass-field', 'name': 'algorithm_version', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 't5-small'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'model_type', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': 'auto-seq2seq-lm'}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prompt', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': "I'm a stochastic parrot."}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'length', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 20}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'stop_token', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'num_beams', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 1}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'do_sample', 'schema': {'type': 'default', 'schema': {'type': 'bool'}, 'default': True}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'temperature', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'repetition_penalty', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'k', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 50}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'p', 'schema': {'type': 'default', 'schema': {'type': 'float'}, 'default': 1.0}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'prefix', 'schema': {'type': 'default', 'schema': {'type': 'str'}, 'default': ''}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}, {'type': 'dataclass-field', 'name': 'number_of_sequences', 'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 8}, 'kw_only': False, 'init': True, 'metadata': {'pydantic_js_functions': [], 'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>]}}], 'type': 'dataclass-args'}, 'slots': True, 'type': 'dataclass'}¶
- __pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- __pydantic_fields__ = {'algorithm_version': FieldInfo(annotation=str, required=False, default='t5-small', init=True, init_var=False, kw_only=False), 'do_sample': FieldInfo(annotation=bool, required=False, default=True, description='Whether or not to use sampling; use greedy decoding otherwise.', init=True, init_var=False, kw_only=False), 'k': FieldInfo(annotation=int, required=False, default=50, description='Number of top-k probability tokens to keep.', init=True, init_var=False, kw_only=False), 'length': FieldInfo(annotation=int, required=False, default=20, description='Length of the generated text.', init=True, init_var=False, kw_only=False), 'model_type': FieldInfo(annotation=str, required=False, default='auto-seq2seq-lm', init=True, init_var=False, kw_only=False), 'num_beams': FieldInfo(annotation=int, required=False, default=1, description='Number of beams for beam search.', init=True, init_var=False, kw_only=False), 'number_of_sequences': FieldInfo(annotation=int, required=False, default=8, description='Number of text sequences to generate.', init=True, init_var=False, kw_only=False), 'p': FieldInfo(annotation=float, required=False, default=1.0, description='Only tokens with cumulative probabilities summing up to this value are kept.', init=True, init_var=False, kw_only=False), 'prefix': FieldInfo(annotation=str, required=False, default='', description='Text defining context provided prior to the prompt.', init=True, init_var=False, kw_only=False), 'prompt': FieldInfo(annotation=str, required=False, default="I'm a stochastic parrot.", description='Prompt for text generation.', init=True, init_var=False, kw_only=False), 'repetition_penalty': FieldInfo(annotation=float, required=False, default=1.0, description='Primarily useful for CTRL model, where 1.2 should be used.', init=True, init_var=False, kw_only=False), 'stop_token': FieldInfo(annotation=str, required=False, default='', description='Stop token for text generation.', init=True, init_var=False, kw_only=False), 'temperature': FieldInfo(annotation=float, required=False, default=1.0, description='Temperature for sampling, the lower the greedier the sampling.', init=True, init_var=False, kw_only=False)}¶
- __pydantic_serializer__ = SchemaSerializer(serializer=Dataclass( DataclassSerializer { class: Py( 0x000056186820c520, ), serializer: Fields( GeneralFieldsSerializer { fields: { "stop_token": SerField { key_py: Py( 0x00007f1dc4fc4370, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "algorithm_version": SerField { key_py: Py( 0x00007f1dc5003aa0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51c2e70, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "num_beams": SerField { key_py: Py( 0x00007f1dc4fc5370, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94680f0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "k": SerField { key_py: Py( 0x00007f1ea9129030, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468710, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "temperature": SerField { key_py: Py( 0x00007f1dc4fc6c30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "number_of_sequences": SerField { key_py: Py( 0x00007f1dc50038c0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea94681d0, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "length": SerField { key_py: Py( 0x00007f1dc4fc44b0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9468350, ), ), serializer: Int( IntSerializer, ), }, ), ), required: true, }, "repetition_penalty": SerField { key_py: Py( 0x00007f1dc5003c30, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "p": SerField { key_py: Py( 0x00007f1ea9534670, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51cd090, ), ), serializer: Float( FloatSerializer { inf_nan_mode: Null, }, ), }, ), ), required: true, }, "prompt": SerField { key_py: Py( 0x00007f1dc4fc5470, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dcab9e100, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "do_sample": SerField { key_py: Py( 0x00007f1dc4fc7db0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x000056185a4635a0, ), ), serializer: Bool( BoolSerializer, ), }, ), ), required: true, }, "prefix": SerField { key_py: Py( 0x00007f1dc4fc4df0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1ea9470030, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "model_type": SerField { key_py: Py( 0x00007f1dc4fc59b0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1dc51c2ef0, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 13, }, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], name: "HuggingFaceSeq2SeqGenerator", }, ), definitions=[])¶
- __pydantic_validator__ = SchemaValidator(title="HuggingFaceSeq2SeqGenerator", validator=Dataclass( DataclassValidator { strict: false, validator: DataclassArgs( DataclassArgsValidator { fields: [ Field { kw_only: false, name: "algorithm_version", py_name: Py( 0x00007f1ea52ed250, ), init: true, init_only: false, lookup_key: Simple { key: "algorithm_version", py_key: Py( 0x00007f1dc5003dc0, ), path: LookupPath( [ S( "algorithm_version", Py( 0x00007f1dc5003d20, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51c2e70, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "model_type", py_name: Py( 0x00007f1ea6163a30, ), init: true, init_only: false, lookup_key: Simple { key: "model_type", py_key: Py( 0x00007f1dc5091370, ), path: LookupPath( [ S( "model_type", Py( 0x00007f1dc4ec4630, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51c2ef0, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prompt", py_name: Py( 0x00007f1ea914d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "prompt", py_key: Py( 0x00007f1dc4ec4730, ), path: LookupPath( [ S( "prompt", Py( 0x00007f1dc4ec4cf0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dcab9e100, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "length", py_name: Py( 0x00007f1ea8b3f9f0, ), init: true, init_only: false, lookup_key: Simple { key: "length", py_key: Py( 0x00007f1dc4ec4db0, ), path: LookupPath( [ S( "length", Py( 0x00007f1dc4ec4c30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468350, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "stop_token", py_name: Py( 0x00007f1e981a5670, ), init: true, init_only: false, lookup_key: Simple { key: "stop_token", py_key: Py( 0x00007f1dc501f870, ), path: LookupPath( [ S( "stop_token", Py( 0x00007f1dc501fd30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "num_beams", py_name: Py( 0x00007f1de45c9570, ), init: true, init_only: false, lookup_key: Simple { key: "num_beams", py_key: Py( 0x00007f1dc501ef30, ), path: LookupPath( [ S( "num_beams", Py( 0x00007f1dc501ea30, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94680f0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "do_sample", py_name: Py( 0x00007f1de45a75b0, ), init: true, init_only: false, lookup_key: Simple { key: "do_sample", py_key: Py( 0x00007f1dc5048470, ), path: LookupPath( [ S( "do_sample", Py( 0x00007f1dc5048ab0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x000056185a4635a0, ), ), on_error: Raise, validator: Bool( BoolValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[bool]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "temperature", py_name: Py( 0x00007f1e33d8d4b0, ), init: true, init_only: false, lookup_key: Simple { key: "temperature", py_key: Py( 0x00007f1dc500af30, ), path: LookupPath( [ S( "temperature", Py( 0x00007f1dc50080f0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "repetition_penalty", py_name: Py( 0x00007f1de459fb40, ), init: true, init_only: false, lookup_key: Simple { key: "repetition_penalty", py_key: Py( 0x00007f1dc5003c80, ), path: LookupPath( [ S( "repetition_penalty", Py( 0x00007f1dc50018e0, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "k", py_name: Py( 0x00007f1ea9129030, ), init: true, init_only: false, lookup_key: Simple { key: "k", py_key: Py( 0x00007f1ea9129030, ), path: LookupPath( [ S( "k", Py( 0x00007f1ea9129030, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9468710, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "p", py_name: Py( 0x00007f1ea9534670, ), init: true, init_only: false, lookup_key: Simple { key: "p", py_key: Py( 0x00007f1ea9534670, ), path: LookupPath( [ S( "p", Py( 0x00007f1ea9534670, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1dc51cd090, ), ), on_error: Raise, validator: Float( FloatValidator { strict: false, allow_inf_nan: true, }, ), validate_default: false, copy_default: false, name: "default[float]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "prefix", py_name: Py( 0x00007f1ea951f5f0, ), init: true, init_only: false, lookup_key: Simple { key: "prefix", py_key: Py( 0x00007f1dc500bbb0, ), path: LookupPath( [ S( "prefix", Py( 0x00007f1dc500ac70, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea9470030, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, Field { kw_only: false, name: "number_of_sequences", py_name: Py( 0x00007f1dcab9ece0, ), init: true, init_only: false, lookup_key: Simple { key: "number_of_sequences", py_key: Py( 0x00007f1dc5003be0, ), path: LookupPath( [ S( "number_of_sequences", Py( 0x00007f1dc5003b40, ), ), ], ), }, validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1ea94681d0, ), ), on_error: Raise, validator: Int( IntValidator { strict: false, }, ), validate_default: false, copy_default: false, name: "default[int]", undefined: Py( 0x00007f1ea71db950, ), }, ), frozen: false, }, ], positional_count: 13, init_only_count: None, dataclass_name: "HuggingFaceSeq2SeqGenerator", validator_name: "dataclass-args[HuggingFaceSeq2SeqGenerator]", extra_behavior: Ignore, extras_validator: None, loc_by_alias: true, }, ), class: Py( 0x000056186820c520, ), fields: [ Py( 0x00007f1ea52ed250, ), Py( 0x00007f1ea6163a30, ), Py( 0x00007f1ea914d4b0, ), Py( 0x00007f1ea8b3f9f0, ), Py( 0x00007f1e981a5670, ), Py( 0x00007f1de45c9570, ), Py( 0x00007f1de45a75b0, ), Py( 0x00007f1e33d8d4b0, ), Py( 0x00007f1de459fb40, ), Py( 0x00007f1ea9129030, ), Py( 0x00007f1ea9534670, ), Py( 0x00007f1ea951f5f0, ), Py( 0x00007f1dcab9ece0, ), ], post_init: None, revalidate: Never, name: "HuggingFaceSeq2SeqGenerator", frozen: false, slots: true, }, ), definitions=[], cache_strings=True)¶
- __repr__()¶
Return repr(self).
- __signature__ = <Signature (*args: Any, algorithm_version: str = 't5-small', model_type: str = 'auto-seq2seq-lm', prompt: str = "I'm a stochastic parrot.", length: int = 20, stop_token: str = '', num_beams: int = 1, do_sample: bool = True, temperature: float = 1.0, repetition_penalty: float = 1.0, k: int = 50, p: float = 1.0, prefix: str = '', number_of_sequences: int = 8) -> None>¶
- __wrapped__¶
alias of
HuggingFaceSeq2SeqGenerator
- algorithm_application: ClassVar[str] = 'HuggingFaceSeq2SeqGenerator'¶
Unique name for the application that is the use of this configuration together with a specific algorithm.
Will be set when registering to
ApplicationsRegistry
, but can be given by direct registration (Seeregister_algorithm_application
)
- algorithm_name: ClassVar[str] = 'HuggingFaceGenerationAlgorithm'¶
Name of the algorithm to use with this configuration.
Will be set when registering to
ApplicationsRegistry