wikipunk commited on
Commit
25a3f03
1 Parent(s): 52d5f6c
Files changed (4) hide show
  1. INFO.md +99 -0
  2. README.md +12 -99
  3. requirements.txt +1 -0
  4. yago-4.5-en.py +5 -3
INFO.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # YAGO 4.5 Dataset (English subset for LLM fine-tuning)
2
+
3
+ ## Dataset Description
4
+ This datasets contains triples filtered from yago-facts.ttl and
5
+ yago-beyond-wikipedia.ttl in the YAGO 4.5 dataset. The SPARQL query
6
+ used to filter the triples is in `raw/filter.sparql`. This represents
7
+ a subset of the YAGO 4.5 dataset maintaining only English labels.
8
+
9
+ I remapped some schema.org URIs to use the
10
+ `http://yago-knowledge.org/resource/` which were not present in the
11
+ schema.org vocabulary. I also removed schema:sameAs and owl:sameAs
12
+ relations from this dataset, as well as triples with xsd:anyURI object
13
+ literals, as my goal is to use this dataset for fine-tuning a large
14
+ language model for knowledge graph completion and I do not want
15
+ to train the base model to predict these kind of relations.
16
+
17
+ ### Overview
18
+
19
+ YAGO 4.5 is the latest version of the YAGO knowledge base. It is
20
+ based on Wikidata — the largest public general-purpose knowledge
21
+ base. YAGO refines the data as follows:
22
+
23
+ * All entity identifiers and property identifiers are human-readable.
24
+ * The top-level classes come from schema.org — a standard repertoire
25
+ of classes and properties maintained by Google and others. The lower
26
+ level classes are a careful selection of the Wikidata taxonomy.
27
+ * The properties come from schema.org.
28
+ * YAGO 4.5 contains semantic constraints in the form of SHACL. These
29
+ constraints keep the data clean, and allow for logical reasoning on
30
+ YAGO.
31
+
32
+
33
+ ### Dataset Structure
34
+ The dataset is structured as follows:
35
+
36
+ - **raw/yago-taxonomy.ttl:** Contains the `rdfs:subClassOf` relations
37
+ for YAGO and the prefix mappings for the N-Triples.
38
+ - **raw/facts.tar.gz:** Compressed file containing chunks of the
39
+ dataset in N-Triples format, representing the factual knowledge in
40
+ YAGO.
41
+
42
+ ### Features
43
+
44
+ Each RDF triple in the dataset is represented with the following features:
45
+
46
+ - **subject:** The subject of the triple, representing the entity.
47
+ - **predicate:** The predicate of the triple, representing the
48
+ relationship between the subject and object.
49
+ - **object:** The object of the triple, representing the entity or
50
+ value linked by the predicate.
51
+
52
+ ### Splits
53
+
54
+ The dataset is logically divided into multiple chunks, each containing
55
+ a subset of RDF triples. Users can load specific chunks or the entire
56
+ dataset based on their requirements.
57
+
58
+ ## Usage
59
+
60
+ ### Loading the Dataset
61
+
62
+ The dataset can be loaded using the Hugging Face `datasets` library as follows:
63
+
64
+ ```python
65
+ from datasets import load_dataset
66
+
67
+ dataset = load_dataset('wikipunk/yago-4.5-en', num_proc=4)
68
+ ```
69
+
70
+ ### Accessing the YAGO Taxonomy File
71
+
72
+ The `yago-taxonomy.ttl` file can be accessed and loaded in every process as follows:
73
+
74
+ ```python
75
+ from rdflib import Graph
76
+
77
+ taxonomy_graph = Graph()
78
+ taxonomy_graph.parse('raw/yago-taxonomy.ttl', format='turtle')
79
+ ```
80
+
81
+ ## Additional Information
82
+
83
+ ### Licensing
84
+
85
+ The YAGO 4.5 dataset is available under the [Creative Commons Attribution-ShareAlike 3.0 license](https://creativecommons.org/licenses/by-sa/3.0/).
86
+
87
+ ### Citation
88
+
89
+ If you use the YAGO 4.5 dataset in your work, please cite the
90
+ following publication:
91
+
92
+ ```bibtex
93
+ @article{suchanek2023integrating,
94
+ title={Integrating the Wikidata Taxonomy into YAGO},
95
+ author={Suchanek, Fabian M and Alam, Mehwish and Bonald, Thomas and Paris, Pierre-Henri and Soria, Jules},
96
+ journal={arXiv preprint arXiv:2308.11884},
97
+ year={2023}
98
+ }
99
+ ```
README.md CHANGED
@@ -1,99 +1,12 @@
1
- # YAGO 4.5 Dataset (English subset for LLM fine-tuning)
2
-
3
- ## Dataset Description
4
- This datasets contains triples filtered from yago-facts.ttl and
5
- yago-beyond-wikipedia.ttl in the YAGO 4.5 dataset. The SPARQL query
6
- used to filter the triples is in `raw/filter.sparql`. This represents
7
- a subset of the YAGO 4.5 dataset maintaining only English labels.
8
-
9
- I remapped some schema.org URIs to use the
10
- `http://yago-knowledge.org/resource/` which were not present in the
11
- schema.org vocabulary. I also removed schema:sameAs and owl:sameAs
12
- relations from this dataset, as well as triples with xsd:anyURI object
13
- literals, as my goal is to use this dataset for fine-tuning a large
14
- language model for knowledge graph completion and I do not want
15
- to train the base model to predict these kind of relations.
16
-
17
- ### Overview
18
-
19
- YAGO 4.5 is the latest version of the YAGO knowledge base. It is
20
- based on Wikidata — the largest public general-purpose knowledge
21
- base. YAGO refines the data as follows:
22
-
23
- * All entity identifiers and property identifiers are human-readable.
24
- * The top-level classes come from schema.org — a standard repertoire
25
- of classes and properties maintained by Google and others. The lower
26
- level classes are a careful selection of the Wikidata taxonomy.
27
- * The properties come from schema.org.
28
- * YAGO 4.5 contains semantic constraints in the form of SHACL. These
29
- constraints keep the data clean, and allow for logical reasoning on
30
- YAGO.
31
-
32
-
33
- ### Dataset Structure
34
- The dataset is structured as follows:
35
-
36
- - **raw/yago-taxonomy.ttl:** Contains the `rdfs:subClassOf` relations
37
- for YAGO and the prefix mappings for the N-Triples.
38
- - **raw/facts.tar.gz:** Compressed file containing chunks of the
39
- dataset in N-Triples format, representing the factual knowledge in
40
- YAGO.
41
-
42
- ### Features
43
-
44
- Each RDF triple in the dataset is represented with the following features:
45
-
46
- - **subject:** The subject of the triple, representing the entity.
47
- - **predicate:** The predicate of the triple, representing the
48
- relationship between the subject and object.
49
- - **object:** The object of the triple, representing the entity or
50
- value linked by the predicate.
51
-
52
- ### Splits
53
-
54
- The dataset is logically divided into multiple chunks, each containing
55
- a subset of RDF triples. Users can load specific chunks or the entire
56
- dataset based on their requirements.
57
-
58
- ## Usage
59
-
60
- ### Loading the Dataset
61
-
62
- The dataset can be loaded using the Hugging Face `datasets` library as follows:
63
-
64
- ```python
65
- from datasets import load_dataset
66
-
67
- dataset = load_dataset('wikipunk/yago-4.5-en', num_proc=4)
68
- ```
69
-
70
- ### Accessing the YAGO Taxonomy File
71
-
72
- The `yago-taxonomy.ttl` file can be accessed and loaded in every process as follows:
73
-
74
- ```python
75
- from rdflib import Graph
76
-
77
- taxonomy_graph = Graph()
78
- taxonomy_graph.parse('raw/yago-taxonomy.ttl', format='turtle')
79
- ```
80
-
81
- ## Additional Information
82
-
83
- ### Licensing
84
-
85
- The YAGO 4.5 dataset is available under the [Creative Commons Attribution-ShareAlike 3.0 license](https://creativecommons.org/licenses/by-sa/3.0/).
86
-
87
- ### Citation
88
-
89
- If you use the YAGO 4.5 dataset in your work, please cite the
90
- following publication:
91
-
92
- ```bibtex
93
- @article{suchanek2023integrating,
94
- title={Integrating the Wikidata Taxonomy into YAGO},
95
- author={Suchanek, Fabian M and Alam, Mehwish and Bonald, Thomas and Paris, Pierre-Henri and Soria, Jules},
96
- journal={arXiv preprint arXiv:2308.11884},
97
- year={2023}
98
- }
99
- ```
 
1
+ ---
2
+ dataset_info:
3
+ features:
4
+ - name: text
5
+ dtype: string
6
+ splits:
7
+ - name: train
8
+ num_bytes: 17
9
+ num_examples: 1
10
+ download_size: 14
11
+ dataset_size: 17
12
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ rdflib>=6.0.0
yago-4.5-en.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
  from datasets import DatasetBuilder, SplitGenerator, DownloadConfig, load_dataset, DownloadManager
3
  from rdflib import Graph, URIRef, Literal, BNode
4
- from rdflib.namespace import RDF, RDFS, OWL, XSD, Namespace
5
 
6
  SCHEMA = Namespace('http://schema.org/')
7
 
@@ -10,7 +10,7 @@ YAGO = Namespace('http://yago-knowledge.org/resource/')
10
  class YAGO45DatasetBuilder(DatasetBuilder):
11
  VERSION = "1.0.0"
12
 
13
- taxonomy = Graph()
14
 
15
  def _info(self):
16
  # Define dataset metadata and features
@@ -47,7 +47,7 @@ class YAGO45DatasetBuilder(DatasetBuilder):
47
  # Load the chunks into an rdflib graph
48
  # Yield individual triples from the graph
49
  for chunk_path in chunk_paths:
50
- graph = Graph()
51
  for prefix, namespace in prefix_mappings.items():
52
  graph.bind(prefix, namespace)
53
  graph.parse(chunk_path, format='nt')
@@ -59,3 +59,5 @@ class YAGO45DatasetBuilder(DatasetBuilder):
59
  'predicate': str(predicate),
60
  'object': str(object_)
61
  }
 
 
 
1
  import os
2
  from datasets import DatasetBuilder, SplitGenerator, DownloadConfig, load_dataset, DownloadManager
3
  from rdflib import Graph, URIRef, Literal, BNode
4
+ from rdflib.namespace import RDF, RDFS, OWL, XSD, Namespace, NamespaceManager
5
 
6
  SCHEMA = Namespace('http://schema.org/')
7
 
 
10
  class YAGO45DatasetBuilder(DatasetBuilder):
11
  VERSION = "1.0.0"
12
 
13
+ taxonomy = Graph(bind_namespaces="core")
14
 
15
  def _info(self):
16
  # Define dataset metadata and features
 
47
  # Load the chunks into an rdflib graph
48
  # Yield individual triples from the graph
49
  for chunk_path in chunk_paths:
50
+ graph = Graph(bind_namespaces="core")
51
  for prefix, namespace in prefix_mappings.items():
52
  graph.bind(prefix, namespace)
53
  graph.parse(chunk_path, format='nt')
 
59
  'predicate': str(predicate),
60
  'object': str(object_)
61
  }
62
+
63
+