manueldeprada HF Staff commited on
Commit
5eb0cfa
·
1 Parent(s): 3f890cc
README.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags:
4
+ - custom_generate
5
+ - sampling
6
+ - kvcache
7
+ ---
8
+
9
+ # Sampling with KV Cache
10
+
11
+ ## Description
12
+ A clean, hackable implementation of sampling (also called ancestral sampling or multinomial sampling). This is a simplified alternative to the complex generation mixin in transformers, designed for readability and ease of modification while maintaining full performance.
13
+
14
+ The implementation supports both sampling and greedy decoding modes, with optional temperature scaling and top-k/top-p filtering.
15
+
16
+ ## Base model
17
+ - [HuggingFaceTB/SmolLM2-135M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct)
18
+
19
+ ## Model compatibility
20
+ Most transformer LLM/VLM models trained for causal language modeling.
21
+
22
+ ## Relevant Arguments
23
+ - `temperature` (float): Sampling temperature (default: 1.0, higher = more random)
24
+ - `top_k` (int): Only consider top-k most probable tokens (default: None)
25
+ - `top_p` (float): Only consider tokens with cumulative probability <= top_p (default: None)
26
+ - `do_sample` (bool): Whether to use sampling (True, default) or greedy decoding (False)
27
+
28
+ ### Logits Processing Order
29
+ Logits processors are applied in sequence: `temperature → softmax → top_k → top_p` (same as HuggingFace's `LogitProcessor` system). Temperature scaling occurs before top-p filtering, affecting the probability distribution that top-p operates on.
30
+
31
+ For example, with `temperature=1.0`, `top_p=0.9` might include tokens A, B, C. With `temperature=0.5`, probability mass is much more concentrated, so `top_p=0.9` might only include token A.
32
+
33
+ ## Outputs
34
+ When `return_dict_in_generate=True`, returns a dictionary with:
35
+ - `sequences`: Generated token IDs
36
+ - `scores`: Log probabilities of sampled tokens (with temperature/sampling modifications)
37
+ - `logprobs`: Original model log probabilities (T=1, no modifications)
38
+ Otherwise, returns a tensor of generated token IDs.
39
+
40
+ ## Example usage
41
+
42
+ ```py
43
+ from transformers import AutoModelForCausalLM, AutoTokenizer
44
+
45
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
46
+ model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct", device_map="auto")
47
+
48
+ inputs = tokenizer(["The quick brown"], return_tensors="pt").to(model.device)
49
+
50
+ # Basic sampling
51
+ gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling", trust_remote_code=True)
52
+
53
+ # With temperature
54
+ gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling", temperature=0.8, trust_remote_code=True)
55
+
56
+ # With top-k
57
+ gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling", top_k=50, trust_remote_code=True)
58
+
59
+ # With top-p (nucleus sampling)
60
+ gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling", top_p=0.9, trust_remote_code=True)
61
+
62
+ # Greedy decoding (no sampling)
63
+ gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling", do_sample=False, trust_remote_code=True)
64
+
65
+ # Get detailed output with probabilities
66
+ gen_out = model.generate(
67
+ **inputs,
68
+ custom_generate="manueldeprada/sampling",
69
+ return_dict_in_generate=True,
70
+ trust_remote_code=True
71
+ )
72
+ print(f"Generated text: {tokenizer.batch_decode(gen_out['sequences'], skip_special_tokens=True)}")
73
+ print(f"Sampling scores: {gen_out['scores']}")
74
+ print(f"Model log probabilities: {gen_out['logprobs']}")
75
+ ```
76
+
77
+ ## Algorithm
78
+ 1. Prepare input sequences
79
+ 2. For each generation step:
80
+ - Get logits from the model for the current sequence
81
+ - Apply temperature scaling to logits
82
+ - Optionally apply top-k filtering (keep only top-k tokens)
83
+ - Optionally apply top-p filtering (nucleus sampling)
84
+ - Convert to probabilities using softmax
85
+ - Sample from the probability distribution (or take argmax for greedy)
86
+ - Append the selected token to the sequence
87
+ - Track sequence completion
88
+ 3. Return generated sequences and probability information
89
+
90
+
91
+
92
+
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "eos_token_id": 0,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 576,
11
+ "initializer_range": 0.041666666666666664,
12
+ "intermediate_size": 1536,
13
+ "is_llama_config": true,
14
+ "max_position_embeddings": 8192,
15
+ "model_type": "llama",
16
+ "num_attention_heads": 9,
17
+ "num_hidden_layers": 30,
18
+ "num_key_value_heads": 3,
19
+ "pretraining_tp": 1,
20
+ "rms_norm_eps": 1e-05,
21
+ "rope_interleaved": false,
22
+ "rope_scaling": null,
23
+ "rope_theta": 100000,
24
+ "tie_word_embeddings": true,
25
+ "torch_dtype": "bfloat16",
26
+ "transformers_version": "4.40.1",
27
+ "use_cache": true,
28
+ "vocab_size": 49152
29
+ }
custom_generate/generate.py ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import Cache, DynamicCache
3
+ from transformers.generation.utils import ModelOutput
4
+ from typing import Optional, Any
5
+
6
+ def prepare_inputs_for_generation(
7
+ input_ids: torch.LongTensor,
8
+ attention_mask: Optional[torch.LongTensor] = None,
9
+ cache_position: Optional[torch.LongTensor] = None,
10
+ **kwargs,
11
+ ):
12
+ input_ids = input_ids[:, cache_position].clone(memory_format=torch.contiguous_format)
13
+ model_inputs = {"cache_position": cache_position,
14
+ "past_key_values": None,
15
+ "input_ids": input_ids,
16
+ "inputs_embeds": None,
17
+ "attention_mask": attention_mask,
18
+ }
19
+ if attention_mask is not None and kwargs.get("position_ids") is None:
20
+ position_ids = attention_mask.long().cumsum(-1) - 1
21
+ position_ids.masked_fill_(attention_mask == 0, 1)
22
+ kwargs["position_ids"] = position_ids
23
+ model_inputs.update({k: v for k, v in kwargs.items() if k not in model_inputs})
24
+ return model_inputs
25
+
26
+ def update_model_kwargs_for_generation(
27
+ outputs: ModelOutput,
28
+ model_kwargs: dict[str, Any],
29
+ num_new_tokens: int = 1,
30
+ ) -> dict[str, Any]:
31
+ if "token_type_ids" in model_kwargs:
32
+ token_type_ids = model_kwargs["token_type_ids"]
33
+ model_kwargs["token_type_ids"] = torch.cat([token_type_ids, token_type_ids[:, -1].unsqueeze(-1)], dim=-1)
34
+ if "attention_mask" in model_kwargs:
35
+ attention_mask = model_kwargs["attention_mask"]
36
+ model_kwargs["attention_mask"] = torch.cat(
37
+ [attention_mask, attention_mask.new_ones((attention_mask.shape[0], 1))], dim=-1
38
+ )
39
+ past_positions = model_kwargs.pop("cache_position")
40
+ new_positions = torch.arange(
41
+ past_positions[-1] + 1, past_positions[-1] + num_new_tokens + 1, dtype=past_positions.dtype
42
+ ).to(past_positions.device)
43
+ model_kwargs["cache_position"] = torch.cat((past_positions, new_positions))
44
+ return model_kwargs
45
+
46
+
47
+ def next_logits_with_cache_update(model, model_kwargs, input_ids):
48
+ """
49
+ Gets the next token logits and updates the KV cache:
50
+ - Runs the model forward pass
51
+ - Extracts logits for the last token
52
+ - Updates the KV cache
53
+ - Returns updated `model_kwargs` and `logits`
54
+
55
+ Args:
56
+ model: The language model
57
+ model_kwargs: Model keyword arguments including KV cache
58
+ input_ids: Current input token IDs
59
+
60
+ Returns:
61
+ Updated model_kwargs, logits for the next token
62
+ """
63
+ model_inputs = prepare_inputs_for_generation(input_ids, **model_kwargs)
64
+ with torch.no_grad():
65
+ outputs = model(**model_inputs, return_dict=True)
66
+
67
+ logits = outputs.logits[:, -1].detach()
68
+ model_kwargs = update_model_kwargs_for_generation(outputs, model_kwargs)
69
+ del outputs
70
+ return model_kwargs, logits
71
+
72
+
73
+ def init_gen(model_kwargs, model, max_new_tokens, bos_token_id):
74
+ """
75
+ Initializes the generation process and prepares the KV cache:
76
+ - Sets up input sequences and model inputs
77
+ - Prepares the KV cache for generation
78
+ - Returns updated `model_kwargs` and `input_ids`
79
+
80
+ Args:
81
+ model_kwargs: Model keyword arguments
82
+ model: The language model
83
+ max_new_tokens: Maximum number of new tokens to generate
84
+ bos_token_id: Beginning-of-sequence token ID
85
+
86
+ Returns:
87
+ Model keyword arguments and input token IDs
88
+ """
89
+ input_ids = model_kwargs.pop("input_ids")
90
+ model_kwargs["past_key_values"] = None
91
+ model_kwargs["cache_position"] = torch.ones(input_ids.shape[1], dtype=torch.int64, device=input_ids.device).cumsum(0) - 1
92
+ return model_kwargs, input_ids
93
+
94
+
95
+ def _apply_top_k(ps, model):
96
+ """Apply top-k filtering to probabilities."""
97
+ if not hasattr(model, "generation_config") or not hasattr(
98
+ model.generation_config, "top_k"
99
+ ):
100
+ return ps
101
+
102
+ top_k = model.generation_config.top_k
103
+ if top_k is None or top_k >= ps.size(-1):
104
+ return ps
105
+
106
+ indices_to_remove = ps < torch.topk(ps, top_k)[0][..., -1, None]
107
+ ps[indices_to_remove] = 0.0
108
+ return ps / ps.sum(dim=-1, keepdim=True)
109
+
110
+
111
+ def _apply_top_p(ps, model):
112
+ """Apply top-p (nucleus) filtering to probabilities."""
113
+ if not hasattr(model, "generation_config") or not hasattr(
114
+ model.generation_config, "top_p"
115
+ ):
116
+ return ps
117
+
118
+ top_p = model.generation_config.top_p
119
+ if top_p is None or top_p >= 1.0:
120
+ return ps
121
+
122
+ sorted_probs, sorted_indices = torch.sort(ps, descending=True)
123
+ cumulative_probs = torch.cumsum(sorted_probs, dim=-1)
124
+
125
+ sorted_indices_to_remove = cumulative_probs > top_p
126
+ sorted_indices_to_remove[..., 1:] = sorted_indices_to_remove[..., :-1].clone()
127
+ sorted_indices_to_remove[..., 0] = 0
128
+
129
+ indices_to_remove = sorted_indices_to_remove.scatter(
130
+ 1, sorted_indices, sorted_indices_to_remove
131
+ )
132
+ ps[indices_to_remove] = 0.0
133
+ return ps / ps.sum(dim=-1, keepdim=True)
134
+
135
+
136
+ def sampling(
137
+ model_kwargs,
138
+ model,
139
+ eos_token_ids,
140
+ pad_token_id,
141
+ bos_token_id,
142
+ do_sample=True,
143
+ max_new_tokens=20,
144
+ temperature=1.0,
145
+ ):
146
+ """
147
+ Sampling implementation with proper KV caching.
148
+
149
+ Args:
150
+ prompts: List of input prompts
151
+ model: The language model
152
+ max_new_tokens: Maximum number of new tokens to generate
153
+ eos_token_ids: List of end-of-sequence token IDs
154
+ pad_token_id: Padding token ID
155
+ bos_token_id: Beginning-of-sequence token ID
156
+ max_new_tokens: Maximum number of new tokens to generate
157
+
158
+ Returns:
159
+ Generated sequences, log probabilities, and metadata
160
+ """
161
+ # Initialize the generation process and prepare the KV cache
162
+ model_kwargs, input_ids = init_gen(
163
+ model_kwargs, model, max_new_tokens, bos_token_id
164
+ )
165
+ batch_size, _ = input_ids.shape
166
+
167
+ # Keeps track of which sequences are finished and their lengths
168
+ active_seqs = input_ids.new_ones((batch_size, 1), dtype=torch.bool)
169
+ # Modified log probabilities of the sequences
170
+ scores = torch.zeros((batch_size, max_new_tokens), dtype=model.dtype)
171
+ # Unfiltered sequence log probabilities (temperature=1, no sampling processors applied)
172
+ logprobs = torch.zeros((batch_size, max_new_tokens), dtype=model.dtype)
173
+
174
+ for i in range(max_new_tokens):
175
+ # Get the next token probabilities and update the KV cache
176
+ model_kwargs, logits = next_logits_with_cache_update(
177
+ model, model_kwargs, input_ids
178
+ )
179
+ # Store original model probabilities (temperature=1, no sampling processors applied)
180
+ model_ps = logits.softmax(-1)
181
+
182
+ # Logit processors (temperature, top-k, top-p). We can chain these!
183
+ ps = (logits / temperature).softmax(-1)
184
+ ps = _apply_top_k(ps, model)
185
+ ps = _apply_top_p(ps, model)
186
+
187
+ # Sample the next token and gather the log probabilities
188
+ if do_sample: # Sampling
189
+ next_token_ids = (
190
+ torch.multinomial(ps, 1) * active_seqs + pad_token_id * ~active_seqs
191
+ )
192
+ else: # Greedy decoding
193
+ next_token_ids = (
194
+ torch.argmax(ps, dim=-1).unsqueeze(-1) * active_seqs
195
+ + pad_token_id * ~active_seqs
196
+ )
197
+ next_token_logprobs = ps.gather(-1, next_token_ids).log()
198
+ next_token_model_logprobs = model_ps.gather(-1, next_token_ids).log()
199
+
200
+ input_ids = torch.cat([input_ids, next_token_ids], dim=-1)
201
+ scores[:, i] = (next_token_logprobs * active_seqs).squeeze()
202
+ logprobs[:, i] = (next_token_model_logprobs * active_seqs).squeeze()
203
+
204
+ active_seqs &= ~torch.isin(next_token_ids, eos_token_ids)
205
+ if active_seqs.sum() == 0:
206
+ break
207
+ return input_ids.detach().cpu(), scores[:, : i + 1], logprobs[:, : i + 1]
208
+
209
+
210
+ def generate(model, **kwargs):
211
+ """
212
+ Sampling strategy - multinomial sampling with temperature and optional top-k/top-p filtering.
213
+ Simple implementation with proper KV caching support.
214
+
215
+ Args:
216
+ model: The language model
217
+ model_kwargs: Model keyword arguments from the tokenizer
218
+ generation_config: Generation configuration
219
+ temperature: Sampling temperature (higher = more random)
220
+ top_k: Only consider top-k most probable tokens
221
+ top_p: Only consider tokens with cumulative probability <= top_p
222
+ **kwargs: Additional arguments
223
+
224
+ Returns:
225
+ Generated token IDs
226
+ """
227
+ generation_config = model.generation_config
228
+ max_new_tokens = kwargs.get("max_new_tokens", generation_config.max_new_tokens)
229
+ max_new_tokens = 512 if max_new_tokens is None else max_new_tokens
230
+ do_sample = kwargs.get("do_sample", True)
231
+ eos_token_ids = kwargs.get("eos_token_ids", generation_config.eos_token_id)
232
+ if eos_token_ids is None:
233
+ raise ValueError(
234
+ "Model generation config does not have an EOS token id. You must provide it to generate() with the eos_token_ids argument."
235
+ )
236
+ eos_token_ids = torch.as_tensor(eos_token_ids, device=model.device)
237
+ if eos_token_ids is not None and eos_token_ids.ndim == 0:
238
+ eos_token_ids = eos_token_ids.unsqueeze(0)
239
+
240
+ pad_token_id = kwargs.get(
241
+ "pad_token_id",
242
+ generation_config.pad_token_id
243
+ if generation_config.pad_token_id is not None
244
+ else eos_token_ids[0],
245
+ )
246
+ bos_token_id = kwargs.get("bos_token_id", generation_config.bos_token_id)
247
+ if bos_token_id is None:
248
+ raise ValueError(
249
+ "Model generation config does not have a BOS token id. You must provide it to generate() with the bos_token_id argument."
250
+ )
251
+ temperature = kwargs.get("temperature", 1.0)
252
+ return_dict = kwargs.get("return_dict_in_generate", False)
253
+
254
+ generated_ids, scores, logprobs = sampling(
255
+ model_kwargs=kwargs,
256
+ model=model,
257
+ eos_token_ids=eos_token_ids,
258
+ pad_token_id=pad_token_id,
259
+ bos_token_id=bos_token_id,
260
+ do_sample=do_sample,
261
+ max_new_tokens=max_new_tokens,
262
+ temperature=temperature,
263
+ )
264
+
265
+ if return_dict:
266
+ return {
267
+ "sequences": generated_ids,
268
+ "scores": scores,
269
+ "logprobs": logprobs,
270
+ }
271
+ else:
272
+ return generated_ids
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "4.40.1"
6
+ }
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:80521b40281d6ce74e35c9282c22539e75aa0ac8578892b2a59955ef78d55da1
3
+ size 269060552
special_tokens_map.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|endoftext|>",
4
+ "<|im_start|>",
5
+ "<|im_end|>",
6
+ "<repo_name>",
7
+ "<reponame>",
8
+ "<file_sep>",
9
+ "<filename>",
10
+ "<gh_stars>",
11
+ "<issue_start>",
12
+ "<issue_comment>",
13
+ "<issue_closed>",
14
+ "<jupyter_start>",
15
+ "<jupyter_text>",
16
+ "<jupyter_code>",
17
+ "<jupyter_output>",
18
+ "<jupyter_script>",
19
+ "<empty_output>"
20
+ ],
21
+ "bos_token": {
22
+ "content": "<|endoftext|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false
27
+ },
28
+ "eos_token": {
29
+ "content": "<|endoftext|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false
34
+ },
35
+ "unk_token": {
36
+ "content": "<|endoftext|>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false
41
+ }
42
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<repo_name>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "4": {
37
+ "content": "<reponame>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "5": {
45
+ "content": "<file_sep>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "6": {
53
+ "content": "<filename>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "7": {
61
+ "content": "<gh_stars>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "8": {
69
+ "content": "<issue_start>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "9": {
77
+ "content": "<issue_comment>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "10": {
85
+ "content": "<issue_closed>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "11": {
93
+ "content": "<jupyter_start>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "12": {
101
+ "content": "<jupyter_text>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "13": {
109
+ "content": "<jupyter_code>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "14": {
117
+ "content": "<jupyter_output>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": true
123
+ },
124
+ "15": {
125
+ "content": "<jupyter_script>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": true
131
+ },
132
+ "16": {
133
+ "content": "<empty_output>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": true
139
+ }
140
+ },
141
+ "additional_special_tokens": [
142
+ "<|endoftext|>",
143
+ "<|im_start|>",
144
+ "<|im_end|>",
145
+ "<repo_name>",
146
+ "<reponame>",
147
+ "<file_sep>",
148
+ "<filename>",
149
+ "<gh_stars>",
150
+ "<issue_start>",
151
+ "<issue_comment>",
152
+ "<issue_closed>",
153
+ "<jupyter_start>",
154
+ "<jupyter_text>",
155
+ "<jupyter_code>",
156
+ "<jupyter_output>",
157
+ "<jupyter_script>",
158
+ "<empty_output>"
159
+ ],
160
+ "bos_token": "<|endoftext|>",
161
+ "clean_up_tokenization_spaces": false,
162
+ "eos_token": "<|endoftext|>",
163
+ "model_max_length": 8192,
164
+ "tokenizer_class": "GPT2Tokenizer",
165
+ "unk_token": "<|endoftext|>",
166
+ "vocab_size": 49152
167
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff