Skip to content

Commit 63523b2

Browse files
committed
[Inference] fix zero shot classification output parsing (#3561)
* fix zero shot classification output parsing * nit
1 parent c9d0870 commit 63523b2

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
@@ -3195,10 +3195,7 @@ def zero_shot_classification(
31953195
)
31963196
response = self._inner_post(request_parameters)
31973197
output = _bytes_to_dict(response)
3198-
return [
3199-
ZeroShotClassificationOutputElement.parse_obj_as_instance({"label": label, "score": score})
3200-
for label, score in zip(output["labels"], output["scores"])
3201-
]
3198+
return ZeroShotClassificationOutputElement.parse_obj_as_list(output)
32023199

32033200
def zero_shot_image_classification(
32043201
self,

src/huggingface_hub/inference/_generated/_async_client.py

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

32533250
async def zero_shot_image_classification(
32543251
self,

0 commit comments

Comments
 (0)