Initial release: trained nanoGPT in safetensors format
Browse files
README.md
CHANGED
|
@@ -21,7 +21,7 @@ A 10.7M parameter character-level GPT trained from scratch on the Tiny Shakespea
|
|
| 21 |
```python
|
| 22 |
import json
|
| 23 |
import torch
|
| 24 |
-
from safetensors.torch import
|
| 25 |
from huggingface_hub import hf_hub_download
|
| 26 |
from model import GPTConfig, GPT
|
| 27 |
|
|
@@ -43,7 +43,7 @@ decode = lambda l: "".join([itos[i] for i in l])
|
|
| 43 |
# 3. Instantiate model
|
| 44 |
config = GPTConfig(**cfg_dict)
|
| 45 |
model = GPT(config)
|
| 46 |
-
|
| 47 |
model.eval()
|
| 48 |
|
| 49 |
# 4. Generate text
|
|
|
|
| 21 |
```python
|
| 22 |
import json
|
| 23 |
import torch
|
| 24 |
+
from safetensors.torch import load_model # <-- Changed to load_model
|
| 25 |
from huggingface_hub import hf_hub_download
|
| 26 |
from model import GPTConfig, GPT
|
| 27 |
|
|
|
|
| 43 |
# 3. Instantiate model
|
| 44 |
config = GPTConfig(**cfg_dict)
|
| 45 |
model = GPT(config)
|
| 46 |
+
load_model(model, weights_file) # <-- Handles tied weights automatically!
|
| 47 |
model.eval()
|
| 48 |
|
| 49 |
# 4. Generate text
|