CREATE KNOWLEDGE_BASE
Syntaxmy_kb
and associates the specified models and storage. my_kb
is a unique identifier of the knowledge base within MindsDB.
from_env()
function to pass parameters when creating knowledge bases.embedding_model
and reranking_model
parameters.
provider = 'openai'
embedding_model
and reranking_model
.
Custom OpenAI API
from the dropdown and use models from any OpenAI-compatible API.openai
as the model provider, users should define the following model parameters.
model_name
stores the name of the OpenAI model to be used.api_key
stores the OpenAI API key.provider = 'openai_azure'
embedding_model
and reranking_model
.
openai_azure
as the model provider, users should define the following model parameters.
model_name
stores the name of the OpenAI model to be used.api_key
stores the OpenAI API key.base_url
stores the base URL of the Azure instance.api_version
stores the version of the Azure instance.provider = 'google'
embedding_model
and reranking_model
.
google
as the model provider, users should define the following model parameters.
model_name
stores the name of the Google model to be used.api_key
stores the Google API key.provider = 'bedrock'
embedding_model
and reranking_model
.
When choosing bedrock
as the model provider, users should define the following model parameters.
model_name
stores the name of the model available via Amazon Bedrock.aws_access_key_id
stores a unique identifier associated with your AWS account, used to identify the user or application making requests to AWS.aws_region_name
stores the name of the AWS region you want to send your requests to (e.g., "us-west-2"
).aws_secret_access_key
stores the secret key associated with your AWS access key ID. It is used to sign your requests securely.aws_session_token
stores a temporary token used for short-term security credentials when using AWS Identity and Access Management (IAM) roles or temporary credentials.provider = 'snowflake'
reranking_model
.
When choosing snowflake
as the model provider, users should choose one of the available models from Snowflake Cortex AI and define the following model parameters.
model_name
stores the name of the model available via Snowflake Cortex AI.api_key
stores the Snowflake Cortex AI API key.snowflake_account_id
stores the Snowflake account ID.embedding_model
embedding_model
parameter to define the specification.
default_embedding_model
in the configuration file, you do not need to provide the embedding_model
parameter when creating a knowledge base. If provide both, then the values from the embedding_model
parameter are used.provider
It is a required parameter. It defines the model provider.
model_name
It is a required parameter. It defines the embedding model name as specified by the provider.
api_key
The API key is required to access the embedding model assigned to a knowledge base. Users can provide it either in this api_key
parameter, or in the OPENAI_API_KEY
environment variable for "provider": "openai"
and AZURE_OPENAI_API_KEY
environment variable for "provider": "azure_openai"
.
base_url
It is an optional parameter, which defaults to https://api.openai.com/v1/
. It is a required parameter when using the azure_openai
provider. It is the root URL used to send API requests.
api_version
It is an optional parameter. It is a required parameter when using the azure_openai
provider. It defines the API version.
reranking_model
false
.
reranking_model
parameter to define the specification.
default_reranking_model
in the configuration file, you do not need to provide the reranking_model
parameter when creating a knowledge base. If provide both, then the values from the reranking_model
parameter are used.provider
It is a required parameter. It defines the model provider as listed in supported LLMs.
model_name
It is a required parameter. It defines the embedding model name as specified by the provider.
api_key
The API key is required to access the embedding model assigned to a knowledge base. Users can provide it either in this api_key
parameter, or in the OPENAI_API_KEY
environment variable for "provider": "openai"
and AZURE_OPENAI_API_KEY
environment variable for "provider": "azure_openai"
.
base_url
It is an optional parameter, which defaults to https://api.openai.com/v1/
. It is a required parameter when using the azure_openai
provider. It is the root URL used to send API requests.
api_version
It is an optional parameter. It is a required parameter when using the azure_openai
provider. It defines the API version.
method
It is an optional parameter. It defines the method used to calculate the relevance of the output rows. The available options include multi-class
and binary
. It defaults to multi-class
.
multi-class
reranking method classifies each document chunk (that meets any specified metadata filtering conditions) into one of four relevance classes:relevance_score
of a document is calculated as the sum of each chunk’s class weight multiplied by its class probability (from model logprob output).The binary
reranking method simplifies classification by determining whether a document is relevant or not, without intermediate relevance levels. With this method, the overall relevance_score
of a document is calculated based on the model log probability.storage
storage
parameter. If not provided, the default ChromaDB is created when creating a knowledge base.
The available options include either PGVector or ChromaDB.
storage
parameter is not provided, the system creates the default ChromaDB vector database called <kb_name>_chromadb
with the default table called default_collection
that stores the embedded data. This default ChromaDB vector database is stored in MindsDB’s storage.
In order to provide the storage vector database, it is required to connect it to MindsDB beforehand.
Here is an example for PGVector.
storage_table
created as it is created when creating a knowledge base.metadata_columns
metadata_columns
cannot be used in content_columns
, and vice versa.id_column
and content_columns
) are considered metadata columns.
Here is an example of usage. A user wants to store the following data in a knowledge base.
product
column can be used as metadata to enable metadata filtering.
content_columns
content_columns
cannot be used in metadata_columns
, and vice versa.content
column is expected by default when inserting data into the knowledge base.
Here is an example of usage. A user wants to store the following data in a knowledge base.
notes
column can be used as content.
id_column
order_id
column can be used as ID.
id_column
parameter, the values from the provided source data column are used to identify source data rows within the knowledge base.
HASH()
or ROW_NUMBER()
.
id_column
parameter is not defined, its default values are build from the hash of the content columns and follow the format: <first 16 char of md5 hash of row content>
.DESCRIBE KNOWLEDGE_BASE
SyntaxDESCRIBE KNOWLEDGE_BASE
command.
DROP KNOWLEDGE_BASE
Syntax