|
| 1 | +# coding=utf-8 |
| 2 | +# Copyright 2024 The TensorFlow Datasets Authors. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +"""Asimov datasets.""" |
| 17 | + |
| 18 | +from tensorflow_datasets.robotics import dataset_importer_builder |
| 19 | + |
| 20 | +ASIMOV_CITATION = """ |
| 21 | +@article{Sermanet2025RobotConstitutions, |
| 22 | + author = {Pierre Sermanet and Anirudha Majumdar and Alex Irpan and Dmitry Kalashnikov and Vikas Sindhwani}, |
| 23 | + title = {Generating Robot Constitutions & Benchmarks for Semantic Safety}, |
| 24 | + journal = {arXiv preprint arXiv:FIXME}, |
| 25 | + url = {https://arxiv.org/abs/FIXME}, |
| 26 | + year = {2025}, |
| 27 | +} |
| 28 | +""" |
| 29 | + |
| 30 | +ASIMOV_HOMEPAGE = 'https://asimov-benchmark.github.io/' |
| 31 | + |
| 32 | + |
| 33 | +class AsimovDilemmasAutoVal( |
| 34 | + dataset_importer_builder.TFDSDatasetImporterBuilder |
| 35 | +): |
| 36 | + """DatasetBuilder for `asimov_dilemmas_auto_val` dataset.""" |
| 37 | + |
| 38 | + def get_description(self): |
| 39 | + return ( |
| 40 | + 'Binary dilemma questions generated from counterfactual situations used' |
| 41 | + ' to auto-amend generated constitutions (validation set).' |
| 42 | + ) |
| 43 | + |
| 44 | + def get_citation(self): |
| 45 | + return ASIMOV_CITATION |
| 46 | + |
| 47 | + def get_homepage(self): |
| 48 | + return ASIMOV_HOMEPAGE |
| 49 | + |
| 50 | + def get_relative_dataset_location(self): |
| 51 | + return 'asimov_dilemmas_auto_val/0.1.0' |
| 52 | + |
| 53 | + |
| 54 | +class AsimovDilemmasScifiTrain( |
| 55 | + dataset_importer_builder.TFDSDatasetImporterBuilder |
| 56 | +): |
| 57 | + """DatasetBuilder for `asimov_dilemmas_scifi_train` dataset.""" |
| 58 | + |
| 59 | + def get_description(self): |
| 60 | + return ( |
| 61 | + 'Multiple-choice ethical questions (with desirable and undesirable' |
| 62 | + ' answers) based on situations inspired from Science Fiction literature' |
| 63 | + ' (training set).' |
| 64 | + ) |
| 65 | + |
| 66 | + def get_citation(self): |
| 67 | + return ASIMOV_CITATION |
| 68 | + |
| 69 | + def get_homepage(self): |
| 70 | + return ASIMOV_HOMEPAGE |
| 71 | + |
| 72 | + def get_relative_dataset_location(self): |
| 73 | + return 'asimov_dilemmas_scifi_train/0.1.0' |
| 74 | + |
| 75 | + |
| 76 | +class AsimovDilemmasScifiVal( |
| 77 | + dataset_importer_builder.TFDSDatasetImporterBuilder |
| 78 | +): |
| 79 | + """DatasetBuilder for `asimov_dilemmas_scifi_val` dataset.""" |
| 80 | + |
| 81 | + def get_description(self): |
| 82 | + return ( |
| 83 | + 'Multiple-choice ethical questions (with desirable and undesirable' |
| 84 | + ' answers) based on situations inspired from Science Fiction literature' |
| 85 | + ' (validation set).' |
| 86 | + ) |
| 87 | + |
| 88 | + def get_citation(self): |
| 89 | + return ASIMOV_CITATION |
| 90 | + |
| 91 | + def get_homepage(self): |
| 92 | + return ASIMOV_HOMEPAGE |
| 93 | + |
| 94 | + def get_relative_dataset_location(self): |
| 95 | + return 'asimov_dilemmas_scifi_val/0.1.0' |
| 96 | + |
| 97 | + |
| 98 | +class AsimovInjuryVal(dataset_importer_builder.TFDSDatasetImporterBuilder): |
| 99 | + """DatasetBuilder for `asimov_injury_val` dataset.""" |
| 100 | + |
| 101 | + def get_description(self): |
| 102 | + return ( |
| 103 | + 'Situations generated from real hospital injury reports (validation' |
| 104 | + ' set).' |
| 105 | + ) |
| 106 | + |
| 107 | + def get_citation(self): |
| 108 | + return ASIMOV_CITATION |
| 109 | + |
| 110 | + def get_homepage(self): |
| 111 | + return ASIMOV_HOMEPAGE |
| 112 | + |
| 113 | + def get_relative_dataset_location(self): |
| 114 | + return 'asimov_injury_val/0.1.0' |
| 115 | + |
| 116 | + |
| 117 | +class AsimovMultimodalAutoVal( |
| 118 | + dataset_importer_builder.TFDSDatasetImporterBuilder |
| 119 | +): |
| 120 | + """DatasetBuilder for `asimov_multimodal_auto_val` dataset.""" |
| 121 | + |
| 122 | + def get_description(self): |
| 123 | + return ( |
| 124 | + '(Image, context, instruction) triplets generated from real images' |
| 125 | + ' (from RoboVQA dataset) which are modified to contain undesirable' |
| 126 | + ' elements, generated instructions can be desirable or undesirable' |
| 127 | + ' (validation set).' |
| 128 | + ) |
| 129 | + |
| 130 | + def get_citation(self): |
| 131 | + return ASIMOV_CITATION |
| 132 | + |
| 133 | + def get_homepage(self): |
| 134 | + return ASIMOV_HOMEPAGE |
| 135 | + |
| 136 | + def get_relative_dataset_location(self): |
| 137 | + return 'asimov_multimodal_auto_val/0.1.0' |
| 138 | + |
| 139 | + |
| 140 | +class AsimovMultimodalManualVal( |
| 141 | + dataset_importer_builder.TFDSDatasetImporterBuilder |
| 142 | +): |
| 143 | + """DatasetBuilder for `asimov_multimodal_manual_val` dataset.""" |
| 144 | + |
| 145 | + def get_description(self): |
| 146 | + return ( |
| 147 | + '(Image, context, instruction) triplets manually taken and written by' |
| 148 | + ' humans while ensuring that the instruction desirability can only be' |
| 149 | + ' determined by looking at the image (validation set)' |
| 150 | + ) |
| 151 | + |
| 152 | + def get_citation(self): |
| 153 | + return ASIMOV_CITATION |
| 154 | + |
| 155 | + def get_homepage(self): |
| 156 | + return ASIMOV_HOMEPAGE |
| 157 | + |
| 158 | + def get_relative_dataset_location(self): |
| 159 | + return 'asimov_multimodal_manual_val/0.1.0' |
0 commit comments