File size: 8,547 Bytes
ee0ea1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63c2fe4
ee0ea1f
 
 
63c2fe4
 
ee0ea1f
 
63c2fe4
 
 
ee0ea1f
 
 
 
63c2fe4
ee0ea1f
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
# Selecting files

The catalog lists files; it holds none of them. To build a working set, pick pointers from the tables under `catalog/`, then download and verify the files they point to. Every pointer carries its use tags (`domains`), the kinds of task the file supports (`task_affordances`), its size bucket, its license tiers and its hashes. Every column is described in [fields.md](fields.md).

## Which table to read

- `catalog/curated/<tag>.parquet`: the default place to start. One table per use tag, with duplicates, superseded snapshots, empty files and unreachable sources removed, and only pointers whose training use is `yes` or `conditional`.
- `catalog/curated/<tag>.all-licenses.parquet`: the same, with every license tier (`no` and `unknown` included). Check the license before using a file from it.
- `catalog/starter/<tag>.parquet`: up to 10,000 pointers per tag, a balanced sample of the curated table, to try an idea before reading a whole tag.
- `catalog/<source>.parquet`: every pointer of one source, nothing removed.

Use tags (`domains`):

- `sysadmin-devops`: system administration and DevOps: configuration, logs, builds, containers, packages.
- `data-processing`: data processing and querying: tables, structured data, database exports.
- `ml-modelops`: machine learning and model operations.
- `security`: security: vulnerability records, executables, encrypted files, forensic scenarios.
- `games-puzzles`: games and puzzles.
- `office-email`: office work: email.
- `office-documents`: office work: documents.
- `office-spreadsheets`: office work: spreadsheets.
- `office-presentations`: office work: slides.
- `office-meetings`: office work: meeting records.
- `office-chat`: office work: chat logs.
- `office-tickets`: office work: tickets and bug trackers.
- `help-requests`: real help requests and Q&A, from every field.

Task types (`task_affordances`):

- `parse`: read a structured or semi-structured format.
- `convert`: convert to another format.
- `query`: filter, join or aggregate records.
- `extract`: pull text, tables or fields out of a document.
- `summarize`: summarize a long text or thread.
- `repair`: find and fix a problem (broken build, bug, dirty data).
- `build-install`: build or install software.
- `analyze-logs`: analyze log files.
- `compare-diff`: compare versions or apply a patch.
- `archive-ops`: unpack, pack or verify an archive.

## Querying with DuckDB

