kunjcr2 commited on
Commit
dfb19fe
·
verified ·
1 Parent(s): 5ab0e78

Upload 13 files

Browse files
README.md CHANGED
@@ -1,79 +1,207 @@
1
  ---
2
- license: mit
3
- datasets:
4
- - SohamGhadge/casual-conversation
5
- language:
6
- - en
7
- base_model:
8
- - openai-community/gpt2-medium
9
- pipeline_tag: question-answering
10
  tags:
 
 
11
  - transformers
12
- - peft
13
- - gpt2
14
  ---
15
 
16
- ## 🧠 Fine-Tuned GPT-2 Medium for Conversational AI
17
- This project fine-tunes the `gpt2-medium` language model to support natural, casual **conversational dialogue** using **PEFT + LoRA**.
18
- ---
19
- ### 🚀 Model Summary
20
- * **Base model**: `gpt2-medium`
21
- * **Objective**: Enable natural question-answering and dialogue
22
- * **Training method**: Supervised Fine-Tuning (SFT) using PEFT with LoRA adapters
23
- * **Tokenizer**: `gpt2` (same as base model)
24
- ---
25
- ### 📈 Training Metrics
26
- | Metric | Value |
27
- | ------------------- | -------------- |
28
- | Global Steps | 2611 |
29
- | Final Training Loss | 2.185 |
30
- | Training Runtime | 430.61 seconds |
31
- | Samples/sec | 138.41 |
32
- | Steps/sec | 17.32 |
33
- | Total FLOPs | 1.12 × 10¹⁵ |
34
- | Epochs | 7.0 |
35
- > These metrics reflect final performance after complete training.
36
- ---
37
- ### 💬 Inference Script
38
- Chat with the model using the `talk()` function below:
39
- ```python
40
- def talk(model=peft_model, tokenizer=tokenizer, device=device):
41
- print("Start chatting with the bot! Type 'exit' to stop.\n")
42
- while True:
43
- question = input("You: ")
44
- if question.lower() == "exit":
45
- print("Goodbye!")
46
- break
47
-
48
- prompt = f"User: {question}\nBot:"
49
- inputs = tokenizer(prompt, return_tensors="pt").to(device)
50
-
51
- with torch.no_grad():
52
- outputs = model.generate(
53
- **inputs,
54
- max_new_tokens=20,
55
- do_sample=True,
56
- temperature=0.7,
57
- top_p=0.9,
58
- pad_token_id=tokenizer.eos_token_id
59
- )
60
-
61
- response = tokenizer.decode(
62
- outputs[0][inputs["input_ids"].shape[-1]:],
63
- skip_special_tokens=True
64
- )
65
-
66
- # Clean response
67
- response = response.split(".")
68
- response = ".".join(response[:-1]) + "."
69
- print("Bot:", response.strip())
70
- ```
71
-
72
- * 🤖 **Stateless**: No memory across turns (yet).
73
- * 🌱 **Future idea**: Add memory/context for multi-turn dialogue.
74
- ---
75
- ### ⚙️ Quick Setup
76
- To use this model locally:
77
- ```bash
78
- pip install transformers peft accelerate
79
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model: openai-community/gpt2-medium
3
+ library_name: peft
4
+ pipeline_tag: text-generation
 
 
 
 
 
5
  tags:
6
+ - base_model:adapter:openai-community/gpt2-medium
7
+ - lora
8
  - transformers
 
 
9
  ---
10
 
11
+ # Model Card for Model ID
12
+
13
+ <!-- Provide a quick summary of what the model is/does. -->
14
+
15
+
16
+
17
+ ## Model Details
18
+
19
+ ### Model Description
20
+
21
+ <!-- Provide a longer summary of what this model is. -->
22
+
23
+
24
+
25
+ - **Developed by:** [More Information Needed]
26
+ - **Funded by [optional]:** [More Information Needed]
27
+ - **Shared by [optional]:** [More Information Needed]
28
+ - **Model type:** [More Information Needed]
29
+ - **Language(s) (NLP):** [More Information Needed]
30
+ - **License:** [More Information Needed]
31
+ - **Finetuned from model [optional]:** [More Information Needed]
32
+
33
+ ### Model Sources [optional]
34
+
35
+ <!-- Provide the basic links for the model. -->
36
+
37
+ - **Repository:** [More Information Needed]
38
+ - **Paper [optional]:** [More Information Needed]
39
+ - **Demo [optional]:** [More Information Needed]
40
+
41
+ ## Uses
42
+
43
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
44
+
45
+ ### Direct Use
46
+
47
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
48
+
49
+ [More Information Needed]
50
+
51
+ ### Downstream Use [optional]
52
+
53
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
54
+
55
+ [More Information Needed]
56
+
57
+ ### Out-of-Scope Use
58
+
59
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
60
+
61
+ [More Information Needed]
62
+
63
+ ## Bias, Risks, and Limitations
64
+
65
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
66
+
67
+ [More Information Needed]
68
+
69
+ ### Recommendations
70
+
71
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
72
+
73
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
74
+
75
+ ## How to Get Started with the Model
76
+
77
+ Use the code below to get started with the model.
78
+
79
+ [More Information Needed]
80
+
81
+ ## Training Details
82
+
83
+ ### Training Data
84
+
85
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
86
+
87
+ [More Information Needed]
88
+
89
+ ### Training Procedure
90
+
91
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
92
+
93
+ #### Preprocessing [optional]
94
+
95
+ [More Information Needed]
96
+
97
+
98
+ #### Training Hyperparameters
99
+
100
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
101
+
102
+ #### Speeds, Sizes, Times [optional]
103
+
104
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
105
+
106
+ [More Information Needed]
107
+
108
+ ## Evaluation
109
+
110
+ <!-- This section describes the evaluation protocols and provides the results. -->
111
+
112
+ ### Testing Data, Factors & Metrics
113
+
114
+ #### Testing Data
115
+
116
+ <!-- This should link to a Dataset Card if possible. -->
117
+
118
+ [More Information Needed]
119
+
120
+ #### Factors
121
+
122
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
123
+
124
+ [More Information Needed]
125
+
126
+ #### Metrics
127
+
128
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
129
+
130
+ [More Information Needed]
131
+
132
+ ### Results
133
+
134
+ [More Information Needed]
135
+
136
+ #### Summary
137
+
138
+
139
+
140
+ ## Model Examination [optional]
141
+
142
+ <!-- Relevant interpretability work for the model goes here -->
143
+
144
+ [More Information Needed]
145
+
146
+ ## Environmental Impact
147
+
148
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
149
+
150
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
151
+
152
+ - **Hardware Type:** [More Information Needed]
153
+ - **Hours used:** [More Information Needed]
154
+ - **Cloud Provider:** [More Information Needed]
155
+ - **Compute Region:** [More Information Needed]
156
+ - **Carbon Emitted:** [More Information Needed]
157
+
158
+ ## Technical Specifications [optional]
159
+
160
+ ### Model Architecture and Objective
161
+
162
+ [More Information Needed]
163
+
164
+ ### Compute Infrastructure
165
+
166
+ [More Information Needed]
167
+
168
+ #### Hardware
169
+
170
+ [More Information Needed]
171
+
172
+ #### Software
173
+
174
+ [More Information Needed]
175
+
176
+ ## Citation [optional]
177
+
178
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
179
+
180
+ **BibTeX:**
181
+
182
+ [More Information Needed]
183
+
184
+ **APA:**
185
+
186
+ [More Information Needed]
187
+
188
+ ## Glossary [optional]
189
+
190
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
191
+
192
+ [More Information Needed]
193
+
194
+ ## More Information [optional]
195
+
196
+ [More Information Needed]
197
+
198
+ ## Model Card Authors [optional]
199
+
200
+ [More Information Needed]
201
+
202
+ ## Model Card Contact
203
+
204
+ [More Information Needed]
205
+ ### Framework versions
206
+
207
+ - PEFT 0.17.0
adapter_config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "openai-community/gpt2-medium",
5
+ "bias": "none",
6
+ "corda_config": null,
7
+ "eva_config": null,
8
+ "exclude_modules": null,
9
+ "fan_in_fan_out": false,
10
+ "inference_mode": true,
11
+ "init_lora_weights": true,
12
+ "layer_replication": null,
13
+ "layers_pattern": null,
14
+ "layers_to_transform": null,
15
+ "loftq_config": {},
16
+ "lora_alpha": 32,
17
+ "lora_bias": false,
18
+ "lora_dropout": 0.05,
19
+ "megatron_config": null,
20
+ "megatron_core": "megatron.core",
21
+ "modules_to_save": null,
22
+ "peft_type": "LORA",
23
+ "qalora_group_size": 16,
24
+ "r": 8,
25
+ "rank_pattern": {},
26
+ "revision": null,
27
+ "target_modules": [
28
+ "c_attn"
29
+ ],
30
+ "target_parameters": null,
31
+ "task_type": "CAUSAL_LM",
32
+ "trainable_token_indices": null,
33
+ "use_dora": false,
34
+ "use_qalora": false,
35
+ "use_rslora": false
36
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edaec14867141bda63bedf799099dc71ad777cb6a5d84726d1a02c9f1d8cbe23
3
+ size 3151856
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6aba1c1a8e1fbea0d3aa4aeecd87cb2bcbf959c8d6e704247ab9171d0f1fada
3
+ size 6332154
rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0b15f86e6f05eb94a1b3debc7b16c8d088ac510e4e6b603cb74692de29e148a
3
+ size 14244
scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2bd999bc59c0619b701327b51c81b58bc5cfbf5320062fe503eba874a431d37
3
+ size 1064
special_tokens_map.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|endoftext|>",
3
+ "eos_token": "<|endoftext|>",
4
+ "pad_token": "<|endoftext|>",
5
+ "unk_token": "<|endoftext|>"
6
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "50256": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ }
12
+ },
13
+ "bos_token": "<|endoftext|>",
14
+ "clean_up_tokenization_spaces": false,
15
+ "eos_token": "<|endoftext|>",
16
+ "extra_special_tokens": {},
17
+ "model_max_length": 1024,
18
+ "pad_token": "<|endoftext|>",
19
+ "tokenizer_class": "GPT2Tokenizer",
20
+ "unk_token": "<|endoftext|>"
21
+ }
trainer_state.json ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": 746,
3
+ "best_metric": 2.618539571762085,
4
+ "best_model_checkpoint": "./gpt2_conv/checkpoint-746",
5
+ "epoch": 7.0,
6
+ "eval_steps": 500,
7
+ "global_step": 2611,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 1.0,
14
+ "grad_norm": 2.6198129653930664,
15
+ "learning_rate": 0.0009501340482573728,
16
+ "loss": 2.6864,
17
+ "step": 373
18
+ },
19
+ {
20
+ "epoch": 1.0,
21
+ "eval_loss": 2.6242876052856445,
22
+ "eval_runtime": 7.6714,
23
+ "eval_samples_per_second": 97.114,
24
+ "eval_steps_per_second": 12.253,
25
+ "step": 373
26
+ },
27
+ {
28
+ "epoch": 2.0,
29
+ "grad_norm": 2.9966814517974854,
30
+ "learning_rate": 0.0009001340482573726,
31
+ "loss": 2.5097,
32
+ "step": 746
33
+ },
34
+ {
35
+ "epoch": 2.0,
36
+ "eval_loss": 2.618539571762085,
37
+ "eval_runtime": 5.9683,
38
+ "eval_samples_per_second": 124.826,
39
+ "eval_steps_per_second": 15.75,
40
+ "step": 746
41
+ },
42
+ {
43
+ "epoch": 3.0,
44
+ "grad_norm": 3.020508050918579,
45
+ "learning_rate": 0.0008501340482573726,
46
+ "loss": 2.3432,
47
+ "step": 1119
48
+ },
49
+ {
50
+ "epoch": 3.0,
51
+ "eval_loss": 2.628633499145508,
52
+ "eval_runtime": 5.8711,
53
+ "eval_samples_per_second": 126.893,
54
+ "eval_steps_per_second": 16.011,
55
+ "step": 1119
56
+ },
57
+ {
58
+ "epoch": 4.0,
59
+ "grad_norm": 2.9825632572174072,
60
+ "learning_rate": 0.0008001340482573727,
61
+ "loss": 2.1637,
62
+ "step": 1492
63
+ },
64
+ {
65
+ "epoch": 4.0,
66
+ "eval_loss": 2.6619577407836914,
67
+ "eval_runtime": 5.8085,
68
+ "eval_samples_per_second": 128.261,
69
+ "eval_steps_per_second": 16.183,
70
+ "step": 1492
71
+ },
72
+ {
73
+ "epoch": 5.0,
74
+ "grad_norm": 3.038879156112671,
75
+ "learning_rate": 0.0007501340482573727,
76
+ "loss": 2.0068,
77
+ "step": 1865
78
+ },
79
+ {
80
+ "epoch": 5.0,
81
+ "eval_loss": 2.7242045402526855,
82
+ "eval_runtime": 5.8714,
83
+ "eval_samples_per_second": 126.886,
84
+ "eval_steps_per_second": 16.01,
85
+ "step": 1865
86
+ },
87
+ {
88
+ "epoch": 6.0,
89
+ "grad_norm": 4.051107883453369,
90
+ "learning_rate": 0.0007001340482573728,
91
+ "loss": 1.8635,
92
+ "step": 2238
93
+ },
94
+ {
95
+ "epoch": 6.0,
96
+ "eval_loss": 2.774700880050659,
97
+ "eval_runtime": 5.9959,
98
+ "eval_samples_per_second": 124.252,
99
+ "eval_steps_per_second": 15.677,
100
+ "step": 2238
101
+ },
102
+ {
103
+ "epoch": 7.0,
104
+ "grad_norm": 6.0618062019348145,
105
+ "learning_rate": 0.0006501340482573726,
106
+ "loss": 1.7221,
107
+ "step": 2611
108
+ },
109
+ {
110
+ "epoch": 7.0,
111
+ "eval_loss": 2.907008409500122,
112
+ "eval_runtime": 5.7642,
113
+ "eval_samples_per_second": 129.246,
114
+ "eval_steps_per_second": 16.308,
115
+ "step": 2611
116
+ }
117
+ ],
118
+ "logging_steps": 1,
119
+ "max_steps": 7460,
120
+ "num_input_tokens_seen": 0,
121
+ "num_train_epochs": 20,
122
+ "save_steps": 500,
123
+ "stateful_callbacks": {
124
+ "EarlyStoppingCallback": {
125
+ "args": {
126
+ "early_stopping_patience": 5,
127
+ "early_stopping_threshold": 0.0
128
+ },
129
+ "attributes": {
130
+ "early_stopping_patience_counter": 5
131
+ }
132
+ },
133
+ "TrainerControl": {
134
+ "args": {
135
+ "should_epoch_stop": false,
136
+ "should_evaluate": false,
137
+ "should_log": false,
138
+ "should_save": true,
139
+ "should_training_stop": true
140
+ },
141
+ "attributes": {}
142
+ }
143
+ },
144
+ "total_flos": 1120715234082816.0,
145
+ "train_batch_size": 8,
146
+ "trial_name": null,
147
+ "trial_params": null
148
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b49c0da53128c40c608dcd5cd487b59b1e7b8054b5ecd04a982de5974ab72e4d
3
+ size 5304
vocab.json ADDED
The diff for this file is too large to render. See raw diff