Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions guides/ai/embeddings.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ extend Incidents with {
}
```

:::tip Prefer calculated elements for vector embeddings
If the database calculates vector embeddings on write it automatically regenerates the embedding if the input data changes.
:::tip Calculated elements for vector embeddings
Database-calculated embeddings [on-write](../../cds/cdl#on-write) stay automatically consistent — the database regenerates the embedding whenever the input data changes, with no extra application code.

The trade-off is synchronous latency on every write. For SAP HANA native [NLP](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-vector-engine-guide/creating-text-embeddings-with-nlp-51eb170d038d4099a9bbb85c08fda888) models, this overhead is usually acceptable. For remote embedding services, or multitenant applications — computing embeddings asynchronously using the [Transactional Outbox](./events/event-queues) can offer better write throughput — if eventual consistency is acceptable.
:::

::: warning Embedding localized elements
A stored ([on-write](../../cds/cdl#on-write)) calculated element **cannot** reference [localized](../uis/localized-data) elements. Instead, embed the default language and use a **multilingual embedding model** so that queries in other languages still match.

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.

how does this work from a modeling perspective?

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.

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.

Currently only via a separate (non-localized) element with the default language. The compiler could use the default language column in the generated DDL to fix this.

:::

::: info Local Testing with H2 and SQLite
Expand Down
Loading