fdurant commited on
Commit
fe7831c
1 Parent(s): 68b896e

fix: better logging

Browse files
Files changed (1) hide show
  1. handler.py +6 -3
handler.py CHANGED
@@ -50,24 +50,27 @@ class EndpointHandler():
50
 
51
  if len(texts) == 1:
52
  # It's a query
53
- logger.debug(f"Query: {texts}")
54
  embedding = self._checkpoint.queryFromText(
55
  queries=texts,
56
  full_length_search=False, # Indicates whether to encode the query for a full-length search.
57
  )
58
- logger.debug(f"Query embedding shape: {embedding.shape}")
59
  return [
60
  {"input": inputs, "query_embedding": embedding.tolist()[0]}
61
  ]
62
  elif len(texts) > 1:
63
  # It's a batch of chunks
64
- logger.info(f"Batch of chunks: {texts}")
 
 
65
  embeddings, token_id_lists = self._checkpoint.docFromText(
66
  docs=texts,
67
  bsize=self._config.bsize, # Batch size
68
  keep_dims=True, # Do NOT flatten the embeddings
69
  return_tokens=True, # Return the tokens as well
70
  )
 
71
  token_lists = []
72
  for text, embedding, token_ids in zip(texts, embeddings, token_id_lists):
73
  logger.debug(f"Chunk: {text}")
 
50
 
51
  if len(texts) == 1:
52
  # It's a query
53
+ logger.info(f"Received query of 1 text with {len(texts[0])} characters and {len(texts[0].split())} words")
54
  embedding = self._checkpoint.queryFromText(
55
  queries=texts,
56
  full_length_search=False, # Indicates whether to encode the query for a full-length search.
57
  )
58
+ logger.info(f"Query embedding shape: {embedding.shape}")
59
  return [
60
  {"input": inputs, "query_embedding": embedding.tolist()[0]}
61
  ]
62
  elif len(texts) > 1:
63
  # It's a batch of chunks
64
+ logger.info(f"Received batch of {len(texts)} chunks")
65
+ for i, text in enumerate(texts):
66
+ logger.info(f"Chunk {i} has {len(text)} characters and {len(text.split())} words")
67
  embeddings, token_id_lists = self._checkpoint.docFromText(
68
  docs=texts,
69
  bsize=self._config.bsize, # Batch size
70
  keep_dims=True, # Do NOT flatten the embeddings
71
  return_tokens=True, # Return the tokens as well
72
  )
73
+ logger.info(f"Chunk embeddings shape: {embeddings.shape}")
74
  token_lists = []
75
  for text, embedding, token_ids in zip(texts, embeddings, token_id_lists):
76
  logger.debug(f"Chunk: {text}")