Views
No views yet


./benchmark contains the APEval benchmark./data contains code to preprocess datasets./eval contains code to evaluate models./gen contains code to prompt LLMs for generation./generic common functions, tools and special tokens./src contains code about Programming-Instruct./train contains code for training CursorCorepip install -r requirements.txt

1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-9B")
5model = AutoModelForCausalLM.from_pretrained(
6 "TechxGenus/CursorCore-Yi-9B",
7 torch_dtype=torch.bfloat16,
8 device_map="auto"
9)
10
11messages = [
12 {"role": "user", "content": "Hi!"},
13]
14prompt = tokenizer.apply_chat_template(
15 messages,
16 tokenize=False,
17 add_generation_prompt=True
18)
19
20inputs = tokenizer.encode(prompt, return_tensors="pt")
21outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512)
22print(tokenizer.decode(outputs[0]))1<|im_start|>system
2You are a helpful programming assistant.<|im_end|>
3<|im_start|>user
4Hi!<|im_end|>
5<|im_start|>assistant
6Hello! 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|>1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from eval.utils import prepare_input_for_wf
4
5tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-9B")
6model = AutoModelForCausalLM.from_pretrained(
7 "TechxGenus/CursorCore-Yi-9B",
8 torch_dtype=torch.bfloat16,
9 device_map="auto"
10)
11sample = {
12 "history": [
13 {
14 "type": "code",
15 "lang": "python",
16 "code": """def quick_sort(arr):
17 if len(arr) <= 1:
18 return arr
19 pivot = arr[len(arr) // 2]
20 left = [x for x in arr if x < pivot]
21 middle = [x for x in arr if x == pivot]
22 right = [x for x in arr if x > pivot]
23 return quick_sort(left) + middle + quick_sort(right)"""
24 }
25 ],
26 "current": {
27 "type": "code",
28 "lang": "python",
29 "code": """def quick_sort(array):
30 if len(arr) <= 1:
31 return arr
32 pivot = arr[len(arr) // 2]
33 left = [x for x in arr if x < pivot]
34 middle = [x for x in arr if x == pivot]
35 right = [x for x in arr if x > pivot]
36 return quick_sort(left) + middle + quick_sort(right)"""
37 },
38 "user": ""
39}
40
41prompt = tokenizer.apply_chat_template(
42 prepare_input_for_wf(sample),
43 tokenize=False,
44 chat_template="assistant-conversation",
45 add_generation_prompt=True
46)
47
48inputs = tokenizer.encode(prompt, return_tensors="pt")
49outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512, do_sample=False)
50print(tokenizer.decode(outputs[0]))1<|im_start|>system
2You are a helpful programming assistant.<|im_end|>
3<|im_start|>history
4```python
5def quick_sort(arr):
6 if len(arr) <= 1:
7 return arr
8 pivot = arr[len(arr) // 2]
9 left = [x for x in arr if x < pivot]
10 middle = [x for x in arr if x == pivot]
11 right = [x for x in arr if x > pivot]
12 return quick_sort(left) + middle + quick_sort(right)
13```<|im_end|>
14<|im_start|>current
15```python
16def quick_sort(array):
17 if len(arr) <= 1:
18 return arr
19 pivot = arr[len(arr) // 2]
20 left = [x for x in arr if x < pivot]
21 middle = [x for x in arr if x == pivot]
22 right = [x for x in arr if x > pivot]
23 return quick_sort(left) + middle + quick_sort(right)
24```<|im_end|>
25<|im_start|>assistant
26<|next_start|>```python
27def quick_sort(array):
28 if len(array) <= 1:
29 return array
30 pivot = array[len(array) // 2]
31 left = [x for x in array if x < pivot]
32 middle = [x for x in array if x == pivot]
33 right = [x for x in array if x > pivot]
34 return quick_sort(left) + middle + quick_sort(right)
35```<|next_end|>
36The 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.
37
38To implement this, we will:
391. Update the parameter name in the function definition from `arr` to `array`.
402. Ensure that all references to `arr` within the function are updated to `array`.
41
42This will make the function definition and internal references consistent, improving code readability and maintainability.<|im_end|>1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from eval.utils import prepare_input_for_wf
4
5tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-9B")
6model = AutoModelForCausalLM.from_pretrained(
7 "TechxGenus/CursorCore-Yi-9B",
8 torch_dtype=torch.bfloat16,
9 device_map="auto"
10)
11sample = {
12 "history": [],
13 "current": {
14 "type": "code",
15 "lang": "python",
16 "code": """def quick_sort(array):
17 if len(arr) <= 1:
18 return arr
19 pivot = arr[len(arr) // 2]
20 left = [x for x in arr if x < pivot]
21 middle = [x for x in arr if x == pivot]
22 right = [x for x in arr if x > pivot]
23 return quick_sort(left) + middle + quick_sort(right)"""
24 },
25 "user": "Add Docstring."
26}
27
28prompt = tokenizer.apply_chat_template(
29 prepare_input_for_wf(sample),
30 tokenize=False,
31 chat_template="assistant-conversation",
32 add_generation_prompt=True
33)
34
35inputs = tokenizer.encode(prompt, return_tensors="pt")
36outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512, do_sample=False)
37print(tokenizer.decode(outputs[0]))1<|im_start|>system
2You are a helpful programming assistant.<|im_end|>
3<|im_start|>current
4```python
5def quick_sort(array):
6 if len(arr) <= 1:
7 return arr
8 pivot = arr[len(arr) // 2]
9 left = [x for x in arr if x < pivot]
10 middle = [x for x in arr if x == pivot]
11 right = [x for x in arr if x > pivot]
12 return quick_sort(left) + middle + quick_sort(right)
13```<|im_end|>
14<|im_start|>user
15Add Docstring.<|im_end|>
16<|im_start|>assistant
17<|next_start|>```python
18def quick_sort(array):
19 """
20 This is an implementation of the quick sort algorithm.
21 """
22 if len(arr) <= 1:
23 return arr
24 pivot = arr[len(arr) // 2]
25 left = [x for x in arr if x < pivot]
26 middle = [x for x in arr if x == pivot]
27 right = [x for x in arr if x > pivot]
28 return quick_sort(left) + middle + quick_sort(right)
29```<|next_end|><|im_end|>1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from eval.utils import prepare_input_for_lc
4
5tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-1.5B-LC")
6model = AutoModelForCausalLM.from_pretrained(
7 "TechxGenus/CursorCore-Yi-1.5B-LC",
8 torch_dtype=torch.bfloat16,
9 device_map="auto"
10)
11sample = {
12 "history": [],
13 "current": {
14 "type": "code",
15 "lang": "python",
16 "code": """def quick_sort(array):
17 if len(arr) <= 1:
18 return arr
19 pivot = arr[len(arr) // 2]
20 left = [x for x in arr if x < pivot]
21 middle = [x for x in arr if x == pivot]
22 right = [x for x in arr if x > pivot]
23 return quick_sort(left) + middle + quick_sort(right)"""
24 },
25 "user": "Add Docstring."
26}
27
28prompt = tokenizer.apply_chat_template(
29 prepare_input_for_lc(sample),
30 tokenize=False,
31 chat_template="assistant-conversation",
32 add_generation_prompt=True
33)
34
35inputs = tokenizer.encode(prompt, return_tensors="pt")
36outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512, do_sample=False)
37print(tokenizer.decode(outputs[0]))1<|im_start|>system
2You are a helpful programming assistant.<|im_end|>
3<|im_start|>current
4```python
51 def quick_sort(array):
62 if len(arr) <= 1:
73 return arr
84 pivot = arr[len(arr) // 2]
95 left = [x for x in arr if x < pivot]
106 middle = [x for x in arr if x == pivot]
117 right = [x for x in arr if x > pivot]
128 return quick_sort(left) + middle + quick_sort(right)
13```<|im_end|>
14<|im_start|>user
15Add Docstring.<|im_end|>
16<|im_start|>assistant
17<|next_start|>1,1
18```
19 '''This function will sort an array using quick sort algorithm'''
20```<|next_end|>
21To 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.
22
23The 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.
24
25Here's the plan:
261. Add a docstring at the beginning of the `quick_sort` function.
272. Ensure the docstring is clear and concise, describing the purpose of the function.
28
29This modification will improve the code's documentation without altering its functionality.<|im_end|>1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from eval.utils import prepare_input_for_sr
4
5tokenizer = AutoTokenizer.from_pretrained("TechxGenus/CursorCore-Yi-1.5B-SR")
6model = AutoModelForCausalLM.from_pretrained(
7 "TechxGenus/CursorCore-Yi-1.5B-SR",
8 torch_dtype=torch.bfloat16,
9 device_map="auto"
10)
11sample = {
12 "history": [],
13 "current": {
14 "type": "code",
15 "lang": "python",
16 "code": """def quick_sort(array):
17 if len(arr) <= 1:
18 return arr
19 pivot = arr[len(arr) // 2]
20 left = [x for x in arr if x < pivot]
21 middle = [x for x in arr if x == pivot]
22 right = [x for x in arr if x > pivot]
23 return quick_sort(left) + middle + quick_sort(right)"""
24 },
25 "user": "Add Docstring."
26}
27
28prompt = tokenizer.apply_chat_template(
29 prepare_input_for_sr(sample),
30 tokenize=False,
31 chat_template="assistant-conversation",
32 add_generation_prompt=True
33)
34
35inputs = tokenizer.encode(prompt, return_tensors="pt")
36outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512, do_sample=False)
37print(tokenizer.decode(outputs[0]))1<|im_start|>system
2You are a helpful programming assistant.<|im_end|>
3<|im_start|>current
4```python
5def quick_sort(array):
6 if len(arr) <= 1:
7 return arr
8 pivot = arr[len(arr) // 2]
9 left = [x for x in arr if x < pivot]
10 middle = [x for x in arr if x == pivot]
11 right = [x for x in arr if x > pivot]
12 return quick_sort(left) + middle + quick_sort(right)
13```<|im_end|>
14<|im_start|>user
15Add Docstring.<|im_end|>
16<|im_start|>assistant
17<|next_start|>```python
18def quick_sort(array):
19<|search_and_replace|>
20def quick_sort(array):
21 """
22 This function implements quick sort algorithm
23 """
24```<|next_end|><|im_end|>1@article{jiang2024cursorcore,
2 title = {CursorCore: Assist Programming through Aligning Anything},
3 author = {Hao Jiang and Qi Liu and Rui Li and Shengyu Ye and Shijin Wang},
4 year = {2024},
5 journal = {arXiv preprint arXiv: 2410.07002}
6}