shahidul034 commited on
Commit
c165272
·
verified ·
1 Parent(s): f18489b

Add files using upload-large-folder tool

Browse files
assignment_llm_1/assignment_image/install_env_and_run.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Install Environment (Conda) and Run Scripts
2
+
3
+ This guide sets up a Conda environment and runs both scripts:
4
+
5
+ - `assignment_image/code/c1.py` (train + save checkpoint)
6
+ - `assignment_image/code/c1_test.py` (evaluate + error analysis)
7
+
8
+ First need to enter this folder:
9
+
10
+ ```bash
11
+ cd assignment_llm_1/assignment_image
12
+ ```
13
+
14
+
15
+ ## 1) Create and activate Conda environment
16
+
17
+ ```bash
18
+ conda create -n transformer_hw python=3.10 -y
19
+ conda activate transformer_hw
20
+ python -m pip install --upgrade pip
21
+ ```
22
+
23
+ ## 2) Install dependencies
24
+
25
+ If there is a `requirements.txt` file in this folder, run:
26
+
27
+ ```bash
28
+ pip install -r requirements.txt
29
+ ```
30
+
31
+
32
+ ## 3) Run training script (`c1.py`)
33
+
34
+ Move to the code directory and run:
35
+
36
+ ```bash
37
+ python code/c1.py
38
+ ```
39
+
40
+ Expected outputs include:
41
+
42
+ - `saved_model/vit_cifar10_best.pt`
43
+ - `saved_model/vit_cifar10_last.pt`
44
+
45
+ ## 4) Run evaluation script (`c1_test.py`)
46
+
47
+ After training completes:
48
+
49
+ ```bash
50
+ python code/c1_test.py \
51
+ --checkpoint-path ./saved_model/vit_cifar10_best.pt \
52
+ --results-dir ./results
53
+ ```
54
+
55
+ This baseline evaluation run saves:
56
+
57
+ - `results/baseline_analysis.txt`
58
+ - `results/misclassified_examples_test.png`
59
+
60
+ ## 5) Run optional pre-trained ViT comparison
61
+
62
+ To run transfer learning and compare baseline vs pre-trained ViT:
63
+
64
+ ```bash
65
+ python code/c1_test.py \
66
+ --checkpoint-path ./saved_model/vit_cifar10_best.pt \
67
+ --results-dir ./results \
68
+ --run-pretrained-experiment
69
+ ```
70
+
71
+ Additional files saved in this mode:
72
+
73
+ - `results/pretrained_vit_analysis.txt`
74
+ - `results/misclassified_examples_pretrained_vit.png`
75
+ - `results/comparison_report.txt`
76
+
77
+ ## 6) Where data and outputs are saved
78
+
79
+ - **Dataset download/cache**: `./data`
80
+ (both `c1.py` and `c1_test.py` load CIFAR-10 from this folder by default)
81
+ - **Model checkpoints from training**: `./saved_model`
82
+ - **Evaluation artifacts/reports**: `./results` (or the path passed with `--results-dir`)
83
+ - **Default checkpoint used by evaluation**: `./saved_model/vit_cifar10_best.pt`
84
+
85
+ ### Quick path summary
86
+
87
+ - Training command: `python code/c1.py`
88
+ - Baseline evaluation: `python code/c1_test.py --checkpoint-path ./saved_model/vit_cifar10_best.pt --results-dir ./results`
89
+ - Baseline + transfer comparison: `python code/c1_test.py --checkpoint-path ./saved_model/vit_cifar10_best.pt --results-dir ./results --run-pretrained-experiment`
90
+
91
+
assignment_llm_1/assignment_image/requirements.txt ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohappyeyeballs==2.6.1
2
+ aiohttp==3.13.3
3
+ aiosignal==1.4.0
4
+ anyio==4.12.1
5
+ async-timeout==5.0.1
6
+ attrs==25.4.0
7
+ certifi==2026.1.4
8
+ charset-normalizer==3.4.4
9
+ click==8.3.1
10
+ contourpy==1.3.2
11
+ cycler==0.12.1
12
+ datasets==4.5.0
13
+ dill==0.4.0
14
+ exceptiongroup==1.3.1
15
+ filelock==3.20.0
16
+ fonttools==4.61.1
17
+ frozenlist==1.8.0
18
+ fsspec==2025.10.0
19
+ h11==0.16.0
20
+ hf-xet==1.2.0
21
+ httpcore==1.0.9
22
+ httpx==0.28.1
23
+ huggingface_hub==1.4.1
24
+ idna==3.11
25
+ Jinja2==3.1.6
26
+ joblib==1.5.3
27
+ kiwisolver==1.4.9
28
+ MarkupSafe==2.1.5
29
+ matplotlib==3.10.8
30
+ mpmath==1.3.0
31
+ multidict==6.7.1
32
+ multiprocess==0.70.18
33
+ networkx==3.4.2
34
+ numpy==2.2.6
35
+ nvidia-cublas-cu11==11.11.3.6
36
+ nvidia-cuda-cupti-cu11==11.8.87
37
+ nvidia-cuda-nvrtc-cu11==11.8.89
38
+ nvidia-cuda-runtime-cu11==11.8.89
39
+ nvidia-cudnn-cu11==9.1.0.70
40
+ nvidia-cufft-cu11==10.9.0.58
41
+ nvidia-curand-cu11==10.3.0.86
42
+ nvidia-cusolver-cu11==11.4.1.48
43
+ nvidia-cusparse-cu11==11.7.5.86
44
+ nvidia-nccl-cu11==2.21.5
45
+ nvidia-nvtx-cu11==11.8.86
46
+ packaging @ file:///home/task_176104877067765/conda-bld/packaging_1761049113113/work
47
+ pandas==2.3.3
48
+ pillow==12.0.0
49
+ propcache==0.4.1
50
+ pyarrow==23.0.0
51
+ pyparsing==3.3.2
52
+ python-dateutil==2.9.0.post0
53
+ pytz==2025.2
54
+ PyYAML==6.0.3
55
+ requests==2.32.5
56
+ scikit-learn==1.7.2
57
+ scipy==1.15.3
58
+ shellingham==1.5.4
59
+ six==1.17.0
60
+ sympy==1.14.0
61
+ threadpoolctl==3.6.0
62
+ torch==2.7.1+cu118
63
+ torchaudio==2.7.1+cu118
64
+ torchvision==0.22.1+cu118
65
+ tqdm==4.67.3
66
+ triton==3.3.1
67
+ typer-slim==0.21.1
68
+ typing_extensions==4.15.0
69
+ tzdata==2025.3
70
+ urllib3==2.6.3
71
+ xxhash==3.6.0
72
+ yarl==1.22.0
assignment_llm_1/assignment_image/results/baseline_analysis.txt ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Baseline ViT (custom checkpoint) results
2
+ Checkpoint: ./saved_model/vit_cifar10_best.pt
3
+ Test Loss: 0.8916
4
+ Test Accuracy: 68.57%
5
+
6
+ Per-class accuracy (lower = harder classes):
7
+ cat | acc= 49.50% | n=1000
8
+ bird | acc= 57.60% | n=1000
9
+ dog | acc= 63.70% | n=1000
10
+ deer | acc= 64.00% | n=1000
11
+ airplane | acc= 69.00% | n=1000
12
+ horse | acc= 71.30% | n=1000
13
+ truck | acc= 73.10% | n=1000
14
+ frog | acc= 77.50% | n=1000
15
+ ship | acc= 78.50% | n=1000
16
+ automobile | acc= 81.50% | n=1000
17
+
18
+ Top confusion pairs (true -> predicted):
19
+ cat -> dog: 214 samples
20
+ dog -> cat: 171 samples
21
+ bird -> deer: 128 samples
22
+ truck -> automobile: 108 samples
23
+ deer -> horse: 100 samples
24
+ horse -> dog: 92 samples
25
+ airplane -> ship: 87 samples
26
+ automobile -> truck: 84 samples
assignment_llm_1/assignment_text/installAndRun.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Install and Run Guide
2
+
3
+ This guide explains how to install dependencies and run the IMDB Transformer experiments in `assignment_llm_1/assignment_text`.
4
+
5
+ First, enter this path using `cd`:
6
+
7
+ ```bash
8
+ cd assignment_llm_1/assignment_text
9
+ ```
10
+
11
+ ## What is added in the code
12
+
13
+ - Model-size experiment support in `assignment_text/code/c1.py`:
14
+ - `small`: `d_model=64`, `num_heads=4`, `num_layers=1`, `d_ff=128`
15
+ - `medium`: `d_model=128`, `num_heads=8`, `num_layers=2`, `d_ff=256`
16
+ - `large`: `d_model=256`, `num_heads=8`, `num_layers=4`, `d_ff=512`
17
+ - Automatic experiment report generation:
18
+ - `assignment_text/saved_model/transformer_imdb_experiment_report.md`
19
+ - Model-size selection in analysis script:
20
+ - `python code/c1_analysis.py --model_size small|medium|large ...`
21
+ - Some qualitative error-analysis instances are available in:
22
+ - `assignment_text/documentation/error_analysis.json`
23
+
24
+ ## 1) Go to the project folder
25
+
26
+ ```bash
27
+ cd ./assignment_llm_1/assignment_text
28
+ ```
29
+
30
+ ## 2) Create and activate environment
31
+
32
+ ### Option A: Conda (recommended if you use Conda)
33
+
34
+ ```bash
35
+ conda create -n transformer_hw python=3.10 -y
36
+ conda activate transformer_hw
37
+ python -m pip install --upgrade pip
38
+ ```
39
+
40
+ ## 3) Install dependencies
41
+
42
+ If there is a `requirements.txt` file in this folder, run:
43
+
44
+ ```bash
45
+ pip install -r requirements.txt
46
+ ```
47
+
48
+
49
+ ## 4) Train all model sizes (small, medium, large)
50
+
51
+ Run training from the `code` directory:
52
+
53
+ ```bash
54
+ python code/c1.py
55
+ ```
56
+
57
+ This will:
58
+ - train `small`, `medium`, and `large` Transformer models,
59
+ - save checkpoints under `assignment_llm_1/assignment_text/saved_model/`,
60
+ - create a Markdown experiment report at:
61
+ - `assignment_llm_1/assignment_text/saved_model/transformer_imdb_experiment_report.md`
62
+
63
+ ## 5) Evaluate and analyze a selected model size
64
+
65
+ From the same `code` directory:
66
+
67
+ ```bash
68
+ python code/c1_analysis.py --split test --model_size small --num_examples 5
69
+ python code/c1_analysis.py --split test --model_size medium --num_examples 5
70
+ python code/c1_analysis.py --split test --model_size large --num_examples 5
71
+ ```
72
+
73
+ Arguments:
74
+ - `--split`: dataset split to evaluate (`test` or `train`)
75
+ - `--model_size`: one of `small`, `medium`, `large`
76
+ - `--num_examples`: number of misclassified examples to print
77
+
78
+ ## 6) (Optional) Use a custom checkpoint path directly
79
+
80
+ If you want to bypass `--model_size`, pass an explicit checkpoint:
81
+
82
+ ```bash
83
+ python code/c1_analysis.py \
84
+ --split test \
85
+ --checkpoint ../saved_model/transformer_imdb_large.pt \
86
+ --num_examples 5
87
+ ```
88
+
89
+ ## 7) Expected output files
90
+
91
+ After running `c1.py`, these files should exist in `assignment_llm_1/assignment_text/saved_model/`:
92
+ - `transformer_imdb_small.pt`
93
+ - `transformer_imdb_medium.pt`
94
+ - `transformer_imdb_large.pt`
95
+ - `transformer_imdb.pt` (summary/compatibility checkpoint)
96
+ - `transformer_imdb_experiment_report.md` (human-readable report)
assignment_llm_1/assignment_text/requirements.txt ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohappyeyeballs==2.6.1
2
+ aiohttp==3.13.3
3
+ aiosignal==1.4.0
4
+ anyio==4.12.1
5
+ async-timeout==5.0.1
6
+ attrs==25.4.0
7
+ certifi==2026.1.4
8
+ charset-normalizer==3.4.4
9
+ click==8.3.1
10
+ contourpy==1.3.2
11
+ cycler==0.12.1
12
+ datasets==4.5.0
13
+ dill==0.4.0
14
+ exceptiongroup==1.3.1
15
+ filelock==3.20.0
16
+ fonttools==4.61.1
17
+ frozenlist==1.8.0
18
+ fsspec==2025.10.0
19
+ h11==0.16.0
20
+ hf-xet==1.2.0
21
+ httpcore==1.0.9
22
+ httpx==0.28.1
23
+ huggingface_hub==1.4.1
24
+ idna==3.11
25
+ Jinja2==3.1.6
26
+ joblib==1.5.3
27
+ kiwisolver==1.4.9
28
+ MarkupSafe==2.1.5
29
+ matplotlib==3.10.8
30
+ mpmath==1.3.0
31
+ multidict==6.7.1
32
+ multiprocess==0.70.18
33
+ networkx==3.4.2
34
+ numpy==2.2.6
35
+ nvidia-cublas-cu11==11.11.3.6
36
+ nvidia-cuda-cupti-cu11==11.8.87
37
+ nvidia-cuda-nvrtc-cu11==11.8.89
38
+ nvidia-cuda-runtime-cu11==11.8.89
39
+ nvidia-cudnn-cu11==9.1.0.70
40
+ nvidia-cufft-cu11==10.9.0.58
41
+ nvidia-curand-cu11==10.3.0.86
42
+ nvidia-cusolver-cu11==11.4.1.48
43
+ nvidia-cusparse-cu11==11.7.5.86
44
+ nvidia-nccl-cu11==2.21.5
45
+ nvidia-nvtx-cu11==11.8.86
46
+ packaging @ file:///home/task_176104877067765/conda-bld/packaging_1761049113113/work
47
+ pandas==2.3.3
48
+ pillow==12.0.0
49
+ propcache==0.4.1
50
+ pyarrow==23.0.0
51
+ pyparsing==3.3.2
52
+ python-dateutil==2.9.0.post0
53
+ pytz==2025.2
54
+ PyYAML==6.0.3
55
+ requests==2.32.5
56
+ scikit-learn==1.7.2
57
+ scipy==1.15.3
58
+ shellingham==1.5.4
59
+ six==1.17.0
60
+ sympy==1.14.0
61
+ threadpoolctl==3.6.0
62
+ torch==2.7.1+cu118
63
+ torchaudio==2.7.1+cu118
64
+ torchvision==0.22.1+cu118
65
+ tqdm==4.67.3
66
+ triton==3.3.1
67
+ typer-slim==0.21.1
68
+ typing_extensions==4.15.0
69
+ tzdata==2025.3
70
+ urllib3==2.6.3
71
+ xxhash==3.6.0
72
+ yarl==1.22.0
results/v3_context/temp0.1_qwen3-14B_base_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp0.1_qwen3-14B_finetuned_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp0.3_qwen3-14B_base_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp0.5_qwen3-14B_finetuned_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp0.7_qwen3-14B_base_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.0_qwen3-14B_base_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.0_qwen3-14B_finetuned_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.1_qwen3-14B_finetuned_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.2_qwen3-14B_base_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.2_qwen3-14B_finetuned_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.3_qwen3-14B_base_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.4_qwen3-14B_base_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.4_qwen3-14B_finetuned_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.5_qwen3-14B_base_with_defs.json ADDED
The diff for this file is too large to render. See raw diff
 
results/v3_context/temp1.5_qwen3-14B_finetuned_with_defs.json ADDED
The diff for this file is too large to render. See raw diff