Skip to content

Train in epochs MLX-lm? #728

Answered by mark-lord
mark-lord asked this question in Q&A
Feb 22, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Ohh weirdly I just implemented your code and now it's not properly reading the number of entries in the JSONL. It's meant to be 140 entries, but for some reason it's detecting 18 as iters_per_epoch? That's both with my version of your code + your original code. Going to try debug but clearly something is up with the way I implemented it. Unless I'm misunderstanding iters.

EDIT: figured out it's because as is, your code is counting the number of letters in the string that points to the file! Had to rejig it:

train_file = "./data/train.jsonl"
iters_per_epoch = -(-sum(1 for _ in open(train_file)) // batch_size)
iters = iters_per_epoch * epochs

This is finally working as intended 😊

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mark-lord
Comment options

@mark-lord
Comment options

Answer selected by mark-lord
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants