Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
model-index:
|
3 |
+
- name: gpt2-medium
|
4 |
+
results:
|
5 |
+
- task:
|
6 |
+
type: text-generation
|
7 |
+
dataset:
|
8 |
+
name: Wikitext
|
9 |
+
type: wikitext
|
10 |
+
metrics:
|
11 |
+
- type: perplexity (BASELINE)
|
12 |
+
value: 26.746555798139067
|
13 |
+
- type: perplexity (BASIC)
|
14 |
+
value: 30.20611307250951
|
15 |
+
---
|
16 |
+
This is a d-Matrix functional reference of the GPT2-MEDIUM model.
|
17 |
+
The reference provides the following functional *configurations*:
|
18 |
+
Configuration | Explanation
|
19 |
+
:-- | :--
|
20 |
+
**`BASELINE`** | a reference functionally equivalent to the original model
|
21 |
+
**`BASIC`** | all linear algebraic operands quantized to `BFP16-64`, and all other operations transformed to approximated kernel simulations
|
22 |
+
|
23 |
+
|
24 |
+
### Usage
|
25 |
+
|
26 |
+
Install d-Matrix [Dmx_Compressor](https://github.com/d-matrix-ai/dmx-compressor) first.
|
27 |
+
```sh
|
28 |
+
pip install dmx_compressor
|
29 |
+
```
|
30 |
+
|
31 |
+
The following is an example model and its evaluation.
|
32 |
+
|
33 |
+
```sh
|
34 |
+
pip install lm-eval
|
35 |
+
```
|
36 |
+
|
37 |
+
```python
|
38 |
+
from dmx.compressor.modeling import DmxModel
|
39 |
+
import lm_eval
|
40 |
+
|
41 |
+
model_args = f"pretrained="d-matrix/gpt2-medium",trust_remote_code=True"
|
42 |
+
|
43 |
+
lm = lm_eval.api.registry.get_model("hf").create_from_arg_string(model_args, {"batch_size": 1})
|
44 |
+
|
45 |
+
# Transform the model with DMX
|
46 |
+
lm._model = DmxModel.from_torch(lm._model).to_basic_model() # Using BASIC configuration
|
47 |
+
|
48 |
+
eval_results = lm_eval.evaluate(lm, lm_eval.tasks.get_task_dict([task]) # Assign desired task, i.e. "wikitext"
|
49 |
+
```
|