Configure question templates, terms, and business logic to expand the LLM's domain knowledge. This significantly improves the model's ability to understand business requirements and generate accurate data query code.
Overview
ChatBI uses a large language model (LLM) to understand natural language questions and generate SQL queries. Although the LLM has strong general capabilities, it needs additional domain knowledge for high accuracy in business-specific scenarios. The knowledge base is designed as a core feature for this purpose. The knowledge base supports three types of objects: Question Template, Term Management, and Business Logic.
Object type | Problem solved | Typical use cases |
Question template | Provides fast responses for recurring analytical queries | High-frequency queries (such as "monthly sales ranking by store"), complex multi-table joins, and scenarios that require precise field mapping |
Term management | Ensures accurate recognition of industry-specific and business-specific vocabulary | Abbreviations (such as "MoM" for month-over-month or "YoY" for year-over-year), multilingual terms, and synonym mapping |
Business logic | Standardizes business rules and calculation methods | Business metric definitions (such as "a valid order has an order amount > 0 and a status of Paid"), and data filtering rules |
Access the feature
Access the ChatBI portal.
Log in to Alibaba Cloud and open the ChatBI Intelligent Data Insights page. Select the access point that matches the region of your DataWorks resources, such as your dataset and serverless resource group.
In the left-side navigation pane, click Knowledge Base
to go to the knowledge base page.
Configure the knowledge base
The ChatBI knowledge base manages the following objects: Question Template, Term Management, and Business Logic.
Configure question templates
Go to the knowledge base page and click the Question Template tab. You can add question templates in two ways:
Add a template from the UI.
On the knowledge base page, click Add to open the Create Question Template page.
Configure the parameters for the question template:
Parameter
Description
Question
Define a common question used in sessions. For example:
Monthly sales trend of Product B in Store A.The question supports variables in the
${parameter_name}format. If you define variables here, you must provide enumerated or sample values in the Parameters field. For example:Monthly sales trend of ${commodityName} in ${shopName}.SQL
Provide an accurate and executable SQL query based on the question. If the question contains
${parameter_name}, the SQL must also include the same parameter name. For example:SELECT shop_name, commodity_name, sales, month FROM ads_order_table WHERE shop_Name = ${shopName} AND commodity_Name = ${commodityName} ORDER BY month;Parameter
If the question and SQL contain
${parameter_name}, provide enumerated or sample values for the parameters. For example:${parameter_name}: ["value1","value2","value3"]Datasets
Specify the datasets this question template applies to. If left empty, the template applies globally.
After you complete the configuration, click Save.
Bulk import from a local file.
On the knowledge base page, click Import and Add.
In the import dialog box, click Download Template. In the template file, fill in the Question Template, Template Script, Template Parameters, and Datasets columns. The parameters are the same as those used for UI configuration.
Drag and drop a local file, or click + in the dialog box to select the file to import.
After you add the file, click Confirm.
Recommendations
Prioritize high-frequency questions: Identify the top 20 most frequently asked questions and configure templates for them first.
Use parameters to improve reusability: Define variable parts (such as store names, product names, and time ranges) as ${parameter_name}. One template can then cover multiple similar questions.
Validate the SQL before saving: Run the SQL query on the dataset to verify that the syntax is correct and the results are as expected.
Configure term management
Go to the knowledge base page and click the Term Management tab. You can add terms in two ways:
Add a term from the UI.
Click Add to open the Create Term page.
Configure the key parameters for the term:
Parameter
Description
Term
A common or specialized word used in business communication and analysis. For example: month-over-month.
Alias
Synonyms, abbreviations, full names, or multilingual translations of the term. Press Enter after each alias to add multiple aliases.
Datasets
Specify the datasets this term applies to. If left empty, the term applies globally.
After you complete the configuration, click Save.
Bulk import from a local file.
On the knowledge base page, click Import and Add.
In the import dialog box, click Download Template. In the template file, fill in the Term, Alias, Description, and Datasets columns. The parameters are the same as those used for UI configuration.
Drag and drop a local file, or click + in the dialog box to select the file to import.
After you add the file, click Confirm.
Recommendations
Prioritize business-specific terms: Focus on adding industry jargon, abbreviations, and internal codenames that the LLM is unlikely to know.
Build a comprehensive alias system: For each term, configure its full name, abbreviation, informal expressions, and other forms. For example, aliases for "month-over-month" can include ["MoM", "Month over Month", "monthly growth rate"].
Avoid conflicts with common words: Do not configure terms for common words such as "order" or "user" unless they have a special business meaning.
Configure business logic
Go to the knowledge base page and click the Business Logic tab. You can add business logic in two ways:
Add business logic from the UI.
Open the Create Business Logic page.
Configure the key parameters for the business logic:
Parameter
Description
Business Concept
The name of a common concept in business communication and analysis. For example: valid order.
Logic Explanation
A definition for the business concept. For example: ord_cnt_1d > 0 indicates a valid order.
Datasets
Specify the datasets this business logic applies to. If left empty, the logic applies globally.
Field
After selecting a dataset, you can select fields from the tables in the dataset to associate the business concept with physical tables and fields.
After you complete the configuration, click Save.
Bulk import from a local file.
On the knowledge base page, click Import and Add.
In the import dialog box, click Download Template. In the template file, fill in the Business Concept, Logic Explanation, Associated table fields, and Datasets columns. The parameters are the same as those used for UI configuration.
Drag and drop a local file, or click + in the dialog box to select the file to import.
After you add the file, click Confirm.
Recommendations
Define key business metrics: Configure the calculation logic for core KPIs such as "valid orders", "active users", and "conversion rate" as business logic.
Be specific in logic explanations: Explain not only what the concept is, but also how to calculate it. For example: "valid order = valid_order_flag = 1 and sales_amount > 0".
Associate physical fields: Select all relevant fields involved in the business logic to help the model understand the relationships between fields.
Manage the knowledge base
Users can edit and delete knowledge base objects.
Edit a knowledge base object
In the left-side navigation pane, click Knowledge Base to go to the knowledge base page.
On the tab for the desired object type, click Edit in the Operation column to open the editing page.
The parameters are the same as described in Configure the knowledge base.
Search for a knowledge base object
Enter a keyword in the search box at the top of each knowledge base tab and press Enter to locate objects.
You can also click a knowledge base object to view its details.
Delete a knowledge base object
On the corresponding tab, find the knowledge base object and click Delete in the Operation column to remove the object from the knowledge base.