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

Update detoxify.py #116

Merged
merged 1 commit into from
Jan 2, 2025
Merged

Update detoxify.py #116

merged 1 commit into from
Jan 2, 2025

Conversation

ACMCMC
Copy link
Contributor

@ACMCMC ACMCMC commented Dec 23, 2024

Optimize the generation of results in predict().

This PR doesn't change any behavior other than using PyTorch directly to generate the results - no need to do a halfway conversion to NumPy. I also removed the need to do a list comprehension.

Optimize the generation of results in `predict()`
@laurahanu
Copy link
Collaborator

Thanks for the PR! Looks good, although I'm still in favour of returning numpy arrays as switching to pytorch tensors might break compatibility if external code expects numpy arrays

@ACMCMC
Copy link
Contributor Author

ACMCMC commented Dec 23, 2024

Thanks for the comment! That's a good point.

However, if you look at the code more closely, you'll see that we're never actually returning NumPy arrays. Instead, we do: PyTorch Tensor -> NumPy Array -> Python List (that's what's returned).

So, in other words, the end user would still get a Dict[str, Union[float, List[float]]]. i.e., not a breaking change :)

If you want I can make that change but I think we could omit that as the return data type is not changed 👍🏻

Copy link
Collaborator

@laurahanu laurahanu left a comment

Choose a reason for hiding this comment

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

Oh yes missed that, looks good then!

@laurahanu laurahanu merged commit 50d16db into unitaryai:master Jan 2, 2025
4 of 5 checks passed
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.

2 participants