Skip to content

Commit

Permalink
added progress bar on classifier and featurizer
Browse files Browse the repository at this point in the history
  • Loading branch information
sfahad1414 committed Apr 26, 2023
1 parent 6b7bdc5 commit 1f47486
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion kairon/shared/nlu/classifier/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from rasa.shared.nlu.constants import TEXT, INTENT
import openai
import numpy as np
from tqdm import tqdm

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -86,7 +87,7 @@ def train(
"""Train the intent classifier on a data set."""
data_map = []
vector_map = []
for example in training_data.intent_examples:
for example in tqdm(training_data.intent_examples):
vector_map.append(self.get_embeddings(example.get(TEXT)))
data_map.append({'text': example.get(TEXT), 'intent': example.get(INTENT)})
np_vector = np.asarray(vector_map, dtype=np.float32)
Expand Down
5 changes: 3 additions & 2 deletions kairon/shared/nlu/featurizer/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from rasa.shared.nlu.training_data.training_data import TrainingData
from rasa.nlu.components import Component
import os
from tqdm import tqdm

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -99,7 +100,7 @@ def _get_model_features_for_batch(
"""
sentence_embeddings = []
sequence_embeddings = []
for example in batch_examples:
for example in tqdm(batch_examples):
text = example.get(attribute)
tokens = example.get(TOKENS_NAMES[attribute])

Expand Down Expand Up @@ -165,7 +166,6 @@ def train(
)

batch_start_index = 0

while batch_start_index < len(non_empty_examples):

batch_end_index = min(
Expand All @@ -179,6 +179,7 @@ def train(
batch_docs = self._get_docs_for_batch(batch_messages, attribute)

for index, ex in enumerate(batch_messages):
print(index)
self._set_lm_features(batch_docs[index], ex, attribute)
batch_start_index += batch_size

Expand Down

0 comments on commit 1f47486

Please sign in to comment.