You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[docs] no hard coding cuda as bnb has multi-backend support (#35867)
* change cuda to DEVICE
* Update docs/source/en/llm_tutorial.md
Co-authored-by: Steven Liu <[email protected]>
---------
Co-authored-by: Steven Liu <[email protected]>
Copy file name to clipboardExpand all lines: docs/source/en/llm_tutorial.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,7 @@ Before you begin, make sure you have all the necessary libraries installed:
40
40
```bash
41
41
pip install transformers bitsandbytes>=0.39.0 -q
42
42
```
43
+
Bitsandbytes supports multiple backends in addition to CUDA-based GPUs. Refer to the multi-backend installation [guide](https://huggingface.co/docs/bitsandbytes/main/en/installation#multi-backend) to learn more.
43
44
44
45
45
46
## Generate text
@@ -101,9 +102,11 @@ Next, you need to preprocess your text input with a [tokenizer](tokenizer_summar
>>> model_inputs = tokenizer(["A list of colors: red, blue"], return_tensors="pt").to("cuda")
109
+
>>> model_inputs = tokenizer(["A list of colors: red, blue"], return_tensors="pt").to(DEVICE)
107
110
```
108
111
109
112
The `model_inputs` variable holds the tokenized text input, as well as the attention mask. While [`~generation.GenerationMixin.generate`] does its best effort to infer the attention mask when it is not passed, we recommend passing it whenever possible for optimal results.
@@ -122,7 +125,7 @@ Finally, you don't need to do it one sequence at a time! You can batch your inpu
122
125
>>> tokenizer.pad_token = tokenizer.eos_token # Most LLMs don't have a pad token by default
123
126
>>> model_inputs = tokenizer(
124
127
... ["A list of colors: red, blue", "Portugal is"], return_tensors="pt", padding=True
0 commit comments