# vietnamaihub/vietnamese_llms architecture

> Architecture diagram of the GitHub repository vietnamaihub/vietnamese_llms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vietnamaihub/vietnamese_llms
- Repository: https://github.com/vietnamaihub/vietnamese_llms

## Overview

##### Main Components
- Data Generation & Translation Module:
- “Generate_and_Translate_Dataset” directory as a component that handles both dataset generation (using human and machine-generated instructions) and translation.
- Dataset Generation: Include “Generation_instruction_OpenAI_api.py” that leverages the Alpaca template.
- Translation: Show two distinct translation pipelines – one using “Using_OpenAI_Translate_API.py” and one using “Using_NLLB_MetaAI_Translate.py.” Also, illustrate the input/output flow associated with the Vietnamese instruction datasets stored under “Vietnamese_Instructions_datasets” (with separated subfolders for Human-generated and Translation outputs).

- Model Fine-Tuning & Training Module:
- “LLMs” directory as a component used for fine-tuning language models. Indicate submodules for:
- Finetuning using LoRA (“Finetune_llm_LoRA.py”)
- Finetuning using QLoRA (“Finetune_llm_QLoRA.py”)
- Inference of fine-tuned models (“inference_llm.py”)
- Mention the integration with optimization tools (e.g., references to DeepSpeed in the “Utils/Deepspeed_config” directory).

- Web UI / Frontend Interface:
- “WebUI” directory as a component that hosts the user interface. This module (with “assistant_gradio.py”) is responsible for serving a Gradio-based demonstration, enabling users to interact with the fine-tuned models.

- Utility & Configurations:
- A “Utils” component that holds shared configurations such as DeepSpeed JSON files and dataset templates (like “alpaca.json”).
- Also, display how the licensing, environment setup (environment.yml), and contribution guidelines (contribute.md) support the overall system.

##### Important Architectural Patterns/Design Principles
- Separation of Concerns: Different components handle dataset generation, model fine-tuning, and user interaction.
- Extensibility: The design is modular; new translation methods or training pipelines can be added to the corresponding modules.
- Pipeline Flow: Emphasize the sequential process – from data generation to translation, then fine-tuning, and finally serving via an interactive UI.

##### Incorporate Relevant Technologies
- Under Data Generation, mention Python scripts and API integrations (OpenAI and NLLB).
- Under Model Training, note the use of fine-tuning techniques (LoRA, QLoRA), potentially backed by DeepSpeed (from the provided configuration files).
- Under UI, indicate the use of the Gradio framework.
- Also, briefly mark integration with external datasets and model checkpoints (referenced in the README with Hugging Face links).

- Every element, such as the datasets directory with its separate sub-folders (Human-generated, Translation – divided into Translational outputs with GPT-3.5, GPT-4, NLLB, etc.), is clearly annotated.
- Where appropriate, put in brief tool names (e.g., OpenAI API, MetaAI’s NLLB) that inform readers of the methods used.

– Starting with dataset generation and translation pipelines,
– Flowing into the fine-tuning/training process of LLMs,
– And ending with the Gradio-based Web UI that allows for model inference and demoing.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Data Generation & Translation Module
    subgraph "Data Generation & Translation"
        DG["Generate_and_Translate_Dataset"]:::backend
        GEN["Generation_instruction_OpenAI_api.py"]:::backend
        TRANS1["Using_OpenAI_Translate_API.py"]:::backend
        TRANS2["Using_NLLB_MetaAI_Translate.py"]:::backend
        DATASET["Vietnamese_Instructions_datasets"]:::data
        DG --> GEN
        DG --> TRANS1
        DG --> TRANS2
        TRANS1 -->|"Translation_Process"| DATASET
        TRANS2 -->|"Translation_Process"| DATASET
    end

    %% Model Fine-Tuning & Training Module
    subgraph "Model Fine-Tuning & Training"
        LLM["LLMs"]:::backend
        LORA["Finetune_llm_LoRA.py"]:::backend
        QLORA["Finetune_llm_QLoRA.py"]:::backend
        INF["inference_llm.py"]:::backend
        LLM --> LORA
        LLM --> QLORA
        LLM --> INF
        DATASET -->|"Dataset_Input"| LLM
    end

    %% Web UI / Frontend Interface
    subgraph "Web UI / Frontend"
        UI["assistant_gradio.py"]:::frontend
        INF -->|"Inference_Responses"| UI
    end

    %% Utility & Configurations
    subgraph "Utilities & Configurations"
        UTILS["Utils"]:::config
        DS["DeepSpeed Configs"]:::config
        TEMPLATE["Dataset Template (alpaca.json)"]:::config
        ENV["environment.yml"]:::config
        CONTRIBUTE["contribute.md"]:::config
        LIC["LICENSE"]:::config
        UTILS --> DS
        UTILS --> TEMPLATE
        UTILS --> ENV
        UTILS --> CONTRIBUTE
        UTILS --> LIC
        LLM ---|"Optimization"| DS
    end

    %% Click Events
    click DG "https://github.com/vietnamaihub/vietnamese_llms/tree/main/Generate_and_Translate_Dataset"
    click GEN "https://github.com/vietnamaihub/vietnamese_llms/blob/main/Generate_and_Translate_Dataset/Generation_instruction_OpenAI_api.py"
    click TRANS1 "https://github.com/vietnamaihub/vietnamese_llms/blob/main/Generate_and_Translate_Dataset/Using_OpenAI_Translate_API.py"
    click TRANS2 "https://github.com/vietnamaihub/vietnamese_llms/blob/main/Generate_and_Translate_Dataset/Using_NLLB_MetaAI_Translate.py"
    click DATASET "https://github.com/vietnamaihub/vietnamese_llms/tree/main/Generate_and_Translate_Dataset/Vietnamese_Instructions_datasets"
    click LLM "https://github.com/vietnamaihub/vietnamese_llms/tree/main/LLMs"
    click LORA "https://github.com/vietnamaihub/vietnamese_llms/blob/main/LLMs/Finetune_llm_LoRA.py"
    click QLORA "https://github.com/vietnamaihub/vietnamese_llms/blob/main/LLMs/Finetune_llm_QLoRA.py"
    click INF "https://github.com/vietnamaihub/vietnamese_llms/blob/main/LLMs/inference_llm.py"
    click DS "https://github.com/vietnamaihub/vietnamese_llms/tree/main/Utils/Deepspeed_config"
    click UI "https://github.com/vietnamaihub/vietnamese_llms/blob/main/WebUI/assisstant_gradio.py"
    click TEMPLATE "https://github.com/vietnamaihub/vietnamese_llms/blob/main/Utils/instructions_dataset_template/alpaca.json"
    click ENV "https://github.com/vietnamaihub/vietnamese_llms/blob/main/environment.yml"
    click CONTRIBUTE "https://github.com/vietnamaihub/vietnamese_llms/blob/main/contribute.md"
    click LIC "https://github.com/vietnamaihub/vietnamese_llms/tree/main/LICENSE"

    %% Styles
    classDef backend fill:#f9e1ff,stroke:#8a2be2,stroke-width:2px;
    classDef frontend fill:#cce5ff,stroke:#0056b3,stroke-width:2px;
    classDef config fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef data fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
