The first one will give you the bare pretrained model, while the second one will have a head attached to do language modeling. Note that AutoModelForLM is deprecated, you should use AutoModelForCausalLM, AutoModelForMaskedLM or AutoModelForSeq2SeqLM depending on the task at hand.