pitt111 commited on
Commit
7a44042
·
verified ·
1 Parent(s): e6fd27c

Upload 6 files

Browse files
README.md CHANGED
@@ -1,3 +1,82 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - code
5
+ library_name: peft
6
+ tags:
7
+ - llm2vec
8
+ - mntp
9
+ - decoder-only
10
+ - pre-training
11
+ - codegemma
12
+ ---
13
+
14
+ ## 📖 Are Decoder-Only Large Language Models the Silver Bullet for Code Search?
15
+
16
+ This model is an official artifact from our research paper: **"[Are Decoder-Only Large Language Models the Silver Bullet for Code Search?](https://arxiv.org/abs/2410.22240)"**.
17
+
18
+ In this work, we conduct a large-scale systematic evaluation of decoder-only Large Language Models for the task of code search and present a set of effective fine-tuning and optimization strategies.
19
+
20
+ For complete details on all our experiments, to reproduce the full training/evaluation pipeline, or to use other models from the paper, please visit our official GitHub repository:
21
+
22
+ ➡️ **[GitHub: Georgepitt/DecoderLLMs-CodeSearch](https://github.com/Georgepitt/DecoderLLMs-CodeSearch)**
23
+
24
+ ---
25
+
26
+ ## Model Card: CodeGemma-7B - MNTP Pre-trained Model
27
+
28
+ ### 📜 Model Description
29
+
30
+ This is a PEFT adapter for the **`deepseek-ai/deepseek-llm-7b-chat`** model, pre-trained with the **Masked Next Token Prediction (MNTP)** objective from the [llm2vec](https://github.com/McGill-NLP/llm2vec) framework.
31
+
32
+ **Important Note on its Role**:
33
+ This model is **not intended for direct downstream task evaluation**. Instead, it serves as a crucial **foundational prerequisite** for our supervised fine-tuned (SupCon) models. The MNTP pre-training enables the decoder-only model to learn bidirectional representations, which is an essential step before applying supervised contrastive learning.
34
+
35
+ ### 🚀 How to Use
36
+
37
+ #### Standalone Use (for Base Embeddings)
38
+
39
+ You can also use this MNTP model by itself to generate text or code embeddings.
40
+
41
+ ```python
42
+ from transformers import AutoTokenizer, AutoModel, AutoConfig
43
+ from peft import PeftModel
44
+ from llm2vec import LLM2Vec
45
+
46
+ base_model_id = "deepseek-ai/deepseek-llm-7b-chat"
47
+ mntp_model_id = "SYSUSELab/DCS-DeepSeekLLM-7B-It-MNTP"
48
+
49
+ tokenizer = AutoTokenizer.from_pretrained(base_model_id)
50
+ config = AutoConfig.from_pretrained(base_model_id, trust_remote_code=True)
51
+ model = AutoModel.from_pretrained(base_model_id, trust_remote_code=True, config=config,
52
+ torch_dtype=torch.bfloat16, device_map="auto")
53
+ model = PeftModel.from_pretrained(model, mntp_model_id)
54
+
55
+ l2v = LLM2Vec(model, tokenizer, pooling_mode="mean", max_length=512)
56
+ embeddings = l2v.encode(["def hello_world():\n print('Hello, World!')"])
57
+ print("Embedding from MNTP model:", embeddings.shape)
58
+ ```
59
+
60
+ ### ⚙️ Training Methodology
61
+
62
+ This model was pre-trained using the **MNTP** objective as described in the `llm2vec` paper. If you wish to train your own MNTP model from scratch, please refer to the instructions in the `Fine-tuning/Fine-tuning_method/MNTP/` directory of our GitHub repository.
63
+
64
+ ### 📄 Citation
65
+
66
+ If you use this model, please cite both our paper and the foundational work of `llm2vec`.
67
+
68
+ ```bibtex
69
+ @article{chen2024decoder,
70
+ title={Are Decoder-Only Large Language Models the Silver Bullet for Code Search?},
71
+ author={Chen, Yuxuan and Liu, Mingwei and Ou, Guangsheng and Li, Anji and Dai, Dekun and Wang, Yanlin and Zheng, Zibin},
72
+ journal={arXiv preprint arXiv:2410.22240},
73
+ year={2024}
74
+ }
75
+
76
+ @article{vaishaal2024llm2vec,
77
+ title={LLM2Vec: Large Language Models Are Good Contextual Text Encoders},
78
+ author={Vaishaal, Shankar and Bansal, Mohit and Arora, Simran},
79
+ journal={arXiv preprint arXiv:2404.05961},
80
+ year={2024}
81
+ }
82
+ ```
adapter_config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": {
4
+ "base_model_class": "LlamaBiModel",
5
+ "parent_library": "llm2vec.models.bidirectional_llama"
6
+ },
7
+ "base_model_name_or_path": "deepseek-ai/deepseek-llm-7b-chat",
8
+ "bias": "none",
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_dropout": 0.05,
18
+ "megatron_config": null,
19
+ "megatron_core": "megatron.core",
20
+ "modules_to_save": null,
21
+ "peft_type": "LORA",
22
+ "r": 16,
23
+ "rank_pattern": {},
24
+ "revision": null,
25
+ "target_modules": [
26
+ "v_proj",
27
+ "gate_proj",
28
+ "down_proj",
29
+ "up_proj",
30
+ "k_proj",
31
+ "q_proj",
32
+ "o_proj"
33
+ ],
34
+ "task_type": null,
35
+ "use_dora": false,
36
+ "use_rslora": false
37
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca0f77e9594b7b0ad96540eec47012bd8382782ce0776a41795373088fbb8247
3
+ size 75010608
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|begin▁of▁sentence|>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|end▁of▁sentence|>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "mask_token": "_",
17
+ "pad_token": {
18
+ "content": "<|end▁of▁sentence|>",
19
+ "lstrip": false,
20
+ "normalized": true,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "added_tokens_decoder": {
5
+ "100000": {
6
+ "content": "<|begin▁of▁sentence|>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "100001": {
14
+ "content": "<|end▁of▁sentence|>",
15
+ "lstrip": false,
16
+ "normalized": true,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "100002": {
22
+ "content": "ø",
23
+ "lstrip": false,
24
+ "normalized": true,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": false
28
+ },
29
+ "100003": {
30
+ "content": "ö",
31
+ "lstrip": false,
32
+ "normalized": true,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": false
36
+ },
37
+ "100004": {
38
+ "content": "ú",
39
+ "lstrip": false,
40
+ "normalized": true,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": false
44
+ },
45
+ "100005": {
46
+ "content": "ÿ",
47
+ "lstrip": false,
48
+ "normalized": true,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": false
52
+ },
53
+ "100006": {
54
+ "content": "õ",
55
+ "lstrip": false,
56
+ "normalized": true,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": false
60
+ },
61
+ "100007": {
62
+ "content": "÷",
63
+ "lstrip": false,
64
+ "normalized": true,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": false
68
+ },
69
+ "100008": {
70
+ "content": "û",
71
+ "lstrip": false,
72
+ "normalized": true,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": false
76
+ },
77
+ "100009": {
78
+ "content": "ý",
79
+ "lstrip": false,
80
+ "normalized": true,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": false
84
+ },
85
+ "100010": {
86
+ "content": "À",
87
+ "lstrip": false,
88
+ "normalized": true,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": false
92
+ },
93
+ "100011": {
94
+ "content": "ù",
95
+ "lstrip": false,
96
+ "normalized": true,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": false
100
+ },
101
+ "100012": {
102
+ "content": "Á",
103
+ "lstrip": false,
104
+ "normalized": true,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": false
108
+ },
109
+ "100013": {
110
+ "content": "þ",
111
+ "lstrip": false,
112
+ "normalized": true,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": false
116
+ },
117
+ "100014": {
118
+ "content": "ü",
119
+ "lstrip": false,
120
+ "normalized": true,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ }
125
+ },
126
+ "bos_token": "<|begin▁of▁sentence|>",
127
+ "chat_template": "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{{ bos_token }}{% for message in messages %}{% if message['role'] == 'user' %}{{ 'User: ' + message['content'] + '\n\n' }}{% elif message['role'] == 'assistant' %}{{ 'Assistant: ' + message['content'] + eos_token }}{% elif message['role'] == 'system' %}{{ message['content'] + '\n\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}",
128
+ "clean_up_tokenization_spaces": false,
129
+ "eos_token": "<|end▁of▁sentence|>",
130
+ "legacy": true,
131
+ "mask_token": "_",
132
+ "model_max_length": 4096,
133
+ "pad_token": "<|end▁of▁sentence|>",
134
+ "sp_model_kwargs": {},
135
+ "tokenizer_class": "LlamaTokenizer",
136
+ "unk_token": null,
137
+ "use_default_system_prompt": false
138
+ }