Feature request : Add progress bar

#13
by malreyyashi - opened

Hello,

Could you consider integrating a progress bar into the embedding process? When dealing with large datasets, tracking the progress and estimating the remaining time becomes challenging. A progress bar could greatly enhance the monitoring process.

Thanks

There's now native support, with show_progress_bar argument.

Otherwise you can always use tqdm very easily yourself:

import tqdm

document_embeddings = []
# np.array_split's second argument takes the desired number of splits as input, not the desired split size
for chunk in tqdm.tqdm(np.array_split(documents, len(documents) // 512)):
    document_embeddings.extend(embedding_model.encode([
        [instruction, doc["text_to_embed"]] for doc in chunk
    ]))
NLP Group of The University of Hong Kong org

Hi, Thanks a lot for your interest in the INSTRUCTOR model!

It is easy to have a progress bar in the encoding process. For example:

from InstructorEmbedding import INSTRUCTOR
model = INSTRUCTOR('hkunlp/instructor-large')
corpus = [['Represent the Wikipedia document for retrieval: ','Capitalism has been dominant in the Western world since the end of feudalism, but most feel[who?] that the term "mixed economies" more precisely describes most contemporary economies, due to their containing both private-owned and state-owned enterprises. In capitalism, prices determine the demand-supply scale. For example, higher demand for certain goods and services lead to higher prices and lower demand for certain goods lead to lower prices.'],
          ['Represent the Wikipedia document for retrieval: ',"The disparate impact theory is especially controversial under the Fair Housing Act because the Act regulates many activities relating to housing, insurance, and mortgage loans—and some scholars have argued that the theory's use under the Fair Housing Act, combined with extensions of the Community Reinvestment Act, contributed to rise of sub-prime lending and the crash of the U.S. housing market and ensuing global economic recession"],
          ['Represent the Wikipedia document for retrieval: ','Disparate impact in United States labor law refers to practices in employment, housing, and other areas that adversely affect one group of people of a protected characteristic more than another, even though rules applied by employers or landlords are formally neutral. Although the protected classes vary by statute, most federal civil rights laws protect based on race, color, religion, national origin, and sex as protected traits, and some laws include disability status and other traits as well.']]
corpus_embeddings = model.encode(corpus,show_progress_bar=True)

Feel free to add any further questions or comments!

Sign up or log in to comment