RichardErkhov commited on
Commit
a0fad42
·
verified ·
1 Parent(s): b680755

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +438 -0
README.md ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ CursorCore-DS-1.3B-SR - AWQ
11
+ - Model creator: https://huggingface.co/TechxGenus/
12
+ - Original model: https://huggingface.co/TechxGenus/CursorCore-DS-1.3B-SR/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ tags:
20
+ - code
21
+ base_model:
22
+ - deepseek-ai/deepseek-coder-1.3b-base
23
+ library_name: transformers
24
+ pipeline_tag: text-generation
25
+ license: other
26
+ license_name: deepseek
27
+ license_link: LICENSE
28
+ ---
29
+
30
+ # CursorCore: Assist Programming through Aligning Anything
31
+
32
+ <p align="center">
33
+ <a href="http://arxiv.org/abs/2410.07002">[📄arXiv]</a> |
34
+ <a href="https://hf.co/papers/2410.07002">[🤗HF Paper]</a> |
35
+ <a href="https://huggingface.co/collections/TechxGenus/cursorcore-series-6706618c38598468866b60e2">[🤖Models]</a> |
36
+ <a href="https://github.com/TechxGenus/CursorCore">[🛠️Code]</a> |
37
+ <a href="https://github.com/TechxGenus/CursorWeb">[Web]</a> |
38
+ <a href="https://discord.gg/Z5Tev8fV">[Discord]</a>
39
+ </p>
40
+
41
+ <hr>
42
+
43
+ - [CursorCore: Assist Programming through Aligning Anything](#cursorcore-assist-programming-through-aligning-anything)
44
+ - [Introduction](#introduction)
45
+ - [Models](#models)
46
+ - [Usage](#usage)
47
+ - [1) Normal chat](#1-normal-chat)
48
+ - [2) Assistant-Conversation](#2-assistant-conversation)
49
+ - [3) Web Demo](#3-web-demo)
50
+ - [Future Work](#future-work)
51
+ - [Citation](#citation)
52
+ - [Contribution](#contribution)
53
+
54
+ <hr>
55
+
56
+ ## Introduction
57
+
58
+ CursorCore is a series of open-source models designed for AI-assisted programming. It aims to support features such as automated editing and inline chat, replicating the core abilities of closed-source AI-assisted programming tools like Cursor. This is achieved by aligning data generated through Programming-Instruct. Please read [our paper](http://arxiv.org/abs/2410.07002) to learn more.
59
+
60
+ <p align="center">
61
+ <img width="100%" alt="conversation" src="https://raw.githubusercontent.com/TechxGenus/CursorCore/main/pictures/conversation.png">
62
+ </p>
63
+
64
+ ![CursorWeb](https://raw.githubusercontent.com/TechxGenus/CursorCore/main/pictures/CursorWeb.gif)
65
+
66
+ ## Models
67
+
68
+ Our models have been open-sourced on Hugging Face. You can access our models here: [CursorCore-Series](https://huggingface.co/collections/TechxGenus/cursorcore-series-6706618c38598468866b60e2"). We also provide pre-quantized weights for GPTQ and AWQ here: [CursorCore-Quantization](https://huggingface.co/collections/TechxGenus/cursorcore-quantization-67066431f29f252494ee8cf3)
69
+
70
+ ## Usage
71
+
72
+ Here are some examples of how to use our model:
73
+
74
+ ### 1) Normal chat
75
+
76
+ Script:
77
+
78
+ ````python
79
+ import torch
80
+ from transformers import AutoTokenizer, AutoModelForCausalLM
81
+
82
+ tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-9B")
83
+ model = AutoModelForCausalLM.from_pretrained(
84
+ "TechxGenus/CursorCore-Yi-9B",
85
+ torch_dtype=torch.bfloat16,
86
+ device_map="auto"
87
+ )
88
+
89
+ messages = [
90
+ {"role": "user", "content": "Hi!"},
91
+ ]
92
+ prompt = tokenizer.apply_chat_template(
93
+ messages,
94
+ tokenize=False,
95
+ add_generation_prompt=True
96
+ )
97
+
98
+ inputs = tokenizer.encode(prompt, return_tensors="pt")
99
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512)
100
+ print(tokenizer.decode(outputs[0]))
101
+ ````
102
+
103
+ Output:
104
+
105
+ ````txt
106
+ <|im_start|>system
107
+ You are a helpful programming assistant.<|im_end|>
108
+ <|im_start|>user
109
+ Hi!<|im_end|>
110
+ <|im_start|>assistant
111
+ Hello! I'm an AI language model and I can help you with any programming questions you might have. What specific problem or task are you trying to solve?<|im_end|>
112
+ ````
113
+
114
+ ### 2) Assistant-Conversation
115
+
116
+ In our work, we introduce a new framework of AI-assisted programming task. It is designed for aligning anything during programming process, used for the implementation of features like Tab and Inline Chat.
117
+
118
+ Script 1:
119
+
120
+ ````python
121
+ import torch
122
+ from transformers import AutoTokenizer, AutoModelForCausalLM
123
+ from eval.utils import prepare_input_for_wf
124
+
125
+ tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-9B")
126
+ model = AutoModelForCausalLM.from_pretrained(
127
+ "TechxGenus/CursorCore-Yi-9B",
128
+ torch_dtype=torch.bfloat16,
129
+ device_map="auto"
130
+ )
131
+ sample = {
132
+ "history": [
133
+ {
134
+ "type": "code",
135
+ "lang": "python",
136
+ "code": """def quick_sort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quick_sort(left) + middle + quick_sort(right)"""
137
+ }
138
+ ],
139
+ "current": {
140
+ "type": "code",
141
+ "lang": "python",
142
+ "code": """def quick_sort(array):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quick_sort(left) + middle + quick_sort(right)"""
143
+ },
144
+ "user": ""
145
+ }
146
+
147
+ prompt = tokenizer.apply_chat_template(
148
+ prepare_input_for_wf(sample),
149
+ tokenize=False,
150
+ chat_template="assistant-conversation",
151
+ add_generation_prompt=True
152
+ )
153
+
154
+ inputs = tokenizer.encode(prompt, return_tensors="pt")
155
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512, do_sample=False)
156
+ print(tokenizer.decode(outputs[0]))
157
+ ````
158
+
159
+ Output 1:
160
+
161
+ ````txt
162
+ <|im_start|>system
163
+ You are a helpful programming assistant.<|im_end|>
164
+ <|im_start|>history
165
+ ```python
166
+ def quick_sort(arr):
167
+ if len(arr) <= 1:
168
+ return arr
169
+ pivot = arr[len(arr) // 2]
170
+ left = [x for x in arr if x < pivot]
171
+ middle = [x for x in arr if x == pivot]
172
+ right = [x for x in arr if x > pivot]
173
+ return quick_sort(left) + middle + quick_sort(right)
174
+ ```<|im_end|>
175
+ <|im_start|>current
176
+ ```python
177
+ def quick_sort(array):
178
+ if len(arr) <= 1:
179
+ return arr
180
+ pivot = arr[len(arr) // 2]
181
+ left = [x for x in arr if x < pivot]
182
+ middle = [x for x in arr if x == pivot]
183
+ right = [x for x in arr if x > pivot]
184
+ return quick_sort(left) + middle + quick_sort(right)
185
+ ```<|im_end|>
186
+ <|im_start|>assistant
187
+ <|next_start|>```python
188
+ def quick_sort(array):
189
+ if len(array) <= 1:
190
+ return array
191
+ pivot = array[len(array) // 2]
192
+ left = [x for x in array if x < pivot]
193
+ middle = [x for x in array if x == pivot]
194
+ right = [x for x in array if x > pivot]
195
+ return quick_sort(left) + middle + quick_sort(right)
196
+ ```<|next_end|>
197
+ The user has provided a revised code change that corrects the parameter name from `arr` to `array` in the `quick_sort` function. This change ensures consistency in the function definition and avoids potential confusion or errors.
198
+
199
+ To implement this, we will:
200
+ 1. Update the parameter name in the function definition from `arr` to `array`.
201
+ 2. Ensure that all references to `arr` within the function are updated to `array`.
202
+
203
+ This will make the function definition and internal references consistent, improving code readability and maintainability.<|im_end|>
204
+ ````
205
+
206
+ Script 2:
207
+
208
+ ````python
209
+ import torch
210
+ from transformers import AutoTokenizer, AutoModelForCausalLM
211
+ from eval.utils import prepare_input_for_wf
212
+
213
+ tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-9B")
214
+ model = AutoModelForCausalLM.from_pretrained(
215
+ "TechxGenus/CursorCore-Yi-9B",
216
+ torch_dtype=torch.bfloat16,
217
+ device_map="auto"
218
+ )
219
+ sample = {
220
+ "history": [],
221
+ "current": {
222
+ "type": "code",
223
+ "lang": "python",
224
+ "code": """def quick_sort(array):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quick_sort(left) + middle + quick_sort(right)"""
225
+ },
226
+ "user": "Add Docstring."
227
+ }
228
+
229
+ prompt = tokenizer.apply_chat_template(
230
+ prepare_input_for_wf(sample),
231
+ tokenize=False,
232
+ chat_template="assistant-conversation",
233
+ add_generation_prompt=True
234
+ )
235
+
236
+ inputs = tokenizer.encode(prompt, return_tensors="pt")
237
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512, do_sample=False)
238
+ print(tokenizer.decode(outputs[0]))
239
+ ````
240
+
241
+ Output 2:
242
+
243
+ ````txt
244
+ <|im_start|>system
245
+ You are a helpful programming assistant.<|im_end|>
246
+ <|im_start|>current
247
+ ```python
248
+ def quick_sort(array):
249
+ if len(arr) <= 1:
250
+ return arr
251
+ pivot = arr[len(arr) // 2]
252
+ left = [x for x in arr if x < pivot]
253
+ middle = [x for x in arr if x == pivot]
254
+ right = [x for x in arr if x > pivot]
255
+ return quick_sort(left) + middle + quick_sort(right)
256
+ ```<|im_end|>
257
+ <|im_start|>user
258
+ Add Docstring.<|im_end|>
259
+ <|im_start|>assistant
260
+ <|next_start|>```python
261
+ def quick_sort(array):
262
+ """
263
+ This is an implementation of the quick sort algorithm.
264
+ """
265
+ if len(arr) <= 1:
266
+ return arr
267
+ pivot = arr[len(arr) // 2]
268
+ left = [x for x in arr if x < pivot]
269
+ middle = [x for x in arr if x == pivot]
270
+ right = [x for x in arr if x > pivot]
271
+ return quick_sort(left) + middle + quick_sort(right)
272
+ ```<|next_end|><|im_end|>
273
+ ````
274
+
275
+ For models in Locate-and-Change (LC) and Search-and-Replace (SR) formats, the output examples are as follows:
276
+
277
+ Script for LC:
278
+
279
+ ````python
280
+ import torch
281
+ from transformers import AutoTokenizer, AutoModelForCausalLM
282
+ from eval.utils import prepare_input_for_lc
283
+
284
+ tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-1.5B-LC")
285
+ model = AutoModelForCausalLM.from_pretrained(
286
+ "TechxGenus/CursorCore-Yi-1.5B-LC",
287
+ torch_dtype=torch.bfloat16,
288
+ device_map="auto"
289
+ )
290
+ sample = {
291
+ "history": [],
292
+ "current": {
293
+ "type": "code",
294
+ "lang": "python",
295
+ "code": """def quick_sort(array):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quick_sort(left) + middle + quick_sort(right)"""
296
+ },
297
+ "user": "Add Docstring."
298
+ }
299
+
300
+ prompt = tokenizer.apply_chat_template(
301
+ prepare_input_for_lc(sample),
302
+ tokenize=False,
303
+ chat_template="assistant-conversation",
304
+ add_generation_prompt=True
305
+ )
306
+
307
+ inputs = tokenizer.encode(prompt, return_tensors="pt")
308
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512, do_sample=False)
309
+ print(tokenizer.decode(outputs[0]))
310
+ ````
311
+
312
+ Output for LC:
313
+
314
+ ````txt
315
+ <|im_start|>system
316
+ You are a helpful programming assistant.<|im_end|>
317
+ <|im_start|>current
318
+ ```python
319
+ 1 def quick_sort(array):
320
+ 2 if len(arr) <= 1:
321
+ 3 return arr
322
+ 4 pivot = arr[len(arr) // 2]
323
+ 5 left = [x for x in arr if x < pivot]
324
+ 6 middle = [x for x in arr if x == pivot]
325
+ 7 right = [x for x in arr if x > pivot]
326
+ 8 return quick_sort(left) + middle + quick_sort(right)
327
+ ```<|im_end|>
328
+ <|im_start|>user
329
+ Add Docstring.<|im_end|>
330
+ <|im_start|>assistant
331
+ <|next_start|>1,1
332
+ ```
333
+ '''This function will sort an array using quick sort algorithm'''
334
+ ```<|next_end|>
335
+ To enhance the readability and maintainability of the code, we should add a docstring to the `quick_sort` function. A docstring provides a clear description of what the function does, which is particularly useful for other developers who might use or modify this code in the future.
336
+
337
+ The docstring will be added immediately after the function definition, explaining that the function uses the quick sort algorithm to sort an array. This will make the code more self-explanatory and easier to understand.
338
+
339
+ Here's the plan:
340
+ 1. Add a docstring at the beginning of the `quick_sort` function.
341
+ 2. Ensure the docstring is clear and concise, describing the purpose of the function.
342
+
343
+ This modification will improve the code's documentation without altering its functionality.<|im_end|>
344
+ ````
345
+
346
+ Script for SR:
347
+
348
+ ````python
349
+ import torch
350
+ from transformers import AutoTokenizer, AutoModelForCausalLM
351
+ from eval.utils import prepare_input_for_sr
352
+
353
+ tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-1.5B-SR")
354
+ model = AutoModelForCausalLM.from_pretrained(
355
+ "TechxGenus/CursorCore-Yi-1.5B-SR",
356
+ torch_dtype=torch.bfloat16,
357
+ device_map="auto"
358
+ )
359
+ sample = {
360
+ "history": [],
361
+ "current": {
362
+ "type": "code",
363
+ "lang": "python",
364
+ "code": """def quick_sort(array):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quick_sort(left) + middle + quick_sort(right)"""
365
+ },
366
+ "user": "Add Docstring."
367
+ }
368
+
369
+ prompt = tokenizer.apply_chat_template(
370
+ prepare_input_for_sr(sample),
371
+ tokenize=False,
372
+ chat_template="assistant-conversation",
373
+ add_generation_prompt=True
374
+ )
375
+
376
+ inputs = tokenizer.encode(prompt, return_tensors="pt")
377
+ outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512, do_sample=False)
378
+ print(tokenizer.decode(outputs[0]))
379
+ ````
380
+
381
+ Output for SR:
382
+
383
+ ````txt
384
+ <|im_start|>system
385
+ You are a helpful programming assistant.<|im_end|>
386
+ <|im_start|>current
387
+ ```python
388
+ def quick_sort(array):
389
+ if len(arr) <= 1:
390
+ return arr
391
+ pivot = arr[len(arr) // 2]
392
+ left = [x for x in arr if x < pivot]
393
+ middle = [x for x in arr if x == pivot]
394
+ right = [x for x in arr if x > pivot]
395
+ return quick_sort(left) + middle + quick_sort(right)
396
+ ```<|im_end|>
397
+ <|im_start|>user
398
+ Add Docstring.<|im_end|>
399
+ <|im_start|>assistant
400
+ <|next_start|>```python
401
+ def quick_sort(array):
402
+ <|search_and_replace|>
403
+ def quick_sort(array):
404
+ """
405
+ This function implements quick sort algorithm
406
+ """
407
+ ```<|next_end|><|im_end|>
408
+ ````
409
+
410
+ ### 3) Web Demo
411
+
412
+ We create a web demo for CursorCore. Please visit [CursorWeb](https://github.com/TechxGenus/CursorWeb) for more details.
413
+
414
+ ## Future Work
415
+
416
+ CursorCore is still in a very early stage, and lots of work is needed to achieve a better user experience. For example:
417
+
418
+ - Repository-level editing support
419
+ - Better and faster editing formats
420
+ - Better user interface and presentation
421
+ - ...
422
+
423
+ ## Citation
424
+
425
+ ```bibtex
426
+ @article{jiang2024cursorcore,
427
+ title = {CursorCore: Assist Programming through Aligning Anything},
428
+ author = {Hao Jiang and Qi Liu and Rui Li and Shengyu Ye and Shijin Wang},
429
+ year = {2024},
430
+ journal = {arXiv preprint arXiv: 2410.07002}
431
+ }
432
+ ```
433
+
434
+ ## Contribution
435
+
436
+ Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.
437
+
438
+