AssumedHydra commited on
Commit
2ccc3e7
·
verified ·
1 Parent(s): 018aedc

Create download_molformer.py

Browse files
Files changed (1) hide show
  1. 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.")