Skip to content

Instantly share code, notes, and snippets.

View boychaboy's full-sized avatar
🐢
slow but steady

Younghun Jeong boychaboy

🐢
slow but steady
View GitHub Profile
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)
@boychaboy
boychaboy / verbose_iteration.py
Created June 29, 2023 07:55
python iteration에서 상태바, 총 소요 시간을 보여주는 기본 코드
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")
@boychaboy
boychaboy / .gitignore (python)
Created July 5, 2023 07:11
python .gitignore
# User Added
# DS_store
.DS_Store
**/.DS_Store
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class