【发布时间】:2022-01-16 20:12:22
【问题描述】:
我正在使用这个Notebook,其中Apply DocumentClassifier部分更改如下。
Jupyter Labs,内核:conda_mxnet_latest_p37。
tqdm 是一个进度条包装器。它似乎在for loops 和CLI 上都有效。但是,我想在线使用它:
classified_docs = doc_classifier.predict(docs_to_classify)
这是一个迭代过程,但在引擎盖之下。
如何将 tqdm 应用于此行?
代码单元:
doc_dir = "GRIs/" # contains 2 .pdfs
with open('filt_gri.txt', 'r') as filehandle:
tags = [current_place.rstrip() for current_place in filehandle.readlines()]
doc_classifier = TransformersDocumentClassifier(model_name_or_path="cross-encoder/nli-distilroberta-base",
task="zero-shot-classification",
labels=tags,
batch_size=2)
# convert to Document using a fieldmap for custom content fields the classification should run on
docs_to_classify = [Document.from_dict(d) for d in docs_sliding_window]
# classify using gpu, batch_size makes sure we do not run out of memory
classified_docs = doc_classifier.predict(docs_to_classify)
【问题讨论】:
-
如果这不可能,有什么替代方案适合我的情况?
标签: python-3.x jupyter-lab tqdm