# hmohebbi/disentangling_representations architecture

> Architecture diagram of the GitHub repository hmohebbi/disentangling_representations, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hmohebbi/disentangling_representations
- Repository: https://github.com/hmohebbi/disentangling_representations

## Overview

This research codebase trains a two-stage information-bottleneck model to separate textual and acoustic features in pretrained speech representations, then evaluates and interprets those representations. The main workflow is speech data and pretrained-model features → stage-one transcription representation → stage-two task representation → probing or attribution. The README also documents corpus preparation, attention-based frame localization, and latent-space visualization. Some analysis and preprocessing files were not sampled, so their internal connections are shown only where documented; unsampled source was not inspected.

Main entry points: [`vib/training.py`](https://github.com/hmohebbi/disentangling_representations/blob/main/vib/training.py) (VIB training), [`probing/z_probing.py`](https://github.com/hmohebbi/disentangling_representations/blob/main/probing/z_probing.py) (Latent probing), [`analysis/compute_model_grads_wrt_input.py`](https://github.com/hmohebbi/disentangling_representations/blob/main/analysis/compute_model_grads_wrt_input.py) (Gradient attribution), [`probing/h_probing.py`](https://github.com/hmohebbi/disentangling_representations/blob/main/probing/h_probing.py) (Hidden-state probing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_corpus_prep["Corpus preparation"]
  node_mfa_prep["MFA corpus prep"]
  node_utils["Data and label utilities<br/>[utils.py]"]
end

subgraph group_model["Disentanglement"]
  node_training["VIB training<br/>[training.py]"]
  node_vib["VIB encoders and decoders<br/>[vib.py]"]
  node_text_stage["Textual stage<br/>[training.py]"]
  node_acoustic_stage["Acoustic stage<br/>[training.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_probe_model["Probe models<br/>[probe.py]"]
  node_hidden_probe["Hidden-state probing<br/>[h_probing.py]"]
  node_latent_probe["Latent probing<br/>[z_probing.py]"]
end

subgraph group_interpretation["Interpretation"]
  node_attention_extract["Attention extraction"]
  node_gradient_attr["Gradient attribution"]
  node_latent_viz["Latent visualization<br/>[tsne.py]"]
end

node_researcher(("Researcher"))
node_speech_data[("Speech datasets")]
node_speech_model["Pretrained speech model"]

node_researcher -->|"starts training"| node_training
node_speech_data -->|"loads splits"| node_training
node_speech_model -->|"extracts features"| node_training
node_training -->|"instantiates"| node_vib
node_training -->|"trains stage one"| node_text_stage
node_training -->|"trains stage two"| node_acoustic_stage
node_hidden_probe -->|"loads splits"| node_speech_data
node_hidden_probe -->|"extracts features"| node_speech_model
node_hidden_probe -->|"trains and evaluates"| node_probe_model
node_latent_probe -->|"loads splits"| node_speech_data
node_latent_probe -->|"extracts features"| node_speech_model
node_latent_probe -->|"loads latent models"| node_vib
node_latent_probe -->|"trains and evaluates"| node_probe_model
node_hidden_probe -->|"uses mappings"| node_utils
node_latent_probe -->|"uses mappings"| node_utils
node_training -->|"uses mappings"| node_utils
node_researcher -.->|"prepares corpus"| node_corpus_prep
node_mfa_prep -.->|"prepares alignments"| node_gradient_attr
node_researcher -->|"localizes frames"| node_attention_extract
node_acoustic_stage -->|"provides attention"| node_attention_extract
node_gradient_attr -->|"loads examples"| node_speech_data
node_gradient_attr -->|"computes gradients through"| node_speech_model
node_gradient_attr -->|"attributes predictions"| node_probe_model
node_gradient_attr -->|"loads alignments"| node_utils
node_latent_viz -.->|"loads examples"| node_speech_data
node_latent_viz -->|"extracts features"| node_speech_model
node_latent_viz -->|"embeds representations"| node_vib

click node_corpus_prep "https://github.com/hmohebbi/disentangling_representations/blob/main/preprocessing/dataset_generation.py"
click node_mfa_prep "https://github.com/hmohebbi/disentangling_representations/blob/main/analysis/preparing_corpus_for_mfa.py"
click node_training "https://github.com/hmohebbi/disentangling_representations/blob/main/vib/training.py"
click node_vib "https://github.com/hmohebbi/disentangling_representations/blob/main/vib/vib.py"
click node_text_stage "https://github.com/hmohebbi/disentangling_representations/blob/main/vib/training.py"
click node_acoustic_stage "https://github.com/hmohebbi/disentangling_representations/blob/main/vib/training.py"
click node_probe_model "https://github.com/hmohebbi/disentangling_representations/blob/main/probing/probe.py"
click node_hidden_probe "https://github.com/hmohebbi/disentangling_representations/blob/main/probing/h_probing.py"
click node_latent_probe "https://github.com/hmohebbi/disentangling_representations/blob/main/probing/z_probing.py"
click node_utils "https://github.com/hmohebbi/disentangling_representations/blob/main/utils.py"
click node_attention_extract "https://github.com/hmohebbi/disentangling_representations/blob/main/analysis/extract_attentions.py"
click node_gradient_attr "https://github.com/hmohebbi/disentangling_representations/blob/main/analysis/compute_model_grads_wrt_input.py"
click node_latent_viz "https://github.com/hmohebbi/disentangling_representations/blob/main/vib/tsne.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_corpus_prep,node_mfa_prep,node_utils toneBlue
class node_training,node_vib,node_text_stage,node_acoustic_stage,node_speech_data toneAmber
class node_probe_model,node_hidden_probe,node_latent_probe toneMint
class node_attention_extract,node_gradient_attr,node_latent_viz toneRose
class node_researcher,node_speech_model toneIndigo
```

## Components

### Data preparation

- [Corpus preparation](https://github.com/hmohebbi/disentangling_representations/blob/main/preprocessing/dataset_generation.py): `preprocessing/dataset_generation.py`
- [MFA corpus prep](https://github.com/hmohebbi/disentangling_representations/blob/main/analysis/preparing_corpus_for_mfa.py): `analysis/preparing_corpus_for_mfa.py`
- [Data and label utilities](https://github.com/hmohebbi/disentangling_representations/blob/main/utils.py): `utils.py`

### Disentanglement

- [VIB training](https://github.com/hmohebbi/disentangling_representations/blob/main/vib/training.py): `vib/training.py`
- [VIB encoders and decoders](https://github.com/hmohebbi/disentangling_representations/blob/main/vib/vib.py): `vib/vib.py`
- [Textual stage](https://github.com/hmohebbi/disentangling_representations/blob/main/vib/training.py): `vib/training.py`
- [Acoustic stage](https://github.com/hmohebbi/disentangling_representations/blob/main/vib/training.py): `vib/training.py`

### Evaluation

- [Probe models](https://github.com/hmohebbi/disentangling_representations/blob/main/probing/probe.py): `probing/probe.py`
- [Hidden-state probing](https://github.com/hmohebbi/disentangling_representations/blob/main/probing/h_probing.py): `probing/h_probing.py`
- [Latent probing](https://github.com/hmohebbi/disentangling_representations/blob/main/probing/z_probing.py): `probing/z_probing.py`

### Interpretation

- [Attention extraction](https://github.com/hmohebbi/disentangling_representations/blob/main/analysis/extract_attentions.py): `analysis/extract_attentions.py`
- [Gradient attribution](https://github.com/hmohebbi/disentangling_representations/blob/main/analysis/compute_model_grads_wrt_input.py): `analysis/compute_model_grads_wrt_input.py`
- [Latent visualization](https://github.com/hmohebbi/disentangling_representations/blob/main/vib/tsne.py): `vib/tsne.py`

### Other components

- **Researcher**
- **Speech datasets**
- **Pretrained speech model**

## Connections

- Researcher → VIB training: starts training (evidence: `README.md`)
- Speech datasets → VIB training: loads splits (evidence: `vib/training.py`)
- Pretrained speech model → VIB training: extracts features (evidence: `vib/training.py`)
- VIB training → VIB encoders and decoders: instantiates (evidence: `vib/training.py`)
- VIB training → Textual stage: trains stage one (evidence: `README.md`)
- VIB training → Acoustic stage: trains stage two (evidence: `README.md`)
- Hidden-state probing → Speech datasets: loads splits (evidence: `probing/h_probing.py`)
- Hidden-state probing → Pretrained speech model: extracts features (evidence: `probing/h_probing.py`)
- Hidden-state probing → Probe models: trains and evaluates (evidence: `probing/h_probing.py`)
- Latent probing → Speech datasets: loads splits (evidence: `probing/z_probing.py`)
- Latent probing → Pretrained speech model: extracts features (evidence: `probing/z_probing.py`)
- Latent probing → VIB encoders and decoders: loads latent models (evidence: `probing/z_probing.py`)
- Latent probing → Probe models: trains and evaluates (evidence: `probing/z_probing.py`)
- Hidden-state probing → Data and label utilities: uses mappings (evidence: `probing/h_probing.py`)
- Latent probing → Data and label utilities: uses mappings (evidence: `probing/z_probing.py`)
- VIB training → Data and label utilities: uses mappings (evidence: `vib/training.py`)
- Researcher → Corpus preparation: prepares corpus (evidence: `README.md`)
- MFA corpus prep → Gradient attribution: prepares alignments (evidence: `README.md`)
- Researcher → Attention extraction: localizes frames (evidence: `README.md`)
- Acoustic stage → Attention extraction: provides attention (evidence: `README.md`)
- Gradient attribution → Speech datasets: loads examples (evidence: `analysis/compute_model_grads_wrt_input.py`)
- Gradient attribution → Pretrained speech model: computes gradients through (evidence: `analysis/compute_model_grads_wrt_input.py`)
- Gradient attribution → Probe models: attributes predictions (evidence: `analysis/compute_model_grads_wrt_input.py`)
- Gradient attribution → Data and label utilities: loads alignments (evidence: `analysis/compute_model_grads_wrt_input.py`)
- Latent visualization → Speech datasets: loads examples
- Latent visualization → Pretrained speech model: extracts features (evidence: `vib/tsne.py`)
- Latent visualization → VIB encoders and decoders: embeds representations (evidence: `vib/tsne.py`)
