-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add argument for extra EOS token to llm-tool #217
base: main
Are you sure you want to change the base?
Conversation
Tools/llm-tool/LLMTool.swift
Outdated
if let extraToken = extraEosToken { | ||
// Create a new configuration with the extra EOS token | ||
var extraTokens = context.configuration.extraEOSTokens | ||
extraTokens.insert(extraToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we just made the properties on ModelConfiguration
var
? There isn't a particular need for them to be let
(I just tend to make things let
unless I know of a need to mutate). Then we can let the owner of the structure decide if it is immutable or not:
/// Additional tokens to use for end of string
public let extraEOSTokens: Set<String>
This code would just be a couple of lines then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intuitively I feel like a model configuration shouldn't need to be changed. It should be static for each model. Maybe we need to rethink how the configurations are generated? Unfortunately I don't have time to delve into this at the moment, but I wanted to mention it, since my solution here isn't very elegant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't changing the registry (it can't change it since they are value types), it is simply overlaying the local extra tokens on the "copy" we are going to use.
By making the properties var
(ModelConfiguration and ModelContext) it would turn this code into roughly:
var context = context
if let extraEosToken {
context.configuration.extraEOSTokens.insert(extraEosToken)
}
I think that would be very clean at expressing what we are trying to do (and is a good use of value types).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidkoski, you can go ahead and change ModelConfiguration in this PR or in a separate PR, whichever you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed commit -- I think that captures what you were doing and is a bit simpler in implementation now that it is mutable
look good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's definitely more concise. Thank you!
- update context/configuration with extra EOS tokens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the addition!
I think we are ready to merge unless you want to add anything. |
I added an argument for the extra EOS token to match the Python implementation and also improved the console output during loading.
Maybe we should rethink how llm-tool is implemented, since this solution is a bit unwieldy.