wolframko commited on
Commit
8d3b7a8
·
verified ·
1 Parent(s): c3559f3

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - BAAI/bge-code-v1
4
+ language:
5
+ - zh
6
+ - en
7
+ tags:
8
+ - bnb-my-repo
9
+ - sentence-transformers
10
+ - sentence-similarity
11
+ - feature-extraction
12
+ - transformers
13
+ pipeline_tag: sentence-similarity
14
+ library_name: sentence-transformers
15
+ license: apache-2.0
16
+ ---
17
+ # BAAI/bge-code-v1 (Quantized)
18
+
19
+ ## Description
20
+ This model is a quantized version of the original model [`BAAI/bge-code-v1`](https://huggingface.co/BAAI/bge-code-v1).
21
+
22
+ It's quantized using the BitsAndBytes library to 4-bit using the [bnb-my-repo](https://huggingface.co/spaces/bnb-community/bnb-my-repo) space.
23
+
24
+ ## Quantization Details
25
+ - **Quantization Type**: int4
26
+ - **bnb_4bit_quant_type**: fp4
27
+ - **bnb_4bit_use_double_quant**: True
28
+ - **bnb_4bit_compute_dtype**: bfloat16
29
+ - **bnb_4bit_quant_storage**: int8
30
+
31
+
32
+
33
+ # 📄 Original Model Information
34
+
35
+
36
+
37
+ <h1 align="center">FlagEmbedding</h1>
38
+
39
+ For more details please refer to our Github: [FlagEmbedding](https://github.com/FlagOpen/FlagEmbedding).
40
+
41
+ **BGE-Code-v1** is an LLM-based code embedding model that supports code retrieval, text retrieval, and multilingual retrieval. It primarily demonstrates the following capabilities:
42
+ - Superior Code Retrieval Performance: The model demonstrates exceptional code retrieval capabilities, supporting natural language queries in both English and Chinese, as well as 20 programming languages.
43
+ - Robust Text Retrieval Capabilities: The model maintains strong text retrieval capabilities comparable to text embedding models of similar scale.
44
+ - Extensive Multilingual Support: BGE-Code-v1 offers comprehensive multilingual retrieval capabilities, excelling in languages such as English, Chinese, Japanese, French, and more.
45
+
46
+ ## Usage
47
+
48
+ ### Using FlagEmbedding
49
+
50
+ ```
51
+ git clone https://github.com/FlagOpen/FlagEmbedding.git
52
+ cd FlagEmbedding
53
+ pip install -e .
54
+ ```
55
+
56
+ ```python
57
+ from FlagEmbedding import FlagLLMModel
58
+ queries = [
59
+ "Delete the record with ID 4 from the 'Staff' table.",
60
+ 'Delete all records in the "Livestock" table where age is greater than 5'
61
+ ]
62
+ documents = [
63
+ "DELETE FROM Staff WHERE StaffID = 4;",
64
+ "DELETE FROM Livestock WHERE age > 5;"
65
+ ]
66
+ model = FlagLLMModel('BAAI/bge-code-v1',
67
+ query_instruction_format="<instruct>{}\n<query>{}",
68
+ query_instruction_for_retrieval="Given a question in text, retrieve SQL queries that are appropriate responses to the question.",
69
+ trust_remote_code=True,
70
+ use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation
71
+ embeddings_1 = model.encode_queries(queries)
72
+ embeddings_2 = model.encode_corpus(documents)
73
+ similarity = embeddings_1 @ embeddings_2.T
74
+ print(similarity)
75
+ ```
76
+
77
+ By default, FlagLLMModel will use all available GPUs when encoding. Please set `os.environ["CUDA_VISIBLE_DEVICES"]` to select specific GPUs. You also can set `os.environ["CUDA_VISIBLE_DEVICES"]=""` to make all GPUs unavailable.
78
+
79
+ ### Using Sentence Transformers
80
+
81
+ ```python
82
+ from sentence_transformers import SentenceTransformer
83
+ import torch
84
+
85
+ # Load the model, optionally in float16 precision for faster inference
86
+ model = SentenceTransformer(
87
+ "BAAI/bge-code-v1",
88
+ trust_remote_code=True,
89
+ model_kwargs={"torch_dtype": torch.float16},
90
+ )
91
+
92
+ # Prepare a prompt given an instruction
93
+ instruction = 'Given a question in text, retrieve SQL queries that are appropriate responses to the question.'
94
+ prompt = f'<instruct>{instruction}\n<query>'
95
+ # Prepare queries and documents
96
+ queries = [
97
+ "Delete the record with ID 4 from the 'Staff' table.",
98
+ 'Delete all records in the "Livestock" table where age is greater than 5'
99
+ ]
100
+ documents = [
101
+ "DELETE FROM Staff WHERE StaffID = 4;",
102
+ "DELETE FROM Livestock WHERE age > 5;"
103
+ ]
104
+
105
+ # Compute the query and document embeddings
106
+ query_embeddings = model.encode(queries, prompt=prompt)
107
+ document_embeddings = model.encode(documents)
108
+
109
+ # Compute the cosine similarity between the query and document embeddings
110
+ similarities = model.similarity(query_embeddings, document_embeddings)
111
+ print(similarities)
112
+ ```
113
+
114
+ ### Using HuggingFace Transformers
115
+
116
+ ```python
117
+ import torch
118
+ import torch.nn.functional as F
119
+
120
+ from torch import Tensor
121
+ from transformers import AutoTokenizer, AutoModel
122
+
123
+
124
+ def last_token_pool(last_hidden_states: Tensor,
125
+ attention_mask: Tensor) -> Tensor:
126
+ left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
127
+ if left_padding:
128
+ return last_hidden_states[:, -1]
129
+ else:
130
+ sequence_lengths = attention_mask.sum(dim=1) - 1
131
+ batch_size = last_hidden_states.shape[0]
132
+ return last_hidden_states[torch.arange(batch_size, device=last_hidden_states.device), sequence_lengths]
133
+
134
+
135
+ def get_detailed_instruct(task_description: str, query: str) -> str:
136
+ return f'<instruct>{task_description}\n<query>{query}'
137
+
138
+
139
+ instruction = 'Given a question in text, retrieve SQL queries that are appropriate responses to the question.'
140
+ queries = [
141
+ "Delete the record with ID 4 from the 'Staff' table.",
142
+ 'Delete all records in the "Livestock" table where age is greater than 5'
143
+ ]
144
+ documents = [
145
+ "DELETE FROM Staff WHERE StaffID = 4;",
146
+ "DELETE FROM Livestock WHERE age > 5;"
147
+ ]
148
+ input_texts = queries + documents
149
+
150
+ tokenizer = AutoTokenizer.from_pretrained('BAAI/bge-code-v1', trust_remote_code=True)
151
+ model = AutoModel.from_pretrained('BAAI/bge-code-v1', trust_remote_code=True)
152
+ model.eval()
153
+
154
+ max_length = 4096
155
+ # Tokenize the input texts
156
+ batch_dict = tokenizer(input_texts, max_length=max_length, padding=True, truncation=True, return_tensors='pt', pad_to_multiple_of=8)
157
+
158
+ with torch.no_grad():
159
+ outputs = model(**batch_dict)
160
+ embeddings = last_token_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
161
+
162
+ # normalize embeddings
163
+ embeddings = F.normalize(embeddings, p=2, dim=1)
164
+ scores = (embeddings[:2] @ embeddings[2:].T) * 100
165
+ print(scores.tolist())
166
+ ```
167
+
168
+ ## Evaluation
169
+
170
+ **BGE-Code-v1** achieves state-of-the-art performance on both the CoIR and CodeRAG benchmarks.
171
+
172
+ - CoIR
173
+
174
+ | | CodeXEmbed-2B | CodeXEmbed-7B | Voyage-Code-002 | Voyage-Code-003 | BGE-Code-v1 |
175
+ |---------------------------------------|---------------|---------------|-----------------|-----------------|-----------|
176
+ | **Apps** | 76.86 | 85.38 | 26.52 | 93.62 | 98.08 |
177
+ | **CosQA** | 40.47 | 42.47 | 29.79 | 34.45 | 46.72 |
178
+ | **Text2SQL** | 78.42 | 78.94 | 69.26 | 62.87 | 64.35 |
179
+ | **CSN** | 87.87 | 89.67 | 81.79 | 89.35 | 89.53 |
180
+ | **CSN-CCR** | 97.66 | 97.95 | 73.45 | 90.05 | 98.30 |
181
+ | **CodeTrans-Contest** | 90.30 | 94.45 | 72.77 | 94.96 | 94.38 |
182
+ | **CodeTrans-DL** | 38.57 | 40.46 | 27.48 | 38.57 | 46.13 |
183
+ | **StackOverFlow-QA** | 94.47 | 96.33 | 67.68 | 97.17 | 95.35 |
184
+ | **CodeFeedBack-ST** | 86.36 | 87.53 | 65.35 | 90.67 | 90.56 |
185
+ | **CodeFeedBack-MT** | 65.51 | 68.83 | 28.74 | 93.58 | 94.38 |
186
+ | **AVG** | **75.65** | **78.20** | **56.26** | **78.53** | **81.77** |
187
+
188
+ - CodedRAG
189
+
190
+ | | HummanEval | MBPP | DS-1000 | ODEX | RepoEval | SWE-bench-Lite | AVG |
191
+ | --------------- | ---------- | ---- | ------- | ---- | -------- | -------------- | ---- |
192
+ | SFR | 100.0 | 99.0 | 19.3 | 37.1 | 83.8 | 62.7 | **67.0** |
193
+ | Jina-v2-code | 100.0 | 97.7 | 26.2 | 19.9 | 90.5 | 58.3 | **65.4** |
194
+ | CodeXEmbed-2B | 100.0 | 97.4 | 25.4 | 23.9 | 88.7 | 52.4 | **64.6** |
195
+ | Voyage-Code-002 | 100.0 | 99.0 | 33.1 | 26.6 | 94.3 | 29.1 | **63.7** |
196
+ | BGE-Code-v1 | 100.0 | 99.2 | 40.9 | 36.1 | 93.1 | 67.4 | **72.8** |
197
+
198
+ ### Instructions for Evaluation
199
+
200
+ ```python
201
+ {
202
+ "Apps": "Given a code contest problem description, retrieve relevant code that can help solve the problem.",
203
+ "CosQA": "Given a web search query, retrieve relevant code that can help answer the query.",
204
+ "Text2SQL": "Given a question in text, retrieve SQL queries that are appropriate responses to the question.",
205
+ "CSN": "Given a piece of code, retrieve the document string that summarizes the code.",
206
+ "CSN-CCR": "Given a piece of code segment, retrieve the code segment that is the latter part of the code.",
207
+ "CodeTrans-DL": "Given a piece of code, retrieve code that is semantically equivalent to the input code.",
208
+ "CodeTrans-Contest": "Given a piece of Python code, retrieve C++ code that is semantically equivalent to the input code.",
209
+ "StackOverFlow-QA": "Given a question that consists of a mix of text and code snippets, retrieve relevant answers that also consist of a mix of text and code snippets, and can help answer the question.",
210
+ "CodeFeedBack-ST": "Given a question that consists of a mix of text and code snippets, retrieve relevant answers that also consist of a mix of text and code snippets, and can help answer the question.",
211
+ "CodeFeedBack-MT": "Given a multi-turn conversation history that consists of a mix of text and code snippets, retrieve relevant answers that also consist of a mix of text and code snippets, and can help answer the question.",
212
+ "HummanEval": "Given a question that consists of a mix of text and code snippets, retrieve relevant answers that also consist of a mix of text and code snippets, and can help answer the question.",
213
+ "MBPP": "Given a textual explanation of code functionality, retrieve the corresponding code implementation.",
214
+ "DS-1000": "Given a question that consists of a mix of text and code snippets, retrieve relevant answers that also consist of a mix of text and code snippets, and can help answer the question.",
215
+ "ODEX": "Given a question, retrieve relevant answers that also consist of a mix of text and code snippets, and can help answer the question.",
216
+ "RepoEval": "Given a piece of code segment, retrieve the code segment that is the latter part of the code.",
217
+ "SWE-bench-Lite": "Given a code snippet containing a bug and a natural language description of the bug or error, retrieve code snippets that demonstrate solutions or fixes for similar bugs or errors (the desired documents)."
218
+ }
219
+ ```
220
+
221
+ ## Citation
222
+
223
+ If you find this repository useful, please consider giving a star :star: and citation
224
+
225
+ ```
226
+ @article{bge-llm,
227
+ title={Making text embedders few-shot learners},
228
+ author={Li, Chaofan and Qin, MingHao and Xiao, Shitao and Chen, Jianlyu and Luo, Kun and Shao, Yingxia and Lian, Defu and Liu, Zheng},
229
+ journal={arXiv preprint arXiv:2409.15700},
230
+ year={2024}
231
+ }
232
+
233
+ @misc{bge-m3,
234
+ title={BGE M3-Embedding: Multi-Lingual, Multi-Functionality, Multi-Granularity Text Embeddings Through Self-Knowledge Distillation},
235
+ author={Jianlv Chen and Shitao Xiao and Peitian Zhang and Kun Luo and Defu Lian and Zheng Liu},
236
+ year={2024},
237
+ eprint={2402.03216},
238
+ archivePrefix={arXiv},
239
+ primaryClass={cs.CL}
240
+ }
241
+
242
+ @misc{bge_embedding,
243
+ title={C-Pack: Packaged Resources To Advance General Chinese Embedding},
244
+ author={Shitao Xiao and Zheng Liu and Peitian Zhang and Niklas Muennighoff},
245
+ year={2023},
246
+ eprint={2309.07597},
247
+ archivePrefix={arXiv},
248
+ primaryClass={cs.CL}
249
+ }
250
+ ```
added_tokens.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<instruct>": 151665,
4
+ "<query>": 151666,
5
+ "<tool_call>": 151657,
6
+ "<|box_end|>": 151649,
7
+ "<|box_start|>": 151648,
8
+ "<|endoftext|>": 151643,
9
+ "<|file_sep|>": 151664,
10
+ "<|fim_middle|>": 151660,
11
+ "<|fim_pad|>": 151662,
12
+ "<|fim_prefix|>": 151659,
13
+ "<|fim_suffix|>": 151661,
14
+ "<|im_end|>": 151645,
15
+ "<|im_start|>": 151644,
16
+ "<|image_pad|>": 151655,
17
+ "<|object_ref_end|>": 151647,
18
+ "<|object_ref_start|>": 151646,
19
+ "<|quad_end|>": 151651,
20
+ "<|quad_start|>": 151650,
21
+ "<|repo_name|>": 151663,
22
+ "<|video_pad|>": 151656,
23
+ "<|vision_end|>": 151653,
24
+ "<|vision_pad|>": 151654,
25
+ "<|vision_start|>": 151652
26
+ }
config.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "BAAI/bge-code-v1",
3
+ "architectures": [
4
+ "Qwen2Model"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "eos_token_id": 151643,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 1536,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 8960,
13
+ "max_position_embeddings": 32768,
14
+ "max_window_layers": 28,
15
+ "model_type": "qwen2",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 28,
18
+ "num_key_value_heads": 2,
19
+ "quantization_config": {
20
+ "_load_in_4bit": true,
21
+ "_load_in_8bit": false,
22
+ "bnb_4bit_compute_dtype": "bfloat16",
23
+ "bnb_4bit_quant_storage": "int8",
24
+ "bnb_4bit_quant_type": "fp4",
25
+ "bnb_4bit_use_double_quant": true,
26
+ "llm_int8_enable_fp32_cpu_offload": false,
27
+ "llm_int8_has_fp16_weight": false,
28
+ "llm_int8_skip_modules": null,
29
+ "llm_int8_threshold": 6.0,
30
+ "load_in_4bit": true,
31
+ "load_in_8bit": false,
32
+ "quant_method": "bitsandbytes"
33
+ },
34
+ "rms_norm_eps": 1e-06,
35
+ "rope_scaling": null,
36
+ "rope_theta": 1000000.0,
37
+ "sliding_window": null,
38
+ "tie_word_embeddings": true,
39
+ "torch_dtype": "float32",
40
+ "transformers_version": "4.49.0",
41
+ "use_cache": false,
42
+ "use_sliding_window": false,
43
+ "vocab_size": 151667
44
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b33d70912d75fb23aa0d9ce3656fc9a9b93d59e42647c9bf86b8fb4ffabe9419
3
+ size 1608708594
special_tokens_map.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<instruct>",
4
+ "<query>"
5
+ ],
6
+ "eos_token": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false
12
+ },
13
+ "pad_token": {
14
+ "content": "<|endoftext|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ }
20
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a56524092f5d0676e63537511b535e73e7580a7efe440247ef3fa43d019a0af0
3
+ size 11422261
tokenizer_config.json ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": true,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "151643": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "151644": {
15
+ "content": "<|im_start|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "151645": {
23
+ "content": "<|im_end|>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "151646": {
31
+ "content": "<|object_ref_start|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "151647": {
39
+ "content": "<|object_ref_end|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "151648": {
47
+ "content": "<|box_start|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "151649": {
55
+ "content": "<|box_end|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "151650": {
63
+ "content": "<|quad_start|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "151651": {
71
+ "content": "<|quad_end|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "151652": {
79
+ "content": "<|vision_start|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "151653": {
87
+ "content": "<|vision_end|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ },
94
+ "151654": {
95
+ "content": "<|vision_pad|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": true
101
+ },
102
+ "151655": {
103
+ "content": "<|image_pad|>",
104
+ "lstrip": false,
105
+ "normalized": false,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": true
109
+ },
110
+ "151656": {
111
+ "content": "<|video_pad|>",
112
+ "lstrip": false,
113
+ "normalized": false,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": true
117
+ },
118
+ "151657": {
119
+ "content": "<tool_call>",
120
+ "lstrip": false,
121
+ "normalized": false,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "151658": {
127
+ "content": "</tool_call>",
128
+ "lstrip": false,
129
+ "normalized": false,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "151659": {
135
+ "content": "<|fim_prefix|>",
136
+ "lstrip": false,
137
+ "normalized": false,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "151660": {
143
+ "content": "<|fim_middle|>",
144
+ "lstrip": false,
145
+ "normalized": false,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "151661": {
151
+ "content": "<|fim_suffix|>",
152
+ "lstrip": false,
153
+ "normalized": false,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "151662": {
159
+ "content": "<|fim_pad|>",
160
+ "lstrip": false,
161
+ "normalized": false,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "151663": {
167
+ "content": "<|repo_name|>",
168
+ "lstrip": false,
169
+ "normalized": false,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": false
173
+ },
174
+ "151664": {
175
+ "content": "<|file_sep|>",
176
+ "lstrip": false,
177
+ "normalized": false,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "151665": {
183
+ "content": "<instruct>",
184
+ "lstrip": false,
185
+ "normalized": false,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": true
189
+ },
190
+ "151666": {
191
+ "content": "<query>",
192
+ "lstrip": false,
193
+ "normalized": false,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": true
197
+ }
198
+ },
199
+ "additional_special_tokens": [
200
+ "<instruct>",
201
+ "<query>"
202
+ ],
203
+ "auto_map": {
204
+ "AutoTokenizer": [
205
+ "BAAI/bge-code-v1--tokenization_qwen.Qwen2Tokenizer",
206
+ null
207
+ ]
208
+ },
209
+ "bos_token": null,
210
+ "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
211
+ "clean_up_tokenization_spaces": false,
212
+ "eos_token": "<|endoftext|>",
213
+ "errors": "replace",
214
+ "extra_special_tokens": {},
215
+ "model_max_length": 256,
216
+ "pad_token": "<|endoftext|>",
217
+ "split_special_tokens": false,
218
+ "tokenizer_class": "Qwen2Tokenizer",
219
+ "unk_token": null
220
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff