Repository navigation
Fix sampler accepts and the Mirostat vocabulary size in LlamaLanguageModel - #429
Merged
Merged
Conversation
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.
This PR fixes two defects in how
LlamaLanguageModelsamples tokens. The text and image generation loops calledllama_sampler_acceptafterllama_sampler_sample, which already accepts the token that it returns. Of the samplers in the package's chain, only the penalties sampler has anacceptthat affects output here, and it recorded each generated token twice. Its window ofrepeatLastNentries then held half as many generated tokens (32 instead of the default 64), and each occurrence in that shorter window counted twice for the frequency penalty. The repeat and presence penalties check only whether a token is in the window, so only the shorter window changed them. Separately,llama_sampler_init_mirostatgot the context size as itsn_vocabargument instead of the vocabulary size.This PR removes the extra accept calls, passes the vocabulary size to Mirostat v1, and builds the sampler chain for all three generation paths with one function,
makeSamplerChain(vocabularySize:options:). Because the package does not accept prompt tokens into the sampler, generated text can change from the 2nd generated token for callers that set a frequency penalty. For callers that use only repeat or presence penalties, including the default repeat penalty of 1.1, it can change from the 34th generated token with the defaultrepeatLastN. Generated text can also change for callers that use Mirostat v1.