-
Notifications
You must be signed in to change notification settings - Fork 327
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
Is it possible to use a locally downloaded model without accessing HF? #655
Comments
Are the params in TransformerLens format? If so, just run
HookedTransformer(cfg) on the relevant config, and then do
`model.load_and_process_state_dict(saved_params)`
If they're in HuggingFace format, load them into a HuggingFace model and do
`HookedTransformer.from_pretrained("qwen-1.5-1b",
hf_model=YOUR_SAVED_TUNED_MODEL)`
…On Thu, 4 Jul 2024 at 13:39, ccp123456 ***@***.***> wrote:
Question
I want to try to experiment with Qwen 1.5 and I already have the
parameters tuned and saved locally, how can I load the trained parameters
instead of downloading them in HF when using the function
HookedTransformer.from_pretrained?
—
Reply to this email directly, view it on GitHub
<#655>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASRPNKLTN2TIXD4ZO7U5XL3ZKU67ZAVCNFSM6AAAAABKLPC7RCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM4TANZXG43DANA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Yes, I tried to do this, but it still tried to access“ https://huggingface.co I would like to know if there is a way to load the model without accessing hf? My model is in hf format. |
Does it try to access it on the line where you load them into a HF model,
or the line where you do HookedTransformer.from_pretrained? The former
should be easy to fix based on the HF docs, they support loading from local
weights I think. The latter might be because it wants the config...
…On Fri, 5 Jul 2024 at 07:03, ccp123456 ***@***.***> wrote:
Are the params in TransformerLens format? If so, just run
HookedTransformer(cfg) on the relevant config, and then do
model.load_and_process_state_dict(saved_params) If they're in HuggingFace
format, load them into a HuggingFace model and do HookedTransformer.from_pretrained("qwen-1.5-1b",
hf_model=YOUR_SAVED_TUNED_MODEL)
… <#m_-2970033271189213853_>
On Thu, 4 Jul 2024 at 13:39, ccp123456 *@*.*> wrote: Question I want to
try to experiment with Qwen 1.5 and I already have the parameters tuned and
saved locally, how can I load the trained parameters instead of downloading
them in HF when using the function HookedTransformer.from_pretrained? —
Reply to this email directly, view it on GitHub <#655
<#655>>, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ASRPNKLTN2TIXD4ZO7U5XL3ZKU67ZAVCNFSM6AAAAABKLPC7RCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM4TANZXG43DANA
<https://github.com/notifications/unsubscribe-auth/ASRPNKLTN2TIXD4ZO7U5XL3ZKU67ZAVCNFSM6AAAAABKLPC7RCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM4TANZXG43DANA>
. You are receiving this because you are subscribed to this thread.Message
ID: @.*>
Yes, I tried to do this, but it still tried to access“
https://huggingface.co I would like to know if there is a way to load the
model without accessing hf? My model is in hf format.
—
Reply to this email directly, view it on GitHub
<#655 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASRPNKNHHF2FJJM7HTOOW7LZKYZM3AVCNFSM6AAAAABKLPC7RCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJQGIZTKOBVGA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
`MODEL_ID = "meta-llama/Meta-Llama-3.1-8B-Instruct" Download and load model!git clone https://huggingface.co/{MODEL_ID} {MODEL_TYPE} Load model and tokenizermodel = HookedTransformer.from_pretrained_no_processing( |
Hello, I have the same issue. Loading other local models works successfully, but loading the local Qwen model keeps attempting to download from Hugging Face. |
@ccp123456 @clclclaiggg Hi guys, I think there's one way to circumvent this issue. You could set the default cache dir of huggingface hub to the path where you store your local models, before loading any models.
You may need to ensure your models are stored in the same format as huggingface models, e.g., having blobs/refs/snapshots dirs. And also make sure the model directory name appears the same as that of huggingface models, e.g., |
Could you show the detail code? |
Sure. The models are in the following structure in my local folder.
Then, I load the models using the following code, without requesting huggingface.co.
|
@Nebularaid2000 Thanks! This workaround works! I just had to make sure to set the os.environ before loading HookedTransformer. |
@hamind Hi, I think there's a few things you may try.
|
Thanks a lot. But it won't work. |
@hamind That's a good practice. I've also seen your proposal to add a function for loading local files. I believe this is a feature worth to be added. |
I am going to close this in favor of #754. Both of these issues are about improving this by default, and I want to keep the issue tracked in a single place. |
Question
I want to try to experiment with Qwen 1.5 and I already have the parameters tuned and saved locally, how can I load the trained parameters instead of downloading them in HF when using the function HookedTransformer.from_pretrained?
The text was updated successfully, but these errors were encountered: