表单识别器 V2 / 成本呈爆炸式增长
Form Recognizer V2 / Costs are exploding
在回应 ChadZ 时,这里的回答是我正在谈论的表单识别器的指标 Form Recognizer Metrics。
在我们的测试中,我们正在检查目录中的文件并按顺序分析它们,等待每个响应,写入结果,获取下一个文件等等。没有多线程。
查看 4 月 14 日的最大峰值,有 15330 个调用。如果我们假设 4 月 14 日的每个调用都需要 10 秒(这会很快,通常最多可能需要一分钟),那么这些分析需要 153300 秒,即 2555 分钟或 42.58 小时。就算分析5秒也得20多个小时
当然我可能是错的,但目前最合乎逻辑的解释是 get-requests 也被跟踪和计费。
原版Post
我正在使用带有标签的自定义模型(使用示例标签工具创建)并使用此 this 页面底部的 "Python Form Recognizer Async Analyze" V2 SDK 代码获取结果。
虽然 V2 中的异步功能比 V1 慢得多(我描述过 ),但它似乎也贵得多。
在 post api 调用后获取结果的原始示例代码如下所示:
n_tries = 15
n_try = 0
wait_sec = 5
max_wait_sec = 60
while n_try < n_tries:
try:
resp = get(url = get_url, headers = {"Ocp-Apim-Subscription-Key": apim_key})
resp_json = resp.json()
if resp.status_code != 200:
print("GET analyze results failed:\n%s" % json.dumps(resp_json))
quit()
status = resp_json["status"]
if status == "succeeded":
print("Analysis succeeded:\n%s" % json.dumps(resp_json))
quit()
if status == "failed":
print("Analysis failed:\n%s" % json.dumps(resp_json))
quit()
# Analysis still running. Wait and retry.
time.sleep(wait_sec)
n_try += 1
wait_sec = min(2*wait_sec, max_wait_sec)
except Exception as e:
msg = "GET analyze results failed:\n%s" % str(e)
print(msg)
quit()
print("Analyze operation did not complete within the allocated time.")
正如您在原始示例代码中所见,它每 5 秒查看一次以获取结果。
我的问题:
在我看来,不仅对分析文档的 api 调用收费,而且对获取结果的每个 get-request 都收费。
自从使用 V2 以来,我们的账单增加了十倍甚至更多。
我们目前处于测试阶段,我们通常每月大约有 400-500 个文档在 V1 中被正确跟踪和计费。使用 V2 和上面的示例代码,我们现在有 63690 (!!!!!) 次通话,每次通话都会收费,费用呈爆炸式增长。
任何人都可以证实这种行为吗?
我个人希望恢复同步操作,其中 api 调用的响应还包含任何文档分析的结果。
try:
url = base_url + "/models/" + model_id + "/analyze"
with open(filepath, "rb") as f:
data_bytes = f.read()
response = requests.post(url=url, data=data_bytes, headers=headers)
return response.json()
except Exception as e:
print(str(e))
return None
不幸的是,这不再有效了......
try:
response = requests.post(url=post_url, data=data_bytes, headers=headers) # , params=params)
if response.status_code != 202:
return None
# Success
get_url = response.headers["operation-location"]
return form_recognizerv2_getdata(get_url, subscription_key)
except Exception as e:
print("POST analyze failed:\n%s" % str(e))
return None
我可以确认在 Form Recognizer v2 中,GET 调用不计费。火车电话也是免费的。如果有计费问题,请联系客户服务。
GetAnalyzeResults 调用不计费。 Form Recognizer 仅针对分析的页面计费,而不是按交易和请求计费。该图 "Form Recognizer Metrics" 显示了您的所有交易和 API 调用,包括 GetAnalyzeResults,但您无需为此付费。 V1和V2的计费是一样的。如果您遇到账单问题,请联系客户服务。
Neta-MSFT
在回应 ChadZ 时,这里的回答是我正在谈论的表单识别器的指标 Form Recognizer Metrics。 在我们的测试中,我们正在检查目录中的文件并按顺序分析它们,等待每个响应,写入结果,获取下一个文件等等。没有多线程。
查看 4 月 14 日的最大峰值,有 15330 个调用。如果我们假设 4 月 14 日的每个调用都需要 10 秒(这会很快,通常最多可能需要一分钟),那么这些分析需要 153300 秒,即 2555 分钟或 42.58 小时。就算分析5秒也得20多个小时
当然我可能是错的,但目前最合乎逻辑的解释是 get-requests 也被跟踪和计费。
原版Post
我正在使用带有标签的自定义模型(使用示例标签工具创建)并使用此 this 页面底部的 "Python Form Recognizer Async Analyze" V2 SDK 代码获取结果。
虽然 V2 中的异步功能比 V1 慢得多(我描述过
在 post api 调用后获取结果的原始示例代码如下所示:
n_tries = 15
n_try = 0
wait_sec = 5
max_wait_sec = 60
while n_try < n_tries:
try:
resp = get(url = get_url, headers = {"Ocp-Apim-Subscription-Key": apim_key})
resp_json = resp.json()
if resp.status_code != 200:
print("GET analyze results failed:\n%s" % json.dumps(resp_json))
quit()
status = resp_json["status"]
if status == "succeeded":
print("Analysis succeeded:\n%s" % json.dumps(resp_json))
quit()
if status == "failed":
print("Analysis failed:\n%s" % json.dumps(resp_json))
quit()
# Analysis still running. Wait and retry.
time.sleep(wait_sec)
n_try += 1
wait_sec = min(2*wait_sec, max_wait_sec)
except Exception as e:
msg = "GET analyze results failed:\n%s" % str(e)
print(msg)
quit()
print("Analyze operation did not complete within the allocated time.")
正如您在原始示例代码中所见,它每 5 秒查看一次以获取结果。
我的问题: 在我看来,不仅对分析文档的 api 调用收费,而且对获取结果的每个 get-request 都收费。
自从使用 V2 以来,我们的账单增加了十倍甚至更多。 我们目前处于测试阶段,我们通常每月大约有 400-500 个文档在 V1 中被正确跟踪和计费。使用 V2 和上面的示例代码,我们现在有 63690 (!!!!!) 次通话,每次通话都会收费,费用呈爆炸式增长。
任何人都可以证实这种行为吗?
我个人希望恢复同步操作,其中 api 调用的响应还包含任何文档分析的结果。
try:
url = base_url + "/models/" + model_id + "/analyze"
with open(filepath, "rb") as f:
data_bytes = f.read()
response = requests.post(url=url, data=data_bytes, headers=headers)
return response.json()
except Exception as e:
print(str(e))
return None
不幸的是,这不再有效了......
try:
response = requests.post(url=post_url, data=data_bytes, headers=headers) # , params=params)
if response.status_code != 202:
return None
# Success
get_url = response.headers["operation-location"]
return form_recognizerv2_getdata(get_url, subscription_key)
except Exception as e:
print("POST analyze failed:\n%s" % str(e))
return None
我可以确认在 Form Recognizer v2 中,GET 调用不计费。火车电话也是免费的。如果有计费问题,请联系客户服务。
GetAnalyzeResults 调用不计费。 Form Recognizer 仅针对分析的页面计费,而不是按交易和请求计费。该图 "Form Recognizer Metrics" 显示了您的所有交易和 API 调用,包括 GetAnalyzeResults,但您无需为此付费。 V1和V2的计费是一样的。如果您遇到账单问题,请联系客户服务。
Neta-MSFT