This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # =========================================================================================================== | |
| # GPT-2 Implementation | |
| # Based on Andrej Karpathy's "Let's reproduce GPT-2" lecture | |
| # https://www.youtube.com/watch?v=l8pRSuU81PU | |
| # | |
| # Modifications done: | |
| # - Custom DataLoader with sequential batching and train/val split | |
| # - Custom tiktokenizer wrapper | |
| # - Checkpoint save/load | |
| # - EOT stop token inference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| def main(): | |
| input_lines = sys.stdin.read().strip().split('\n') | |
| idx = 0 | |
| N = int(input_lines[idx]) | |
| idx += 1 | |
| results = [] | |
| for _ in range(N): |