GithubHelp home page GithubHelp logo

Comments (2)

rasbt avatar rasbt commented on May 29, 2024 3

These are good questions!

I am not sure which one is better: .reshape() or .view()?

I wouldn't say one is better than the other but yeah, they are subtly different

  • The .view method returns a new tensor with the same data as the original tensor.

  • The .reshape method and can handle non-contiguous tensors and will automatically make a contiguous copy of the tensor if necessary.

I've been using .view in the main book for consistency (and because it's been the original method in PyTorch for reshaping before .reshape was added later).

But yeah, it requires the .contiguous here. (Maybe not a bad thing though for educational purposes.)

I will update it here in bonus material as well, changing .reshape to .view, to make it more consistent.

.unbind(0) is not necessary (the shape of queries, keys, values does not change without it), is it a speed concern?

I think you might be right. I will investigate ...

According to the equivalent implementation in F.scaled_dot_product_attention(), it seems like self.proj() is missing at the end:

Good catch, I may have missed that one. Will update it!

from llms-from-scratch.

rasbt avatar rasbt commented on May 29, 2024 3

Looks like adding the missing projection layer had only minimal impact on the runtime. You can find the updated results in #131 . Thanks again for all your thoughtful question. Please feel free to reopen this or post new issues if you have any follow-up questions.

from llms-from-scratch.

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.