Commit
·
5d510b4
1
Parent(s):
7ee4284
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- deepsparse
|
| 4 |
+
---
|
| 5 |
+
## Usage
|
| 6 |
+
|
| 7 |
+
```python
|
| 8 |
+
from deepsparse import TextGeneration
|
| 9 |
+
model = TextGeneration(model="deployment")
|
| 10 |
+
print(model("How to make banana bread?", max_new_tokens=200).generations[0].text)
|
| 11 |
+
"""
|
| 12 |
+
1. Start by preparing the ingredients. You will need 3 cups of all-purpose flour, 1 cup of sugar, 1 egg, 1/2 teaspoful of vanilla extract, 1/2 teaspoful of baking powder, 1/2 teaspoful of salt, and 1 cup of milk.
|
| 13 |
+
2. Mix the flour, sugar, and egg in a bowl.
|
| 14 |
+
3. In a separate bowl, mix the vanilla extract and baking powder.
|
| 15 |
+
4. Add the salt and milk to the flour mixture.
|
| 16 |
+
5. Mix everything together until you have a smooth batter.
|
| 17 |
+
6. Pour the batter into a greased 9-inch pan.
|
| 18 |
+
7. Bake the bread at 350°F for 20 minutes.
|
| 19 |
+
8. Let the bread cool and then slice it into individual slices.
|
| 20 |
+
9.
|
| 21 |
+
"""
|
| 22 |
+
```
|
| 23 |
+
## One-shot and Export
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
git clone https://github.com/neuralmagic/sparseml
|
| 27 |
+
pip install -e "sparseml[transformers]"
|
| 28 |
+
python sparseml/src/sparseml/transformers/sparsification/obcq/obcq.py TinyLlama/TinyLlama-1.1B-Chat-v0.4 open_platypus --recipe recipe.yaml --save True
|
| 29 |
+
python sparseml/src/sparseml/transformers/sparsification/obcq/export.py --task text-generation --model_path obcq_deployment
|
| 30 |
+
cp deployment/model.onnx deployment/model-orig.onnx
|
| 31 |
+
python onnx_kv_inject.py --input-file deployment/model-orig.onnx --output-file deployment/model.onnx
|
| 32 |
+
```
|