Comments (8)
And thanks for your reminder =v=
We updated the README.md about how to load the model.
from llm-pruner.
Hi.
One simple way to fix it is not to save the tokenizer. You can delete Line 217 in hf_prune.py, which will become:
if args.save_model:
model.half()
torch.save({
'model': model,
}, logger.best_checkpoint_path)
And after that, if you load your model on the local machine, you will encounter another problem that says LLMPruner not found
or something like that (I don't remember the exact error message). The way to solve it is to put the folder LLMPruner
in the same directory you execute the loading script.
And, that is the problem of using torch.load()
and torch.save()
to load and restore the model, which will cause a lot of problems if switching to a new machine or even changing to a new folder 😔
from llm-pruner.
Hi.
We provide a script 'generate.py' to use the pruned model. The instruction can be found in README.md. Another simple way to load the model is :
checkpoint = torch.load('pytorch_model.bin', map_location = 'cpu')
model, tokenizer = checkpoint['model'], checkpoint['tokenizer']
Since the model does not have a consistent configuration for all layers (like some layers might be wider than others), we cannot use the model.from_pretrained to load the model. We are still working on this to make it possible.
from llm-pruner.
thanks!appreciate that!
i just tried but i get a wired issue, i pruner the base model on my server ,then i took the state_dict
down to my local machine to do some test ,but i found that the state_dict
cached the server_file_path
i tried:
import torch
pruned_dict = torch.load('/home/usr-fy/vicuna7b_pru/pytorch_model.bin', map_location='cpu')
tokenizer, model = pruned_dict['tokenizer'], pruned_dict['model']
'/home/usr-fy/vicuna7b_pru/pytorch_model.bin'
is my local machine path
then i get :
File "/home/usr-fy/anaconda3/envs/LLM-Pruner/lib/python3.10/site-packages/sentencepiece/__init__.py", line 310, in LoadFromFile
return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
OSError: Not found: "/data/app/vicuna-7b-v1.1/tokenizer.model": No such file or directory Error #2
the "/data/app/vicuna-7b-v1.1/tokenizer.model"
is the base_model_path on my server
i dont know how to modify the path, it seems contained by the model.bin
file
from llm-pruner.
thanks a lot for your reply! i get your point
i'll try it later :)
from llm-pruner.
Hi @Zhuqln , we just implemented a new feature to save & load pruned models https://github.com/VainF/Torch-Pruning#3-save--load. This feature allows us to re-create a pruned model from unpruned ones.
We will test it on LLM-Pruner and get back to you if there are any updates.
from llm-pruner.
appreciate that ,i'm looking forward to your achievements! @VainF
by the way, i'm using LLM-Pruner for inference now and its goes well @horseee ,thanks!
from llm-pruner.
Glad it's working well for you!
from llm-pruner.
Related Issues (20)
- Pruning MQA?
- 在将部分层进行剪枝之后,不能直接通过tgi加载模型
- Adding a tutorial for adapting new models?
- 401 Client Error: Unauthorized for url: https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/tokenizer_config.json HOT 1
- cannot import name 'SiLUActivation' from 'transformers.activations' HOT 1
- Issue: Missing Generation of `pytorch_model.bin` File During Model Tuning HOT 3
- Cannot use huggface to load
- OSError: Can't load tokenizer for 'baffo32/decapoda-research-llama-7B-hf'. HOT 1
- ConnectionError: Couldn't reach https://raw.githubusercontent.com/wojzaremba/lstm/master/data/ptb.train.txt (ReadTimeout(ReadTimeoutError("HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Read timed out. (read timeout=100)"))) HOT 1
- The quantization of the compressed models
- 延迟评估 HOT 1
- 剪枝率值的问题
- Unable to reproduce the results for param_first and param_second in the paper after finetuning.
- RecursionError: maximum recursion depth exceeded HOT 1
- Is this method implementable on multi-GPUs?
- How to prune the embedding and lm_head?
- I tired Mistral 7b model, but I got this issue
- Pruning llama3
- Evaluation:UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
- No random seed Settings found in post_training.py
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llm-pruner.