Portable Language Model Guidance

Pyramid's internal Portable Language Model (PLM) engine is a small, fast, natural language engine that only operates in English. Due to its size, its interpretive capabilities are more limited when compared to Large Language Models (LLMs). Therefore, the following guidance is provided to help users get the best results from and natural language querying based on the PLM.

Note: For general advice on asking questions that applies across the engines, see Writing your Queries / Prompts.

Basics: Asking a Question

The following sections explain the basic elements of writing functional NLQ questions. A key aspect in understanding the depth and breadth of the NLQ engine is that the different concepts explained below and in the extended NLQ intelligence logic can and should be used in combination - allowing the user to build extremely sophisticated analytical content with fairly straight forward, plain English text.

Entities

At the most basic level the questions must include the names of one or more measures / values in the data model you're querying. Typically you would also include one ore columns / hierarchies from the model as well. These are known as "Entities" and they represent the "nouns" you are asking about as part of your analysis. For example "Show sales by product" tells the engine to find two entities - "sales" and "product" and then attempt to derive a query from that selection.

Multiple Entities

If a question references multiple entities, the engine will attempt to calculate the "Cartesian" result of those entities. For example "Show sales and expenses by promotion" tells the engine to calculate a query showing "sales" and "expense" data for each of the elements in the "product" hierarchy. Extending that to "Show sales and expenses by promotion and gender" tells the engine to calculate a query showing "sales" and "expense" data in the combination of elements of the "product" and "gender" hierarchies.

General Syntax

The next aspect relates to question syntax. The PLM engine is expecting normal English questions written the way a person would inquire about their data set. For example, "What were sales and expenses this year." While the engine can be forgiving on sentence structure, there are basic syntactical elements the user needs to provide in their question:

  • Spelling: While some spelling mistakes are ignored, the spelling of key entities (measure and hierarchies) is important. For instance typing in "SAL" instead of "SALES" will not produce a result. However, typing in "SALE" will work, due the intelligent word stemming framework in the engine. (See below.)
  • Grammar: Using correct grammar when asking your question is helpful and can, in some circumstances, drive slightly different outcomes. But it's not always critical - sometimes writing keywords alone will return the desired query. Correct grammar and use of prepositions will ensure that your question is interpreted most correctly, and the right result is returned. For example, if you want to know product sales over the last 4 quarters, write "what were product sales over the last 4 quarters?". Writing "product sales last 4 quarters." may not produce the same result.
  • Punctuation: While adding punctuation to your questions is also helpful, it is not critical. This includes commas, question marks, and periods. Generally the engine is not sensitive to case, however, proper casing names of geographic locations or names of people can provide the engine with a stronger hint that the item is a proper noun. Both of these elements are used in the advanced query intelligence.

Word Stemming

The PLM's internal smarts includes the ability to "stem" words or find known derivatives of a word to identify entities or other key words and phrases. Word stemming does not correct spelling issues, instead it solves the variations used by people to describe the same common thing. (However, this is not the same as finding related words like a thesaurus). For instance typing in "EXPENSIVE", the engine will attempt to find something called "Expensive", failing a direct hit, it will stem expensive and look for "Expense", "Expenses" etc. If you had a measure called "Expenses", the following would return a successful result "Show me the most expensive countries".

Thesaurus

In addition to the word stemming capabilities, the PLM engine includes a thesaurus - allowing users to type words that may NOT exactly match entities or key operations. Instead, the engine will ask the thesaurus for alternatives and attempt to use those in addition to the supplied syntax to find the best fitting query. Words from the thesaurus may also be run through the stemming engine above. For instance typing "Merchandise", the engine may find something like "Product" (stemmed to "Products"). Using "postcode" can be used interchangeably with "zip" or "zip code", or typing in "sex" may be swapped out for "gender".

Instructive Terms

Visuals

By default, the engine will draw the results of questions using the smart visualization engine, which uses augmented logic to resolve the best way to draw your results. However, you can instruct the engine to draw a specific visual by including the plain name of the chart type in the question text such as: grid, column chart, pie, line chart, and so on. For example "Show me sales by month in a grid".

  • To tell the engine to use the AI-suggested visualizations instead, use phrases like "recommend a visual" or "redraw" in the chat bot.
  • Click here for more details on how the visualizations work and overriding the automated choices.

Sorting

You can add sorting to your query by using phrases such as: highest, lowest, most, least, ascending, descending. For example "Show highest products by sales" will do a descending sorted list of products using the sales metric. "products by sales, descending" and "Which product had the most sales?" will achieve the same outcomes.

Note: By default, all "sort" commands are descending.

Filtering

You can add numeric filtering to your query by using phrases such as: Top x, Bottom x. For example "Show top 15 products by sales" will do a descending sorted list of top 15 products using the sales metric.

Advanced NLQ Intelligence

Beyond the basics described above, the NLQ engine has specialized capabilities for handling date and time, geospatial entities, proper nouns, and using advanced analytical methods. Understanding how these are accessed and how they work can greatly expand the functionality.