Commit
·
fc786e8
1
Parent(s):
ed29ba9
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- deepsparse
|
4 |
+
---
|
5 |
+
## Usage
|
6 |
+
|
7 |
+
```python
|
8 |
+
from deepsparse import TextGeneration
|
9 |
+
|
10 |
+
prompt = "How to get in a good university?"
|
11 |
+
formatted_prompt = f"<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
|
12 |
+
|
13 |
+
model = TextGeneration(model="hf:nm-testing/TinyLlama-1.1B-Chat-v0.4-pruned50-quant")
|
14 |
+
print(model(formatted_prompt, max_new_tokens=200).generations[0].text)
|
15 |
+
|
16 |
+
"""
|
17 |
+
The university is a place where you learn and gain skills. It is a place where you learn by reading books, doing experiments, and doing research. It is a place where you learn by doing projects. It is a place where you learn by doing research. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a place where you learn by doing research. The university is a place where you learn by reading books. The university is a place where you learn by doing projects. The university is a
|
18 |
+
"""
|
19 |
+
```
|
20 |
+
## One-shot and Export
|
21 |
+
|
22 |
+
```bash
|
23 |
+
git clone https://github.com/neuralmagic/sparseml
|
24 |
+
pip install -e "sparseml[transformers]" "torch<2"
|
25 |
+
git checkout update/onnx_export/duplicate
|
26 |
+
python sparseml/src/sparseml/transformers/sparsification/obcq/obcq.py TinyLlama/TinyLlama-1.1B-Chat-v0.4 open_platypus --recipe recipe.yaml --save True
|
27 |
+
python sparseml/src/sparseml/transformers/sparsification/obcq/export.py --task text-generation --model_path obcq_deployment
|
28 |
+
cp deployment/model.onnx deployment/model-orig.onnx
|
29 |
+
python onnx_kv_inject.py --input-file deployment/model-orig.onnx --output-file deployment/model.onnx
|
30 |
+
```
|