Remove stale top_k workaround (HF bug fixed upstream)#497
Conversation
The transformers#35736 bug (top_k in pipeline constructor) was fixed in Feb 2025. Remove the workaround comment and pass top_k directly to pipeline() constructor as intended. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request re-enables the 'top_k' and 'function_to_apply' parameters in the Hugging Face audio classification pipeline. Feedback suggests also passing the 'batch_size' parameter to the pipeline constructor to ensure consistency with the cache key and improve performance. Additionally, a potential TypeError was identified when 'top_k' is set to 1, as the pipeline's return format changes from a list to a single dictionary, which may break post-processing logic.
| top_k=top_k, | ||
| function_to_apply=function_to_apply, |
There was a problem hiding this comment.
The batch_size parameter is included in the cache key but is not passed to the pipeline constructor, which means the pipeline will default to a batch size of 1, ignoring the user's preference and potentially impacting performance.
Additionally, please note that when top_k=1, the Hugging Face pipeline returns a single dictionary per input instead of a list of dictionaries. This will cause a TypeError in the post-processing logic at line 158, which expects a list of dictionaries to iterate over.
| top_k=top_k, | |
| function_to_apply=function_to_apply, | |
| top_k=top_k, | |
| function_to_apply=function_to_apply, | |
| batch_size=batch_size, |
batch_size is passed at pipe() call time, not pipeline() constructor. Including it in the cache key created unnecessary duplicate pipelines. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
transformers#35736 fixed Feb 2025. Pass top_k directly to pipeline constructor.