# simonaytes/sot architecture

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

- Interactive diagram: https://gitdiagram.com/simonaytes/sot
- Repository: https://github.com/simonaytes/sot

## Overview

##### Project Type and Purpose
- SoT is an open-source Python framework/library designed to enhance reasoning in language models. It does this by implementing three reasoning paradigms – Conceptual Chaining, Chunked Symbolism, and Expert Lexicons – and automatically selecting the optimal strategy using a pretrained DistilBERT model.
- It is intended to be integrated with various LLMs, as shown in the provided quickstart examples (using Qwen2.5 and other LLMs), and supports multiple output formats (llm, vlm, raw).

##### High-Level File Structure Analysis
- The top-level files include standard Python project files (LICENSE, README.md, pyproject.toml, requirements.txt) along with the main package directory “sketch_of_thought.”
- Within the sketch_of_thought package, the structure is organized into:
- The core module (sketch_of_thought.py) that likely implements primary functionality.
- A “config” directory holding configuration files and language-specific prompt files organized by language (EN, IT, DE, KR). This division reflects an architectural emphasis on supporting multilingual prompts.
- Other config resources like exemplars, label mappings, and warning utilities.
- This organization indicates a clear separation between the core logic, configuration/settings, and prompt data.

##### Key Components
a. Frontend/Client Interface (User Application):
- This element represents the caller or client that imports and uses the SoT module to classify questions and build the context for LLM interaction.
b. SoT Core Module:
- The central processing logic (sketch_of_thought.py) that exposes the API for classifying questions, retrieving prompts, and initializing context.
c. Configuration & Prompt Manager:
- The “config” folder, which is split into:
- General configuration files and settings (config.py, warnings, exemplars.json, label_mapping.json).
- Language-specific prompt directories (EN, KR, IT, DE) that provide system prompt files for each reasoning paradigm.
d. Paradigm Selection Model:
- Representation of the underlying pretrained DistilBERT model used for automatically selecting the appropriate reasoning paradigm based on the input question.
e. LLM Integration Layer:

##### Relationships and Data Flow
- That after classification, the system retrieves the matching language-specific system prompt from the Config/Prompts directories.
- Then, illustrate how the system uses helper functions (e.g., get_initialized_context) to format the output in one of the supported formats (llm, vlm, raw), resulting in a structured context integrated with exemplars.

##### Architectural Patterns and Technologies
- Separation of concerns: The configuration management (prompts, settings) is decoupled from core processing logic.
- The use of a pretrained DistilBERT model for auto-selection is a key design pattern—show this as a decision module within the overall workflow.
- Mention core libraries such as PyTorch (as indicated by the README badges), Hugging Face Transformers, and Python 3.10+.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client/Caller"]:::frontend
    B["Input (User Question)"]:::input
    C["SoT Core Module"]:::core
    D["Paradigm Selection Model (DistilBERT)"]:::decision

    subgraph "Configuration & Prompt Manager"
        subgraph "General Configurations"
            A1["Config File (config.py)"]:::configgrp
            A2["Exemplars (exemplars.json)"]:::configgrp
            A3["Label Mapping (label_mapping.json)"]:::configgrp
            A4["Warnings (warnings.py)"]:::configgrp
        end
        subgraph "Language-specific Prompts"
            B1["Prompt Files (DE/EN/IT/KR)"]:::configgrp
        end
    end

    J["Context Builder"]:::core
    K["LLM Integration"]:::llm

    A -->|"sends"| B
    B -->|"routes"| C
    C -->|"classifies"| D
    C -->|"fetches"| A1
    D -->|"selects"| B1
    A1 -->|"supplements"| B1
    B1 -->|"builds"| J
    J -->|"formats"| K

    click C "https://github.com/simonaytes/sot/blob/main/sketch_of_thought/sketch_of_thought.py"
    click A1 "https://github.com/simonaytes/sot/blob/main/sketch_of_thought/config/config.py"
    click A2 "https://github.com/simonaytes/sot/blob/main/sketch_of_thought/config/exemplars.json"
    click A3 "https://github.com/simonaytes/sot/blob/main/sketch_of_thought/config/label_mapping.json"
    click A4 "https://github.com/simonaytes/sot/blob/main/sketch_of_thought/config/warnings.py"
    click B1 "https://github.com/simonaytes/sot/tree/main/sketch_of_thought/config/prompts"

    classDef frontend fill:#f2d7d5,stroke:#d98880,stroke-width:2px;
    classDef input fill:#d5f5e3,stroke:#82e0aa,stroke-width:2px;
    classDef core fill:#d6eaf8,stroke:#85c1e9,stroke-width:2px;
    classDef decision fill:#fcf3cf,stroke:#f7dc6f,stroke-width:2px;
    classDef configgrp fill:#f9e79f,stroke:#f4d03f,stroke-width:2px;
    classDef llm fill:#e8daef,stroke:#af7ac5,stroke-width:2px;
```
