Skip to main content

Magic tips

Make the most of Hex Magic.

Like all AI-driven features, accuracy can vary based on the model, prompt, and other factors. To improve your querying success and give a sense of what you can do, here's some specific examples and advice on how best to work with Magic.

Magic knows about table and column metadata

Magic has context on your tables and schemas that allow it to map to the most relevant data objects. Adding descriptions on your databases, schemas, tables, and columns in the Data manager can improve Magic's responses that reference these objects.

Being as specific as possible in your prompt and using @ tagging to reference tables and dataframes will improve response accuracy.

Magic knows what's going on in the rest of your project

Magic also has metadata on your project, so it can reference dataframes and variables that have been created earlier. In the example below, just asking a question about orders prompts Magic to access the orders dataframe from a previous query. It also has access to the columns and datatypes, so it can intelligently operate on the data.

Similarly, if pandas had already been imported in an earlier stage, Magic would have seen that and not re-imported it.

Magic does not know about your data

Magic only has access to metadata, not row-level data. This is done intentionally to make Magic as secure & private as possible, but it means there are some families of tasks Magic has trouble with.

Here, Magic incorrectly attempts to sum a WEIGHT column with data that still has 'lbs' appended to it, since it doesn't know what that column actually looks like. Providing a simple example of the data in your prompt resolves the problem. You can also add a description to this column in the Data Manager so that Magic knows the format.

Some key situations where a lack of row-level data access shows:

  • Blind operations or transforms where knowing what a string looks like is critical (like above).

  • Complex joins where the join column needs to be transformed or compound keys are required. e.g: "find the matching columns containing user join information and use them to join tables".

  • Anything else that requires specific knowledge of what a row of data looks like.

It helps to be precise

Magic can be a bit like water, taking the path of least resistance if you aren't specific. Reference specific columns, tables, and give examples of your ideal output to make Magic as accurate as possible.

  • Reference a specific table name to get a fine-tuned result:
  • Specify exactly the shape of the output you want:

On this page