Upload model.py
Browse files
model.py
CHANGED
|
@@ -14,11 +14,11 @@ MODEL_NAME = "bigcode/starcoderbase-1b"
|
|
| 14 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 15 |
|
| 16 |
# Initialize text generation pipeline
|
| 17 |
-
#
|
| 18 |
generator = pipeline(
|
| 19 |
"text-generation",
|
| 20 |
model=MODEL_NAME,
|
| 21 |
-
|
| 22 |
device_map="auto", # Automatically choose device (CPU if no GPU)
|
| 23 |
token=HF_TOKEN # Pass token for gated models
|
| 24 |
)
|
|
|
|
| 14 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 15 |
|
| 16 |
# Initialize text generation pipeline
|
| 17 |
+
# We'll use FP16 for better performance on CPU (if supported)
|
| 18 |
generator = pipeline(
|
| 19 |
"text-generation",
|
| 20 |
model=MODEL_NAME,
|
| 21 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 22 |
device_map="auto", # Automatically choose device (CPU if no GPU)
|
| 23 |
token=HF_TOKEN # Pass token for gated models
|
| 24 |
)
|