Spaces:
Sleeping
Sleeping
Create download_molformer.py
#3
by AssumedHydra - opened
- download_molformer.py +13 -0
download_molformer.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Run once at build time to cache MoLFormer weights into the repo."""
|
| 2 |
+
from transformers import AutoModel, AutoTokenizer
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
cache_dir = os.path.join(os.path.dirname(__file__), "molformer_cache")
|
| 6 |
+
os.makedirs(cache_dir, exist_ok=True)
|
| 7 |
+
|
| 8 |
+
print("Downloading MoLFormer-XL...")
|
| 9 |
+
AutoTokenizer.from_pretrained("ibm/MoLFormer-XL-both-10pct",
|
| 10 |
+
trust_remote_code=True, cache_dir=cache_dir)
|
| 11 |
+
AutoModel.from_pretrained("ibm/MoLFormer-XL-both-10pct",
|
| 12 |
+
trust_remote_code=True, cache_dir=cache_dir)
|
| 13 |
+
print("Done.")
|