# priyanshu-profile/genteel-negotiator architecture

> Architecture diagram of the GitHub repository priyanshu-profile/genteel-negotiator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyanshu-profile/genteel-negotiator
- Repository: https://github.com/priyanshu-profile/genteel-negotiator

## Overview

##### Project type and purpose
- This is a research‐oriented machine‐learning system for polite negotiation dialogue, combining a mixture‐of‐experts architecture with reinforcement learning to train a negotiation agent (the “GENTEEL-NEGOTIATOR”).
- It provides data‐construction pipelines, a training loop (main.py), a specialized reward module (rewards_main.py), and built‐in evaluation metrics (BLEU, CIDEr, ROUGE, Word2Vec etc.).

##### File structure
Top level:
- GENTEEL-NEGOTIATOR/ – core code
- Sample_Data/ – example datasets
- README.md, GENTEEL-NEGOTIATOR_Appendix.pdf

Inside GENTEEL-NEGOTIATOR/:
- data/ – data ingestion & preprocessing
– ConstructDataset/, ConstructGraph/, ConstructSimulatorData/
– IND/ and NegoChat/ raw samples
- src/ – model components & utilities
– dataloader.py, model.py, classifiers.py, rewards.py, utils.py
- metrics/ – evaluation suite
– metric_utils.py, metrics.py, pycocoevalcap/ (BLEU, CIDEr, METEOR, ROUGE), word2vec/
- rewards/ – reward computation data loader & calculators
- main.py – orchestrates training & evaluation
- rewards_main.py – orchestrates reward‐based simulations

##### README
- Confirms: “LLM-Enhanced Mixture-of-Expert-based Reinforcement Learning”
- Sample data provided for IND and NeGoChat
- Paper reference to politeness markers & negotiation dialogue

a. Main components:
1. Data Ingestion & Preprocessing
- Raw data (IND, NeGoChat)
- ConstructDataset, ConstructGraph, ConstructSimulatorData modules
2. DataLoader & Feature Extraction
- src/dataloader.py, src/utils.py
3. Model Architecture
- Mixture-of-Experts policy network (src/model.py)
- Classifiers for politeness or other dialogue acts (src/classifiers.py)
4. Reinforcement Learning Engine
- Training loop in main.py
- Interaction with simulated environment (uses ConstructSimulatorData)
5. Reward Modules
- Custom rewards (rewards/construct_dataset.py, rewards/rewards_dataloader.py)
- rewards_main.py to kickoff reward‐driven simulations
6. Evaluation Suite
- In‐training metrics (metrics/metric_utils.py, metrics/metrics.py)
- Standard NLP metrics (pycocoevalcap, word2vec)

b. Relationships & interactions:
- Raw Data → Data Construction (graph & dataset constructors) → DataLoader
- DataLoader → Model (Mixture-of-Experts + LLM embeddings)
- Model ⇄ Environment (policy generates utterances → environment returns state/reward)
- Environment uses Reward Modules to compute reward signals
- Training Loop updates Model parameters using rewards
- Final model outputs → Evaluation Suite → Metric reports

c. Architectural patterns & design principles:
- Pipeline pattern for data processing
- Modular separation: data / model / reward / metrics
- Reinforcement Learning loop decoupled from data constructors
- Mixture-of-Experts layer for modular policy components

