ShwStone commited on
Commit
8629262
·
verified ·
1 Parent(s): dcac981

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +49 -33
README.md CHANGED
@@ -1,52 +1,68 @@
1
- # humaneval-leetcode
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- 本项目用于生成并上传 HumanEval 风格的 LeetCode 数据集。
4
 
5
- ## 上传到 Hugging Face
6
 
7
- ### 1) 安装依赖
8
 
9
- 需要 `huggingface_hub`
10
 
11
- ```bash
12
- pip install huggingface_hub
13
- ```
14
 
15
- ### 2) 登录(任选其一)
16
 
17
- - 环境变量:
 
18
 
19
- ```bash
20
- export HF_TOKEN=your_hf_token
21
- ```
22
 
23
- - 或使用 CLI 登录:
 
 
 
 
 
24
 
25
- ```bash
26
- huggingface-cli login
27
- ```
28
 
29
- ### 3) 运行上传脚本
 
30
 
31
- 假设你的数据在根目录,并且文件命名为 `train.jsonl` / `test.jsonl`:
32
 
33
- ```bash
34
- python scripts/upload_to_hf_dataset.py \
35
- --repo-id your-username/your-dataset \
36
- --data-dir .
37
- ```
38
 
39
- 如果你的文件名不同,可以用 `--patterns` 指定:
 
40
 
41
- ```bash
42
- python scripts/upload_to_hf_dataset.py \
43
- --repo-id your-username/your-dataset \
44
- --data-dir . \
45
- --patterns train.jsonl test.jsonl
46
  ```
47
 
48
- ### 自动识别说明
 
 
49
 
50
- Hugging Face 会自动识别 JSONL/CSV/Parquet 等常见格式,并根据文件名(如 `train.jsonl`、`test.jsonl`)自动划分 splits。
51
 
52
- 需更复杂的加载逻辑需提供自定义 dataset script
 
1
+ ---
2
+ language:
3
+ - en
4
+ - zh
5
+ license: mit
6
+ size_categories:
7
+ - 1K<n<10K
8
+ pretty_name: HumanEval-LeetCode Input-Only
9
+ configs:
10
+ - config_name: default
11
+ data_files:
12
+ - split: train
13
+ path: "train.jsonl"
14
+ - split: test
15
+ path: "test.jsonl"
16
+ ---
17
 
18
+ # HumanEval-LeetCode Input-Only
19
 
20
+ 本数据集由 LeetCode 题目自动转换而来,目标是生成 HumanEval 风格的 **Input-Only** 提示(prompt)。每条样本包含题目描述与函数签名,描述中的 Input/Output 被转换成 `>>> func(...)` / `>>> output` 的交互式示例,便于直接用于代码生成评测或训练。
21
 
22
+ ## 数据格式
23
 
24
+ 每行是一个 JSON 对象(JSONL)
25
 
26
+ - `task_id`:题目唯一标识
27
+ - `prompt`:包含函数签名与 docstring 的完整提示
 
28
 
29
+ 示例字段:
30
 
31
+ - `task_id`: string
32
+ - `prompt`: string
33
 
34
+ ## 生成流程(概述)
 
 
35
 
36
+ 1. 读取 LeetCode 题目(题目描述 + starter code)。
37
+ 2. 提取函数名。
38
+ 3. 将题目描述中的 Input/Output 转为:
39
+ - `>>> func(inputs...)`
40
+ - `>>> output`
41
+ 4. 输出为 JSONL。
42
 
43
+ ## 数据划分
 
 
44
 
45
+ - `train.jsonl`
46
+ - `test.jsonl`
47
 
48
+ ## 使用方式
49
 
50
+ Python 读取示例:
 
 
 
 
51
 
52
+ ```python
53
+ import json
54
 
55
+ with open("train.jsonl", "r", encoding="utf-8") as f:
56
+ for line in f:
57
+ item = json.loads(line)
58
+ print(item["task_id"], item["prompt"][:80])
59
+ break
60
  ```
61
 
62
+ ## 许可协议
63
+
64
+ MIT
65
 
66
+ ## 引用
67
 
68
+ 果使用该数据集请注明来源或引用本项目