Batch text processing #73
Replies: 9 comments
-
|
You can do it like this: def batch_predict_entities(self, texts, labels, flat_ner=True, threshold=0.5):
"""
Predict entities for a batch of texts.
texts: List of texts | List[str]
labels: List of labels | List[str]
...
""" |
Beta Was this translation helpful? Give feedback.
-
|
Thank you very much, I tried this approach and came accross this issue: Is there any plan to resolve it anytime soon on the new releases? |
Beta Was this translation helpful? Give feedback.
-
|
Fixed now. You can install v0.1.9 @Definelymes |
Beta Was this translation helpful? Give feedback.
-
|
Hi @urchade Urchade |
Beta Was this translation helpful? Give feedback.
-
|
Hi, The batch processing are processed in parallel @Hitish99 |
Beta Was this translation helpful? Give feedback.
-
|
How does this batch processing really works? Above is my implementation for self-study. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I’m trying to perform batch inference using GLiNER and noticed that the batch method seems slower than the sequential one. Here’s what I tried: Batch processingmodel.batch_predict_entities(texts, labels, threshold=0.5) Sequential processingdf["text"].apply(lambda x: model.predict_entities(x, labels, threshold=0.5)) Surprisingly, the second (sequential) approach is faster in my case. Thank you |
Beta Was this translation helpful? Give feedback.
-
|
I agree with folks above, batch processing is slower than sequential. Making it cost prohibitive to use in production with high traffic sadly. @urchade |
Beta Was this translation helpful? Give feedback.
-
|
@Shrinivas23 sequence packing should solve this in v0.2.23, I pushed a PR for this and there is a ~2.5x speedup in workloads, benchmarks scripts contain different test distributions |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I was wondering if there is a feature (or would be in future) to process multiple texts at a same time instead of processing them one by one in sequential manner.
Beta Was this translation helpful? Give feedback.
All reactions