Read pooling_mode_mean_tokens with get() so a partial config does not raise - #1188
Open
Aryan-Pardeshi wants to merge 1 commit into
Open
Read pooling_mode_mean_tokens with get() so a partial config does not raise#1188Aryan-Pardeshi wants to merge 1 commit into
Aryan-Pardeshi wants to merge 1 commit into
Conversation
… raise PoolingFactory.method() guarded every other pooling flag with .get() but looked up pooling_mode_mean_tokens with a bracket, so a 1_Pooling/config.json that sets a mode without that key raised KeyError out of PoolingFactory.create() instead of resolving a method. A missing flag now reads as disabled, matching an explicit false. Closes neuml#1187
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.
Closes #1187
PoolingFactory.method()guarded every other pooling flag with.get()but readpooling_mode_mean_tokenswith a bracket lookup, so a1_Pooling/config.jsonthat sets a mode without that key raisedKeyErrorout ofPoolingFactory.create()instead of resolving a method:A missing flag now reads as disabled, matching an explicit
falseand the defensive style used by the rest of the module (config and config.get(...),maxlength()'sif configguard,load()swallowingDownloadError).Tests
testPartialPoolingConfigcovers the resolution table both ways — cls/last with the mean key absent and present-and-false both resolve to their method, mean-enabled and an empty config resolve tomeanpooling.Note on #1186
#1186 adds a third flag check on the same lines (
pooling_mode_max_tokens). Whichever of the two lands second I'll bring in line — it's a one-token change either way.