Update app.py
Browse files
app.py
CHANGED
|
@@ -21,22 +21,21 @@ else:
|
|
| 21 |
# --- Muat Model dan Tokenizer ---
|
| 22 |
# Proses ini hanya berjalan sekali saat aplikasi dimulai
|
| 23 |
print("Memuat tokenizer...")
|
| 24 |
-
# Menambahkan trust_remote_code=True untuk mengizinkan kode kustom dari model
|
|
|
|
| 25 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 26 |
model_id,
|
| 27 |
-
token=hf_token,
|
| 28 |
trust_remote_code=True
|
| 29 |
)
|
| 30 |
|
| 31 |
print("Memuat model... Ini mungkin memakan waktu beberapa menit.")
|
| 32 |
-
# Menambahkan trust_remote_code=True juga untuk model
|
| 33 |
# torch_dtype=torch.bfloat16 mengurangi penggunaan memori.
|
| 34 |
# device_map="auto" akan secara otomatis menggunakan GPU jika tersedia.
|
| 35 |
model = AutoModelForCausalLM.from_pretrained(
|
| 36 |
model_id,
|
| 37 |
torch_dtype=torch.bfloat16,
|
| 38 |
device_map="auto",
|
| 39 |
-
token=hf_token,
|
| 40 |
trust_remote_code=True,
|
| 41 |
)
|
| 42 |
print("Model berhasil dimuat!")
|
|
|
|
| 21 |
# --- Muat Model dan Tokenizer ---
|
| 22 |
# Proses ini hanya berjalan sekali saat aplikasi dimulai
|
| 23 |
print("Memuat tokenizer...")
|
| 24 |
+
# Menambahkan trust_remote_code=True untuk mengizinkan kode kustom dari model.
|
| 25 |
+
# Token tidak perlu dilewatkan lagi setelah login().
|
| 26 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 27 |
model_id,
|
|
|
|
| 28 |
trust_remote_code=True
|
| 29 |
)
|
| 30 |
|
| 31 |
print("Memuat model... Ini mungkin memakan waktu beberapa menit.")
|
| 32 |
+
# Menambahkan trust_remote_code=True juga untuk model.
|
| 33 |
# torch_dtype=torch.bfloat16 mengurangi penggunaan memori.
|
| 34 |
# device_map="auto" akan secara otomatis menggunakan GPU jika tersedia.
|
| 35 |
model = AutoModelForCausalLM.from_pretrained(
|
| 36 |
model_id,
|
| 37 |
torch_dtype=torch.bfloat16,
|
| 38 |
device_map="auto",
|
|
|
|
| 39 |
trust_remote_code=True,
|
| 40 |
)
|
| 41 |
print("Model berhasil dimuat!")
|