Knowledge Bases
The portable definition of a Knowledge Base: settings, never documents.
A Package carries how a Knowledge Base indexes and searches, and never the documents. The author's files are theirs, and the installer brings their own.
name: Product Docs
embedding:
slot: embedding
modelPreference: text-embedding-3-small
searchMode: hybrid
hybridAlpha: 0.6
indexConfig:
metadata:
use_builtin: true
fields:
- name: product
type: text
required: true
description: The product the document is about.
dataMode: schema-onlyRun npx @elizon/cli@<cliVersion> example knowledge-base for a complete project with a file like
this one. validate and build both check the file against the rules on this page.
| Field | Meaning |
|---|---|
name | Display name, 1–100 characters, unique in the project it installs into. |
embedding.slot | The llm Slot whose model builds and searches the index. |
embedding.modelPreference | The embedding model you would choose, or null. Used when the installer's LLM Configuration offers it; otherwise that Configuration's first embedding model is used. |
searchMode | How queries are matched: vector, keyword or hybrid. See Search modes. |
hybridAlpha | A number from 0 to 1: the balance between keyword and vector matching. Read only in hybrid mode. |
indexConfig | Index settings in their stored shape, or null for the defaults. See Index settings. |
dataMode | Always schema-only: the Knowledge Base is created empty and filled by the installer. Any other value is refused. |
Search modes
searchMode takes exactly one of three values. Any other value, including a different
capitalisation, is refused by validate and build with PORTABLE_DEFINITION_INVALID, and the
message lists the three. The platform refuses the same values when a Knowledge Base is created,
edited or imported. A value stored before this check existed was normalised to hybrid, which is
how it was already searched.
| Value | What a query does | hybridAlpha |
|---|---|---|
vector | Embeds the query and returns the chunks nearest in meaning. Finds paraphrases; can miss exact part numbers and codes. | Ignored. |
keyword | BM25 keyword ranking only; the query is never embedded. Finds exact words, codes and names; misses paraphrases. | Ignored. |
hybrid | Runs both and blends the scores. The default in Studio, and the right choice for most documentation. | 0 is all keyword, 1 is all vector. |
Index settings
indexConfig is the Knowledge Base's knowledge_base_config, in the shape Studio stores and
exports: { hnsw, bm25, metadata: { use_builtin, fields } }. null, an empty object, or any
section or key left out means the default below. The settings are fixed when the index is created;
the installer can change them later in Studio, which re-indexes.
Only the keys below are honoured. A key not listed here, at any level, is accepted and carried but
ignored, and validate and build warn KB_INDEX_CONFIG_KEY_IGNORED naming it (for example
indexConfig.hnsw.efConstruction), so check the spelling. The warning does not fail the command.
A listed key with a value of the wrong type, or an enum value not listed, is refused with
PORTABLE_DEFINITION_INVALID.
name: Product Docs
embedding:
slot: embedding
modelPreference: null
searchMode: vector
hybridAlpha: 0.5
indexConfig:
hnsw:
distance_metric: cosine
ef_construction: 128
max_connections: 16
ef: 64
bm25:
bm25_k1: 1.2
bm25_b: 0.75
metadata:
use_builtin: false
fields:
- name: product
type: text
required: true
description: The product the document is about.
- name: released
type: date
required: false
description: null
dataMode: schema-onlyhnsw: the vector index
| Key | Type | Default | Meaning |
|---|---|---|---|
distance_metric | string | cosine | How vector distance is measured: cosine, dot, l2-squared, hamming or manhattan. |
ef_construction | integer | 128 | Build-time search width. Higher builds a better index, more slowly. |
max_connections | integer | 16 | Links per node in the graph. Higher is more accurate and uses more memory. |
ef | integer | 64 | Query-time search width. Higher is more accurate and slower. -1 turns on dynamic ef (the three rows below). |
dynamic_ef_factor | integer | 8 | Only when ef is -1: ef becomes the result limit times this. |
dynamic_ef_min | integer | 100 | Only when ef is -1: the lower bound for that ef. |
dynamic_ef_max | integer | 500 | Only when ef is -1: the upper bound for that ef. |
vector_cache_max_objects | integer | 1000000000000 | How many vectors the index keeps in memory. |
bm25: the keyword index
| Key | Type | Default | Meaning |
|---|---|---|---|
bm25_k1 | number | 1.2 | Term-frequency saturation. Higher lets repeated words count for more. |
bm25_b | number | 0.75 | Length normalisation, 0 to 1. Higher penalises long chunks more. |
cleanup_interval_seconds | integer | 300 | How often the keyword index is cleaned up. |
index_timestamps | boolean | false | Index creation and update times, so they can be filtered on. |
index_null_state | boolean | false | Index whether a property is empty, so emptiness can be filtered on. |
index_property_length | boolean | false | Index property lengths, so length can be filtered on. |
bm25 is read in keyword and hybrid mode, hnsw in vector and hybrid mode; both indexes
are always built.
metadata: fields per document
| Key | Type | Default | Meaning |
|---|---|---|---|
use_builtin | boolean | false | Adds uploader, upload_date, last_update_date and source to every chunk. |
fields | list | [] | Fields the installer fills per document at upload. Agents and the Knowledge Search node can filter on them. |
Each entry of fields:
| Key | Type | Default | Meaning |
|---|---|---|---|
name | string | — | Required. A letter, then letters, digits and underscores; at most 230 characters. See below. |
type | string | — | Required. One of text, text[], int, int[], bool, number, number[], date, phone. |
required | boolean | false | Studio will not upload a document without a value for it. The API does not check it. |
description | string or null | null | Shown to the person uploading. |
A field name is refused with PORTABLE_DEFINITION_INVALID by validate and build, naming the
field (for example fields[0].name), when it:
- breaks the rule above, such as
2nd-fieldor_private; - is one the platform writes itself:
document_id,kb_id,source_id,chunk_index,document_nameandtext, which every chunk carries, oruploader,upload_date,last_update_dateandsource, whichuse_builtinadds (reserved even when it is off); - is one Weaviate keeps for itself:
id,_id,_additionalandvector; - repeats another field's name.
Names are compared ignoring case. Weaviate, which stores the index, treats two property names that
differ only in case as the same property, so Text clashes with text, and region and Region
are the same field. Weaviate's own names it compares exactly; refusing ID or Vector too is
deliberately stricter, so that no field has a name easily confused with one of them.
The platform applies the same rule when a field is added to a Knowledge Base: on create and edit it answers 422, and on import it answers 400.
A field stored before this check existed is left as it is:
- It stays editable. Saving the Knowledge Base's settings in Studio resends every stored field unchanged, and that save is accepted. Only a newly added field is checked, and it must not clash with any stored one.
- A Knowledge Base that holds such a field cannot be carried in a Package. Exporting it from Studio
into a Package fails with
PORTABLE_DEFINITION_INVALID, naming the field. - A Knowledge Base export file that holds such a field cannot be imported. Remove or rename the field in the file first.
The stored shape, not the API's
indexConfig uses the stored key names use_builtin and fields[].name. The knowledge-service
create API calls them use_builtin_metadata and field_name; the install renames them. Written
with the API names, use_builtin_metadata is ignored and a field with field_name but no name
is refused.
Chunking is not part of the definition
Chunking strategy, chunk_size and overlap are chosen per document, at upload, by whoever
uploads it. A Knowledge Base has no chunking settings of its own, and because a Package carries
no documents, there is nothing to put them on. See
Chunking strategies in the user guide.
The Slots it needs
slots:
- id: embedding
type: llm
required: true
description: The model used to index and search your documents.
boundTo: [knowledgeBases.product-docs]
- id: product-documents
type: knowledge-source
required: true
description: Your own product documentation.
boundTo: [knowledgeBases.product-docs]Choose the embedding model once
Changing a Knowledge Base's embedding model after its documents are indexed invalidates the index. Say so in the Slot's description.
At install
- The installer chooses the embedding model, then uploads files, connects a source (for example, a web page crawled with the pages under it), or skips.
- A skipped Knowledge Base is created empty and listed as outstanding. An empty Knowledge Base answers nothing, which looks like a broken Package, so the warning stays on the Package's page until it has content.
- Packages with Knowledge Bases install into a project, not the Organization level.
Link it to Agents with config.knowledge.knowledge_bases: [knowledgeBases.<name>] in the Agent's
definition. See Knowledge Bases for a
walkthrough.