Skip to main content

Models

Picking your favorite model is the final step in creating a RAG pipeline. LangDB allows you to plug in your desired LLM model and use it for generating responses. Currently, only OpenAI models are supported. As is with prompts, creating a model is as simple as composing a SQL query. After model creation, it can be run as a SQL function to generate responses based on the input text.

Creating a Model

We will be using the open_ai_provider created in the Providers section to create completions model.

To create a model, you need to use the CREATE MODEL SQL command.

CREATE MODEL sentiment_analysis(
input
) USING open_ai_provider(temperature = 0.3)
PROMPT ( system "Classify the text into neutral, negative, or positive
Text: {{input}}
Sentiment:" )
SETTINGS retries = 2;

This is the basic syntax for creating a model. For more advanced options, you can refer to the CREATE MODEL syntax.

Using a Model

Once you have created a model, you can use it to generate responses. The model can be run as a SQL function to generate responses based on the input text.

SELECT sentiment_analysis('This is a horrible TV show. The acting is terrible and the plot is boring.');

Deleting a Model

If you want to delete a model, you can use the DROP MODEL SQL command. Additionally, you can also specify the CASCADE keyword at the end to remove dependent prompts.

DROP MODEL sentiment_analysis;