Skip to content

Conversation

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Dec 9, 2021

What does this PR do?

In doc examples in some PT model files, there are cannot import name error. This PR fixes this issue.

Who can review?

@patrickvonplaten

Question:

@patrickvonplaten , in modeling_unispeech.py, there are examples using

from transformers import UniSpeechSatFeatureExtractor

And in some docstring, there are

:class:`~transformers.UniSpeechSatProcessor`

However, these can't be imported

ImportError: cannot import name 'UniSpeechSatFeatureExtractor' from 'transformers' (/home/ydshieh/Desktop/ydshieh/transformers/src/transformers/__init__.py)

Is there any reason to make these objects invisible to transformers?

return self.decoder(*args, **kwargs)


# Copied from transformers.models.bart.modeling_bart.BartForCausalLM with Bart->BigBirdPegasus, 'facebook/bart-large'->"google/bigbird-pegasus-large-arxiv"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

can't keep copy here, because there is no BigBirdPegasusTokenizer

Copy link
Contributor

Choose a reason for hiding this comment

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

could we try to keep the copy and change Bart->BigBirdPegasus to BartDecoderWrapper->BigBirdPegasusDecoderWrapper and BartForCausalLM->BigBirdPegasusForCausalLM? This way the tokenizer should stay the same :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me try it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The following does the trick:

  • BartDecoderWrapper->BigBirdPegasusDecoderWrapper
  • BartForCausalLM->BigBirdPegasusForCausalLM
  • BartPreTrainedModel->BigBirdPegasusPreTrainedModel
  • BartTokenizer->PegasusTokenizer
  • 'facebook/bart-large'->"google/bigbird-pegasus-large-arxiv"

Copy link
Contributor

Choose a reason for hiding this comment

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

perfect!

@patrickvonplaten
Copy link
Contributor

Great catch - thanks a lot for fixing it! I think we should do the exact same thing for the speech models (UniSpeech, SEW, UniSpeechSAT) actually. Feel free to open a PR if you want - I'll put it on my ToDo list as well though

@ydshieh
Copy link
Collaborator Author

ydshieh commented Dec 11, 2021

@patrickvonplaten

So UniSpeechSatFeatureExtractor shouldn't be used by UniSpeechSatModel , and it is supposed to use Wav2Vec2FeatureExtractor?

I have seen

_PROCESSOR_FOR_DOC = "Wav2Vec2Processor"
_SEQ_CLASS_PROCESSOR_FOR_DOC = "Wav2Vec2FeatureExtractor"

and UniSpeechSatFeatureExtractor is not visible to transformers. But I don't have the full context.

@patrickvonplaten
Copy link
Contributor

@patrickvonplaten

So UniSpeechSatFeatureExtractor shouldn't be used by UniSpeechSatModel , and it is supposed to use Wav2Vec2FeatureExtractor?

I have seen

_PROCESSOR_FOR_DOC = "Wav2Vec2Processor"
_SEQ_CLASS_PROCESSOR_FOR_DOC = "Wav2Vec2FeatureExtractor"

and UniSpeechSatFeatureExtractor is not visible to transformers. But I don't have the full context.

Yeah there is no UniSpeechFeatureExtractor since it's the same as Wav2Vec2FeatureExtractor so we should instead just use Wav2Vec2FeatureExtractor. Happy to resolve this is another PR though!

@patrickvonplaten
Copy link
Contributor

@ydshieh - if ok for you, I would like to merge this one now and then if you want we could open a new one for UniSpeechFeatureExtractor

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@ydshieh
Copy link
Collaborator Author

ydshieh commented Dec 13, 2021

@ydshieh - if ok for you, I would like to merge this one now and then if you want we could open a new one for UniSpeechFeatureExtractor

Sure, ok for me.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@sgugger sgugger merged commit ca0b82b into huggingface:master Dec 13, 2021
@ydshieh ydshieh deleted the fix_doc_example_006 branch May 5, 2022 10:41
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.

3 participants