Skip to content

Commit c20abf5

Browse files
[Inference] fix zero shot classification output parsing (#3561)
* fix zero shot classification output parsing * nit
1 parent 55abd38 commit c20abf5

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/huggingface_hub/inference/_client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,10 +3196,7 @@ def zero_shot_classification(
31963196
)
31973197
response = self._inner_post(request_parameters)
31983198
output = _bytes_to_dict(response)
3199-
return [
3200-
ZeroShotClassificationOutputElement.parse_obj_as_instance({"label": label, "score": score})
3201-
for label, score in zip(output["labels"], output["scores"])
3202-
]
3199+
return ZeroShotClassificationOutputElement.parse_obj_as_list(output)
32033200

32043201
def zero_shot_image_classification(
32053202
self,

src/huggingface_hub/inference/_generated/_async_client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,10 +3246,7 @@ async def zero_shot_classification(
32463246
)
32473247
response = await self._inner_post(request_parameters)
32483248
output = _bytes_to_dict(response)
3249-
return [
3250-
ZeroShotClassificationOutputElement.parse_obj_as_instance({"label": label, "score": score})
3251-
for label, score in zip(output["labels"], output["scores"])
3252-
]
3249+
return ZeroShotClassificationOutputElement.parse_obj_as_list(output)
32533250

32543251
async def zero_shot_image_classification(
32553252
self,

0 commit comments

Comments
 (0)