Skip to main content

Model Management

The Model Management section provides guidance on how to manage and configure models for analytics and semantic analysis tasks within FlockMTL. These tasks involve processing and analyzing text, embeddings, and other data types using pre-configured models, either system-defined or user-defined, based on specific use cases. Each database is configured with its own model management table during the initial load.

1. Model Configuration

Models are stored in a table with the following structure:

Column NameDescription
Model NameUnique identifier for the model
Model TypeSpecific model type (e.g., gpt-4, llama3)
ProviderSource of the model (e.g., openai, azure, ollama)
Model ArgumentsJSON configuration parameters such as context_window size and max_output_tokens

2. Management Commands

  • Retrieve all available models
GET MODELS;
  • Retrieve details of a specific model
GET MODEL 'model_name';
  • Create a new user-defined model
CREATE MODEL('model_name', 'model', 'provider', {'context_window': 128000, 'max_output_tokens': 8000})
  • Modify an existing user-defined model
UPDATE MODEL('model_name', 'model', 'provider', {'context_window': 128000, 'max_output_tokens': 8000});
  • Remove a user-defined model
DELETE MODEL 'model_name';

3. SQL Query Examples

Semantic Text Completion

SELECT llm_complete(
{'model_name': 'gpt-4'},
{'prompt_name': 'product-description'},
{'input_text': product_description}
) AS generated_description
FROM products;
SELECT llm_complete(
{'model_name': 'semantic_search_model'},
{'prompt_name': 'search-query'},
{'search_query': query}
) AS search_results
FROM search_data;

4. Global and Local Models

Model creation is database specific if you want it to be available irrespective of the database then make it a GLOBAL mode. Note that previously, the creation was specific to the running database, which is LOCAL by default and the keyword LOCAL is optional.

Create Models

  • Create a global model:
CREATE GLOBAL MODEL('model_name', 'model_type', 'provider', {'context_window': 128000, 'max_output_tokens': 8000})
  • Create a local model (default if no type is specified):
CREATE LOCAL MODEL('model_name', 'model_type', 'provider', {'context_window': 128000, 'max_output_tokens': 8000})
CREATE MODEL('model_name', 'model_type', 'provider', {'context_window': 128000, 'max_output_tokens': 8000})

Toggle Model State

  • Toggle a model's state between global and local:
UPDATE MODEL 'model_name' TO GLOBAL;
UPDATE MODEL 'model_name' TO LOCAL;

All the other queries remain the same for both global and local prompts.