Skip to content

Refine vector embeddings docs - #2826

Merged
sjvans merged 2 commits into
node-embeddingsfrom
vector-embeddings-aug
Sep 3, 2026
Merged

Refine vector embeddings docs#2826
sjvans merged 2 commits into
node-embeddingsfrom
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
vkozyura
vkozyura previously approved these changes Aug 18, 2026
Comment thread guides/databases/vector-embeddings.md Outdated
```
- 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?

Comment thread guides/databases/vector-embeddings.md Outdated
::: 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.

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.

Comment thread guides/databases/vector-embeddings.md Outdated
- **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.

Comment thread guides/databases/vector-embeddings.md Outdated
```
- 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?

@sjvans
sjvans force-pushed the vector-embeddings-aug branch from 25bd72f to a173e4c Compare September 3, 2026 12:03
@sjvans
sjvans changed the base branch from main to node-embeddings September 3, 2026 12:03
@sjvans

sjvans commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Heads up @MattSchur @renejeglinsky @vkozyura — I rebased this branch and retargeted the base from main to node-embeddings (force-push with lease; your two commits and authorship are preserved).

Why: node-embeddings carries the Node.js vector-embedding docs for the upcoming @cap-js/ai local-ONNX support (landing in 1.2.0), and it edits the same lines as this PR. Rebasing here avoids a collision on main and lets the two efforts merge as one story.

During conflict resolution I made one factual change to this PR's content: where it read "CAP Java additionally allows local ONNX / Node not yet supported" (info box, DB-implementation bullets), I updated it to both runtimes — Java via LangChain4j, Node.js via @cap-js/ai — on the assumption 1.2.0 ships in time. @vkozyura, this reverses your earlier "not yet" on the ONNX question; please sanity-check. The local-MTXS-on-SQLite note still says ONNX is not yet wired there, which I believe is still accurate.

Everything else from this PR is kept as-is: the <Beta/>+Postgres warning, the HANA NLP/AI Core bullets, the REAL_VECTOR link, and the Java cross-links.

One open thread: @renejeglinsky asked whether the bare "not supported by CAP" for the Postgres vector_embedding() bullet is helpful enough. I bridged it to tell developers what to do instead (compute at app level, or define their own DB function). Happy to revert to the terser wording if you'd prefer.

@sjvans

sjvans commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

continuing in #2837

@sjvans
sjvans merged commit f0533a2 into node-embeddings Sep 3, 2026
4 of 5 checks passed
@sjvans
sjvans deleted the vector-embeddings-aug branch September 3, 2026 12:42
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.

4 participants