Datasets:
Size:
10K - 100K
License:
File size: 8,054 Bytes
ae62622 f64fd5e ae62622 f64fd5e 2f732a7 f64fd5e ae62622 f64fd5e ae62622 f64fd5e ae62622 f64fd5e ae62622 f64fd5e ae62622 f64fd5e ae62622 f64fd5e ae62622 f64fd5e ae62622 f64fd5e ae62622 235eb4f ae62622 f64fd5e 3289f4f 235eb4f 3289f4f f64fd5e 3289f4f 235eb4f 3289f4f f64fd5e 3289f4f 235eb4f 3289f4f f64fd5e ae62622 f64fd5e f5c1f01 f64fd5e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Dataset for the Occlusion task."""
import json
import datasets
logger = datasets.logging.get_logger(__name__)
try:
import lzma as xz
except ImportError:
import pylzma as xz
# TODO: Add final BibTeX citation
# Find for instance the citation on arxiv or on the dataset repo/website
_CITATION = """\
@misc{baumgartner_nina_occlusion_2022,
title = {From Occlusion to Transparancy – An Occlusion-Based Explainability Approach for Legal Judgment Prediction in Switzerland},
shorttitle = {From Occlusion to Transparancy},
abstract = {Natural Language Processing ({NLP}) models have been used for more and more complex tasks such as Legal Judgment Prediction ({LJP}). A {LJP} model predicts the outcome of a legal case by utilizing its facts. This increasing deployment of Artificial Intelligence ({AI}) in high-stakes domains such as law and the involvement of sensitive data has increased the need for understanding such systems. We propose a multilingual occlusion-based explainability approach for {LJP} in Switzerland and conduct a study on the bias using Lower Court Insertion ({LCI}). We evaluate our results using different explainability metrics introduced in this thesis and by comparing them to high-quality Legal Expert Annotations using Inter Annotator Agreement. Our findings show that the model has a varying understanding of the semantic meaning and context of the facts section, and struggles to distinguish between legally relevant and irrelevant sentences. We also found that the insertion of a different lower court can have an effect on the prediction, but observed no distinct effects based on legal areas, cantons, or regions. However, we did identify a language disparity with Italian performing worse than the other languages due to representation inequality in the training data, which could lead to potential biases in the prediction in multilingual regions of Switzerland. Our results highlight the challenges and limitations of using {NLP} in the judicial field and the importance of addressing concerns about fairness, transparency, and potential bias in the development and use of {NLP} systems. The use of explainable artificial intelligence ({XAI}) techniques, such as occlusion and {LCI}, can help provide insight into the decision-making processes of {NLP} systems and identify areas for improvement. Finally, we identify areas for future research and development in this field in order to address the remaining limitations and challenges.},
author = {{Baumgartner, Nina}},
year = {2022},
langid = {english}
}
"""
# You can copy an official description
_DESCRIPTION = """\
This dataset contains an implementation of occlusion for the SwissJudgmentPrediction task.
"""
_LICENSE = "cc-by-sa-4.0"
_LANGUAGES = [
"de",
"fr",
"it",
]
_URL = "https://huggingface.co/datasets/rcds/occlusion_swiss_judgment_prediction/resolve/main/data/"
_URLS = {
"test_1": _URL + "test_occ_1.jsonl",
"test_2": _URL + "test_occ_2.jsonl",
"test_3": _URL + "test_occ_3.jsonl",
"test_4": _URL + "test_occ_4.jsonl",
}
class OcclusionSwissJudgmentPredictionConfig(datasets.BuilderConfig):
"""BuilderConfig for OcclusionSwissJudgmentPrediction."""
def __init__(self, language: str, **kwargs):
"""BuilderConfig for OcclusionSwissJudgmentPrediction.
Args:
language: One of de, fr, it, or all
**kwargs: keyword arguments forwarded to super.
"""
super(OcclusionSwissJudgmentPredictionConfig, self).__init__(**kwargs)
self.language = language
class OcclusionSwissJudgmentPrediction(datasets.GeneratorBasedBuilder):
"""This dataset contains court decision for the occlusion task in swiss judgment prediction"""
VERSION = datasets.Version("1.1.0")
BUILDER_CONFIG_CLASS = OcclusionSwissJudgmentPredictionConfig
BUILDER_CONFIGS = [
OcclusionSwissJudgmentPredictionConfig(
name=lang,
language=lang,
version=datasets.Version("1.1.0", ""),
description=f"Plain text import of OcclusionSwissJudgmentPrediction for the {lang} language",
)
for lang in _LANGUAGES
] + [
OcclusionSwissJudgmentPredictionConfig(
name="all",
language="all",
version=datasets.Version("1.1.0", ""),
description="Plain text import of OcclusionSwissJudgmentPrediction for all languages",
)
]
def _info(self):
features = datasets.Features(
{
"id": datasets.Value("int32"),
"year": datasets.Value("int32"),
"label": datasets.Value("string"),
"language": datasets.Value("string"),
"region": datasets.Value("string"),
"canton": datasets.Value("string"),
"legal_area": datasets.Value("string"),
"explainability_label": datasets.Value("string"),
"occluded_text": datasets.Value("string"),
"text": datasets.Value("string")
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
supervised_keys=None,
homepage="https://github.com/ninabaumgartner/SwissCourtRulingCorpus",
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
# dl_manager is a datasets.download.DownloadManager that can be used to
# download and extract URLs
try:
dl_dir = dl_manager.download(_URLS)
except Exception:
logger.warning(
"If this download failed try a few times before reporting an issue"
)
raise
return [
datasets.SplitGenerator(
name="test_1",
# These kwargs will be passed to _generate_examples
gen_kwargs={"filepath": dl_dir["test_1"]},
),
datasets.SplitGenerator(
name="test_2",
# These kwargs will be passed to _generate_examples
gen_kwargs={"filepath": dl_dir["test_2"]},
),
datasets.SplitGenerator(
name="test_3",
# These kwargs will be passed to _generate_examples
gen_kwargs={"filepath": dl_dir["test_3"]},
),
datasets.SplitGenerator(
name="test_4",
# These kwargs will be passed to _generate_examples
gen_kwargs={"filepath": dl_dir["test_4"]},
),
]
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form."""
if self.config.language in ["all"] + _LANGUAGES:
with open(filepath, encoding="utf-8") as f:
for id_, row in enumerate(f):
data = json.loads(row)
_ = data.setdefault("language", "n/a")
if self.config.language in ["all"] or data["language"] == self.config.language:
yield id_, data
|