Snaseem2026 commited on
Commit
3ab633a
·
verified ·
1 Parent(s): 149f2d9

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +269 -154
  2. special_tokens_map.json +5 -35
  3. tokenizer_config.json +0 -7
  4. training_args.bin +3 -0
README.md CHANGED
@@ -1,199 +1,314 @@
1
  ---
 
 
 
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
- ## Model Details
 
 
 
 
 
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
 
 
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
 
29
 
30
- <!-- Provide the basic links for the model. -->
 
 
 
 
 
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
 
35
 
36
- ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
39
 
40
- ### Direct Use
 
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
 
 
 
 
 
 
43
 
44
- [More Information Needed]
 
45
 
46
- ### Downstream Use [optional]
 
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
 
49
 
50
- [More Information Needed]
 
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
 
78
  ### Training Data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
- <!-- 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. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
 
115
- #### Factors
 
 
 
 
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- 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).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
 
 
176
 
177
- [More Information Needed]
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
 
 
 
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
 
 
 
 
 
 
 
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
1
  ---
2
+ language:
3
+ - en
4
+ license: mit
5
  library_name: transformers
6
+ tags:
7
+ - text-classification
8
+ - code-quality
9
+ - documentation
10
+ - code-comments
11
+ - developer-tools
12
+ - code-review
13
+ - distilbert
14
+ datasets:
15
+ - synthetic
16
+ metrics:
17
+ - accuracy
18
+ - f1
19
+ - precision
20
+ - recall
21
+ base_model: distilbert-base-uncased
22
+ pipeline_tag: text-classification
23
+ widget:
24
+ - text: "This function calculates the Fibonacci sequence using dynamic programming to avoid redundant calculations. Time complexity: O(n), Space complexity: O(n)"
25
+ example_title: "Excellent Comment"
26
+ - text: "Calculates the sum of two numbers and returns the result"
27
+ example_title: "Helpful Comment"
28
+ - text: "does stuff with numbers"
29
+ example_title: "Unclear Comment"
30
+ - text: "DEPRECATED: Use calculate_new() instead. This method will be removed in v2.0"
31
+ example_title: "Outdated Comment"
32
+ - text: "Validates user input against SQL injection attacks using parameterized queries"
33
+ example_title: "Excellent Example 2"
34
+ - text: "magic happens here"
35
+ example_title: "Unclear Example 2"
36
+ model-index:
37
+ - name: code-comment-classifier
38
+ results:
39
+ - task:
40
+ type: text-classification
41
+ name: Text Classification
42
+ dataset:
43
+ name: Synthetic Code Comments
44
+ type: synthetic
45
+ metrics:
46
+ - type: accuracy
47
+ value: 0.9485
48
+ name: Accuracy
49
+ verified: false
50
+ - type: f1
51
+ value: 0.9468
52
+ name: F1 Score
53
+ verified: false
54
+ - type: precision
55
+ value: 0.9535
56
+ name: Precision
57
+ verified: false
58
+ - type: recall
59
+ value: 0.9485
60
+ name: Recall
61
+ verified: false
62
  ---
63
 
64
+ # Code Comment Quality Classifier 🔍
65
 
66
+ Automatically classify code comments into quality categories to improve code documentation and review processes.
67
 
68
+ ## 🎯 Model Description
69
 
70
+ This fine-tuned DistilBERT model analyzes code comments and classifies them into **4 quality categories**:
71
 
72
+ | Category | Precision | Recall | Description |
73
+ |----------|-----------|--------|-------------|
74
+ | 🌟 **Excellent** | 100% | 100% | Clear, comprehensive, highly informative comments with context |
75
+ | ✅ **Helpful** | 88.9% | 100% | Good comments that add value but could be more detailed |
76
+ | ⚠️ **Unclear** | 100% | 79.2% | Vague, confusing, or uninformative comments |
77
+ | 🚫 **Outdated** | 92.3% | 100% | Deprecated, obsolete, or TODO comments |
78
 
