> ## Documentation Index
> Fetch the complete documentation index at: https://docs.veadk.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Use local in-memory storage

The `local` backend stores knowledge in an in-memory vector index from LlamaIndex. Knowledge text is embedded by an embedding model, written to an in-process vector index, and retrieved by similarity. It requires no external service, is the **default backend** for `KnowledgeBase`, and is ideal for local debugging and quick validation.

<Warning>
  Data lives only in process memory and is lost when the program exits. Use a persistent backend in production.
</Warning>

## When to use

* Local debugging, teaching, or quickly validating a RAG flow;
* No external vector store required — only an embedding model.

## Dependencies

```bash lines theme={null}
pip install "veadk-python[extensions]"
```

## Usage

```python lines theme={null}
from veadk import Agent
from veadk.knowledgebase import KnowledgeBase

kb = KnowledgeBase(backend="local", index="company_faq")
kb.add_from_text("The standard annual leave is 15 days per year, available after one year of service.")

agent = Agent(
    name="demo",
    instruction="Answer the user; when needed, use the `load_knowledgebase` tool to search the knowledge base.",
    knowledgebase=kb,
)
```

You can also pass embedding config explicitly via `backend_config`:

```python lines theme={null}
from veadk.knowledgebase import KnowledgeBase
from veadk.configs.model_configs import EmbeddingModelConfig

kb = KnowledgeBase(
    backend="local",
    index="company_faq",
    backend_config={
        "index": "company_faq",
        "embedding_config": EmbeddingModelConfig(
            name="doubao-embedding-vision-250615",
            dim=2048,
        ),
    },
)
```

## Parameters

### Constructor parameters

`backend_config` supports the following settings:

| Parameter | Type | Default | Description |
| :- | :- | :- | :- |
| `index` | `str` | No default; provided by `KnowledgeBase` | Knowledge base index name. The local backend imposes no naming restrictions. |
| `embedding_config` | `EmbeddingModelConfig` | Read automatically from `MODEL_EMBEDDING_*` env vars | Embedding model config. |

### Embedding config

`embedding_config` is an `EmbeddingModelConfig` with env prefix `MODEL_EMBEDDING_`:

| Field | Env var | Type | Default | Description |
| :- | :- | :- | :- | :- |
| `name` | `MODEL_EMBEDDING_NAME` | `str` | `doubao-embedding-vision-250615` | Embedding model name. |
| `dim` | `MODEL_EMBEDDING_DIM` | `int` | `2048` | Embedding vector dimension. |
| `api_base` | `MODEL_EMBEDDING_API_BASE` | `str` | `https://ark.cn-beijing.volces.com/api/v3/` | API base of the embedding service. |
| `api_key` | `MODEL_EMBEDDING_API_KEY` | `str` | Falls back to `MODEL_AGENT_API_KEY`, then an auto-fetched Ark token | Key for accessing the embedding service. |

## Environment variables

```bash lines theme={null}
# Embedding model
export MODEL_EMBEDDING_NAME="doubao-embedding-vision-250615"
export MODEL_EMBEDDING_DIM=2048
export MODEL_EMBEDDING_API_KEY="your-ark-api-key"
```

<Note>
  The local backend depends only on an embedding model and requires no database connection config. Text is automatically split into chunks by file type before embedding.
</Note>
