TechxGenus commited on
Commit
f3b924b
1 Parent(s): 6a3acf6

Upload README.md with huggingface_hub

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