skilledu/chatgpt4-code-instruct
收藏资源简介:
ChatGPT4 Code Instruct是一个对话式数据集,专注于代码指令任务。它源自evol-codealpaca-v1数据集,经过翻译并使用ChatGPT4处理生成。数据集包含43482行数据,大小为274 MB,主要语言为马来语(ms),但也提供英语和其他语言版本。数据示例展示了如何通过指令修正Python代码中的错误(如将for循环改为while循环并修复越界bug),并确保正确处理空列表。该数据集旨在支持代码生成、修正和多语言对话任务,适用于训练和评估AI模型在编程辅助方面的能力。
### 数据集元信息 任务类别:会话式(conversational) 语言:马来语(Malay) # ChatGPT4 代码指令数据集(ChatGPT4 Code Instruct) 本数据集初始源自 https://huggingface.co/datasets/theblackcat102/evol-codealpaca-v1,由ChatGPT4处理生成。 相关配套Jupyter笔记本可访问:https://github.com/mesolitica/malaysian-dataset/tree/master/chatbot/chatgpt4-code-instruct 数据集文件为 `synthetic-codealpaca-v1-chatgpt4.jsonl`,共计43482条记录,总大小274 MB。 ## 示例数据 python {"instruction": "请将以下Python脚本中的现有`for`循环替换为`while`循环,使其遍历整数列表中的元素。 当前脚本存在一处Bug:尝试打印超出列表边界的对象。请修复该错误,并将循环替换为`while`循环,同时确保脚本能够正确处理空列表。 python # 定义整数列表 arr = [1, 2, 3, 4] # 获取列表长度 n = len(arr) # 遍历列表并输出每个元素 for i in range(n+1): print(arr[i]) ", "output": "为修改该脚本,我们将使用`while`循环的逻辑,并确保索引不会超出列表长度范围,同时正确处理空列表的情况。 修改后的脚本如下: python # 定义整数列表 arr = [1, 2, 3, 4] # 获取列表长度 n = len(arr) # 先判断列表是否非空 if n > 0: i = 0 # 遍历列表并输出每个元素 while i < n: print(arr[i]) i += 1 else: print("列表为空。") 在该脚本中,循环开始前我们先检查列表长度`n`是否大于0。若不满足(即列表为空),则打印对应提示信息。 随后使用`while`循环,当索引`i`小于列表长度`n`时执行循环体。每次迭代中,打印当前列表元素并将索引加1,以此遍历所有列表元素。 该方案可避免索引越界错误,因为我们不会尝试访问超出列表边界的索引。", "instruction_en": "Please amend the subsequent Python script so that it includes a 'while' loop rather than the existing 'for' loop, which iterates through the items of an integer list. The script currently has a bug where it attempts to print an object that is outside the bounds of the list. Fix this error and modify the script to use 'while' instead of 'for' loop. Ensure your script correctly handles empty lists. python # Establish an integer list arr = [1, 2, 3, 4] # Determine the length of the list n = len(arr) # Traverse the list and output each individual element for i in range(n+1): print(arr[i]) ", "indon_ins": false, "indon_output": true, "rejected_ins": false, "rejected_output": false, "instruction_ms": "请将以下Python脚本中的现有`for`循环替换为`while`循环,使其遍历整数列表中的元素。 当前脚本存在一处Bug:尝试打印超出列表边界的对象。请修复该错误,并将循环替换为`while`循环,同时确保脚本能够正确处理空列表。 python # 定义整数列表 arr = [1, 2, 3, 4] # 获取列表长度 n = len(arr) # 遍历列表并输出每个元素 for i in range(n+1): print(arr[i]) ", "output_ms": "为修改该脚本,我们将使用`while`循环的逻辑,并确保索引不会超出列表长度范围,同时正确处理空列表的情况。 修改后的脚本如下: python # 定义整数列表 arr = [1, 2, 3, 4] # 获取列表长度 n = len(arr) # 先判断列表是否非空 if n > 0: i = 0 # 遍历列表并输出每个元素 while i < n: print(arr[i]) i += 1 else: print("列表为空。") 在该脚本中,循环开始前我们先检查列表长度`n`是否大于0。若不满足(即列表为空),则打印对应提示信息。 随后使用`while`循环,当索引`i`小于列表长度`n`时执行循环体。每次迭代中,打印当前列表元素并将索引加1,以此遍历所有列表元素。 该方案可避免索引越界错误,因为我们不会尝试访问超出列表边界的索引。"}