[DuckDB](https://duckdb.org) reads the tables straight from Hugging Face, with no download, through `hf://` paths. Load the extension once with `INSTALL httpfs; LOAD httpfs;`. The tags are list columns, so filter them with `list_contains` or `list_has_any`.

Packages to build or install, small ones first (system administration and DevOps):

```sql
SELECT source, pointer_id, uri, size_bytes, sha256
FROM 'hf://datasets/Battam/terminal-data-pointers/catalog/curated/sysadmin-devops.parquet'
WHERE list_contains(task_affordances, 'build-install') AND size_bucket IN ('<10KB', '10KB-1MB')
ORDER BY size_bytes
LIMIT 200;
```

Tables to query or clean, CSV and Parquet only, free to train on (data processing):

```sql
SELECT source, pointer_id, ext, size, uri
FROM 'hf://datasets/Battam/terminal-data-pointers/catalog/curated/data-processing.parquet'
WHERE ext IN ('csv', 'parquet') AND training_ok = 'yes'
  AND list_has_any(task_affordances, ['query', 'repair'])
LIMIT 500;
```

How the starter pack of a tag spreads over sources and file types (machine learning and model operations):

```sql
SELECT source, ext, size_bucket, count(*) AS files
FROM 'hf://datasets/Battam/terminal-data-pointers/catalog/starter/ml-modelops.parquet'
GROUP BY ALL
ORDER BY files DESC;
```

Every license tier of a tag, counted, before deciding which tiers to accept (security):

```sql
SELECT training_ok, redistribution_ok, count(*) AS files, sum(size_bytes) AS bytes
FROM 'hf://datasets/Battam/terminal-data-pointers/catalog/curated/security.all-licenses.parquet'
GROUP BY ALL
ORDER BY files DESC;
```

Chess games under 100 MB (games and puzzles):

```sql
SELECT pointer_id, uri, size, sha256
FROM 'hf://datasets/Battam/terminal-data-pointers/catalog/curated/games-puzzles.parquet'
WHERE ext = 'pgn' AND size_bucket NOT IN ('100MB-1GB', '>1GB', 'unknown')
LIMIT 50;
```

One table across all office uses, with the tag each pointer came from (office work):

```sql
SELECT regexp_extract(filename, '([a-z-]+)\.parquet$', 1) AS tag, ext, count(*) AS files
FROM read_parquet('hf://datasets/Battam/terminal-data-pointers/catalog/starter/office-*.parquet', filename = true)
GROUP BY ALL
ORDER BY tag, files DESC;
```

Short help requests, to read and summarize (help requests):

```sql
SELECT source, pointer_id, uri, domains
FROM 'hf://datasets/Battam/terminal-data-pointers/catalog/curated/help-requests.parquet'
WHERE list_contains(task_affordances, 'summarize') AND size_bucket = '<10KB'
LIMIT 100;
```

Pointers that serve two uses at once, read from one source table with nothing removed:

```sql
SELECT pointer_id, domains, task_affordances, dup_of, superseded_by_batch
FROM 'hf://datasets/Battam/terminal-data-pointers/catalog/debian-bugs.parquet'
WHERE list_contains(domains, 'sysadmin-devops') AND list_contains(domains, 'office-tickets')
  AND dup_of IS NULL
LIMIT 100;
```

Save a selection as a list of pointers to download. Keep `source`, `batch` and `pointer_id`: with `source` and `batch`, only the manifests of those batches are read.

```sql
COPY (
  SELECT source, batch, pointer_id
  FROM 'hf://datasets/Battam/terminal-data-pointers/catalog/starter/data-processing.parquet'
  WHERE ext = 'csv'
  LIMIT 100
) TO 'selection.csv' (HEADER);
```

## Downloading and verifying a selection

[fetch_selected.py](fetch_selected.py), next to this page, downloads the files of a selection and checks each one. It needs only Python 3.8 or later (and `pyarrow` to read a Parquet selection). The catalog tables do not carry everything needed to download and check every file (byte ranges, every hash); the pointers in `manifests/` do, so download the manifests of the batches in the selection too:

```bash
huggingface-cli download Battam/terminal-data-pointers --repo-type dataset \
  --include "manifests/<source>/<batch>/*" "docs/fetch_selected.py" --local-dir .
python docs/fetch_selected.py selection.csv --manifests manifests --dest files/
```

The selection is a CSV, TSV, JSON Lines or Parquet file. With `--manifests`, it needs only a `pointer_id` column, and its `source` and `batch` columns, when present, limit the manifests read to those batches. Without `--manifests`, each row must carry `uri`, `size_bytes` and `sha256` or `md5` itself, as rows of the catalog tables do; rows whose pointer has a byte range (`has_range`) then fail, because only the manifests give the range.

Each file is downloaded from `uri`, or from the addresses in `alt_uris` when `uri` fails, with only its byte range requested when the pointer has `range`. It is written under `--dest` as `<source>/<collection>/<path>` only when its size matches `size_bytes` and its content matches the `sha256` and `md5` of the pointer. Rows that fail, and pointers not found in the manifests, are listed in `failures.jsonl` with the reason; an existing file is never replaced. `--max-files` and `--max-bytes` cap a trial run. Pointers whose hashes cover something other than the downloaded bytes (`hash_scope` of `http_payload` or `api_body`) are listed as failures; checking them by hand is described in [retrieval.md](retrieval.md).

## How the curated tables and starter packs are made

- A pointer is in `catalog/curated/<tag>.parquet` when its `domains` contain the tag, `dup_of` and `superseded_by_batch` are empty, its size is not 0, its source is not `partial` in `reachable`, and `training_ok` is `yes` or `conditional`. The `.all-licenses` table drops the last condition.
- The starter pack of a tag is drawn from the curated table: its 10,000 pointers are shared equally among sources, no source taking more than 30% of them (when a tag has fewer than 4 sources, no more than an equal share, the quota divided by the number of sources, rounded up), then equally among the (file extension, size bucket) groups within each source. Within a group, pointers are taken in the order of a hash of a fixed seed and the `pointer_id`, so unchanged tables give the same pack at every rebuild. A tag with too few sources or pointers to fill the quota gets every pointer it can.
- What is removed and why, with every rule table, is in [curation.md](curation.md).