Skip to main content
Knowledge accumulates your organisation's own query conventions. Question-SQL pairs teach Mimir how your organisation writes SQL, Instructions set the definitions and formatting an answer must follow, and both are scoped to a specific semantic model.

Knowledge

The same question can be answered by many different pieces of SQL, but every organisation has its own metric definitions, its own preferred columns and its own expectations about presentation. Knowledge is where those conventions are stored, so that Mimir's output matches what you actually expect instead of having to be re-explained in every conversation.

Open the Knowledge tab at the top and the left side splits into Question-SQL pairs and Instructions. Back to project in the top left returns to the project screen.

Knowledge is scoped to a semantic model

Knowledge belongs to the currently selected semantic model, not to the whole Project. Knowledge created under the POS store semantic model is invisible when you switch to the CRM membership semantic model, and the screen shows no data. Before adding or reviewing knowledge, check that the right semantic model is selected at the top.

Question-SQL pairs: teaching Mimir how you write SQL

One pair is a question plus the SQL you consider correct for it. Once saved, Mimir refers to that approach when it meets a similar question instead of deriving one from scratch every time.

Take store inventory in the retail project. The store_inventory table carries both store_id / store_name and sku / sku_name, and both on_hand and safety_stock. Which two columns to subtract for a shortfall, and whether to show a store's code or its name, are team conventions rather than something the data can decide. Write the convention down as a pair:

Question

哪些門市的聯名鈦保溫瓶低於安全庫存?

SQL statement

SELECT store_name, sku_name, on_hand, safety_stock, safety_stock - on_hand AS shortage
FROM retail_pos.store_inventory
WHERE sku = 'SKU-8801' AND on_hand < safety_stock
ORDER BY shortage DESC

This one pair settles three things at once: a shortfall is safety stock minus on-hand, the filter is on-hand below safety stock, and the output uses store_name and sku_name rather than codes.

The saved Question-SQL pair list: question, SQL and creation time

To add one, click Add question-SQL pair in the top right. The Question field takes the question itself, and SQL statement is an editor with syntax highlighting. When you have filled both in, Preview data runs the query once so you can confirm it returns something, then Submit saves it.

Adding a Question-SQL pair: the Question field and the SQL editor

The menu on each row offers Edit and Delete. Deleting asks for confirmation and warns that it cannot be undone.

The Edit and Delete menu on a list row

Instructions: setting how answers are given

An Instruction stores a rule rather than a query example, which suits the case where the numbers are right but the presentation is not. Continuing the example above, writing the same convention as a general rule saves preparing SQL for every related question:

回答門市庫存問題時,缺口一律定義為安全庫存減現有庫存,並以件為單位;
門市一律顯示 store_name 而不是 store_id,商品一律顯示 sku_name 而不是 sku。

A saved Instruction: the rule, its scope and its creation time

Click Add an instruction to add one. The form has two parts:

  • Apply instruction to: the scope. Global applies the rule to every question. Matched to relevant questions applies it only when a similar question is detected. The list's Matching questions column reflects this setting: the rule above was saved as Global, so it shows Global (all questions).
  • Instruction details: the rule itself, up to 3000 characters. The field's helper text asks for a rule Mimir should follow when generating SQL.

The Add an instruction form: the Global and Matched scopes, and the rule field

The choice of scope matters in practice. A column-display convention like the one above suits Global, because every store-inventory question should follow it. A rule that only holds in a specific situation, such as a special calculation during one campaign, should be Matched so it does not contaminate answers to other questions.

Which one to use

The two affect different stages: Question-SQL pairs affect how the query is written, Instructions affect how the answer is given.

  • When a metric keeps coming out wrong, or the wrong table keeps being queried, add a Question-SQL pair and give Mimir the correct approach directly.
  • When the numbers are right but the presentation is not, for example codes instead of names, inconsistent units, or a missing column you always use, add an Instruction.
  • When one convention covers both the calculation and the presentation, add both: the pair gets this question right, and the instruction makes other related questions follow the same rule.