# mdhaffar/named-entity-recognition architecture

> Architecture diagram of the GitHub repository mdhaffar/named-entity-recognition, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mdhaffar/named-entity-recognition
- Repository: https://github.com/mdhaffar/named-entity-recognition

## Overview

##### Project type and purpose
- This is a modular machine-learning training pipeline for spoken language understanding. It trains (a) an Automatic Speech Recognition (ASR) model, (b) a Text-to-ASR-Embeddings (T2AE) model, and (c) a Named Entity Recognition (NLU/SLU) model, then stitches them into an end-to-end system. It leverages PyTorch and SpeechBrain, driven entirely by Python scripts and YAML configs.

##### File structure
- Top-level scripts:
– train_ASR.py (uses wav2vec_ASR.yaml)
– train_NLU_from_TTS_emb.py (uses NER.yaml)
- Config files (YAML):
– wav2vec_ASR.yaml → ASR model settings
– NER.yaml → NLU model settings
- README.md for usage
There are no subdirectories, so each script is a standalone module in the pipeline.

##### Key insights from README
- Step 1: Train ASR
- Step 2: Extract last-layer ASR embeddings + train T2AE via SpeechBrain’s TTS recipe
- Step 3: Train NLU on extracted embeddings
- Step 4: Integrate ASR and SLU into an end-to-end flow

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration & Config Manager
    Orchestrator["Orchestration & Config Manager"]:::config
    click Orchestrator "https://github.com/mdhaffar/named-entity-recognition/blob/main/README.md"

    %% Data Ingestion & ASR Training
    Preprocess["Data Ingestion & Preprocessing"]:::data
    click Preprocess "https://github.com/mdhaffar/named-entity-recognition/blob/main/train_ASR.py"
    ASRTrain["ASR Training Module"]:::train
    click ASRTrain "https://github.com/mdhaffar/named-entity-recognition/blob/main/train_ASR.py"
    ASRConfig["ASR Config (wav2vec_ASR.yaml)"]:::config
    click ASRConfig "https://github.com/mdhaffar/named-entity-recognition/blob/main/wav2vec_ASR.yaml"

    %% Artifacts
    Audio["Raw Audio Files"]:::data
    Transcripts["Transcripts"]:::data
    Embeddings["ASR Latent Embeddings"]:::data

    %% Embedding Extraction
    EmbExtract["Embedding Extraction Layer"]:::train
    click EmbExtract "https://github.com/mdhaffar/named-entity-recognition/blob/main/train_ASR.py"

    %% T2AE Training
    T2AE["T2AE Training Module"]:::train
    click T2AE "https://github.com/mdhaffar/named-entity-recognition/blob/main/train_NLU_from_TTS_emb.py"

    %% NLU/NER Training
    NLUTrain["NLU/NER Training Module"]:::train
    click NLUTrain "https://github.com/mdhaffar/named-entity-recognition/blob/main/train_NLU_from_TTS_emb.py"
    NERConfig["NLU/NER Config (NER.yaml)"]:::config
    click NERConfig "https://github.com/mdhaffar/named-entity-recognition/blob/main/NER.yaml"

    %% Learned Mapping & Predictions
    Mapping["Learned Text→Embedding Mapping"]:::data
    Predictions["Named-Entity Predictions"]:::data

    %% Final Inference
    Inference["Final Inference Pipeline"]:::train

    %% External Dependency
    SpeechBrain["SpeechBrain Recipes"]:::external

    %% Flow
    Orchestrator -->|reads configs & launches scripts| Preprocess
    Preprocess -->|audio→ASR training| ASRTrain
    ASRTrain -->|uses config| ASRConfig
    ASRTrain --> Audio
    ASRTrain --> Transcripts
    ASRTrain --> Embeddings
    Embeddings --> EmbExtract
    EmbExtract --> T2AE
    Transcripts --> T2AE
    T2AE -->|outputs mapping| Mapping
    Mapping --> NLUTrain
    Embeddings --> NLUTrain
    NLUTrain -->|uses config| NERConfig
    NLUTrain --> Predictions
    ASRTrain --> SpeechBrain
    T2AE --> SpeechBrain
    Predictions --> Inference
    ASRTrain --> Inference

    %% Styles
    classDef data fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px
    classDef train fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px
    classDef config fill:#FFF9C4,stroke:#F57F17,stroke-width:2px
    classDef external fill:#FFCCBC,stroke:#BF360C,stroke-width:2px
```
