regisss HF staff commited on
Commit
bca38f0
1 Parent(s): e138706

Modify the "Usage" section of the model card

Browse files

The code snippet in the "Usage" section of the model card is not runnable per se because it requires a dataset and pre/post-processing. We now points toward the QA example of optimum-habana and give the command to run this example with ALBERT Large.

Files changed (1) hide show
  1. README.md +22 -21
README.md CHANGED
@@ -23,25 +23,26 @@ This enables to specify:
23
  ## Usage
24
 
25
  The model is instantiated the same way as in the Transformers library.
26
- The only difference is that there are a few new training arguments specific to HPUs:
27
-
28
- ```
29
- from optimum.habana import GaudiTrainer, GaudiTrainingArguments
30
- from transformers import AlbertTokenizer, AlbertModel
31
-
32
- tokenizer = AlbertTokenizer.from_pretrained("albert-large-v2")
33
- model = AlbertModel.from_pretrained("albert-large-v2")
34
- args = GaudiTrainingArguments(
35
- output_dir="/tmp/output_dir",
36
- use_habana=True,
37
- use_lazy_mode=True,
38
- gaudi_config_name="Habana/albert-large-v2",
39
- )
40
-
41
- trainer = GaudiTrainer(
42
- model=model,
43
- args=args,
44
- tokenizer=tokenizer,
45
- )
46
- trainer.train()
47
  ```
 
 
 
23
  ## Usage
24
 
25
  The model is instantiated the same way as in the Transformers library.
26
+ The only difference is that there are a few new training arguments specific to HPUs.
27
+
28
+ [Here](https://github.com/huggingface/optimum-habana/blob/main/examples/question-answering/run_qa.py) is a question-answering example script to fine-tune a model on SQuAD. You can run it with ALBERT Large with the following command:
29
+ ```bash
30
+ python run_qa.py \
31
+ --model_name_or_path albert-large-v2 \
32
+ --gaudi_config_name Habana/albert-large-v2 \
33
+ --dataset_name squad \
34
+ --do_train \
35
+ --do_eval \
36
+ --per_device_train_batch_size 32 \
37
+ --per_device_eval_batch_size 4 \
38
+ --learning_rate 5e-5 \
39
+ --num_train_epochs 2 \
40
+ --max_seq_length 384 \
41
+ --doc_stride 128 \
42
+ --output_dir /tmp/squad/ \
43
+ --use_habana \
44
+ --use_lazy_mode \
45
+ --throughput_warmup_steps 2
 
46
  ```
47
+
48
+ Check the [documentation](https://huggingface.co/docs/optimum/habana_index) out for more advanced usage and examples.