Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix optional model in tabular tasks #2018

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix optional model in tabular tasks
  • Loading branch information
Wauplin committed Feb 6, 2024
commit 3c5b39728a3e256ab6166b57c5d3dfdcd41ba7d1
18 changes: 10 additions & 8 deletions src/huggingface_hub/inference/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,16 +1063,17 @@ def table_question_answering(
)
return _bytes_to_dict(response) # type: ignore

def tabular_classification(self, table: Dict[str, Any], *, model: str) -> List[str]:
def tabular_classification(self, table: Dict[str, Any], *, model: Optional[str] = None) -> List[str]:
"""
Classifying a target category (a group) based on a set of attributes.

Args:
table (`Dict[str, Any]`):
Set of attributes to classify.
model (`str`):
The model to use for the tabular-classification task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint.
model (`str`, *optional*):
The model to use for the tabular classification task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint. If not provided, the default recommended text classification model will be used.
Defaults to None.

Returns:
`List`: a list of labels, one per row in the initial table.
Expand Down Expand Up @@ -1107,16 +1108,17 @@ def tabular_classification(self, table: Dict[str, Any], *, model: str) -> List[s
response = self.post(json={"table": table}, model=model, task="tabular-classification")
return _bytes_to_list(response)

def tabular_regression(self, table: Dict[str, Any], *, model: str) -> List[float]:
def tabular_regression(self, table: Dict[str, Any], *, model: Optional[str] = None) -> List[float]:
"""
Predicting a numerical target value given a set of attributes/features in a table.

Args:
table (`Dict[str, Any]`):
Set of attributes stored in a table. The attributes used to predict the target can be both numerical and categorical.
model (`str`):
The model to use for the tabular-regression task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint.
model (`str`, *optional*):
The model to use for the tabular regression task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint. If not provided, the default recommended text classification model will be used.
Defaults to None.

Returns:
`List`: a list of predicted numerical target values.
Expand Down
18 changes: 10 additions & 8 deletions src/huggingface_hub/inference/_generated/_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,16 +1080,17 @@ async def table_question_answering(
)
return _bytes_to_dict(response) # type: ignore

async def tabular_classification(self, table: Dict[str, Any], *, model: str) -> List[str]:
async def tabular_classification(self, table: Dict[str, Any], *, model: Optional[str] = None) -> List[str]:
"""
Classifying a target category (a group) based on a set of attributes.

Args:
table (`Dict[str, Any]`):
Set of attributes to classify.
model (`str`):
The model to use for the tabular-classification task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint.
model (`str`, *optional*):
The model to use for the tabular classification task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint. If not provided, the default recommended text classification model will be used.
Defaults to None.

Returns:
`List`: a list of labels, one per row in the initial table.
Expand Down Expand Up @@ -1125,16 +1126,17 @@ async def tabular_classification(self, table: Dict[str, Any], *, model: str) ->
response = await self.post(json={"table": table}, model=model, task="tabular-classification")
return _bytes_to_list(response)

async def tabular_regression(self, table: Dict[str, Any], *, model: str) -> List[float]:
async def tabular_regression(self, table: Dict[str, Any], *, model: Optional[str] = None) -> List[float]:
"""
Predicting a numerical target value given a set of attributes/features in a table.

Args:
table (`Dict[str, Any]`):
Set of attributes stored in a table. The attributes used to predict the target can be both numerical and categorical.
model (`str`):
The model to use for the tabular-regression task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint.
model (`str`, *optional*):
The model to use for the tabular regression task. Can be a model ID hosted on the Hugging Face Hub or a URL to
a deployed Inference Endpoint. If not provided, the default recommended text classification model will be used.
Defaults to None.

Returns:
`List`: a list of predicted numerical target values.
Expand Down
Loading