Open
Conversation
Author
|
A bit of context, I'm using it on a serverless lambda web api (knative), the model is only queried a few times before the program exits. Reduces the cold-start a lot |
gstvg
commented
Jun 27, 2022
|
|
||
| v := make(Vector, m.dim) | ||
| if err := binary.Read(r, binary.LittleEndian, v); err != nil { | ||
| log.Printf("word2vec: LazyModel.Map read %s %s", w, err) //todo return the error and change the api? |
dhowden
requested changes
Jul 6, 2022
Member
dhowden
left a comment
There was a problem hiding this comment.
Hey! Thanks for the contribution - this is a great idea!
Reading through the change: instead of having the and lazy/original model inside Model, how about putting the lazy implementation in a new model implementation entirely:
type LazyModel struct {
dim int
lazyWords map[string]int64
reader LazyReader
}... and then implement the Coser methods on this new type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add method to lazy load the model, saving only
the offset at each word vector starts on the
io.Reader, and reading at it only when needed
Adds a flag lazy on word-server to use it
Also calls file.Close() on word-server in
case of error loading the model, because the
deferred one isn't called after os.Exit