-
Notifications
You must be signed in to change notification settings - Fork 25.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using batching with pipeline and transformers #31641
Comments
UPDATE: It doesn't work! It works for small datasets and smaller batch sizes, but fails silently with no errors on a large dataset with a reasonable batch size. For example, the script uses BATCH_SIZE =2 and a dataset with 4 inputs. This took 4 minutes to run with Llama-2-chat on an A100. When I considered the full dataset, which is ~7200 inputs with a batch size of 4, it was hanging on the |
@arunasank have you tried using the map method ? def fn(batch) :
batch["new_col"] = pipe(batch["prompt"])
return batch
dataset = dataset.map(fn, batched = True , batch_size = BATCH_SIZE )
responses = dataset["new_col"] |
Yes, I did that with/without setting |
Hi @arunasank, have you tried other models and other methods of dataset creation to see if the issue recurs? It'd be helpful if you could figure out some minimal specific reproducer code for this issue, so that we could run it here and figure out what's going on! |
System Info
transformers
version: 4.41.2Who can help?
@ArthurZucker @Narsil @stevhliu
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
for d in tqdm(pipe(KeyDataset(dataset, 'prompt'), batch_size=BATCH_SIZE)):
and doesn't progress. No errors are thrown.batch_size
is not provided in the above line, but tqdm only shows progress on completion.batch_size
with this linepipe = pipeline("text-generation", model="meta-llama/Llama-2-70b-chat-hf", device_map='auto', max_new_tokens=1024, batch_size=BATCH_SIZE, model_kwargs={"cache_dir": os.environ['TRANSFORMERS_CACHE'], "quantization_config": nf4_config})
but it doesn't work.Expected behavior
I would expect the code to work with batching.
Clear documentation on batching when using pipelines would be appreciated.
The text was updated successfully, but these errors were encountered: