Giter Club home page Giter Club logo

Comments (3)

sm354 avatar sm354 commented on August 26, 2024

This post does the same as in your line of code. I also manually checked that the parameters are different in the two ways: AutoModel.from_config and AutoModel.from_pretrained. Could you please confirm this?

from kgt5.

apoorvumang avatar apoorvumang commented on August 26, 2024

Hi Shubham

Pretrained weights are not loaded when loading with config (see https://huggingface.co/docs/transformers/v4.18.0/en/model_doc/t5#transformers.T5ForConditionalGeneration). In the current code, as you pointed out, model is loaded as follows

config = T5Config().from_pretrained('t5-small')
model = T5ForConditionalGeneration(config)

This is not the same as model = T5ForConditionalGeneration.from_pretrained('t5-small'). In our case, from_pretrained method of T5ForConditionalGeneration is not called, hence weights aren't loaded.

I confirmed this in a colab notebook here: https://colab.research.google.com/drive/1Gh5gbp6tl9P-DBHQ_ottV2rBVMB_gSRU?usp=sharing. You can first try generating from the model loaded using the config route (as is done in KGT5 code) and it generates garbage. If you switch to model = T5ForConditionalGeneration.from_pretrained('t5-small'), you can see that it outputs meaningful generations.

Please let me know if you still have doubts on whether it is initialized with pretrained weights or not. Also, I would suggest you look into the 'apoorv-dump' branch instead of main if you want to see a more updated codebase (but its not clean). In that branch, there is a specific flag for enabling the use of pretrained LM weights. I will try and update to using AutoModel.from_config to make it clear that weights aren't loaded, thanks for the suggestion.

from kgt5.

sm354 avatar sm354 commented on August 26, 2024

Thanks for the confirmation! Closing the issue.

from kgt5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.