Skip to content

Commit

Permalink
load model in bf16
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxindongwork committed Aug 21, 2024
1 parent f40451d commit 2cb9068
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/language-modeling/gemma_tuning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@
"outputs": [],
"source": [
"from transformers import AutoModelForCausalLM\n",
"model = AutoModelForCausalLM.from_pretrained(model_id, use_cache=False)"
"import torch\n",
"model = AutoModelForCausalLM.from_pretrained(model_id, use_cache=False, torch_dtype=torch.bfloat16)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/language-modeling/llama_tuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ model_id = "meta-llama/Meta-Llama-3-8B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Add custom token for padding Llama
tokenizer.add_special_tokens({'pad_token': tokenizer.eos_token})
model = AutoModelForCausalLM.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
```

To tune the model with the [Abirate/english_quotes](https://huggingface.co/datasets/Abirate/english_quotes) dataset, you can load it and obtain the `quote` column:
Expand Down

0 comments on commit 2cb9068

Please sign in to comment.