The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
Error code: DatasetGenerationError Exception: ArrowNotImplementedError Message: Cannot write struct type '_format_kwargs' with no child field to Parquet. Consider adding a dummy child field. Traceback: Traceback (most recent call last): File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2011, in _prepare_split_single writer.write_table(table) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 583, in write_table self._build_writer(inferred_schema=pa_table.schema) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 404, in _build_writer self.pa_writer = self._WRITER_CLASS(self.stream, schema) File "/src/services/worker/.venv/lib/python3.9/site-packages/pyarrow/parquet/core.py", line 1010, in __init__ self.writer = _parquet.ParquetWriter( File "pyarrow/_parquet.pyx", line 2157, in pyarrow._parquet.ParquetWriter.__cinit__ File "pyarrow/error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status File "pyarrow/error.pxi", line 91, in pyarrow.lib.check_status pyarrow.lib.ArrowNotImplementedError: Cannot write struct type '_format_kwargs' with no child field to Parquet. Consider adding a dummy child field. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2027, in _prepare_split_single num_examples, num_bytes = writer.finalize() File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 602, in finalize self._build_writer(self.schema) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 404, in _build_writer self.pa_writer = self._WRITER_CLASS(self.stream, schema) File "/src/services/worker/.venv/lib/python3.9/site-packages/pyarrow/parquet/core.py", line 1010, in __init__ self.writer = _parquet.ParquetWriter( File "pyarrow/_parquet.pyx", line 2157, in pyarrow._parquet.ParquetWriter.__cinit__ File "pyarrow/error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status File "pyarrow/error.pxi", line 91, in pyarrow.lib.check_status pyarrow.lib.ArrowNotImplementedError: Cannot write struct type '_format_kwargs' with no child field to Parquet. Consider adding a dummy child field. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1529, in compute_config_parquet_and_info_response parquet_operations = convert_to_parquet(builder) File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1154, in convert_to_parquet builder.download_and_prepare( File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1027, in download_and_prepare self._download_and_prepare( File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1122, in _download_and_prepare self._prepare_split(split_generator, **prepare_split_kwargs) File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1882, in _prepare_split for job_id, done, content in self._prepare_split_single( File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2038, in _prepare_split_single raise DatasetGenerationError("An error occurred while generating the dataset") from e datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
_data_files
list | _fingerprint
string | _format_columns
null | _format_kwargs
dict | _format_type
null | _output_all_columns
bool | _split
string |
---|---|---|---|---|---|---|
[
{
"filename": "data-00000-of-00001.arrow"
}
] | 3f12ee7def04b7e4 | null | {} | null | false | train |
Data for LLM ASCII Art
This repo contains open-sourced SFT data for fine-tuning LLMs on ASCII Art Generation.
Dataset Links
Link | Language | Size |
---|---|---|
ascii_art_generation_140k | English | 138,941 |
ascii_art_generation_140k_bilingual | Chinese & English | 138,941 |
Data Preparation
Training data description
The training data consists of 138,941 ASCII arts instruction-response samples for LLMs to perform SFT.
The source images of these samples are either from LAION-COCO-NLLB (majority) or from Imagenet-Sketch.
Data Processing
- 1) ASCII Art Conversion from Image: All images are simply converted to ASCII art by ascii-image-converter through the following command:
ascii-image-converter path/to/image -m " .+#@/()" -H 20 --negative
- 2) Blank Space Cropping: Crop horizontal and vertical blank spaces to remove redundant space tokens. See the example below:
# Illustration of raw ascii art output
# by ascii-image-converter
# ============== Top corner =========================
\n
\n
. .#. \n
++ .. +++++........ \n
+#+. .##+++++++++.............. \n
.++##########++++......++...++++.. \n
+##.+##++#++++...+++.++..... \n
+. ++ .#+. .+.. \n
\n
\n
\n
# ============== Bottom corner ======================
# After Blank Space Cropping
# ============== Top corner =========================
. .#.\n
++ .. +++++........\n
+#+. .##+++++++++..............\n
.++##########++++......++...++++..\n
+##.+##++#++++...+++.++.....\n
+. ++ .#+. .+..\n
# ============== Bottom corner ======================
- 3) Instruction-Response Sample Format: We use a simple prompt template to format our training sample:
# template user instruction
Draw {caption} in ASCII art{instruction}
# template for assistant response
\```
{ascii_txt}
\```
A real training sample:
{
"id": "6d8c10c8-df57-461d-8a88-2fe74f578f6f",
"conversations": [
{
"role": "user",
"content": "Draw The legs and heels are wearing orange shoes. in ASCII art in small size"
},
{
"role": "assistant",
"content": "```\n ......... .. ...\n ........ ... ...\n ........ ... ...\n ........ ... ..\n ....... ... ...\n ...... ... ...\n ...... ... ...\n ...... .......\n ....... ......\n ....+.+#. .......\n .......###..... ...+.\n ......##@@........+##.\n .....#@###... ....####\n .....@@+ .+.. ...+###.\n .+. .#@. .... . .##+++\n.++######@#. .... .##. .+\n++##++##++...++++...+##. .+\n +##@#########. .\n ............\n```"
}
],
"meta": {
"width": 29,
"height": 19
}
}
# Visualization of the above sample
Instruction: Draw The legs and heels are wearing orange shoes. in ASCII art in small size
Response:
......... .. ...
........ ... ...
........ ... ...
........ ... ..
....... ... ...
...... ... ...
...... ... ...
...... .......
....... ......
....+.+#. .......
.......###..... ...+.
......##@@........+##.
.....#@###... ....####
.....@@+ .+.. ...+###.
.+. .#@. .... . .##+++
.++######@#. .... .##. .+
++##++##++...++++...+##. .+
+##@#########. .
............
Data Filtering
Not all processed ascii arts are of high quality. Here are several attempts to filter low-quality samples (~85% data samples are filtered, resulting our current training dataset).
- 1) Density: Defined as 1 - the ratio of non-space character in all characters. We only keep samples with proper density (0.3 < density < 0.6)
"""bad case to be filtered
@@@@@@@@///(/@#+......+#@((///////
///////////(@. .++++. ..#((///////
(((////////(# .@@.## #((///////
(((////////(@+. .... ..#((///////
///////////(/@@#+++.+##@/((///////
//////((/////(((((((((((((///////(
(//((//((//(((((//((((//(/((((((((
(((((/@((//((((((/(((((((((@((((((
(((((((((((((((#@(((/((((((@/+/(((
(((((///(((((((##(((((((((((/@/(((
"""
def calculate_density(ascii_text):
space_cnt = 0
max_characters_per_line = max(len(l) for l in ascii_text.split("\n"))
n_lines = len(ascii_text.split("\n"))
for l in ascii_text.split("\n"):
for i, c in enumerate(l):
if c == " ":
space_cnt += 1
space_cnt += (max_characters_per_line - len(l))
return 1 - space_cnt / (max_characters_per_line * n_lines)
- 2) Diversity: Defined as 1 - the ratio of dot characters among all non-space characters. We filter samples of low diversity.
"""bad case to be filtered
.+. .. ... .. .++ .+ +.
.+.+... .. .. . . . . .
.... .. ... .. .+ .. . .
..... .+ ... .. + .. . .
.... .. ... . + .. . .
.... .. .+. . .. .. . .
..... .. ... .. .. .. . .
... .. ... .. .. .. . .
...... .++ .+. .. .+ +. . .
"""
def calculate_diversity(ascii_text):
dot_cnt, non_space_cnt = 0, 0
for c in ascii_text:
if c == ".":
dot_cnt += 1
if c != " ":
non_space_cnt += 1
return 1 - dot_cnt / non_space_cnt
- 3) No Isolation: We filter samples having isolated lines (all blank space for previous 3 lines)
"""bad case to be filtered
....
.... .. .
..+++++++........ .
..+++++++........ .
...++++++.... . .
...++++.+... .
. ........... .
. . ....... .
...++........ .
................ .
.++++ .. ..
+############.
#/@@@@@@@@@@@+
"""
def check_isolation(ascii_text):
lines = ascii_text.split("\n")
for i, l in enumerate(lines):
has_character = False
for c in l:
if c != " ":
has_character = True
break
if has_character and i > 3:
# check whether there's prev and after 2 lines
isolation_from_previous = True
for prev_i in range(max(0, i-3), i):
if not all(c == " " for c in lines[prev_i]):
isolation_from_previous = False
break
if isolation_from_previous:
return True
return False
Bilingual Version
Apart from the English dataset, we add a Chinese-English bilingual version dataset, where 50% of the image captions are changed to Chinese (thanks to the translations from laion-coco-nllb).
{'zh': 69777, 'en': 69164}
Note that the total number of training samples are always 138,941.
Limitations
- Color: Current implementation only supports black and white ascii art generation (Although there're inevitably color descriptions in training samples, we have no choice but ignore them for now.). Adding additional prediction head for RGB colors could be worth trying. You can find colored ascii art examples in ascii-image-converter.
- Downloads last month
- 50