gagni commited on
Commit
bdfcdbe
·
verified ·
1 Parent(s): 255a26f

Copy of Nicolassuez/t5-small-commitbench@9752c0f

Browse files
Files changed (4) hide show
  1. README.md +164 -0
  2. config.json +63 -0
  3. model.safetensors +3 -0
  4. tokenizer.json +0 -0
README.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: google-t5/t5-small
4
+ tags:
5
+ - commit-message-generation
6
+ - text2text-generation
7
+ - summarization
8
+ - code
9
+ datasets:
10
+ - Maxscha/commitbench
11
+ language:
12
+ - en
13
+ library_name: transformers
14
+ pipeline_tag: text-generation
15
+ metrics:
16
+ - rouge
17
+ - bleu
18
+ ---
19
+
20
+ > Unmodified mirror of the files listed below of [thealper2/t5-small-commitbench](https://huggingface.co/thealper2/t5-small-commitbench) at revision `d17f8b367741834411f2ad160c3a2438f9e2a92f`, kept so aSup does not depend on a third-party repository. Licenses and credits are those of the original (see below and any model card next to the files).
21
+ >
22
+ > Files: `config.json`, `tokenizer.json`, `model.safetensors`
23
+
24
+
25
+ # thealper2/t5-small-commitbench
26
+
27
+ `google-t5/t5-small` fine-tuned on [Maxscha/commitbench](https://huggingface.co/datasets/Maxscha/commitbench) for
28
+ commit message generation: given a git diff, generate the commit message describing it.
29
+
30
+ ## Task format
31
+
32
+ Text-to-text. The input is a task prefix followed by the raw git diff, the target is the
33
+ commit message.
34
+
35
+ ```
36
+ generate commit message: <git diff>
37
+ ```
38
+
39
+ ## Training data
40
+
41
+ [Maxscha/commitbench](https://huggingface.co/datasets/Maxscha/commitbench) official splits, used unchanged:
42
+
43
+ | Split | Examples in split | Examples used |
44
+ |---|---|---|
45
+ | train | 1,165,213 | 500,000 |
46
+ | validation | 249,689 | 2,000 |
47
+ | test | 249,688 | not used for training |
48
+
49
+ Languages covered by the dataset: Python, JavaScript, PHP, Ruby, Java, Go.
50
+
51
+ ## Training configuration
52
+
53
+ | Setting | Value |
54
+ |---|---|
55
+ | Base model | `google-t5/t5-small` |
56
+ | Parameters | 60.5M |
57
+ | Max source length | 512 tokens |
58
+ | Max target length | 64 tokens |
59
+ | Per-device batch size | 32 |
60
+ | Gradient accumulation | 1 |
61
+ | Effective batch size | 32 |
62
+ | Learning rate | 3e-05 |
63
+ | LR schedule | linear |
64
+ | Warmup ratio | 0.05 |
65
+ | Weight decay | 0.01 |
66
+ | Epochs | 2.0 |
67
+ | Label smoothing | 0.0 |
68
+ | Gradient clipping | 1.0 |
69
+ | Mixed precision | bf16 |
70
+ | Seed | 42 |
71
+ | Optimizer | AdamW |
72
+ | Training time | 1.219 h |
73
+ | Hardware | NVIDIA GeForce RTX 5060 Ti (15.9 GB) |
74
+
75
+ Truncation at these limits (measured on a 50k sample with the T5 tokenizer):
76
+ - 0.7% of the diffs exceed 512 source tokens.
77
+ - 4.47% of the commit messages exceed 64 target tokens.
78
+
79
+ ## Results
80
+
81
+ - Final training loss: **3.5762**
82
+ - Best validation loss: **3.2414**
83
+
84
+ Test split (20,000 examples), beam search with `num_beams=4`:
85
+
86
+ | Metric | Value |
87
+ |---|---|
88
+ | rouge1 | 19.31 |
89
+ | rouge2 | 4.668 |
90
+ | rougeL | 17.42 |
91
+ | rougeLsum | 17.42 |
92
+ | bleu | 2.148 |
93
+ | exact_match | 0.04 |
94
+ | gen_len_words_mean | 5.005 |
95
+ | ref_len_words_mean | 11.27 |
96
+
97
+ Per programming language:
98
+
99
+ | Language | n | ROUGE-1 | ROUGE-2 | ROUGE-L | BLEU | Exact match |
100
+ |---|---|---|---|---|---|---|
101
+ | Python | 5,722 | 21.20 | 6.05 | 19.29 | 2.73 | 0.04 |
102
+ | JavaScript | 4,468 | 18.86 | 4.05 | 17.07 | 2.01 | 0.02 |
103
+ | PHP | 3,489 | 17.04 | 3.46 | 15.29 | 1.64 | 0.09 |
104
+ | Ruby | 2,808 | 22.08 | 5.79 | 19.65 | 2.44 | 0.04 |
105
+ | Java | 1,799 | 15.19 | 2.61 | 13.58 | 1.02 | 0.06 |
106
+ | Go | 1,714 | 18.65 | 4.45 | 16.75 | 2.11 | 0.00 |
107
+
108
+ ROUGE and BLEU are lexical-overlap metrics. They do not fully capture whether a commit
109
+ message describes a change correctly, and generic messages can score well.
110
+
111
+ ## Usage
112
+
113
+ ```python
114
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
115
+
116
+ model_id = "thealper2/t5-small-commitbench"
117
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
118
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
119
+
120
+ diff = open("change.patch").read()
121
+ inputs = tokenizer(
122
+ "generate commit message: " + diff,
123
+ max_length=512,
124
+ truncation=True,
125
+ return_tensors="pt",
126
+ )
127
+ output = model.generate(
128
+ **inputs,
129
+ num_beams=4,
130
+ max_new_tokens=64,
131
+ length_penalty=1.0,
132
+ no_repeat_ngram_size=3,
133
+ )
134
+ print(tokenizer.decode(output[0], skip_special_tokens=True))
135
+ ```
136
+
137
+ Default generation settings: `num_beams=4`, `max_new_tokens=64`,
138
+ `min_new_tokens=0`, `length_penalty=1.0`,
139
+ `no_repeat_ngram_size=3`, `do_sample=False` (deterministic).
140
+
141
+ ## Limitations
142
+
143
+ - CommitBench replaces identifying literals with placeholder tokens: every diff contains
144
+ `<HASH>` instead of commit hashes, and 26.5% of the reference messages contain `<I>` (numbers),
145
+ `<URL>` or `<EMAIL>`. The model therefore also generates these tokens, e.g. `Bumped version to <I>`.
146
+ - The T5 sentencepiece vocabulary does not cover every character used in source code (curly braces, backslashes, angle brackets), so about 2.35% of the input tokens become `<unk>`. This limits how precisely the model can read a diff.
147
+ - Diffs longer than 512 tokens are truncated; the tail of the change is
148
+ not visible to the model.
149
+ - CommitBench splits are random over commits, not over repositories: 98.6% of the test examples
150
+ come from repositories that also appear in the training split. No `(diff, message)` pair is
151
+ shared across splits, but the reported scores partly reflect familiarity with a project's
152
+ commit style rather than generalization to unseen code.
153
+ - The dataset is English-only and covers six languages; behaviour on other languages or
154
+ on very large multi-file changes is untested.
155
+ - CommitBench is released under CC BY-NC 4.0, which restricts commercial use of the data.
156
+
157
+ ## Reproducibility
158
+
159
+ - python: `3.12.3`
160
+ - torch: `2.11.0+cu128`
161
+ - transformers: `5.17.0`
162
+ - datasets: `4.3.0`
163
+ - tokenizers: `0.23.2`
164
+ - seed: `42`
config.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "T5ForConditionalGeneration"
4
+ ],
5
+ "classifier_dropout": 0.0,
6
+ "d_ff": 2048,
7
+ "d_kv": 64,
8
+ "d_model": 512,
9
+ "decoder_start_token_id": 0,
10
+ "dense_act_fn": "relu",
11
+ "dropout_rate": 0.1,
12
+ "dtype": "float32",
13
+ "eos_token_id": 1,
14
+ "feed_forward_proj": "relu",
15
+ "initializer_factor": 1.0,
16
+ "is_decoder": false,
17
+ "is_encoder_decoder": true,
18
+ "is_gated_act": false,
19
+ "layer_norm_epsilon": 1e-06,
20
+ "model_type": "t5",
21
+ "n_positions": 512,
22
+ "num_decoder_layers": 6,
23
+ "num_heads": 8,
24
+ "num_layers": 6,
25
+ "output_past": true,
26
+ "pad_token_id": 0,
27
+ "relative_attention_max_distance": 128,
28
+ "relative_attention_num_buckets": 32,
29
+ "scale_decoder_outputs": true,
30
+ "task_specific_params": {
31
+ "summarization": {
32
+ "early_stopping": true,
33
+ "length_penalty": 2.0,
34
+ "max_length": 200,
35
+ "min_length": 30,
36
+ "no_repeat_ngram_size": 3,
37
+ "num_beams": 4,
38
+ "prefix": "summarize: "
39
+ },
40
+ "translation_en_to_de": {
41
+ "early_stopping": true,
42
+ "max_length": 300,
43
+ "num_beams": 4,
44
+ "prefix": "translate English to German: "
45
+ },
46
+ "translation_en_to_fr": {
47
+ "early_stopping": true,
48
+ "max_length": 300,
49
+ "num_beams": 4,
50
+ "prefix": "translate English to French: "
51
+ },
52
+ "translation_en_to_ro": {
53
+ "early_stopping": true,
54
+ "max_length": 300,
55
+ "num_beams": 4,
56
+ "prefix": "translate English to Romanian: "
57
+ }
58
+ },
59
+ "tie_word_embeddings": true,
60
+ "transformers_version": "5.17.0",
61
+ "use_cache": true,
62
+ "vocab_size": 32128
63
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d619724d679d2fb7bd6e597b09d4af441c14e37ded9e918868ba63f58b40de4
3
+ size 242041896
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff