Lit Models¶
deepke.relation_extraction.few_shot.lit_models.base module¶
- class deepke.relation_extraction.few_shot.lit_models.base.BaseLitModel(model, device, args)[source]¶
Bases:
torch.nn.modules.module.ModuleGeneric PyTorch-Lightning class that must be initialized with a PyTorch module.
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
deepke.relation_extraction.few_shot.lit_models.transformer module¶
- deepke.relation_extraction.few_shot.lit_models.transformer.multilabel_categorical_crossentropy(y_pred, y_true)[source]¶
- class deepke.relation_extraction.few_shot.lit_models.transformer.BertLitModel(model, device, args, tokenizer)[source]¶
Bases:
deepke.relation_extraction.few_shot.lit_models.base.BaseLitModeluse AutoModelForMaskedLM, and select the output by another layer in the lit model
- forward(x)[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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.