Trivial#

class recwizard.pipelines.trivial.configuration_trivial.TrivialConfig(**kwargs)[source]#
__init__(**kwargs)[source]#
Parameters:
  • WEIGHT_DIMENSIONS (dict, optional) – The dimension and dtype of module parameters. Used to initialize the parameters when they are not explicitly specified in module initialization. Defaults to None. See also recwizard.module_utils.BaseModule.prepare_weight().

  • **kwargs – Additional parameters. Will be passed to the PretrainedConfig.__init__.

class recwizard.pipelines.trivial.modeling_trivial.TrivialPipeline(config: BaseConfig | None = None, rec_module: BaseModule | None = None, gen_module: BaseModule | None = None, rec_tokenizer: BaseTokenizer | None = None, gen_tokenizer: BaseModule | None = None, **kwargs)[source]#
forward(input_ids, attention_mask, labels=None, **kwargs)[source]#

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

response(**kwargs)#

The main function for the model to generate a response given a query.

Parameters:
  • query (str) – The formatted dialogue history. See the format at First Example.

  • return_dict (bool) – if set to True, will return a dict of outputs instead of a single output.

  • rec_args (dict) – The arguments passed to the recommender module.

  • gen_args (dict) – The arguments passed to the generator module.

__init__(config: BaseConfig | None = None, rec_module: BaseModule | None = None, gen_module: BaseModule | None = None, rec_tokenizer: BaseTokenizer | None = None, gen_tokenizer: BaseModule | None = None, **kwargs)#

Initialize the model with the recommender/generator modules and the corresponding tokenizers.

If the tokenizers are not passed, the model will try to get the tokenizers by calling get_tokenizer on the modules.

Parameters:
  • config (BaseConfig) – The config file as is used in transformers.PreTrainedModel.

  • rec_module (BaseModule) – The recommender module.

  • rec_tokenizer (BaseTokenizer) – The tokenizer for the recommender module.

  • gen_module (BaseModule) – The generator module.

  • gen_tokenizer (BaseTokenizer) – The tokenizer for the generator module.

  • **kwargs – The other keyword arguments used for transformers.PreTrainedModel.