Skip to content

Instantly share code, notes, and snippets.

@Helw150
Helw150 / parallel_t5.py
Last active May 10, 2023 14:52
Flan T5 Parallel Usage
from transformers import AutoTokenizer, T5ForConditionalGeneration
# Model Init
n_gpu = 8
tokenizer = AutoTokenizer.from_pretrained("google/flan-ul2")
model = T5ForConditionalGeneration.from_pretrained("google/flan-ul2")
heads_per_gpu = len(model.encoder.block) // n_gpu
device_map = {
gpu: list(
range(
@jordwalke
jordwalke / watch.sh
Last active September 19, 2018 22:30
Watcher Script Using Unix Find.
#!/bin/bash
# Invoke like this:
# ./watch.sh my command here
# And it will run 'my command here' once, and then when it detects changes.
# TODO: Don't just search in the last second. Search for updates since the last
# completed build. Otherwise for big directories, midway through your search
# you've already taken 1s and you will miss updates.
@EderSantana
EderSantana / CATCH_Keras_RL.md
Last active October 16, 2023 08:32
Keras plays catch - a single file Reinforcement Learning example