File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
examples/speculative_decoding/scripts Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 1616import argparse
1717import json
1818import os
19+ from itertools import islice
1920
2021import torch
2122from transformers import AutoTokenizer
@@ -47,9 +48,8 @@ def main():
4748 print ("Calibrating vocab..." )
4849 tokenizer = AutoTokenizer .from_pretrained (args .model )
4950 with open (args .data ) as f :
50- conversations = [json .loads (line )["conversations" ] for line in f ]
51- if args .calibrate_size :
52- conversations = conversations [: args .calibrate_size ]
51+ lines = islice (f , args .calibrate_size ) if args .calibrate_size else f
52+ conversations = [json .loads (line )["conversations" ] for line in lines ]
5353 conversations = [item for sublist in conversations for item in sublist ]
5454
5555 d2t = calibrate_frequent_vocab (tokenizer , conversations , args .draft_vocab_size )
You can’t perform that action at this time.
0 commit comments