FEAT: add support for local model checkpoints and trust_remote_code in HuggingFaceChatTarget #574
+101
−27
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.
Overview
This pull request adds support for loading local model checkpoints in the
HuggingFaceChatTarget
class through the newmodel_path
parameter. It also introduces thetrust_remote_code
parameter to handle models that require executing custom code during loading.These enhancements improve the flexibility and usability of the
HuggingFaceChatTarget
class by enabling users to:model_path
parameter, supporting local model checkpoints.trust_remote_code=True
, necessary for models likemicrosoft/Phi-3-mini-4k-instruct
.Work Completed
HuggingFaceChatTarget
Class:model_path
Parameter:__init__
method to include the optionalmodel_path
parameter.load_model_and_tokenizer
method to load models from a local directory whenmodel_path
is provided.trust_remote_code
Parameter:trust_remote_code
parameter with a default value ofFalse
to the__init__
method.trust_remote_code
to thefrom_pretrained
methods when loading the tokenizer and model.model_id
.trust_remote_code=False
, so models that do not require it are unaffected.Related Issue
Issue #572