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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update detoxify.py #116

wants to merge 1 commit into from

Conversation

ACMCMC
Copy link

@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
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 👍🏻

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