Skip to content

Libraries: Language modeling with PyTorch (1)#303

Merged
edoardob90 merged 27 commits into
mainfrom
new-material/pytorch-llm-tutorial
May 12, 2025
Merged

Libraries: Language modeling with PyTorch (1)#303
edoardob90 merged 27 commits into
mainfrom
new-material/pytorch-llm-tutorial

Conversation

@edoardob90

@edoardob90 edoardob90 commented May 7, 2025

Copy link
Copy Markdown
Member

Part 1 notebook introduces the fundamentals of neural network-based language modeling, from traditional bi-gram approaches to the simplest neural networks.

  • Implementation of a single-layer neural network for character-level language modeling
  • Comparison with the bigram model approach, highlighting similarities in performance but differences in flexibility
  • Step-by-step explanation of the neural network pipeline:
    • One-hot encoding of character inputs
    • Forward pass through a weight matrix
    • Softmax transformation to obtain probability distributions
    • Loss calculation using negative log-likelihood
    • Backward pass for gradient computation
    • Weight updates using gradient descent
  • Introduction to regularization
  • Demonstration of sampling from the trained model

It's the first step of a step-by-step introduction/overview of language modeling using PyTorch library.

@edoardob90

edoardob90 commented May 7, 2025

Copy link
Copy Markdown
Member Author

Left to do:

  • Add more references to extra material
  • Update Table of Contents
  • Finalize the exercises

@edoardob90

edoardob90 commented May 10, 2025

Copy link
Copy Markdown
Member Author

Left to do:

  • Add solutions notebook

@edoardob90 edoardob90 force-pushed the new-material/pytorch-llm-tutorial branch from f36ddee to 9dad59f Compare May 12, 2025 08:28
Comment thread 32_language_modeling_1.ipynb Outdated
@despadam

Copy link
Copy Markdown
Contributor

Also, this should be included in 00_index.ipynb

@despadam despadam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👏

@edoardob90 edoardob90 merged commit cbd5572 into main May 12, 2025
1 check passed
@edoardob90 edoardob90 deleted the new-material/pytorch-llm-tutorial branch May 12, 2025 20:23

@Snowwpanda Snowwpanda left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, good work.

"device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n",
"\n",
"# Load dataset\n",
"words = open('data/names.txt', 'r').read().splitlines()\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"words = open('data/names.txt', 'r').read().splitlines()\n",
"words = open('data/lm/names.txt', 'r').read().splitlines()\n",

names is in a subfolder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants