# What Are STM Modules in G0DM0D3? A Complete Guide to Semantic Transformation

> Discover STM modules in G0DM0D3. Learn how these semantic transformation modules customize AI output, from removing hedging to changing formal text to casual speech.

- Repository: [pliny/G0DM0D3](https://github.com/elder-plinius/G0DM0D3)
- Tags: complete-guide
- Published: 2026-07-19

---

**STM (Semantic Transformation Modules) in G0DM0D3 are lightweight plug‑in transformers that modify raw AI output before it reaches the user, enabling custom linguistic styles like removing hedging phrases or converting formal text to casual speech.**

G0DM0D3 implements a modular text processing layer called **STM modules** that sits between the language model and the user interface. These self‑contained transformers allow developers and users to apply semantic modifications—such as stripping disclaimers or adjusting tone—without retraining the underlying AI. According to the elder‑plinius/G0DM0D3 source code, the system centers around a strict TypeScript interface and a functional pipeline that processes text through enabled modules sequentially.

## The STMModule Interface

The foundation of the system is defined in [`src/stm/modules.ts`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/stm/modules.ts), where every module must satisfy the **STMModule** contract. This interface, located at lines 6‑15, requires metadata fields—`id`, `name`, `description`, `version`, `author`, and `enabled`—alongside an optional `config` object.

The critical component is the `transformer` function, which receives the current text string and optional configuration, then returns the transformed string. This functional signature ensures that all modules remain pure, deterministic, and composable.

## Built‑in Semantic Transformation Modules

G0DM0D3 ships with three reference implementations that demonstrate common text normalization patterns. These are aggregated in the `allModules` array (lines 134‑138) for easy enumeration by the UI.

### hedgeReducer

The **hedgeReducer** module eliminates tentative language that weakens AI assertions. As implemented in [`src/stm/modules.ts`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/stm/modules.ts) at lines 21‑53, it removes phrases like “I think,” “maybe,” and “perhaps,” then re‑capitalizes sentences to maintain proper grammar and punctuation.

### directMode

**DirectMode** strips conversational filler from AI responses. Located at lines 59‑90 in [`src/stm/modules.ts`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/stm/modules.ts), it targets polite preambles such as “Sure, …” or “Of course, …” to deliver immediate, concise answers without social buffering.

### casualMode

The **casualMode** module rewrites formal vocabulary into conversational equivalents. According to the source at lines 96‑128, it substitutes words like “However” with “But” and “Utilize” with “Use,” adjusting the register without altering the underlying semantic meaning.

## Applying STM Modules with applySTMs

The **applySTMs** function serves as the main entry point for the transformation pipeline. Defined at lines 141‑152 in [`src/stm/modules.ts`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/stm/modules.ts), it iterates over the module array, executing only those where `enabled` is `true`. This function is invoked in [`src/components/ChatArea.tsx`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/components/ChatArea.tsx) to process raw AI output before it renders in the chat interface, ensuring that all active transformations are applied consistently.

```tsx
// 1️⃣ Import the STM utilities
import {
  allModules,
  applySTMs,
  type STMModule,
} from '@/src/stm/modules'

// 2️⃣ Enable the modules you want (e.g., via user settings)
const enabledModules: STMModule[] = allModules.map(m => ({
  ...m,
  enabled: m.id === 'hedge_reducer' || m.id === 'casual_mode', // enable two modules
}))

// 3️⃣ Transform a raw AI response
const rawResponse = "I think the solution is to utilize the API. However, you might want to consider alternative approaches."
const polished = applySTMs(rawResponse, enabledModules)

// polished now contains:
// "The solution is to use the API. But, you might want to consider alternative approaches."

```

## Creating Custom STM Modules

Developers can extend the system by creating objects that conform to the STMModule interface without modifying the core library. The following example demonstrates runtime registration of a custom transformer that adds emphasis to statements.

```tsx
// 4️⃣ Dynamically add a custom STM at runtime
const customEmphasis: STMModule = {
  id: 'emphasis',
  name: 'Emphasis Add‑On',
  description: 'Adds exclamation points to strong statements',
  version: '1.0.0',
  author: 'Your Name',
  enabled: true,
  transformer: (input) => input.replace(/\.$/g, '!') // replace final period with exclamation
}

// Use it together with the built‑ins
const modules = [...allModules, customEmphasis]
const result = applySTMs("The task is complete.", modules)

```

## Integration Architecture

The STM system integrates with the broader application through specific architectural touchpoints:

- **[`src/store/index.ts`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/store/index.ts)** persists user preferences regarding which modules are active across sessions.
- **[`src/components/SettingsModal.tsx`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/components/SettingsModal.tsx)** provides the UI surface where users toggle modules on and off, binding to the store.
- **[`research/eval_stm_precision.ts`](https://github.com/elder-plinius/G0DM0D3/blob/main/research/eval_stm_precision.ts)** contains a benchmark suite that evaluates how STM modules affect output quality, precision, and readability metrics.

## Summary

- **STM modules** are plug‑in transformers that modify AI output post‑generation to adjust tone, style, or clarity.
- The **STMModule interface** in [`src/stm/modules.ts`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/stm/modules.ts) enforces a consistent contract for metadata and transformation logic.
- Built‑in modules include **hedgeReducer**, **directMode**, and **casualMode** for common text normalization tasks.
- The **applySTMs** function orchestrates the pipeline, filtering for enabled modules only before rendering.
- Custom modules can be injected at runtime by conforming to the TypeScript interface and passing them to the transformation pipeline.

## Frequently Asked Questions

### What does STM stand for in G0DM0D3?

STM stands for **Semantic Transformation Modules**. These are lightweight, functional text processors that alter the style, tone, or structure of AI‑generated content before it is displayed to the user, acting as a post‑processing layer.

### How do I enable or disable STM modules in G0DM0D3?

User preferences are managed through the settings store in [`src/store/index.ts`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/store/index.ts) and exposed via the UI in [`src/components/SettingsModal.tsx`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/components/SettingsModal.tsx). You toggle the `enabled` boolean on specific module instances, and the `applySTMs` function automatically filters for active modules during the transformation pipeline.

### Can I create my own STM module without modifying the core codebase?

Yes. The system supports runtime injection of custom modules. As long as your object implements the STMModule interface—providing the required metadata and a `transformer` function—you can append it to the modules array and pass it to `applySTMs`, as demonstrated in the custom emphasis example.

### Where does the actual text transformation happen in the application lifecycle?

The transformation occurs in [`src/components/ChatArea.tsx`](https://github.com/elder-plinius/G0DM0D3/blob/main/src/components/ChatArea.tsx), where raw AI responses are piped through `applySTMs` immediately before being rendered in the chat interface. This ensures that all enabled semantic modifications are applied consistently to every message displayed to the user.