# AI & RAG Explained

## How the AI Generates Story

AI Wuxiaworld uses Large Language Models (LLMs) to generate narrative responses in real-time. When you make a choice, the AI:

1. Receives your action and current game state
2. Retrieves relevant passages from the original novel (RAG)
3. Recalls important memories from your playthrough
4. Generates a coherent narrative response with new choices

## What is RAG?

RAG (Retrieval-Augmented Generation) is our core technology for supplying source context to the model. Instead of relying solely on the AI's training data, we:

- Index the complete text of the original novel into a vector database
- Search for passages relevant to the current scene
- Feed those passages to the AI as context

The retrieved context supplies details such as character names, locations, power systems, and relationships. This can improve grounding and consistency, but it cannot guarantee that every generated detail is accurate.

## Pacing & Action Pricing

The AI also judges the *weight* of what you do. When you write a free-text action, a lightweight model estimates its narrative cost — a small gesture costs little, "seclude for three months" costs a lot. That cost feeds the chapter pacing budget (本章气数) and decides how fast the story advances toward the next chapter.

## Tracking Deviation

In Reforge mode, the AI also scores how far each turn pushes the story away from the original novel. This **deviation (偏离度)** accumulates across your run and contributes to its final score. The Reforge Board is not open yet; future ranking rules will be shown on the board itself.

## Why Responses May Vary

AI generation is inherently non-deterministic. The same choice may produce different narratives on different playthroughs. This is by design — it creates replayability and unique experiences.

## Content Disclaimer

AI-generated content may occasionally:

- Contain factual inconsistencies with the source material
- Produce unexpected narrative directions
- Vary in quality between responses

The AI is a creative tool, not a perfect author. Enjoy the unique stories it creates!
