Giter Club home page Giter Club logo

Comments (2)

rasbt avatar rasbt commented on August 16, 2024

That's a good point, thanks for bringing that up. Just pasting the relevant passage here for context:

Note that we increase the stride to 5, which is the max length + 1. This is to utilize the data set fully (we don't skip a single word) but also avoid any overlap between the batches, since more overlap could lead to increased overfitting. For instance, if we set the stride equal to the max length, the target ID for the last input token ID in each row would become the first input token ID in the next row.

And the tokens as they appear in tokenizer.encode(raw_text) are as follows:

[40, 367, 2885, 1464, 1807, 3619, 402, 271, 10899, 2138, 257, 7026, 15632, 438, 2016, ...]

max_len=4, stride=5:

In the book I (and code) I used the following setting:

batch 1
x: [40,   367,   2885,  1464]
y: [367,  2885,  1464,  1807]

batch 2
x: [ 3619,   402,   271, 10899]
y: [  402,   271, 10899,  2138],

max_len=4, stride=4:

The alternative, without skipping a token in x, is:

batch 1
x: [  40,   367,   2885,  1464]
y: [  367,  2885,  1464,  1807]

batch 2
x: [ 1807,  3619,   402,   271]
y: [ 3619,   402,   271, 10899]

In this case, the token 1807 is "repeated." I.e. it appears as a target in y (batch 1) and input in x (batch 2). It's not repeated in the input, but it gets used 2x in a way. But thinking about this more, I think this max_len=4, stride=4 should probably be preferred.

from llms-from-scratch.

rasbt avatar rasbt commented on August 16, 2024

Just updated it in the code and manuscript. Thanks again.

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.