langspace.probe.traversal package
Module contents
- class langspace.probe.traversal.TraversalProbe(model: LangVAE, data: Iterable[Sentence], sample_size: int, dims: List[int], annotations: Dict[str, List[str]] = None)[source]
Bases:
LatentSpaceProbeA probe for analyzing latent space traversal in an LM-VAE.
This probe performs a systematic traversal along specified latent dimensions. It first encodes a set of input sentences into latent representations, then perturbs these representations along each of the desired dimensions. The perturbed latent points are subsequently decoded back into sentences, allowing the user to inspect how modifications in particular latent dimensions affect the generated output.
- model
The LM-VAE model to be probed.
- Type:
LangVAE
- annotations
Optional dictionary of annotation types to be processed and all
- their possible values, for conditional encoding.
- report() DataFrame[source]
Generate a report detailing the latent space traversal results.
- Returns:
- A pandas DataFrame containing the traversal report with the following columns:
’seeds’: The source sentences.
’dim’: The latent dimension traversed.
’distance’: The perturbation magnitude used in the traversal.
’generate’: The generated sentence from the traversed latent point.
- Return type:
DataFrame