Trilogy NLP

SQL for Humans and AI

Trilogy-NLP aims to be a highly reliable platform for natural language interrogation of structured database contents. It aims to achieve this by mapping natural language queries to a well-defined but expressive middle layer (Trilogy!), which then executes the SQL to retrieve results. It aims be able to effectively generate queries rapidly without direct database access.

Principles:

  • High precision
  • No special syntax - the agents should work with what humans would
  • Performant - magic is more magic when it's fast
  • One-shot - iterative cycles shouldn't be a requirement to get a good answer

Installation

Trilogy NLP is available as a python package

pip install pytrilogy-nlp

Quickstart

Trilogy-NLPopen in new window is a Trilogy integration that adds natural language processing to Trilogy, enabling users to write queries in natural language and have them translated to SQL via the Trilogy semantic model. The simplified abstraction of a Trilogy model is natural fit for generative AI models, bypassing potential hallucination issues and SQL correctness challenges by focusing the model solely on interpreting the user query and mapping that to the higher level semantic layer.

WARNING

Trilogy-NLP is in active development and may not always return correct results. As with other generative AI tools, experimenting with what prompts produce the best results is recommended.

Trilogy-NLP can either be used in an interactive analytics context, as a helper for users to write queries, or as a backend for a chatbot or other natural language interface to a database.

You can experiment with querying the titanic dataset we've defined using Trilogy-NLP below.

TIP

You can view the generated SQL query just like with Trilogy - and you can also easily just generate Trilogy code. Trilogy-NLP is often a good place to start a query that can then be further refined.