codeby-hp commited on
Commit
1e4646e
·
verified ·
1 Parent(s): ea261bd

Initial release: trained nanoGPT in safetensors format

Browse files
Files changed (1) hide show
  1. README.md +2 -2
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 load_file
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
- model.load_state_dict(load_file(weights_file))
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