zhengruifeng opened a new pull request, #58688:
URL: https://github.com/apache/spark/pull/58688

   ### What changes were proposed in this pull request?
   
   This PR reduces the serialized size of `mllib`'s `Word2VecModel` by:
   
   - computing `numWords` and `vectorSize` from the model data instead of 
storing them;
   - removing the derived `wordList` cache and iterating over `wordIndex` when 
finding synonyms;
   - making the lazily computed word-vector inverse norms transient.
   
   ### Why are the changes needed?
   
   These values are derived from `wordIndex` and `wordVectors`. Storing them in 
the serialized model
   duplicates data, including an array containing the full vocabulary, and 
increases the pressure from
   shipping models between the Spark Connect server and executors.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing Word2Vec tests:
   
   ```
   build/sbt 'mllib/testOnly *Word2VecSuite'
   ```
   
   The run passed 19 tests with no failures. No new tests were added because 
this is an internal
   representation refactor covered by the existing synonym, Java API, and model 
persistence tests.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex (GPT-5)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to