Update script.py
Browse files
script.py
CHANGED
|
@@ -20,6 +20,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
|
| 20 |
from retrying import retry
|
| 21 |
|
| 22 |
bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
|
|
|
| 23 |
|
| 24 |
# Load tokenizer
|
| 25 |
_tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct")
|
|
@@ -27,7 +28,7 @@ _tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct")
|
|
| 27 |
# Load model with quantization
|
| 28 |
base_model = AutoModelForCausalLM.from_pretrained(
|
| 29 |
"Qwen/Qwen2.5-Coder-7B-Instruct",
|
| 30 |
-
quantization_config=bnb_config,
|
| 31 |
device_map="auto",
|
| 32 |
)
|
| 33 |
|
|
|
|
| 20 |
from retrying import retry
|
| 21 |
|
| 22 |
bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 23 |
+
RunningInCOLAB = 'google.colab' in str(get_ipython()) if hasattr(__builtins__,'__IPYTHON__') else False
|
| 24 |
|
| 25 |
# Load tokenizer
|
| 26 |
_tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-Coder-7B-Instruct")
|
|
|
|
| 28 |
# Load model with quantization
|
| 29 |
base_model = AutoModelForCausalLM.from_pretrained(
|
| 30 |
"Qwen/Qwen2.5-Coder-7B-Instruct",
|
| 31 |
+
quantization_config=bnb_config if RunningInCOLAB else None,
|
| 32 |
device_map="auto",
|
| 33 |
)
|
| 34 |
|