d-matrix commited on
Commit
23a2db5
1 Parent(s): 1b8d8ef

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -25
README.md CHANGED
@@ -52,35 +52,22 @@ The reference provides the following functional *configurations*:
52
 
53
  ### Usage
54
 
55
- Prerequisites:
56
- - Install d-Matrix ML Tools: `pip install dmx-mltools`
57
- - clone this repo. `cd` to the cloned repo.
58
 
59
  ```python
60
- >>> import os
61
- >>> from mltools import dmx
62
- >>> from transformers import pipeline
63
- >>> import evaluate
64
- >>> from datasets import load_dataset
65
 
66
- >>> pipe = pipeline(
67
- >>> "text-generation",
68
- >>> model="d-matrix/gpt2",
69
- >>> revision="gpt2-xl",
70
- >>> dmx_config="BASELINE",
71
- >>> use_auth_token=os.environ.get("HUGGING_FACE_HUB_TOKEN"),
72
- >>> trust_remote_code=True,
73
- >>> # device_map="auto", # enabling model parallel on multi-GPU nodes
74
- >>> )
75
- >>> pipe.model = dmx.Model(
76
- >>> pipe.model, monkey_patched=False, hf=True, input_names=["input_ids", "labels"]
77
- >>> )
78
 
79
- >>> perplexity = evaluate.load("d-matrix/dmx_perplexity", module_type="metric")
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