Sponsored content
This guide “ai&publisher=kdnuggets” rel=”noopener” target=”_blank”>Five essential elements of each semantic layer“, can help you understand the breadth of the modern semantic layer.
The ai-powered data experience
The evolution of front-end technologies has made it possible to embed quality analytics experiences directly into many software products, further accelerating the proliferation of data products and experiences.
And now, with the advent of large language models, we are experiencing another radical shift in technology that will enable many new features and even the arrival of an entirely new class of products across multiple use cases and domains, including data.
LLMs are taking the data consumption layer to the next level with ai-powered data experiences ranging from chatbots that answer questions about your business data to ai agents that take actions based on signals and anomalies in the data.
<img decoding="async" alt="Semantic layer: the backbone of ai-powered data experiences” width=”100%” src=”https://technicalterrence.com/wp-content/uploads/2023/10/Semantic-layer-the-backbone-of-AI-powered-data-experiences.png”/><img decoding="async" src="https://technicalterrence.com/wp-content/uploads/2023/10/Semantic-layer-the-backbone-of-AI-powered-data-experiences.png" alt="Semantic layer: the backbone of ai-powered data experiences” width=”100%”/>
The semantic layer provides context to LLMs
LLMs are indeed a game-changer, but inevitably, as with all technology, they have their limitations. The LLMs amaze; The problem of garbage in and garbage out has never been more problematic. Let’s think about it like this: when humans find it difficult to understand inconsistent and disorganized data, LLM will simply compound that confusion to produce incorrect answers.
We can’t feed LLM the database schema and expect it to generate the correct SQL. To operate correctly and execute reliable actions, you need to have sufficient context and semantics about the data you consume; you must understand the metrics, dimensions, entities and relational aspects of the data that feed it. Basically, LLM needs a semantic layer.
The semantic layer organizes the data into meaningful business definitions and then allows you to query these definitions, rather than querying the database directly.
The application of ‘query’ is equally important as that of ‘definitions’ because it forces LLM to query data through the semantic layer, ensuring the correctness of the queries and the data returned. With that, the semantic layer solves the problem of LLM hallucinations.
<img decoding="async" alt="Semantic layer: the backbone of ai-powered data experiences” width=”100%” src=”https://technicalterrence.com/wp-content/uploads/2023/10/1697757540_941_Semantic-layer-the-backbone-of-AI-powered-data-experiences.png”/><img decoding="async" src="https://technicalterrence.com/wp-content/uploads/2023/10/1697757540_941_Semantic-layer-the-backbone-of-AI-powered-data-experiences.png" alt="Semantic layer: the backbone of ai-powered data experiences” width=”100%”/>
Additionally, the combination of LLM and semantic layers can enable a new generation of ai-powered data experiences. At Cube, we have already witnessed many organizations building custom LLM-based internal applications and startups like Delphi building out-of-the-box solutions on top of Cube’s semantic layer (demo here).
Aside from this cutting edge of development, we see Cube as an integral part of modern ai technology, sitting on top of data warehouses, providing context to ai agents, and acting as an interface to query data.
<img decoding="async" alt="Semantic layer: the backbone of ai-powered data experiences” width=”100%” src=”https://technicalterrence.com/wp-content/uploads/2023/10/1697757540_889_Semantic-layer-the-backbone-of-AI-powered-data-experiences.png”/><img decoding="async" src="https://technicalterrence.com/wp-content/uploads/2023/10/1697757540_889_Semantic-layer-the-backbone-of-AI-powered-data-experiences.png" alt="Semantic layer: the backbone of ai-powered data experiences” width=”100%”/>
The Cube data model provides structure and definitions that are used as context for LLM to understand the data and generate correct queries. LLM does not need to navigate complex joins and metric calculations because Cube abstracts them and provides a simple interface that operates on enterprise-level terminology instead of SQL table and column names. This simplification helps LLM to be less prone to errors and avoid hallucinations.
For example, an ai-based application would first read the Cube meta API endpoint, download all semantic layer definitions, and store them as embeddings in a vector database. Later, when a user submits a query, these embeds would be used in the message to LLM to provide additional context. LLM would then respond with a query generated to Cube and the application would execute it. This process can be chained and repeated multiple times to answer complicated questions or create summary reports.
Performance
As for response times, when working on complicated queries and tasks, the ai system may need to query the semantic layer multiple times, applying different filters.
Therefore, to ensure reasonable performance, these queries should be cached and not always sent to the underlying data stores. Cube provides a relational caching engine to create pre-aggregations over raw data and implements aggregate awareness to route queries to these aggregates when possible.
Security
And finally, security and access control should never be an afterthought when creating ai-based applications. As mentioned above, generating raw SQL and running it against a data warehouse can produce incorrect results.
However, ai poses an additional risk: since it cannot be controlled and can generate arbitrary SQL, direct access between ai and raw data stores can also be a significant security vulnerability. Instead, generating SQL through the semantic layer can ensure that granular access control policies are in place.
And more…
We have many exciting integrations with the ai ecosystem lined up and we can’t wait to share them with you. Meanwhile, if you’re working on an ai-powered app, consider trying Cube Cloud for free.
Download the guide “ai&publisher=kdnuggets” rel=”noopener” target=”_blank”>Five essential characteristics of each semantic layer” Learn more.