This file contains 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
# User Added | |
# DS_store | |
.DS_Store | |
**/.DS_Store | |
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class |
This file contains 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 tqdm | |
start = time.time() | |
with tqdm.tqdm(total=len(inputs)) as pbar: | |
for batch_inputs in batch(inputs, BATCH_SIZE): | |
# do something | |
pbar.update(len(batch_inputs)) | |
end = time.time() | |
print(f"Time elapsed: {end-start:.3f} seconds") |
This file contains 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
def batch(iterable, n=1): | |
total = len(iterable) | |
for ndx in range(0, total, n): | |
yield iterable[ndx:min(ndx + n, total)] | |
for batch_response in batch(responses, args.batch_size): | |
prompt_hate = beep_hate([r['prompt'] for r in batch_response], args.device) |