Node.js: Vector Embeddings - #2837
Conversation
Correct the install command (full peer deps), config (nested embedding.model, no default), and framing (experimental, local dev only) for the ai-sqlite database kind.
@cap-js/ai now redirects the standard sqlite (and sqlite:memory) database instead of adding an ai-sqlite kind. A default embedding model exists (pin for stability); requires @sap/cds ^10.1 and @cap-js/sqlite ^3.1.
Drop the embedding.model config block and version details; @cap-js/ai works with no configuration (default model). Details in its README.
On SQLite the model-name argument to vector_embedding is ignored; the locally configured model is used. The same query runs unchanged on HANA and SQLite, so no 'local' placeholder is needed.
Remove the Database Implementation bullet list that restated the per-DB Database-Specific Considerations subsections; fold the HANA NLP/AI Core note into the SAP HANA subsection; link the local-testing info box down to the SQLite setup.
|
Note on the "lexical subword embeddings" wording (kept as-is per @MattSchur, flagging for discussion): On SQLite/H2 the default So "lexical subword embeddings" slightly oversells it: it captures character-n-gram overlap, not meaning. Two paraphrases with no shared trigrams score as unrelated. That's exactly why the doc then points to local ONNX models for real semantic embeddings — which is good — but readers may expect the default to already be semantic. Proposal for a follow-up: call the default something like "a deterministic hash-based emulation (character n-grams)" and reserve "embeddings" for the ONNX path. Leaving the current wording in place for now; @MattSchur let's align. |
- Merge SQLite/H2 emulation guidance under a single 'SQLite and H2' section with an ONNX-models subsection (Java LangChain4j + Node.js @cap-js/ai), and reduce the info box to a one-line pointer. - Fix the Query for Similarity Node.js example: repeat the vector_embedding expression in .where (a where clause can't reference a select-list alias) and use the alias only in .orderBy; add a note. - cds-data.md: state vector support for SAP HANA, SQLite and H2.
Co-authored-by: Matthias Schur <107557548+MattSchur@users.noreply.github.com>
This is exactly lexical (or surface) vs. semantic embeddings, but I agree "embedding" might be confused with "captures semantics". What about "Lexical Character-Hash Vectors"? |
|
@MattSchur agreed — "Lexical Character-Hash Vectors" nails it: lexical (surface, not semantic), character-hash (the FNV-1a hash of char n-grams), and vectors rather than embeddings so it doesn't imply meaning. Applied to the SQLite/H2 note:
Pushed to |
Per PR review: 'lexical subword embeddings' oversold the deterministic FNV-1a hash of character n-grams as semantic. Call it what it is.
Co-authored-by: Matthias Schur <107557548+MattSchur@users.noreply.github.com>
No description provided.