Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained(
5 "naveedashfaq/llama-3-8b-pruned-30-percent",
6 torch_dtype=torch.float16,
7 device_map="auto",
8 trust_remote_code=True
9)
10tokenizer = AutoTokenizer.from_pretrained("naveedashfaq/llama-3-8b-pruned-30-percent")
11
12# Generate text
13inputs = tokenizer("Hello, how are you?", return_tensors="pt").to(model.device)
14outputs = model.generate(**inputs, max_new_tokens=50)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))1# Clone llama.cpp
2git clone https://github.com/ggerganov/llama.cpp
3cd llama.cpp
4make
5
6# Download and convert the model
7huggingface-cli download naveedashfaq/llama-3-8b-pruned-30-percent --local-dir ./llama-3-8b-pruned
8python convert.py ./llama-3-8b-pruned/
9
10# Optional: Quantize to reduce size further
11./quantize ./llama-3-8b-pruned/ggml-model-f16.gguf ./llama-3-8b-pruned/ggml-model-q4_0.gguf q4_01@article{ma2023llmpruner,
2 title={LLM-Pruner: On the Structural Pruning of Large Language Models},
3 author={Ma, Xinyin and Fang, Gongfan and Wang, Xinchao},
4 journal={arXiv preprint arXiv:2305.11627},
5 year={2023}
6}