Huayang
commited on
Upload folder using huggingface_hub
Browse files- nlgraph.py +7 -4
- play.ipynb +64 -0
nlgraph.py
CHANGED
|
@@ -41,7 +41,7 @@ class NLGraph(datasets.GeneratorBasedBuilder):
|
|
| 41 |
"question": datasets.Value("string"),
|
| 42 |
"answer": datasets.Value("string"),
|
| 43 |
"difficulty": datasets.Value("string"),
|
| 44 |
-
"doc_id": datasets.Value("
|
| 45 |
# add more fields depending on your JSONL schema
|
| 46 |
}),
|
| 47 |
supervised_keys=None,
|
|
@@ -50,15 +50,18 @@ class NLGraph(datasets.GeneratorBasedBuilder):
|
|
| 50 |
)
|
| 51 |
|
| 52 |
def _split_generators(self, dl_manager):
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
| 54 |
return [
|
| 55 |
datasets.SplitGenerator(
|
| 56 |
name=datasets.Split.TRAIN,
|
| 57 |
-
gen_kwargs={"filepath":
|
| 58 |
),
|
| 59 |
datasets.SplitGenerator(
|
| 60 |
name=datasets.Split.TEST,
|
| 61 |
-
gen_kwargs={"filepath":
|
| 62 |
),
|
| 63 |
]
|
| 64 |
|
|
|
|
| 41 |
"question": datasets.Value("string"),
|
| 42 |
"answer": datasets.Value("string"),
|
| 43 |
"difficulty": datasets.Value("string"),
|
| 44 |
+
"doc_id": datasets.Value("int"),
|
| 45 |
# add more fields depending on your JSONL schema
|
| 46 |
}),
|
| 47 |
supervised_keys=None,
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
def _split_generators(self, dl_manager):
|
| 53 |
+
data_files = {
|
| 54 |
+
"test": dl_manager.download_and_extract(os.path.join(self.config.name, "test.jsonl")),
|
| 55 |
+
"train": dl_manager.download_and_extract(os.path.join(self.config.name, "train.jsonl")),
|
| 56 |
+
}
|
| 57 |
return [
|
| 58 |
datasets.SplitGenerator(
|
| 59 |
name=datasets.Split.TRAIN,
|
| 60 |
+
gen_kwargs={"filepath": data_files['train']},
|
| 61 |
),
|
| 62 |
datasets.SplitGenerator(
|
| 63 |
name=datasets.Split.TEST,
|
| 64 |
+
gen_kwargs={"filepath": data_files['test']},
|
| 65 |
),
|
| 66 |
]
|
| 67 |
|
play.ipynb
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 6,
|
| 6 |
+
"id": "9af628c3",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [
|
| 9 |
+
{
|
| 10 |
+
"name": "stderr",
|
| 11 |
+
"output_type": "stream",
|
| 12 |
+
"text": [
|
| 13 |
+
"Generating train split: 201 examples [00:00, 8109.65 examples/s]\n",
|
| 14 |
+
"Generating test split: 39 examples [00:00, 3546.17 examples/s]\n"
|
| 15 |
+
]
|
| 16 |
+
}
|
| 17 |
+
],
|
| 18 |
+
"source": [
|
| 19 |
+
"from datasets import load_dataset\n",
|
| 20 |
+
"\n",
|
| 21 |
+
"dataset = load_dataset(\"huayangli/nlgraph\", \"GNN\", trust_remote_code=True)"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"cell_type": "code",
|
| 26 |
+
"execution_count": 10,
|
| 27 |
+
"id": "3bd68df7",
|
| 28 |
+
"metadata": {},
|
| 29 |
+
"outputs": [
|
| 30 |
+
{
|
| 31 |
+
"name": "stdout",
|
| 32 |
+
"output_type": "stream",
|
| 33 |
+
"text": [
|
| 34 |
+
"{'question': 'Determine if there is a path between two nodes in the graph. Note that (i,j) means that node i and node j are connected with an undirected edge.\\nGraph: (0,1) (1,2) (3,4) (4,5)\\nQ: Is there a path between node 1 and node 4?\\nA: Node 1 is in the connected block consisted of node 0, node 1, and node 2.\\nNode 4 is in the connected block consisting of node 3, node 4, and node 5. Node 1 and node 4 are not in the same connected block, so the answer is no.\\n\\nDetermine if there is a path between two nodes in the graph. Note that (i,j) means that node i and node j are connected with an undirected edge.\\nGraph: (0,1) (0,2) (1,5) (1,2) (1,3) (2,5)\\nQ: Is there a path between node 2 and node 3?\\nA: Node 2 is connected to node 1, node 1 is connected to node 3. We can follow the path: 2->1->3, so the answer is yes.\\n\\nDetermine if there is a path between two nodes in the graph. Note that (i,j) means that node i and node j are connected with an undirected edge.\\nGraph: (0,2) (0,5) (0,6) (1,3) (1,4) (2,5) (2,6) (3,4) (5,6)\\nQ: Is there a path between node 5 and node 4?\\nA: Node 5 is in the connected block consisted of node 0, node 2, node 5, and node 2.\\nNode 4 is in the connected block consisting of node 1, node 3, and node 4. Node 5 and node 4 are not in the same connected block, so the answer is no.\\n\\nDetermine if there is a path between two nodes in the graph. Note that (i,j) means that node i and node j are connected with an undirected edge.\\nGraph: (0,1) (0,7) (0,6) (1,7) (1,5) (1,6) (5,9) (2,8) (2,4) (2,3) (3,8)\\nQ: Is there a path between node 7 and node 9?\\nA: Node 7 is connected to node 1, node 1 is connected to node 5, node 5 is connected to node 9.\\nWe can follow the path: 7->1->5->9, so the answer is yes.\\n\\nDetermine if there is a path between two nodes in the graph. Note that (i,j) means that node i and node j are connected with an undirected edge.\\nGraph: (0,12) (0,13) (0,2) (0,14) (0,23) (0,8) (0,1) (0,25) (0,27) (0,10) (1,29) (1,13) (1,19) (1,28) (1,23) (1,30) (1,25) (1,24) (2,12) (2,5) (2,14) (2,17) (2,23) (3,7) (3,12) (3,19) (3,23) (3,8) (3,30) (3,25) (3,24) (4,33) (5,20) (5,23) (5,30) (6,15) (6,11) (7,32) (7,17) (7,23) (7,8) (7,10) (8,29) (8,12) (8,32) (8,20) (8,19) (8,17) (8,30) (9,29) (9,28) (9,30) (9,24) (10,13) (10,20) (10,14) (10,22) (11,31) (12,13) (12,23) (12,27) (12,26) (13,29) (13,32) (13,14) (13,28) (13,30) (13,24) (14,17) (14,30) (14,22) (14,27) (15,16) (15,31) (15,33) (17,32) (17,20) (17,19) (17,27) (17,24) (17,26) (18,21) (20,28) (20,30) (20,25) (21,31) (22,32) (22,28) (22,30) (23,28) (23,25) (23,27) (24,29) (24,28) (24,26) (25,32) (26,29) (26,27) (27,32) (27,30) (28,32) (28,30)\\nQ: Is there a path between node 14 and node 2?\\nA:', 'answer': 'The answer is yes.', 'difficulty': 'hard', 'doc_id': '0'}\n"
|
| 35 |
+
]
|
| 36 |
+
}
|
| 37 |
+
],
|
| 38 |
+
"source": [
|
| 39 |
+
"print(dataset['train'][0])"
|
| 40 |
+
]
|
| 41 |
+
}
|
| 42 |
+
],
|
| 43 |
+
"metadata": {
|
| 44 |
+
"kernelspec": {
|
| 45 |
+
"display_name": "olmes",
|
| 46 |
+
"language": "python",
|
| 47 |
+
"name": "python3"
|
| 48 |
+
},
|
| 49 |
+
"language_info": {
|
| 50 |
+
"codemirror_mode": {
|
| 51 |
+
"name": "ipython",
|
| 52 |
+
"version": 3
|
| 53 |
+
},
|
| 54 |
+
"file_extension": ".py",
|
| 55 |
+
"mimetype": "text/x-python",
|
| 56 |
+
"name": "python",
|
| 57 |
+
"nbconvert_exporter": "python",
|
| 58 |
+
"pygments_lexer": "ipython3",
|
| 59 |
+
"version": "3.10.18"
|
| 60 |
+
}
|
| 61 |
+
},
|
| 62 |
+
"nbformat": 4,
|
| 63 |
+
"nbformat_minor": 5
|
| 64 |
+
}
|