I am trying to use a huggingface model with a pre-existing training framework. The issue is that instead of the model returning a pytorch tensor, its returning a ClassifierOutput object.
Is there a way to have the model return a pytorch tensor using configs or at the initialization? I could only find a way to return a tuple, but I only want the output tensor.
You can define a new class that extends from the Hugging Face model, override forward
to first call forward
from the base class and then only return the thing you care about.
Thanks for the answer. I came up with the same solution and it works! Its not as pretty as just doing model = SomeModel(output_only_tensor=True)
, but it gets the job done.
I thought this might be a more common issue and that there would be an easier way to do this, but I guess not