Skip to content

Commit a1cfea5

Browse files
committed
Merge branch 'main' of github.com:ebrahimpichka/examples into gat
2 parents d390c94 + 6fc19c7 commit a1cfea5

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

distributed/minGPT-ddp/mingpt/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import torch
23
from torch.utils.data import random_split
34
from torch.distributed import init_process_group, destroy_process_group

distributed/rpc/batch/parameter_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def update_and_fetch_model(ps_rref, grads):
5454
p.grad /= self.batch_update_size
5555
self.curr_update_size = 0
5656
self.optimizer.step()
57-
self.optimizer.zero_grad()
57+
self.optimizer.zero_grad(set_to_none=False)
5858
fut.set_result(self.model)
5959
timed_log("PS updated model")
6060
self.future_model = torch.futures.Future()

legacy/snli/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# PyTorch-based NLI Training with SNLI
2+
3+
## 📝 Overview
4+
5+
This repository contains Python scripts to train a Natural Language Inference (NLI) model, specifically the `SNLIClassifier`, using the Stanford Natural Language Inference (SNLI) corpus. The trained model predicts textual entailment, identifying if a statement is entailed, contradicted, or neither by another statement.
6+
7+
## ⚙️ Dependencies
8+
9+
Install the necessary Python libraries with:
10+
11+
```bash
12+
pip install -r requirements.txt
13+
```
14+
15+
The `requirements.txt` file includes:
16+
17+
```
18+
torch
19+
torchtext
20+
spacy
21+
```
22+
23+
## 💻 Usage
24+
25+
Start the training process with:
26+
27+
```bash
28+
python train.py --lower --word-vectors [PATH_TO_WORD_VECTORS] --vector-cache [PATH_TO_VECTOR_CACHE] --epochs [NUMBER_OF_EPOCHS] --batch-size [BATCH_SIZE] --save-path [PATH_TO_SAVE_MODEL] --gpu [GPU_NUMBER]
29+
```
30+
31+
## 🏋️‍♀️ Training
32+
33+
The script trains the model on mini-batches of data across a specified number of epochs. It saves the best-performing model on the validation set as a `.pt` file in the specified directory.
34+
35+
## 📚 Scripts
36+
37+
- `model.py`: Defines the `SNLIClassifier` model and auxiliary classes.
38+
- `util.py`: Contains utility functions for directory creation and command-line argument parsing.
39+
40+
## 📣 Note
41+
42+
Ensure the `model.py` and `util.py` scripts are available in your working directory.

0 commit comments

Comments
 (0)