Skip to content

Refine vector embeddings docs - #2826

Open
MattSchur wants to merge 3 commits into
mainfrom
vector-embeddings-aug
Open

Refine vector embeddings docs#2826
MattSchur wants to merge 3 commits into
mainfrom
vector-embeddings-aug

Conversation

@MattSchur

Copy link
Copy Markdown
Contributor

No description provided.

@MattSchur
MattSchur requested a review from vkozyura August 18, 2026 11:16
vkozyura
vkozyura previously approved these changes Aug 18, 2026
```
- Vectors stored in native `vector` type
- `vector_embedding()` function must be defined by application developers for both testing and production use.
- `vector_embedding()` function is not supported by CAP.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the previous sentence more helpful to developers? Or let's say more explicit about what it means for CAP developers if they want to use such a function?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MattSchur @vkozyura What is your reply to my comment above?

@MattSchur MattSchur Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres is usually not used for testing but for production, so simple mock embeddings are not sufficient. For production, I don't think that implementing a vector_embedding function on Postgres is the best approach. I would rather go with computing the embeddings on app level or via an asynchronous vectorizer.

@vkozyura, @BobdenOs what's your take on that?

::: info Local Testing with H2 and SQLite
On H2 and SQLite the `CQL.vectorEmbedding` function is emulated using a hash-based algorithm to support local testing. For PostgreSQL, customers must define their own `vector_embedding` function for both testing and production use.
On H2 and SQLite the `CQL.vectorEmbedding` function is emulated to support local testing.
Both runtimes support a hash-based mock embedding, CAP Java additionally allows using local [ONNX](https://onnx.ai) embeddings models.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vkozyura Node ships ONNX support via @cap-js/ai, correct?

Suggested change
Both runtimes support a hash-based mock embedding, CAP Java additionally allows using local [ONNX](https://onnx.ai) embeddings models.
Both runtimes support a hash-based mock embedding, as well as local [ONNX](https://onnx.ai) embeddings models.

- **SQLite & H2:** Hash-based deterministic implementation for testing. Can be overridden by application developers to use external embedding services.
- **PostgreSQL:** No default implementation. Application developers must define their own `vector_embedding` function.
- **SAP HANA:** Uses embedding models from the [NLP](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-predictive-analysis-library/natural-language-processing-nlp) extension or an [SAP AI Core](https://help.sap.com/docs/sap-ai-core/sap-ai-core-service-guide/what-is-sap-ai-core) remote source.
- **SQLite & H2:** Hash-based mock embedding. CAP Java additionally allows using local [ONNX](https://onnx.ai) embeddings models.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **SQLite & H2:** Hash-based mock embedding. CAP Java additionally allows using local [ONNX](https://onnx.ai) embeddings models.
- **SQLite & H2:** Hash-based mock embedding or local [ONNX](https://onnx.ai) embeddings models.

```
- Vectors stored in native `vector` type
- `vector_embedding()` function must be defined by application developers for both testing and production use.
- `vector_embedding()` function is not supported by CAP.

@MattSchur MattSchur Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postgres is usually not used for testing but for production, so simple mock embeddings are not sufficient. For production, I don't think that implementing a vector_embedding function on Postgres is the best approach. I would rather go with computing the embeddings on app level or via an asynchronous vectorizer.

@vkozyura, @BobdenOs what's your take on that?

Using vector functions in [stored calculated elements](../../cds/cdl#on-write) with [local MTXS](../../guides/multitenancy/mtxs#test-drive-locally) on SQLite isn't supported.
::: warning Local MTXS on SQLite
Using vector functions in [stored calculated elements](../../cds/cdl#on-write) with [local MTXS](../../guides/multitenancy/mtxs#test-drive-locally) on SQLite
calls the custom functions of the CAP Node.js runtime. Using local [ONNX](https://onnx.ai) embedding models is not yet supported.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vkozyura would this work with @cap-js/ai? What model would be used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants