Skip to content

[SPARK-59521][ML] Store word vectors directly in Word2VecModel - #58811

Draft
zhengruifeng wants to merge 3 commits into
apache:masterfrom
zhengruifeng:ml-word2vec-store-vectors-dev-7
Draft

zhengruifeng wants to merge 3 commits into
apache:masterfrom
zhengruifeng:ml-word2vec-store-vectors-dev-7

Conversation

@zhengruifeng

@zhengruifeng zhengruifeng commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR changes org.apache.spark.ml.feature.Word2VecModel to store its word index and
flattened word vectors directly instead of wrapping an
org.apache.spark.mllib.feature.Word2VecModel.

It also moves the synonym-search implementation into the ML Word2VecModel companion object,
reuses it from both the ML and MLlib models, and updates model fitting, copying, size estimation,
transformation, and persistence to use the directly stored data.

Why are the changes needed?

The ML model only needs the word index and vector array from the legacy MLlib model.
Storing those values directly removes the unnecessary model wrapper and keeps the ML model's
implementation and synonym-search logic self-contained.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

The following focused suites pass with 17 tests:

build/sbt 'mllib/testOnly org.apache.spark.ml.feature.Word2VecSuite org.apache.spark.mllib.feature.Word2VecSuite'

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Codex (GPT-5)

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.

1 participant