Open taniokay opened 1 month ago
It seems in BasicScorer, the _embed func when using Async still process request sequentially not in parallel, and it also take httpx some time to send a retry request when it triggerd async client twice in a short time. can get a log like
2024-11-11 16:52:57,114 - langcheck.metrics.eval_clients._openai - INFO - Azure Async Called.
2024-11-11 16:52:57,214 - httpx - INFO - HTTP Request: POST https://xxxxxx.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2023-05-15 "HTTP/1.1 200 OK"
2024-11-11 16:52:57,226 - langcheck.metrics.eval_clients._openai - INFO - AsyncAzure embedding Response takes 0.11207866668701172 s
2024-11-11 16:52:57,731 - langcheck.metrics.eval_clients._openai - INFO - Azure Async Called.
2024-11-11 16:52:57,733 - openai._base_client - INFO - Retrying request to /embeddings in 0.765730 seconds
2024-11-11 16:52:58,562 - httpx - INFO - HTTP Request: POST https://xxxxxx.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2023-05-15 "HTTP/1.1 200 OK"
2024-11-11 16:52:58,566 - langcheck.metrics.eval_clients._openai - INFO - AsyncAzure embedding Response takes 0.8344950675964355 s
2024-11-11 16:52:58,569 - langcheck.metrics.eval_clients._openai - INFO - Azure Async Called.
2024-11-11 16:52:58,573 - openai._base_client - INFO - Retrying request to /embeddings in 0.934265 seconds
2024-11-11 16:52:59,582 - httpx - INFO - HTTP Request: POST https://xxxxxx.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2023-05-15 "HTTP/1.1 200 OK"
2024-11-11 16:52:59,590 - langcheck.metrics.eval_clients._openai - INFO - AsyncAzure embedding Response takes 1.0200066566467285 s
2024-11-11 16:53:00,094 - langcheck.metrics.eval_clients._openai - INFO - Azure Async Called.
2024-11-11 16:53:00,096 - openai._base_client - INFO - Retrying request to /embeddings in 0.770774 seconds
2024-11-11 16:53:00,928 - httpx - INFO - HTTP Request: POST https://xxxxxx.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2023-05-15 "HTTP/1.1 200 OK"
2024-11-11 16:53:00,936 - langcheck.metrics.eval_clients._openai - INFO - AsyncAzure embedding Response takes 0.8413498401641846 s
2024-11-11 16:53:00,937 - langcheck.metrics.eval_clients._openai - INFO - Azure Async Called.
2024-11-11 16:53:00,939 - openai._base_client - INFO - Retrying request to /embeddings in 0.790448 seconds
2024-11-11 16:53:01,798 - httpx - INFO - HTTP Request: POST https://xxxxxx.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2023-05-15 "HTTP/1.1 200 OK"
2024-11-11 16:53:01,801 - langcheck.metrics.eval_clients._openai - INFO - AsyncAzure embedding Response takes 0.8630878925323486 s
2024-11-11 16:53:02,304 - langcheck.metrics.eval_clients._openai - INFO - Azure Async Called.
I can push a small fix on this.
Thanks for the analysis Vela! It is surprising to me that the calls are actually sequential...
It would be great if you could push a fix, thank you so much!!
Thanks for the analysis Vela! It is surprising to me that the calls are actually sequential...
It would be great if you could push a fix, thank you so much!!
becuase async.run will cost a lot of time maintain the lifecycle of a new event loop at every time it get called, so all these _embed are executed in different event loop, it will looks like a squentially function calling.
From PR #159: