|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""An extension of Umar Butler's open-australian-legal-corpus dataset to include 1024 long embeddings from OpenAI's text-embedding-3-large model""" |
|
|
|
import json |
|
import datasets |
|
|
|
|
|
_CITATION = """\ |
|
@misc{open-australian-legal-embeddings-openai, |
|
title = {Open Australian Legal Embeddings OpenAI}, |
|
author={Rob Kopel}, |
|
year={2024}, |
|
version={1.0} |
|
url={https://huggingface.co/datasets/R0bk/open-australian-legal-embeddings-openai} |
|
} |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
An extension of Umar Butler's open-australian-legal-corpus dataset to include 1024 long embeddings from OpenAI's text-embedding-3-large model. |
|
If you wish to explore or deploy in your environment it can be used with open-australian-legal-explorer on github. |
|
""" |
|
|
|
_HOMEPAGE = "https://huggingface.co/datasets/R0bk/open-australian-legal-embeddings-openai" |
|
|
|
_LICENSE = """ |
|
Please see the open-australian-legal-corpus licence [Open Australian Legal Corpus](https://huggingface.co/datasets/umarbutler/open-australian-legal-corpus/blob/main/LICENCE.md). |
|
""" |
|
|
|
_URLS = { |
|
'metadatas' : 'data/metadatas.jsonl', |
|
'texts' : 'data/texts.jsonl', |
|
'embeddings' : 'data/embeddings.jsonl', |
|
} |
|
|
|
class OpenAustralianLegalEmbeddingsOpenai(datasets.GeneratorBasedBuilder): |
|
"""An extension of Umar Butler's open-australian-legal-corpus dataset to include 1024 long embeddings from OpenAI's text-embedding-3-large model""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
DEFAULT_CONFIG_NAME = "train" |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
'version_id' : datasets.Value('string'), |
|
'type' : datasets.Value('string'), |
|
'jurisdiction' : datasets.Value('string'), |
|
'source' : datasets.Value('string'), |
|
'citation' : datasets.Value('string'), |
|
'url' : datasets.Value('string'), |
|
'is_last_chunk' : datasets.Value('bool'), |
|
'chunk_index' : datasets.Value('int'), |
|
'text' : datasets.Value('string'), |
|
'embedding' : [datasets.Value('float32')] |
|
} |
|
), |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
dl_files = dl_manager.download_and_extract(_URLS) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
'metadatas_path' : dl_files['metadatas'], |
|
'texts_path' : dl_files['texts'], |
|
'embeddings_path' : dl_files['embeddings'], |
|
} |
|
) |
|
] |
|
|
|
def _generate_examples(self, embed_path, metas_path, texts_path): |
|
with open(embed_path, 'r') as embeds, \ |
|
open(metas_path, 'r') as metas, \ |
|
open(texts_path, 'r') as texts: |
|
|
|
for key, (embed, meta, text) in enumerate(zip(embeds, metas, texts)): |
|
yield key, { |
|
**json.loads(meta), |
|
'text': json.loads(text), |
|
'embedding': json.loads(embed) |
|
} |
|
|