Views
No views yet
pip install deepsparse-nightly[llm]1from deepsparse import TextGeneration
2
3prompt = "How to make banana bread?"
4formatted_prompt = f"### User:\n{prompt}\n\n### Assistant:\n"
5
6model = TextGeneration(model_path="hf:neuralmagic/Nous-Hermes-2-SOLAR-10.7B-pruned50-quant-ds")
7
8print(model(formatted_prompt, max_new_tokens=200).generations[0].text)
9"""
10To make banana bread, you will need the following ingredients:
11
12- 3 ripe bananas
13- 1 cup of milk
14- 1 cup of sugar
15- 1/2 cup of butter
16- 2 eggs
17- 1 teaspoon of baking powder
18- 1 teaspoon of salt
19- 2 cups of flour
20
21Here's a simple recipe to make banana bread:
22
231. Preheat your oven to 350°F (175°C).
24
252. In a large bowl, mash the ripe bananas.
26
273. Add the milk, sugar, butter, eggs, baking powder, salt, and flour to the mashed bananas. Mix everything together until you have a smooth batter.
28
294. Pour the batter into a greased loaf pan.
30
315. Bake the banana bread for about 60 minutes or until a tooth
32"""
### User:\n
{prompt}
### Assistant:\nrecipe.yaml in this repo and follow the instructions below.1git clone https://github.com/neuralmagic/sparseml
2pip install -e "sparseml[transformers]"
3python sparseml/src/sparseml/transformers/sparsification/obcq/obcq.py NousResearch/Nous-Hermes-2-SOLAR-10.7B open_platypus --recipe recipe.yaml --save True
4python sparseml/src/sparseml/transformers/sparsification/obcq/export.py --task text-generation --model_path obcq_deployment
5cp deployment/model.onnx deployment/model-orig.onnx1import os
2import onnx
3from sparseml.exporters.kv_cache_injector import KeyValueCacheInjector
4input_file = "deployment/model-orig.onnx"
5output_file = "deployment/model.onnx"
6model = onnx.load(input_file, load_external_data=False)
7model = KeyValueCacheInjector(model_path=os.path.dirname(input_file)).apply(model)
8onnx.save(model, output_file)
9print(f"Modified model saved to: {output_file}")