# Configure semantics and standard Q&A

Semantic configuration adds business definitions so agents can interpret material and questions. In knowledge-base details, **Semantic configuration** separates **NL2SQL**, for structured queries, from **RAG**, for document retrieval and answers. Choose the area matching your material.

| Problem | Starting point |
| --- | --- |
| A document answer misunderstands a term or condition | RAG business rules |
| Repeated questions need an approved answer | RAG standard Q&A |
| Incorrect metrics, joins, or structured-query definitions | The corresponding NL2SQL setting |

## RAG: add document business rules

Rules explain how to interpret associated files, including terminology and applicable conditions.

1. Select **RAG → Business rules** and create a rule.
2. Enter its identifier and select associated files.
3. Describe conditions, interpretation, and exclusions in natural language.
4. Save, check the list, and test representative questions.

Identifiers support up to 50 characters and must use lowercase English letters, underscores, or hyphens, such as `product_term_rule`. The file selector supports searching and multiple selections. Only files with completed parsing and embedding can be selected. Check processing in the Knowledge tab if a new file is missing.

Example rule: “In this document, a valid order is paid and has not been fully refunded. Exclude canceled orders. This definition applies only to the business described in this file.”

## RAG: configure standard Q&A

Open **RAG → Standard Q&A** and create an entry to maintain approved questions and answers.

| Field | How to fill it |
| --- | --- |
| Identifier (required) | Up to 50 characters: lowercase English letters, underscores, or hyphens |
| Description | Optional, up to 200 characters describing scope |
| Associated files (required) | Search and select processed files supporting the answer |
| Usage mode (required) | Reference or mandatory use, as described below |
| Standard question (required) | The common wording of the question |
| Similar questions | Enter an equivalent wording and select Add; repeat as needed |
| Standard answer (required) | Business-approved content suitable for the user |

| Mode | Meaning | Suitable use |
| --- | --- | --- |
| Reference | Interpret together with files and other semantic configuration | Answers requiring the user's specific conditions |
| Mandatory | Use the standard answer directly when intent, business object, and key conditions match | Fixed answers with a clearly defined scope |

Similar questions must preserve the business object, period, and key conditions. “What was this period's revenue?” and “What was last period's revenue?” should not share an answer merely because their wording is similar.

After saving, test the standard question, an equivalent wording, and a question with different key conditions. Verify consistency for the first two and absence of inappropriate reuse for the third.

(nl2sql-semantics)=

## NL2SQL: explain structured-query definitions

NL2SQL turns natural-language questions into structured queries. Import and inspect business tables first, then maintain the relevant definitions.

| Entry | Purpose | Prepare |
| --- | --- | --- |
| Metrics | Define values such as revenue or active-customer count | Definition, unit, calculation, and filters |
| Business rules | Explain business conditions governing a query | Scope, inclusions, and exclusions |
| Table relationships | Define joins | Join fields and one-to-one or one-to-many relationships |
| Standard Q&A | Supply an approved reference for common queries | Typical questions, expected definitions, and verifiable results |
| Advanced configuration | Add table/field descriptions, mandatory constraints, and dynamic queries | Field meanings, filters, and read-only queries |

Select associated data and enter the business definition in the current form, save, and inspect the list. NL2SQL uses tables and its own fields; RAG's file-Q&A form does not apply directly.

For “net revenue,” confirm currency units, refund treatment, and the time field, then compare a short period with a calculation from the source table.

## Import and export semantics

Use the semantic import and export entries to exchange configuration. Inspect exported files. For import, follow the accepted format and verify that associated files or tables match the target knowledge base. Check saved lists and actual answers afterward; uploading a file is not business validation.

## Structured configuration guides

- [Metrics and filters](nl2sql-metrics.md): base metrics, derived formulas, and AND/OR groups.
- [Business rules, table relationships, and standard Q&A](nl2sql-rules.md): interpretation, JOIN previews, and read-only SQL.
- [Advanced configuration](nl2sql-advanced.md): descriptions, mandatory constraints, dynamic queries, and result handling.

```{toctree}
:maxdepth: 1
:hidden:

nl2sql-metrics
nl2sql-rules
nl2sql-advanced
```
