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

Convert tensor dtype to float64 #388

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

christinaexyou
Copy link
Contributor

When the .results or to_json() method is called on models bootstrapped using the SequenceClassification module it returns an error. For example:

MODEL_ID = "JungleLee/bert-toxic-comment-classification"
BOOTSTRAPPED_TOXICITY_CLASSIFIER = SequenceClassification.bootstrap(MODEL_ID)
classification_results = BOOTSTRAPPED_TOXICITY_CLASSIFIER.run(DOCUMENT)
print(classification_results.results)

Output:

TypeError: Object of type <class 'numpy.float32'> is not JSON serializable

This PR resolves this error by converting the tensor data type to float64 before converting it to a numpy array.

Copy link
Collaborator

@evaline-ju evaline-ju left a comment

Choose a reason for hiding this comment

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

LGTM - thanks!

@evaline-ju evaline-ju merged commit 97ae2bf into caikit:main Sep 4, 2024
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