fix: better logging
Browse files- 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.
|
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.
|
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"
|
|
|
|
|
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}")
|