d. Key technologies & frameworks:
- Python (all modules)
- PyTorch or TensorFlow (implied in src/model.py)
- pycocoevalcap for standard NLP metrics
- Word2Vec/Glove conversion scripts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration
    subgraph "Orchestration Scripts"
        MAIN["main.py"]:::orchestration
        RMAIN["rewards_main.py"]:::orchestration
    end

    %% Data & Preprocessing
    subgraph "Data & Preprocessing" 
        direction TB
        RawIND[(sample_IND.csv)]:::data
        RawNC[(readme.md)]:::data
        subgraph "ConstructDataset" 
            direction TB
            CD1["construct_dataset.py"]:::data
            CD2["extraction.py"]:::data
            CD3["politeness_extract.py"]:::data
            CD4["utils.py"]:::data
        end
        subgraph "ConstructGraph"
            direction TB
            CG1["construct_graph.py"]:::data
            CG2["extraction.py"]:::data
            CG3["politemarker.py"]:::data
            CG4["utils.py"]:::data
        end
        subgraph "ConstructSimulatorData"
            direction TB
            CS["construct_dataset.py"]:::data
        end
    end

    %% DataLoader & Feature Extraction
    subgraph "DataLoader & Feature Extraction"
        direction TB
        DL["dataloader.py"]:::data
        DLU["utils.py"]:::data
    end

    %% Model & Policy Network
    subgraph "Model Architecture" 
        direction TB
        MODEL["model.py"]:::model
        GATE{Expert Selection}:::model
        EXP1["Expert A"]:::model
        EXP2["Expert B"]:::model
        CLASS["classifiers.py"]:::model
    end

    %% Reinforcement Learning Loop
    subgraph "Reinforcement Learning Engine"
        direction TB
        ENV("Environment"):::model
    end

    %% Reward Modules
    subgraph "Reward Modules"
        direction TB
        RCD["construct_dataset.py"]:::reward
        RDL["rewards_dataloader.py"]:::reward
        SRW["src/rewards.py"]:::reward
    end

    %% Evaluation Suite
    subgraph "Evaluation & Metrics"
        direction TB
        MU["metric_utils.py"]:::metric
        M["metrics.py"]:::metric
        subgraph "pycocoevalcap" 
            direction TB
            B["bleu.py"]:::metric
            CI["cider.py"]:::metric
            ME["meteor.py"]:::metric
            RO["rouge.py"]:::metric
        end
        subgraph "word2vec"
            direction TB
            W2V["evaluate.py"]:::metric
            GW["generate_w2v_files.py"]:::metric
            GV["glove2word2vec.py"]:::metric
        end
    end

    %% Connections
    MAIN -->|"uses"| RawIND
    MAIN -->|"uses"| RawNC
    RawIND -->|"fed into"| CD1
    RawIND --> CD2
    RawIND --> CD3
    RawNC -->|"fed into"| CG1
    RawNC --> CG2
    RawNC --> CG3
    CD1 --> DL
    CD4 --> DL
    CG1 --> DL
    CG4 --> DL
    CS --> ENV
    DL -->|"features"| MODEL
    MODEL --> GATE
    GATE --> EXP1
    GATE --> EXP2
    MODEL --> CLASS
    MODEL -->|"action"| ENV
    ENV -->|"state/reward"| MODEL
    ENV --> RCD
    ENV --> RDL
    RCD --> RMAIN
    RDL --> RMAIN
    RMAIN --> MODEL
    MODEL -->|"trained model"| MU
    MODEL --> M
    M --> B
    M --> CI
    M --> ME
    M --> RO
    M --> W2V
    M --> GW
    M --> GV

    %% Click Events
    click CD1 "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructDataset/construct_dataset.py"
    click CD2 "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructDataset/extraction.py"
    click CD3 "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructDataset/politeness_extract.py"
    click CD4 "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructDataset/utils.py"
    click CG1 "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructGraph/construct_graph.py"
    click CG2 "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructGraph/extraction.py"
    click CG3 "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructGraph/politemarker.py"
    click CG4 "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructGraph/utils.py"
    click CS "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/ConstructSimulatorData/construct_dataset.py"
    click RawIND "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/IND/sample_IND.csv"
    click RawNC "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/data/NegoChat/readme.md"
    click DL "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/src/dataloader.py"
    click DLU "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/src/utils.py"
    click MODEL "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/src/model.py"
    click CLASS "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/src/classifiers.py"
    click MAIN "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/main.py"
    click RCD "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/rewards/construct_dataset.py"
    click RDL "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/rewards/rewards_dataloader.py"
    click SRW "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/src/rewards.py"
    click RMAIN "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/rewards_main.py"
    click MU "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/metric_utils.py"
    click M "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/metrics.py"
    click B "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/pycocoevalcap/bleu/bleu.py"
    click CI "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/pycocoevalcap/cider/cider.py"
    click ME "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/pycocoevalcap/meteor/meteor.py"
    click RO "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/pycocoevalcap/rouge/rouge.py"
    click W2V "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/word2vec/evaluate.py"
    click GW "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/word2vec/generate_w2v_files.py"
    click GV "https://github.com/priyanshu-profile/genteel-negotiator/blob/main/GENTEEL-NEGOTIATOR/metrics/word2vec/glove2word2vec.py"

    %% Styles
    classDef data fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef model fill:#e2f5e9,stroke:#238636,color:#238636
    classDef reward fill:#fff5e5,stroke:#d29922,color:#d29922
    classDef metric fill:#f3e8ff,stroke:#6f42c1,color:#6f42c1
    classDef orchestration fill:#f0f0f0,stroke:#444444,color:#444444
```
