regisss HF staff commited on
Commit
4a3d811
1 Parent(s): a1c79f4

Change usage section

Browse files
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 BertTokenizer, BertModel
31
-
32
- tokenizer = BertTokenizer.from_pretrained("bert-large-uncased-whole-word-masking")
33
- model = BertModel.from_pretrained("bert-large-uncased-whole-word-masking")
34
- args = GaudiTrainingArguments(
35
- output_dir="/tmp/output_dir",
36
- use_habana=True,
37
- use_lazy_mode=True,
38
- gaudi_config_name="Habana/bert-large-uncased-whole-word-masking",
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 BERT Large with the following command:
29
+ ```bash
30
+ python run_qa.py \
31
+ --model_name_or_path bert-large-uncased-whole-word-masking \
32
+ --gaudi_config_name gaudi_config_name_or_path \
33
+ --dataset_name squad \
34
+ --do_train \
35
+ --do_eval \
36
+ --per_device_train_batch_size 24 \
37
+ --per_device_eval_batch_size 8 \
38
+ --learning_rate 3e-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.