Views
No views yet
pip install nm-vllm[sparse]1from vllm import LLM, SamplingParams
2
3model = LLM("nm-testing/OpenHermes-2.5-Mistral-7B-pruned50", sparsity="sparse_w16a16")
4prompt = "How to make banana bread?"
5formatted_prompt = f"<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant"
6
7sampling_params = SamplingParams(max_tokens=100)
8outputs = model.generate(formatted_prompt, sampling_params=sampling_params)
9print(outputs[0].outputs[0].text)
10"""
11Here is a simple recipe for making banana bread:
12
13Ingredients:
14- 3 ripe bananas
15- 2 eggs
16- 1/2 cup of sugar
17- 1/2 cup of butter
18- 2 cups of flour
19- 1 teaspoon baking powder
20- 2 teaspoons of baking soda
21
22Instructions:
231. Preheat your oven at 350 degree Fahrenant.
24"""<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistantrecipe.yaml in this repo and follow the instructions below.1git clone https://github.com/neuralmagic/sparseml
2pip install -e "sparseml[transformers]"1import sparseml.transformers
2
3original_model_name = "teknium/OpenHermes-2.5-Mistral-7B"
4calibration_dataset = "open_platypus"
5output_directory = "output/"
6
7recipe = """
8test_stage:
9 obcq_modifiers:
10 SparseGPTModifier:
11 sparsity: 0.5
12 sequential_update: true
13 mask_structure: 0:0
14 targets: ['re:model.layers.\d*$']
15"""
16
17# Apply SparseGPT to the model
18sparseml.transformers.oneshot(
19 model=original_model_name,
20 dataset=calibration_dataset,
21 recipe=recipe,
22 output_dir=output_directory,
23)