Skip to content

Node.js: Vector Embeddings - #2837

Merged
sjvans merged 18 commits into
mainfrom
node-embeddings
Sep 4, 2026
Merged

Node.js: Vector Embeddings#2837
sjvans merged 18 commits into
mainfrom
node-embeddings

Conversation

@sjvans

@sjvans sjvans commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

No description provided.

sjvans and others added 9 commits August 26, 2026 10:06
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.
MattSchur and others added 4 commits September 3, 2026 14:42
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.
Comment thread guides/ai/embeddings.md Outdated
Comment thread guides/ai/embeddings.md Outdated
Comment thread java/cds-data.md Outdated
Comment thread guides/ai/embeddings.md Outdated
@sjvans

sjvans commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Note on the "lexical subword embeddings" wording (kept as-is per @MattSchur, flagging for discussion):

On SQLite/H2 the default vector_embedding emulation isn't a learned/semantic embedding — verifying against cds-dbs (sqlite/lib/SQLiteService.js, the VECTOR_EMBEDDING default), it's a deterministic hash: lowercase → extract 3-char n-grams → FNV-1a hash each → project into a 384-dim vector via the hashing trick → L2-normalize. The source comment itself calls it "hash-based," and the function is registered deterministic (it ignores text_type and model_and_version).

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.
@sjvans
sjvans marked this pull request as ready for review September 3, 2026 22:29
Comment thread java/cds-data.md Outdated
Comment thread java/working-with-cql/query-api.md Outdated
Co-authored-by: Matthias Schur <107557548+MattSchur@users.noreply.github.com>
@MattSchur

Copy link
Copy Markdown
Contributor

"lexical subword embeddings" slightly oversells it: it captures character-n-gram overlap, not meaning

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"?

@sjvans

sjvans commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@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:

On SQLite and H2, the vector_embedding function is emulated using lexical character-hash vectors by default. These capture surface (character-n-gram) overlap, not meaning. To compute semantic embeddings, use local ONNX models.

Pushed to node-embeddings.

Per PR review: 'lexical subword embeddings' oversold the deterministic
FNV-1a hash of character n-grams as semantic. Call it what it is.
Comment thread java/working-with-cql/query-api.md Outdated
Co-authored-by: Matthias Schur <107557548+MattSchur@users.noreply.github.com>
@sjvans
sjvans added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit c05656f Sep 4, 2026
4 checks passed
@sjvans
sjvans deleted the node-embeddings branch September 4, 2026 11:31
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