EventStream.transformer.lightning_modules.embedding module¶
A PyTorch Lightning runnable module for getting embeddings from a pre-trained ESGPT model.
- class EventStream.transformer.lightning_modules.embedding.ESTForEmbedding(config: StructuredTransformerConfig | dict[str, Any], pretrained_weights_fp: Path)[source]¶
Bases:
LightningModuleA PyTorch Lightning Module for extracting embeddings only model.
- class EventStream.transformer.lightning_modules.embedding.EmbeddingsOnlyModel(config: StructuredTransformerConfig)[source]¶
Bases:
StructuredTransformerPreTrainedModelA “model” which simply retrieves the final embeddings from the encoder and returns them.
- forward(*args, **kwargs)[source]¶
Define 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.
- EventStream.transformer.lightning_modules.embedding.get_embeddings(cfg: FinetuneConfig)[source]¶
Gets embeddings.
Writes embeddings to
cfg.load_from_model_dir / "embeddings" / cfg.task_df_name / "{split}_embeddings.pt".- Parameters:¶
- cfg: FinetuneConfig¶
The fine-tuning configuration object specifying the cohort for which and model from which you wish to get embeddings.