Disable tqdm
#66
by
ivanstepanovftw
- opened
https://huggingface.co/jinaai/xlm-roberta-flash-implementation/discussions/48
Previously tried to disable useless tqdm without luck when performing .encode() until someone pointed me to the root cause, to this repo. Here is the description of the tqdm issue: https://github.com/huggingface/transformers/issues/34438
Have you tried to pass show_progress_bar=False
to the encode function?
I tried your code with this and I only see the reporting from your own process bar after the change:
import asyncio
import logging
import numpy as np
import torch
import tqdm.asyncio as tqdm
from tqdm.contrib.logging import logging_redirect_tqdm
from transformers import AutoModel
logger = logging.getLogger(__name__)
async def main():
text_encoder_model = AutoModel.from_pretrained("jinaai/jina-embeddings-v3", trust_remote_code=True)
if torch.cuda.is_available():
text_encoder_model.to(torch.device('cuda'))
text_encoder_model = text_encoder_model.to(torch.bfloat16)
for i in tqdm.tqdm(range(100), desc="Encoding and commiting", unit="messages", unit_scale=32):
- embedding = text_encoder_model.encode("Hello", task="retrieval.passage", truncate_dim=128 * 6)
+ embedding = text_encoder_model.encode("Hello", task="retrieval.passage", truncate_dim=128 * 6, show_progress_bar=False)
logger.info(f"{np.mean(embedding, axis=0)}")
await asyncio.sleep(0.5)
if __name__ == '__main__':
# logging.basicConfig(level=logging.ERROR, format="[+%(relativeCreated)d ms] [%(asctime)s] %(message)s", datefmt="%H:%M:%S")
logging.basicConfig(level=logging.INFO, format="[+%(relativeCreated)d ms] [%(asctime)s] %(message)s", datefmt="%H:%M:%S")
logger.setLevel(logging.DEBUG)
with logging_redirect_tqdm(loggers=[logger]):
asyncio.run(main())
If you don't pass the show_progress_bar
argument the model determines based on the log lever whether to set it to True or False. I think this is causing your code to show the progress bar.