RichardErkhov commited on
Commit
e6498aa
1 Parent(s): d8187b1

uploaded readme

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