Skip to content

Conversation

@alex-matton
Copy link
Contributor

  • multilabel classification adds two new fields: predictions and confidences. Add support for these fields.
  • mutlilabel classification doesn't return prediction and confidence fields. Mark these fields as optional.
  • prediction and confidence fields will eventually be removed. Add "to be deprecated" comments.

Important note: this PR does not introduce any breaking change.

@alex-matton alex-matton force-pushed the alexandre/new_classify_support branch 2 times, most recently from e1c27dd to 634c298 Compare October 13, 2023 21:11
@alex-matton alex-matton marked this pull request as ready for review October 13, 2023 21:14
@alex-matton alex-matton requested review from a team and sanderland as code owners October 13, 2023 21:14
self.input = input
self.prediction = prediction
self.confidence = confidence
self.prediction = prediction # to be deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you expect to deprecate this field in the future?

Copy link
Contributor Author

@alex-matton alex-matton Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lfayoux You're probably better positioned to answer this question than me. I'm not sure what the standard procedure is for field deprecation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be deprecated when we do an api version change. Not sure if we still want to support this field in the future

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the following?

 @property
 def prediction(self):
      print("your deprecation warning here")
      return self.prediction

After a couple of release you can remove it altogether

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took that into account

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely no print calls, we have logger for that.
@mkozakov could you comment on versioning and if the above is an acceptable way to have breaking api and sdk changes?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging warnings for now is ok. when we deprecate we will need to bump the major SDK version

Copy link
Contributor

@sanderland sanderland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test that covers this, add to changelog, and bump the minor version

@harry-cohere harry-cohere removed their request for review October 16, 2023 13:26
@alex-matton
Copy link
Contributor Author

@sanderland I implemented all your requested changes 👍. For the tests it is not possible to use a real co.classify() call as it would require to finetune a model first (which takes ~30min). Instead, I mocked the _request() call and tried all the possible format outputs.


if self._prediction is None or self._confidence is None:
if self._prediction is not None or self._confidence is not None:
raise ValueError("Cannot have one of prediction and confidence be None and not the other one")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError("Cannot have one of prediction and confidence be None and not the other one")
raise ValueError("Cannot have one of `prediction` and `confidence` be `None` and not the other one")

self.input = input
self.prediction = prediction
self.confidence = confidence
self.prediction = prediction # to be deprecated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging warnings for now is ok. when we deprecate we will need to bump the major SDK version

@alex-matton alex-matton force-pushed the alexandre/new_classify_support branch from acba0ea to da18bbc Compare October 17, 2023 21:08
@alex-matton alex-matton merged commit 085cb98 into main Oct 19, 2023
@alex-matton alex-matton deleted the alexandre/new_classify_support branch October 19, 2023 14:03
fede-kamel pushed a commit to fede-kamel/cohere-python that referenced this pull request Jan 26, 2026
* add support for multilabel

* address comments

* replace mocker with monkeypatch

* print -> log

* address comment

* remove ambiguity in comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants