huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
135.19k stars 27.06k forks source link

[Documentation] PLEASE HELP with very simple tasks!!! #13190

Closed asigalov61 closed 3 years ago

asigalov61 commented 3 years ago

Hello hugginface team,.

First of all, I wanted to report a bug I am getting in Google Colab.

When I do:

from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained('allenai/scibert_scivocab_uncased')
input_ids = tokenizer('I enjoy walking with my cute dog', return_tensors='pt').input_ids
model = AutoModel.from_pretrained('allenai/scibert_scivocab_uncased')
model.eval()
model.generate(input_ids)

I get:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-85c40f45fd28> in <module>()
      1 input_ids = tokenizer('I enjoy walking with my cute dog', return_tensors='pt').input_ids
----> 2 model.generate(input_ids=input_ids)

2 frames
/usr/local/lib/python3.7/dist-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs)
     26         def decorate_context(*args, **kwargs):
     27             with self.__class__():
---> 28                 return func(*args, **kwargs)
     29         return cast(F, decorate_context)
     30 

/usr/local/lib/python3.7/dist-packages/transformers/generation_utils.py in generate(self, input_ids, max_length, min_length, do_sample, early_stopping, num_beams, temperature, top_k, top_p, repetition_penalty, bad_words_ids, bos_token_id, pad_token_id, eos_token_id, length_penalty, no_repeat_ngram_size, encoder_no_repeat_ngram_size, num_return_sequences, max_time, max_new_tokens, decoder_start_token_id, use_cache, num_beam_groups, diversity_penalty, prefix_allowed_tokens_fn, output_attentions, output_hidden_states, output_scores, return_dict_in_generate, forced_bos_token_id, forced_eos_token_id, remove_invalid_values, synced_gpus, **model_kwargs)
    996                 return_dict_in_generate=return_dict_in_generate,
    997                 synced_gpus=synced_gpus,
--> 998                 **model_kwargs,
    999             )
   1000 

/usr/local/lib/python3.7/dist-packages/transformers/generation_utils.py in greedy_search(self, input_ids, logits_processor, stopping_criteria, max_length, pad_token_id, eos_token_id, output_attentions, output_hidden_states, output_scores, return_dict_in_generate, synced_gpus, **model_kwargs)
   1301                 continue  # don't waste resources running the code we don't need
   1302 
-> 1303             next_token_logits = outputs.logits[:, -1, :]
   1304 
   1305             # Store scores, attentions and hidden_states when required

AttributeError: 'BaseModelOutputWithPoolingAndCrossAttentions' object has no attribute 'logits'

===========================================================================

Secondly, I am reporting to you another very serious issue IMHO that needs to be addressed ASAP!!!

THERE ARE NO CLEAR AND SIMPLE EXAMPLES ON HOW TO USE HUGGINFACE models/software ANYWHERE !!!!

WTF??? I do not mean to be rude but this is ridiculous and insulting. I have wasted hours going through your docs, w/o ANY success. Everything is either absolutely unclear or does not work properly.

WHAT I PERSONALLY NEED:

GOOGLE COLABS that show in a few lines of code how to train Huggingface models from scratch (NOT A SINGLE EXAMPLE ANYWHERE). And also most of your examples and colabs are either incomplete/not working or very specific so they can't be used elsewhere!!!

====================================================================

I would really appreciate it if you would address all of these issues ASAP because otherwise, I will not be able to use Huggingface transformers nor would I recommend it to anyone.

Thank you very much for listening to my criticism. I do not mean to chastise, only to help make huggingface better! :)

Alex.

patrickvonplaten commented 3 years ago

Hey Alex,

I'm sorry that you didn't manage to find what you were looking for in the docs.

1) Please not that "bert-like" models should not be used for sequence generation, but rather for sequence classification. The model "allenai/scibert_scivocab_uncased" is essentially a bert-base-uncased model you can checkout here where you can see some examples. Only seq2seq and lm-head models should make use of generate. This doc might help you for more explanation: https://huggingface.co/transformers/model_summary.html

2) Re: Examples:

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.