|
| 1 | +--- |
| 2 | +title: How to Alter Existing Knowledge Bases |
| 3 | +sidebarTitle: Alter KB |
| 4 | +--- |
| 5 | + |
| 6 | +The `ALTER KNOWLEDGE_BASE` command enables users to modify the configuration of the existing knowledge base without the need to recreate it. |
| 7 | + |
| 8 | +This document lists parameters that can be altered, explains the process and the effect on the existing knowledge base. |
| 9 | + |
| 10 | +## `ALTER KNOWLEDGE_BASE` Syntax |
| 11 | + |
| 12 | +Here is the syntax used to alter the existing knowledge base. |
| 13 | + |
| 14 | +```sql |
| 15 | +ALTER KNOWLEDGE_BASE <kb_name> |
| 16 | +USING |
| 17 | + <param_name> = <value>, |
| 18 | + ...; |
| 19 | +``` |
| 20 | + |
| 21 | +The following parameters can be altered: |
| 22 | + |
| 23 | +* `embedding_model` |
| 24 | + |
| 25 | + Users can alter only the API key of the provider used for the embedding model, while users cannot alter the provider and the model itself because it would be incompatible with the already embedded content that is stored in a knowledge base. |
| 26 | + |
| 27 | + ```sql |
| 28 | + ALTER KNOWLEDGE_BASE my_kb |
| 29 | + USING |
| 30 | + embedding_model = { 'api_key': 'new-api-key' }; |
| 31 | + ``` |
| 32 | + |
| 33 | + Upon altering the API key of the embedding model’s provider, ensure that the new API key has access to the same embedding model so that the knowledge base can continue to function without issues. |
| 34 | + |
| 35 | +* `reranking_model` |
| 36 | + |
| 37 | + Users can turn off reranking by setting `reranking_model = false`, or change the provider, API key, and model used for reranking. |
| 38 | + |
| 39 | + ```sql |
| 40 | + ALTER KNOWLEDGE_BASE my_kb |
| 41 | + USING |
| 42 | + reranking_model = { ‘provider’: ‘new_provider’, ‘model_name’: ‘new_model’, 'api_key': 'new-api-key' }; |
| 43 | + |
| 44 | + ALTER KNOWLEDGE_BASE my_kb |
| 45 | + USING |
| 46 | + reranking_model = false; |
| 47 | + ``` |
| 48 | + |
| 49 | + Upon updating the reranking model, the knowledge base will use the newly defined reranking model when reranking results, provided that reranking is turned on. |
| 50 | + |
| 51 | +* `content_columns` |
| 52 | + |
| 53 | + Users can change the content columns. |
| 54 | + |
| 55 | + ```sql |
| 56 | + ALTER KNOWLEDGE_BASE my_kb |
| 57 | + USING |
| 58 | + content_columns=['content_col1', 'conten_col2', ...]; |
| 59 | + ``` |
| 60 | + |
| 61 | + Upon changing the content columns, all the previously inserted content stays unchanged. Now the knowledge base will be embedding content from columns defined in the most recent call to `ALTER KNOWLEDGE_BASE`. |
| 62 | + |
| 63 | +* `metadata_columns` |
| 64 | + |
| 65 | + Users can change the metadata columns, overriding the existing metadata columns. |
| 66 | + |
| 67 | + ```sql |
| 68 | + ALTER KNOWLEDGE_BASE my_kb |
| 69 | + USING |
| 70 | + metadata_columns=['metadata_col1', 'metadata_col2', ...]; |
| 71 | + ``` |
| 72 | + |
| 73 | + Upon changing the metadata columns: |
| 74 | + - All metadata fields are stored in the knowledge base. No data is removed. |
| 75 | + - Users can filter only by metadata fields defined in the most recent call to `ALTER KNOWLEDGE_BASE`. |
| 76 | + - To be able to filter by all metadata fields, include them in the list as below. |
| 77 | + |
| 78 | + ```sql |
| 79 | + ALTER KNOWLEDGE_BASE my_kb |
| 80 | + USING |
| 81 | + metadata_columns=[‘existing_metadata_fields’, ..., 'new_metadata_fields', ...]; |
| 82 | + ``` |
| 83 | + |
| 84 | +* `id_column` |
| 85 | + |
| 86 | + Users can change the ID column. |
| 87 | + |
| 88 | + ```sql |
| 89 | + ALTER KNOWLEDGE BASE my_kb |
| 90 | + USING |
| 91 | + id_column='my_id'; |
| 92 | + ``` |
| 93 | + |
| 94 | + Upon changing the ID column, users must keep in mind that inserting data with an already existing ID value will update the existing row and not create a new one. |
| 95 | + |
| 96 | +* `storage` |
| 97 | + |
| 98 | + Users cannot update the underlying vector database of the existing knowledge base. |
| 99 | + |
| 100 | +* `preprocessing` |
| 101 | + |
| 102 | + Users can modify the [`preprocessing` parameters as defined here](/mindsdb_sql/knowledge_bases/insert_data#chunking-data). |
0 commit comments