d-matrix
commited on
Commit
•
23a2db5
1
Parent(s):
1b8d8ef
Update README.md
Browse files
README.md
CHANGED
@@ -52,35 +52,22 @@ The reference provides the following functional *configurations*:
|
|
52 |
|
53 |
### Usage
|
54 |
|
55 |
-
|
56 |
-
- Install d-Matrix ML Tools: `pip install dmx-mltools`
|
57 |
-
- clone this repo. `cd` to the cloned repo.
|
58 |
|
59 |
```python
|
60 |
-
|
61 |
-
|
62 |
-
>>> from transformers import pipeline
|
63 |
-
>>> import evaluate
|
64 |
-
>>> from datasets import load_dataset
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
>>> )
|
75 |
-
>>> pipe.model = dmx.Model(
|
76 |
-
>>> pipe.model, monkey_patched=False, hf=True, input_names=["input_ids", "labels"]
|
77 |
-
>>> )
|
78 |
|
79 |
-
|
80 |
-
>>> input_texts = load_dataset("ptb_text_only", "penn_treebank", split="test")["sentence"]
|
81 |
-
>>> results = perplexity.compute(model=pipe.model.body, references=input_texts)
|
82 |
-
>>> print(results)
|
83 |
-
{'loss': 3.0451672077178955, 'perplexity': 21.0135440826416}
|
84 |
```
|
85 |
|
86 |
### Evaluation results
|
|
|
52 |
|
53 |
### Usage
|
54 |
|
55 |
+
Install d-Matrix ML Tools first: `pip install dmx-mltools`.
|
|
|
|
|
56 |
|
57 |
```python
|
58 |
+
import os
|
59 |
+
from mltools.dmx import pipeline
|
|
|
|
|
|
|
60 |
|
61 |
+
pipe = pipeline(
|
62 |
+
task="text-generation",
|
63 |
+
model="d-matrix/gpt2",
|
64 |
+
revision="temp-distilgpt2",
|
65 |
+
dmx_config="BASELINE",
|
66 |
+
trust_remote_code=True,
|
67 |
+
# device_map="auto", # enabling model parallel on multi-GPU nodes
|
68 |
+
)
|
|
|
|
|
|
|
|
|
69 |
|
70 |
+
results = pipe.evaluate(metric="d-matrix/perplexity", dataset="wikitext-2")
|
|
|
|
|
|
|
|
|
71 |
```
|
72 |
|
73 |
### Evaluation results
|