79
+ ### 📊 Overall Performance
80
 
81
+ - **Accuracy**: 94.85%
82
+ - **F1 Score**: 94.68%
83
+ - *🚀 Quick Start
84
 
85
+ ### Using Transformers Pipeline (Easiest)
86
 
87
+ ```python
88
+ from transformers import pipeline
 
 
 
 
 
89
 
90
+ # Load the classifier
91
+ classifier = pipeline("text-classification", model="Snaseem2026/code-comment-classifier")
92
 
93
+ # Classify comments
94
+ comments = [
95
+ "This function uses dynamic programming for O(n) time complexity",
96
+ "does stuff",
97
+ "DEPRECATED: use new_function() instead"
98
+ ]
99
 
100
+ results = classifier(comments)
101
+ for comment, result in zip(comments, results):
102
+ print(f"{comment}: {result['label']} ({result['score']:.2%} confidence)")
103
+ ```
104
 
105
+ ### Manual Usage with Transformers
106
 
107
+ ```python
108
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
109
+ import torch
110
 
111
+ # Load model and tokenizer
112
+ mod💡 Use Cases
113
 
114
+ ### 1. **Code Review Automation**
115
+ Automatically flag low-quality comments during pull request reviews:
116
+ ```python
117
+ def check_pr_comments(file_comments):
118
+ classifier = pipeline("text-classification", model="Snaseem2026/code-comment-classifier")
119
+ results = classifier(file_comments)
120
+ return [c for c, r in zip(file_comments, results) if r['label'] in ['unclear', 'outdated']]
121
+ ```
122
 
123
+ ### 2. **Documentation Quality Audits**
124
+ Scan codebases to identify documentation that needs improvement.
125
 
126
+ ### 3. **Developer Education**
127
+ Help developers learn what constitutes good documentation practices.
128
 
129
+ ### 4. **IDE Integration**
130
+ Provide real-time feedback on comment quality while coding.
131
 
132
+ ### 5. **Technical Debt Analysis**
133
+ Identify outdated comments and TODOs that need addressing.
134
 
135
+ ## 🏋️ Training Details
136
 
137
+ ### Model Architecture
138
+ - **Base Model**: [distilbert-base-uncased](https://huggingface.co/distilbert-base-uncased)
139
+ - **Parameters**: 66.96 million
140
+ - **Model Type**: Sequence Classification
141
+ - **Framework**: PyTorch + Hugging Face Transformers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
  ### Training Data
144
+ - **Dataset Size**: 970 samples (776 train, 97 validation, 97 test)
145
+ - **Data Source**: Synthetic code comments
146
+ - **Classes**: 4 (balanced distribution)
147
+ - **Language**: English
148
+
149
+ ### Training Hyperparameters
150
+ - **Epochs**: 3
151
+ - **Batch Size**: 16 (train), 32 (eval)
152
+ - **Learning Rate**: 2e-5
153
+ - **Optimizer**: AdamW
154
+ - **Weight Decay**: 0.01
155
+ - **Warmup Steps**: 500
156
+ - **Max Sequence Length**: 512 tokenselpful", "unclear", "outdated"]
157
+ print(f"Quality: {labels[predicted_class]} (confidence: {confidence:.2%})")
158
+ ```
159
+
160
+ ### Batch Processing
161
+
162
+ ```python
163
+ from transformers import pipeline
164
+
165
+ classifier = pipeline("text-classification", model="Snaseem2026/code-comment-classifier")
166
+
167
+ comments = [
168
+ "Implements binary search with O(log n) time complexity",
169
+ "TODO fix later",
170
+ "Handles user authentication",
171
+ 📈 Evaluation Results
172
+
173
+ ### Test Set Performance (97 samples)
174
+
175
+ ```
176
+ precision recall f1-score support
177
+
178
+ excellent 1.0000 1.0000 1.0000 25
179
+ helpful 0.8889 1.0000 0.9412 24
180
+ unclear 1.0000 0.7917 0.8837 24
181
+ outdated 0.9231 1.0000 0.9600 24
182
+
183
+ accuracy 0.9485 97
184
+ macro avg 0.9530 0.9479 0.9462 97
185
+ weighted avg 0.9535 0.9485 0.9468 97
186
+ ```
187
+
188
+ ### Key Findings
189
+ - ✨ **Perfect classification** of excellent comments (100% precision & recall)
190
+ - 🎯 **Zero false negatives** for helpful and outdated comments
191
+ - ⚠️ Slight challenge distinguishing unclear comments from other categories
192
+ - 📊 Strong overall performance with 94.85% accuracy
193
+
194
+ ## ⚠️ Limitations
195
+
196
+ 1. **Synthetic Training Data**: Model trained on synthetic examples; may require fine-tuning for specific domains (e.g., scientific computing, embedded systems)
197
+ 2. **English Only**: Currently supports English code comments only
198
+ 3. **No Code Context**: Evaluates comments in isolation without analyzing the actual code
199
+ 4. **Subjectivity**: Comment quality is inherently subjective; model reflects patterns in training data
200
+ 5. **Short Comments**: May struggle with very short comments (< 3 words)
201
+
202
+ ## 🎯 Intended Use
203
+
204
+ ### Recommended Use
205
+ - Supplementary tool in code review automation
206
+ - Documentation quality auditing
207
+ - Developer education and training
208
+ - IDE plugins for real-time feedback
209
+
210
+ ### Not Recommended
211
+ - Sole decision-maker for code quality
212
+ - Production-critical systems without human oversight
213
+ - Evaluating non-English comments
214
+ - Analyzing code quality (only evaluates comments)
215
+
216
+ ## 🔧 How to Improve Performance
217
+
218
+ ### Fine-tune on Your Domain
219
+ ```python
220
+ from transformers import AutoModelForSequenceClassification, Trainer, TrainingArguments
221
+
222
+ # Load the pre-trained model
223
+ model = AutoModelForSequenceClassification.from_pretrained("Snaseem2026/code-comment-classifier")
224
+
225
+ # Fine-tune on your domain-specific data
226
+ training_args = TrainingArguments(
227
+ output_dir="./fine_tuned_model",
228
+ learning_rate=1e-5, # Lower learning rate for fine-tuning
229
+ num_train_epochs=2,
230
+ per_device_train_batch_size=8,
231
+ )
232
+
233
+ trainer = Trainer(
234
+ model=model,
235
+ args=training_args,
236
+ train_dataset=your_dataset,
237
+ )
238
+ trainer.train()
239
+ ```
240
+
241
+ ## 📝 License
242
+
243
+ **MIT License** - Free to use, modify, and distribute for commercial and non-commercial purposes.
244
+
245
+ ## 🙏 Acknowledgments
246
+
247
+ - Built with [🤗 Transformers](https://huggingface.co/transformers/)
248
+ - Base model: [DistilBERT](https://huggingface.co/distilbert-base-uncased) by Hugging Face
249
+ - Inspired by the need for better code documentation practices in software development
250
+
251
+ ## 📚 Citation
252
+
253
+ If you use this model in your research or application, please cite:
254
 
255
+ ```bibtex
256
+ @misc{code-comment-classifier-2026,
257
+ author = {Naseem, Sharyar},
258
+ title = {Code Comment Quality Classifier},
259
+ year = {2026},
260
+ publisher = {Hugging Face},
261
+ journal = {Hugging Face Model Hub},
262
+ howpublished = {\url{https://huggingface.co/Snaseem2026/code-comment-classifier}}
263
+ }
264
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
 
266
+ ## 📧 Contact
267
+
268
+ For questions, suggestions, or collaboration:
269
+ - 🤗 Hugging Face: [@Snaseem2026](https://huggingface.co/Snaseem2026)
270
+ - 📫 Issues: Report on the model's discussion tab
271
 
272
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
 
274
+ <div align="center">
275
 
276
+ **Made with ❤️ for the developer community**
277
 
278
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
279
+ [![Transformers](https://img.shields.io/badge/Transformers-4.35+-blue.svg)](https://github.com/huggingface/transformers)
280
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
281
 
282
+ [🤗 Model Hub](https://huggingface.co/Snaseem2026/code-comment-classifier) • [Report Issue](https://huggingface.co/Snaseem2026/code-comment-classifier/discussions)
283
 
284
+ </div>
285
 
286
+ ## Limitations
287
 
288
+ - Trained on synthetic data; may require fine-tuning for specific domains
289
+ - English comments only
290
+ - Evaluates comments in isolation without code context
291
+ - Comment quality assessment is subjective
292
 
293
+ ## Intended Use
294
 
295
+ This model is designed for **educational and productivity purposes**. Use as a supplementary tool in code review processes, not as a replacement for human judgment.
296
 
297
+ ## License
298
 
299
+ MIT License - Free to use, modify, and distribute.
300
 
301
+ ## Citation
302
 
303
+ ```bibtex
304
+ @misc{code-comment-classifier-2026,
305
+ title={Code Comment Quality Classifier},
306
+ year={2026},
307
+ publisher={Hugging Face},
308
+ howpublished={\url{https://huggingface.co/your-username/code-comment-classifier}}
309
+ }
310
+ ```
311
 
312
+ ---
313
 
314
+ Built with [Hugging Face Transformers](https://huggingface.co/transformers/) • Base model: [DistilBERT](https://huggingface.co/distilbert-base-uncased)
special_tokens_map.json CHANGED
@@ -1,37 +1,7 @@
1
  {
2
- "cls_token": {
3
- "content": "[CLS]",
4
- "lstrip": false,
5
- "normalized": false,
6
- "rstrip": false,
7
- "single_word": false
8
- },
9
- "mask_token": {
10
- "content": "[MASK]",
11
- "lstrip": false,
12
- "normalized": false,
13
- "rstrip": false,
14
- "single_word": false
15
- },
16
- "pad_token": {
17
- "content": "[PAD]",
18
- "lstrip": false,
19
- "normalized": false,
20
- "rstrip": false,
21
- "single_word": false
22
- },
23
- "sep_token": {
24
- "content": "[SEP]",
25
- "lstrip": false,
26
- "normalized": false,
27
- "rstrip": false,
28
- "single_word": false
29
- },
30
- "unk_token": {
31
- "content": "[UNK]",
32
- "lstrip": false,
33
- "normalized": false,
34
- "rstrip": false,
35
- "single_word": false
36
- }
37
  }
 
1
  {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
tokenizer_config.json CHANGED
@@ -46,18 +46,11 @@
46
  "do_lower_case": true,
47
  "extra_special_tokens": {},
48
  "mask_token": "[MASK]",
49
- "max_length": 512,
50
  "model_max_length": 512,
51
- "pad_to_multiple_of": null,
52
  "pad_token": "[PAD]",
53
- "pad_token_type_id": 0,
54
- "padding_side": "right",
55
  "sep_token": "[SEP]",
56
- "stride": 0,
57
  "strip_accents": null,
58
  "tokenize_chinese_chars": true,
59
  "tokenizer_class": "DistilBertTokenizer",
60
- "truncation_side": "right",
61
- "truncation_strategy": "longest_first",
62
  "unk_token": "[UNK]"
63
  }
 
46
  "do_lower_case": true,
47
  "extra_special_tokens": {},
48
  "mask_token": "[MASK]",
 
49
  "model_max_length": 512,
 
50
  "pad_token": "[PAD]",
 
 
51
  "sep_token": "[SEP]",
 
52
  "strip_accents": null,
53
  "tokenize_chinese_chars": true,
54
  "tokenizer_class": "DistilBertTokenizer",
 
 
55
  "unk_token": "[UNK]"
56
  }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6832f2d92a4eb7be0c28d655c5fbe622f84d59c589ff33d2da3bdb508e7ac75c
3
+ size 5777