epoyraz commited on
Commit
57a1624
·
verified ·
1 Parent(s): 45c66cd

Upload model support files

Browse files
Files changed (1) hide show
  1. config.py +34 -0
config.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import torch
4
+
5
+ DATA_DIR = "data"
6
+ TOKENIZER_PATH = "tokenizer.json"
7
+ CHECKPOINT_DIR = "checkpoints"
8
+ TRAIN_TOKENS_CACHE = "data/train_tokens.npy"
9
+ VAL_TOKENS_CACHE = "data/val_tokens.npy"
10
+
11
+ DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
12
+ DTYPE = torch.float16 if DEVICE == "cuda" else torch.float32
13
+
14
+
15
+ def load_dotenv(path=".env"):
16
+ """Tiny dependency-free .env loader. Populates os.environ (does not overwrite
17
+ variables already set in the real environment). Lets HF_TOKEN live in a
18
+ gitignored .env file instead of being hardcoded or pasted into the shell."""
19
+ if not os.path.exists(path):
20
+ return
21
+ with open(path, encoding="utf-8") as f:
22
+ for line in f:
23
+ line = line.strip()
24
+ if not line or line.startswith("#") or "=" not in line:
25
+ continue
26
+ key, _, value = line.partition("=")
27
+ key, value = key.strip(), value.strip().strip('"').strip("'")
28
+ os.environ.setdefault(key, value)
29
+
30
+
31
+ load_dotenv()
32
+
33
+ # HuggingFace token (optional for public datasets like wikitext-103; used if present).
34
+ HF_TOKEN = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_TOKEN")