Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: odc-by
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
---
|
6 |
+
|
7 |
+
# DuckDB datasets for `id` querying on FineWeb
|
8 |
+
|
9 |
+
This repo contains DuckDB databases to check whether a given WARC UID exists in a FineWeb dump. Usage example
|
10 |
+
is given below, but note especially that if you are using URNs (likely, if you are working with CommonCrawl data),
|
11 |
+
then you first have to extract the UID (the `id` column is of type `UUID` in the databases).
|
12 |
+
|
13 |
+
|
14 |
+
## Download
|
15 |
+
|
16 |
+
All files:
|
17 |
+
|
18 |
+
```shell
|
19 |
+
huggingface-cli download BramVanroy/fineweb-duckdbs --local-dir duckdbs/fineweb/ --include *.duckdb --repo-type dataset
|
20 |
+
```
|
21 |
+
|
22 |
+
One file:
|
23 |
+
|
24 |
+
```shell
|
25 |
+
huggingface-cli download BramVanroy/fineweb-duckdbs fw-CC-MAIN-2024-51.duckdb --local-dir duckdbs/fineweb/ --repo-type dataset
|
26 |
+
```
|
27 |
+
|
28 |
+
|
29 |
+
## Usage
|
30 |
+
|
31 |
+
Originally developed to be used with a library to look for Creative Commons licensing information: https://github.com/BramVanroy/CommonCrawl-CreativeCommons/
|
32 |
+
|
33 |
+
```python
|
34 |
+
import re
|
35 |
+
import duckdb
|
36 |
+
|
37 |
+
|
38 |
+
uid_re = re.compile(r"<urn:uuid:([a-zA-Z0-9]{8}-?[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{12})>")
|
39 |
+
|
40 |
+
duckdb_path = "duckdbs/fineweb/fw-CC-MAIN-2019-30.duckdb"
|
41 |
+
con = duckdb.connect(duckdb_path, read_only=True)
|
42 |
+
|
43 |
+
uuid_urn = "<urn:uuid:93081b76-bc46-4d2f-98f0-2d9687b80967>"
|
44 |
+
# !! Important: extract the UUID from the URN
|
45 |
+
uid = uid_re.sub("\\1", uuid_urn).replace("-", "")
|
46 |
+
|
47 |
+
query = "SELECT EXISTS (SELECT 1 FROM data WHERE id = ?)"
|
48 |
+
exists = bool(con.execute(query, uid).fetchone()[0])
|
49 |
+
|
50 |
+
print(f"Does ID {uid} exist? {exists}")
|
51 |
+
# Does ID 93081b76bc464d2f98f0-2d9687b80967 exist? True
|
52 |
+
```
|