Skip to content

Extend embeddings docs - #2788

Open
vkozyura wants to merge 4 commits into
mainfrom
extend-embeddings-page
Open

Extend embeddings docs#2788
vkozyura wants to merge 4 commits into
mainfrom
extend-embeddings-page

Conversation

@vkozyura

Copy link
Copy Markdown
Contributor

@vkozyura
vkozyura requested review from danjoa and smahati as code owners July 30, 2026 15:13
@vkozyura
vkozyura marked this pull request as draft July 30, 2026 15:13
@vkozyura
vkozyura removed the request for review from danjoa July 30, 2026 15:14
@vkozyura vkozyura changed the title Extend embeddings docs [DRAFT] Extend embeddings docs Jul 30, 2026
@vkozyura
vkozyura marked this pull request as ready for review July 31, 2026 11:57
@vkozyura vkozyura changed the title [DRAFT] Extend embeddings docs Extend embeddings docs Jul 31, 2026
@vkozyura
vkozyura requested review from BobdenOs and PDT42 August 4, 2026 07:40
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 to support local testing.
::: info Local Testing with SQLite and PostgreSQL
SAP HANA supports all vector functions including the `vector_embedding` function with real AI models. PostgreSQL supports vector functions when the pgvector extension is created, but does not support the `vector_embedding` function natively. A hash-based `vector_embedding` function is provided for both SQLite and PostgreSQL to avoid issues and crashes during development, but it is strongly recommended to override this function with a reasonable custom or third-party implementation for production use.

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.

Where did the h2 reference go ?
What is the purpose of mentioning that SAP HANA works in an info section ?
This comment mentions that for Postgres a hash version is delivered, but this is not currently the case.

We should probably add the information that for Postgres production the customers have to define their own vector_embedding function.

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.

changed. my hope was that compiler will deliver hash function soon.

Comment thread guides/databases/vector-embeddings.md Outdated
```
l2normalize(vector) → vector
```
Normalizes a vector to unit length.

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.

unit length being -1 to 1 ?

Comment thread guides/databases/vector-embeddings.md Outdated

**Database Implementation:**
- **HANA:** Uses real AI models (SAP built-in models or external remote sources)
- **SQLite & PostgreSQL:** Hash-based deterministic implementation for testing. Can be overridden by application developers to use external embedding services.

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.

Postgres function not currently automatically deployed.

@vkozyura vkozyura Aug 5, 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.

changed. again, I hoped for soon compiler change

Comment thread guides/databases/vector-embeddings.md Outdated
## Database-Specific Considerations

### SQLite
- Vector functions implemented as JavaScript UDFs

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.

I don't think we should document this internal details.

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.

removed sqlite section from here

Comment thread guides/databases/vector-embeddings.md Outdated
### SQLite
- Vector functions implemented as JavaScript UDFs
- Vectors stored as JSON strings
- No external dependencies required

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.

Sounds a bit weird when the future state is not mentioned.

Comment thread guides/databases/vector-embeddings.md Outdated
- Vector functions implemented as JavaScript UDFs
- Vectors stored as JSON strings
- No external dependencies required
- `vector_embedding()` uses hash-based algorithm for testing. Override the JavaScript function to use real embedding services in production.

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.

@cap-js/sqlite is not meant to be used for production.

Comment thread guides/databases/vector-embeddings.md Outdated
- `vector_embedding()` uses hash-based algorithm for testing. Override the JavaScript function to use real embedding services in production.

### PostgreSQL
- Requires creating the [pgvector extension](https://github.com/pgvector/pgvector) in the database:

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.

not just creating it is also required that the Postgres instance that they use already has the plugin binaries included.

Comment thread guides/databases/vector-embeddings.md Outdated
```
- Vectors stored in native `vector` type
- `vector_embedding()` SQL function uses hash-based algorithm for testing. Override the SQL function to use real embedding services in production.
- For Node.js, optional `pgvector` npm package for type registration: `npm install pgvector`

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.

Are the vector types optional for the client ? I guess if people run queries like:

SELECT * FROM Books WHERE cosine_similarity(description, vector_embedding(?, 'QUERY')) > 0.8

Then the ? will be a simple string. The client would not actually need to have the vector type support unless they explicitly query for the vector type.

Comment thread guides/databases/vector-embeddings.md Outdated
Comment on lines +174 to +177
- `vector_embedding()` supports built-in SAP models:
- `SAP_NEB.20240715` (German, English, Spanish, French, Portuguese - 768 dimensions)
- `SAP_GXY.20250407` (All above + Italian, Japanese, Chinese - 768 dimensions)
- Can use external remote sources (Azure OpenAI, SAP AI Core) as optional 4th parameter

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.

I think it would be better to exclude the specifics. So that the official SAP HANA help docs can be used as their source of truth directly instead. Otherwise we have to somehow know what models HANA has released in all possible SAP HANA versions.

```
:::

## Vector Functions

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.

We should consider simply referencing to the official SAP HANA documentation for these functions. As we are required to provide an equivalent implementation of those functions.

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.

As we are providing only subset of HANA functions, I list them here, but for more details i added link to HANA page.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants