prrao87 commited on
Commit
caa11ad
·
verified ·
1 Parent(s): 1050f41

Update README with LanceDB examples

Browse files
Files changed (1) hide show
  1. README.md +225 -152
README.md CHANGED
@@ -9,242 +9,315 @@ language:
9
  tags:
10
  - retrieval
11
  - text
 
12
  - lance
13
  pretty_name: fineweb-edu-lance
14
  size_categories:
15
- - 1M<n<10M
16
  ---
17
  # FineWeb-Edu (Lance Format)
18
 
19
- FineWeb-edu dataset with over 1.5 billion rows. Each passage ships with cleaned text, metadata, and 384-dim text embeddings for retrieval-heavy workloads.
20
 
 
21
 
22
- ## Load via `datasets.load_dataset`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  ```python
25
- import datasets
 
 
 
26
 
27
- hf_ds = datasets.load_dataset(
28
- "lance-format/fineweb-edu",
29
- split="train",
30
- streaming=True,
 
 
31
  )
32
- # Take first three rows and print titles
33
- for row in hf_ds.take(3):
34
- print(row["title"])
35
  ```
36
 
37
- Use Lance's native connector when you need ANN search, FTS, or direct access to embeddings while still pointing to the copy hosted on Hugging Face:
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  ```python
40
- import lance
41
 
42
- ds = lance.dataset("hf://datasets/lance-format/fineweb-edu/data/train.lance")print(f"Total passages: {ds.count_rows():,}")
 
 
43
  ```
44
 
45
- These tables can also be consumed by [LanceDB](https://lancedb.github.io/lancedb/), the multimodal lakehouse and embedded search library built on top of Lance, for simplified vector search and other queries.
 
 
46
 
47
  ```python
48
  import lancedb
49
 
50
  db = lancedb.connect("hf://datasets/lance-format/fineweb-edu/data")
51
  tbl = db.open_table("train")
52
- print(f"LanceDB table opened with {len(tbl)} passages")
53
  ```
54
 
 
55
 
 
56
 
57
- > The dataset hosted on Hugging Face Hub does **not** currently have pre-built ANN (vector) or FTS (full-text search) indices.
58
- >
 
 
 
 
 
59
 
60
- > - For any search or similarity workloads, you should download the dataset locally and build indices yourself.
61
- >
62
  > ```bash
63
- > # Download once
64
- > huggingface-cli download lance-format/fineweb-edu --repo-type dataset --local-dir ./fineweb-edu
65
- >
66
- > # Then load locally and build indices
67
- > import lance
68
- > ds = lance.dataset("./fineweb-edu")
69
- > # ds.create_index(...)
70
  > ```
71
- >
72
 
 
73
 
74
- ## Why Lance?
75
 
76
- - Optimized for AI workloads: Lance keeps multimodal data and vector search-ready storage in the same columnar format designed for accelerator-era retrieval (see [lance.org](https://lance.org)).
77
- - Images + embeddings + metadata travel as one tabular dataset.
78
- - On-disk, scalable ANN index means
79
- - Schema evolution lets you add new features/columns (moderation tags, embeddings, etc.) without rewriting the raw data.
80
 
 
 
81
 
82
- ## Quick Start (Lance Python)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  ```python
85
- import lance
86
- import pyarrow as pa
 
 
 
 
 
 
 
 
 
 
87
 
88
- lance_ds = lance.dataset("hf://datasets/lance-format/fineweb-edu/data/train.lance")
89
 
90
- # Browse titles & language without touching embeddings
91
- rows = lance_ds.scanner(
92
- columns=["title", "language"],
93
- limit=5
94
- ).to_table().to_pylist()
95
 
96
- # Vector similarity from the on-dataset ANN index
97
- ref = lance_ds.take([0], columns=["text_embedding", "title"])
98
- query_vec = pa.array([ref.to_pylist()[0]["text_embedding"]],
99
- type=ref.schema.field("text_embedding").type)
100
 
101
- results = lance_ds.scanner(
102
- nearest={
103
- "column": "text_embedding",
104
- "q": query_vec[0],
105
- "k": 5,
106
- "nprobes": 8,
107
- "refine_factor": 20,
108
- },
109
- columns=["title", "language", "text"],
110
- ).to_table().to_pylist()
111
- ```
112
 
113
- > **Hugging Face Streaming Note**
114
- > - Streaming uses conservative ANN parameters (`nprobes`, `refine_factor`) to stay within HF rate limits.
115
- > - Prefer local copies (`huggingface-cli download lance-format/fineweb-edu --local-dir ./fineweb`) for heavy workloads, then point Lance at `./fineweb`.
116
 
117
- ## Dataset Schema
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
- Common columns you'll find in this Lance dataset:
120
- - `text` – cleaned passage content.
121
- - `title` – page/article title when available.
122
- - `url` – canonical source URL.
123
- - `language` + `language_probability` – detector outputs for filtering.
124
- - Quality metadata from FineWeb-Edu (e.g., heuristic scores or length stats).
125
- - `text_embedding` – 384-dimension float32 vector for retrieval.
126
 
127
- ## Usage Examples
128
 
129
- > **Search snippets for reference**
130
- > The vector/FTS examples below show the Lance APIs you’ll use once indexes are available. The hosted dataset doesn’t yet ship ANN/FTS indexes—download locally (or build indexes yourself) before running them. Pre-built indexes are coming soon.
131
 
132
- ### 1. Sample documents without embeddings
133
 
134
  ```python
135
- scanner = ds.scanner(
136
- columns=["title", "language", "text"],
137
- filter="language = 'en'",
138
- limit=5,
139
- )
140
- for doc in scanner.to_table().to_pylist():
141
- print(doc["title"], doc["language"])
142
- print(doc["text"][:200], "...\n")
 
143
  ```
144
 
145
- ### 2. Vector search for semantically similar passages
146
 
147
  ```python
148
- ref_doc = ds.take([123], columns=["text_embedding", "title", "text"]).to_pylist()[0]
149
- emb_type = ds.to_table(columns=["text_embedding"], limit=1).schema.field("text_embedding").type
150
- query = pa.array([ref_doc["text_embedding"]], type=emb_type)
151
-
152
- neighbors = ds.scanner(
153
- nearest={
154
- "column": "text_embedding",
155
- "q": query[0],
156
- "k": 6,
157
- "nprobes": 8,
158
- "refine_factor": 20,
159
- },
160
- columns=["title", "language", "text"],
161
- ).to_table().to_pylist()[1:]
162
- ```
163
-
164
- ### LanceDB Vector Search
165
  ```python
166
  import lancedb
 
 
167
 
168
- db = lancedb.connect("hf://datasets/lance-format/fineweb-edu/data")
169
  tbl = db.open_table("train")
170
 
171
- # Get a passage to use as a query
172
- ref_passage = tbl.limit(1).offset(123).select(["text_embedding", "text"]).to_pandas().to_dict('records')[0]
173
- query_embedding = ref_passage["text_embedding"]
174
 
175
- results = tbl.search(query_embedding) \
176
- .limit(5) \
177
- .to_list()
178
  ```
179
 
180
- ### 3. Full-text search with Lance FTS
181
 
182
- ```python
183
- hits = ds.scanner(
184
- full_text_query="quantum computing",
185
- columns=["title", "language", "text"],
186
- limit=10,
187
- fast_search=True,
188
- ).to_table().to_pylist()
189
- ```
190
 
191
- ### LanceDB Full-Text Search
192
  ```python
193
  import lancedb
194
 
195
  db = lancedb.connect("hf://datasets/lance-format/fineweb-edu/data")
196
  tbl = db.open_table("train")
197
 
198
- results = tbl.search("quantum computing") \
199
- .select(["title", "language", "text"]) \
200
- .limit(10) \
201
- .to_list()
202
  ```
203
 
 
204
 
205
- See `fineweb_edu/example.py` on lance-huggingface repo for a complete walkthrough that combines HF streaming batches with Lance-powered retrieval.
206
-
207
- ## Dataset Evolution
 
 
208
 
209
- Lance supports flexible schema and data evolution ([docs](https://lance.org/guide/data_evolution/?h=evol)). You can add/drop columns, backfill with SQL or Python, rename fields, or change data types without rewriting the whole dataset. In practice this lets you:
210
- - Introduce fresh metadata (moderation labels, embeddings, quality scores) as new signals become available.
211
- - Add new columns to existing datasets without re-exporting terabytes of video.
212
- - Adjust column names or shrink storage (e.g., cast embeddings to float16) while keeping previous snapshots queryable for reproducibility.
213
 
214
  ```python
215
- import lance
216
- import pyarrow as pa
217
- import numpy as np
218
 
219
- # Assume ds is a local Lance dataset
220
- # ds = lance.dataset("./fineweb_edu_local")
221
 
222
- base = pa.table({"id": pa.array([1, 2, 3]), "text": pa.array(["A", "B", "C"])})
223
- dataset = lance.write_dataset(base, "fineweb_evolution", mode="overwrite")
224
 
225
- # 1. Add a schema-only column (data to be added later)
226
- dataset.add_columns(pa.field("subject", pa.string()))
227
 
228
- # 2. Add a column with data
229
- dataset.add_columns({"quality_bucket": "'unknown'"})
230
 
231
- # 3. Generate rich columns via Python batch UDFs
232
- @lance.batch_udf()
233
- def random_embedding(batch):
234
- vecs = np.random.rand(batch.num_rows, 384).astype("float32")
235
- return pa.RecordBatch.from_arrays(
236
- [pa.FixedSizeListArray.from_arrays(vecs.ravel(), 384)],
237
- names=["text_embedding"],
 
 
238
  )
 
 
 
239
 
240
- dataset.add_columns(random_embedding)
 
 
 
 
 
 
241
 
242
- # 4. Bring in annotations with merge
243
- labels = pa.table({"id": pa.array([1, 2, 3]), "label": pa.array(["math", "history", "science"])})
244
- dataset.merge(labels, "id")
245
 
246
- # 5. Rename or cast columns as needs change
247
- dataset.alter_columns({"path": "subject", "name": "topic"})
248
- dataset.alter_columns({"path": "text_embedding", "data_type": pa.list_(pa.float16(), 384)})
 
 
 
 
 
 
249
  ```
250
- You can iterate on embeddings, quality tags, or moderation fields while keeping earlier dataset versions available for reproducible experiments.
 
9
  tags:
10
  - retrieval
11
  - text
12
+ - fineweb
13
  - lance
14
  pretty_name: fineweb-edu-lance
15
  size_categories:
16
+ - 1B<n<10B
17
  ---
18
  # FineWeb-Edu (Lance Format)
19
 
20
+ A Lance-formatted version of [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) — **over 1.5 billion educational web passages** with cleaned text, source metadata, language detection signals, and 384-dim text embeddings — available directly from the Hub at `hf://datasets/lance-format/fineweb-edu/data/train.lance`.
21
 
22
+ ## Key features
23
 
24
+ - **Cleaned passage text** in the `text` column with the source `url` and `title` carried alongside.
25
+ - **Language detection signals** (`language`, `language_probability`) for filtered subsets.
26
+ - **Pre-computed 384-dim text embeddings** in `text_embedding`, ready for ANN search once an index is built locally.
27
+ - **One columnar dataset** — scan metadata cheaply, project just the columns each query needs, defer the heavy `text` and `text_embedding` reads to the rows that matter.
28
+
29
+ > **No pre-built indices on the Hub copy yet.** At 1.5 B+ rows the on-disk indices are too large to ship comfortably alongside the data on the Hub. The Search, Curate, Evolve, and Train sections below describe the same APIs you'd use against a fully indexed dataset, but vector and full-text examples assume a local copy with `IVF_PQ` and `INVERTED` indices built once after download. See the Materialize-a-subset section at the end for a focused-subset workflow that makes indexing tractable.
30
+
31
+ ## Splits
32
+
33
+ `train.lance`
34
+
35
+ ## Schema
36
+
37
+ | Column | Type | Notes |
38
+ |---|---|---|
39
+ | `text` | `string` | Cleaned passage body |
40
+ | `title` | `string` | Page or article title when available |
41
+ | `url` | `string` | Canonical source URL |
42
+ | `language` | `string` | Detected language code (e.g., `en`) |
43
+ | `language_probability` | `float32` | Confidence of the language detector |
44
+ | `text_embedding` | `fixed_size_list<float32, 384>` | Passage embedding for retrieval |
45
+ | *FineWeb-Edu quality metadata* | — | Heuristic scores and length statistics carried over from the upstream corpus |
46
+
47
+ ## Pre-built indices
48
+
49
+ None bundled at present. Build the recommended indices on a local copy:
50
 
51
  ```python
52
+ import lancedb
53
+
54
+ db = lancedb.connect("./fineweb-edu/data")
55
+ tbl = db.open_table("train")
56
 
57
+ tbl.create_index(
58
+ metric="cosine",
59
+ vector_column_name="text_embedding",
60
+ index_type="IVF_PQ",
61
+ num_partitions=2048,
62
+ num_sub_vectors=96,
63
  )
64
+ tbl.create_fts_index("text", replace=True)
 
 
65
  ```
66
 
67
+ Both indices live next to the data, so subsequent queries against the same local path pick them up automatically.
68
+
69
+ ## Why Lance?
70
+
71
+ 1. **Blazing Fast Random Access**: Optimized for fetching scattered rows, making it ideal for random sampling, real-time ML serving, and interactive applications without performance degradation.
72
+ 2. **Native Multimodal Support**: Store text, embeddings, and other data types together in a single file. Large binary objects are loaded lazily, and vectors are optimized for fast similarity search.
73
+ 3. **Native Index Support**: Lance comes with fast, on-disk, scalable vector and FTS indexes that sit right alongside the dataset on the Hub, so you can share not only your data but also your embeddings and indexes without your users needing to recompute them.
74
+ 4. **Efficient Data Evolution**: Add new columns and backfill data without rewriting the entire dataset. This is perfect for evolving ML features, adding new embeddings, or introducing moderation tags over time.
75
+ 5. **Versatile Querying**: Supports combining vector similarity search, full-text search, and SQL-style filtering in a single query, accelerated by on-disk indexes.
76
+ 6. **Data Versioning**: Every mutation commits a new version; previous versions remain intact on disk. Tags pin a snapshot by name, so retrieval systems and training runs can reproduce against an exact slice of history.
77
+
78
+ ## Load with `datasets.load_dataset`
79
+
80
+ You can load Lance datasets via the standard HuggingFace `datasets` interface, suitable when your pipeline already speaks `Dataset` / `IterableDataset` or you want a quick streaming sample.
81
 
82
  ```python
83
+ import datasets
84
 
85
+ hf_ds = datasets.load_dataset("lance-format/fineweb-edu", split="train", streaming=True)
86
+ for row in hf_ds.take(3):
87
+ print(row["title"] or row["url"])
88
  ```
89
 
90
+ ## Load with LanceDB
91
+
92
+ LanceDB is the embedded retrieval library built on top of the Lance format ([docs](https://lancedb.com/docs)), and is the interface most users interact with. It wraps the dataset as a queryable table with search and filter builders, and is the entry point used by the Search, Curate, Evolve, Versioning, and Materialize-a-subset sections below.
93
 
94
  ```python
95
  import lancedb
96
 
97
  db = lancedb.connect("hf://datasets/lance-format/fineweb-edu/data")
98
  tbl = db.open_table("train")
99
+ print(len(tbl))
100
  ```
101
 
102
+ ## Load with Lance
103
 
104
+ `pylance` is the Python binding for the Lance format and works directly with the format's lower-level APIs. Reach for it when you want to inspect dataset internals — schema, scanner, fragments, the list of pre-built indices.
105
 
106
+ ```python
107
+ import lance
108
+
109
+ ds = lance.dataset("hf://datasets/lance-format/fineweb-edu/data/train.lance")
110
+ print(ds.count_rows(), ds.schema.names)
111
+ print(ds.list_indices())
112
+ ```
113
 
114
+ > **Tip — for production use, download locally first.** Streaming from the Hub works for exploration, but at 1.5 B+ rows random access and any kind of search are dramatically faster against a local copy, and ANN / FTS require local indices anyway:
 
115
  > ```bash
116
+ > hf download lance-format/fineweb-edu --repo-type dataset --local-dir ./fineweb-edu
 
 
 
 
 
 
117
  > ```
118
+ > Then point Lance or LanceDB at `./fineweb-edu/data`. For most workflows, the Materialize-a-subset section is a better starting point than downloading the full 1.5 B-row corpus.
119
 
120
+ ## Search
121
 
122
+ Once an `IVF_PQ` index exists on `text_embedding`, dense retrieval is a single call. In production you would encode a query string through the same 384-dim text encoder used at ingest and pass the resulting vector to `tbl.search(...)`. The example below uses the embedding from row 42 as a runnable stand-in.
123
 
124
+ ```python
125
+ import lancedb
 
 
126
 
127
+ db = lancedb.connect("./fineweb-edu/data") # local copy with the indices from the section above
128
+ tbl = db.open_table("train")
129
 
130
+ seed = (
131
+ tbl.search()
132
+ .select(["text_embedding", "url"])
133
+ .limit(1)
134
+ .offset(42)
135
+ .to_list()[0]
136
+ )
137
+
138
+ hits = (
139
+ tbl.search(seed["text_embedding"])
140
+ .metric("cosine")
141
+ .where("language = 'en' AND language_probability > 0.9", prefilter=True)
142
+ .select(["title", "url", "text"])
143
+ .limit(10)
144
+ .to_list()
145
+ )
146
+ for r in hits:
147
+ print(f"{r['url']}\n {(r['title'] or '')[:80]}")
148
+ ```
149
+
150
+ The result set carries only the projected columns. The `text_embedding` vector is never read on the result side, and the `text` body is fetched only for the ten passages that actually came back, keeping the working set small even though the corpus is enormous.
151
+
152
+ Because the recommended setup also builds an `INVERTED` index on `text`, the same query can be issued as a hybrid search that combines the dense vector with a keyword query. LanceDB merges the two result lists and reranks them in a single call, which is useful when a phrase must literally appear in the passage but the dense side still does most of the ranking.
153
 
154
  ```python
155
+ hybrid_hits = (
156
+ tbl.search(query_type="hybrid")
157
+ .vector(seed["text_embedding"])
158
+ .text("quantum computing")
159
+ .where("language = 'en'", prefilter=True)
160
+ .select(["title", "url", "text"])
161
+ .limit(10)
162
+ .to_list()
163
+ )
164
+ for r in hybrid_hits:
165
+ print(f"{r['url']}\n {(r['title'] or '')[:80]}")
166
+ ```
167
 
168
+ Tune `metric`, `nprobes`, and `refine_factor` on the vector side to trade recall against latency.
169
 
170
+ ## Curate
 
 
 
 
171
 
172
+ A typical curation pass over a web corpus starts with a metadata filter — pick high-confidence English, drop short or low-quality fragments, restrict to a domain — before any text gets read. Stacking predicates inside a single filtered scan keeps the result small and explicit, and the bounded `.limit(1000)` makes it cheap to inspect.
 
 
 
173
 
174
+ ```python
175
+ import lancedb
 
 
 
 
 
 
 
 
 
176
 
177
+ db = lancedb.connect("hf://datasets/lance-format/fineweb-edu/data")
178
+ tbl = db.open_table("train")
 
179
 
180
+ candidates = (
181
+ tbl.search()
182
+ .where(
183
+ "language = 'en' "
184
+ "AND language_probability > 0.95 "
185
+ "AND length(text) >= 1000",
186
+ prefilter=True,
187
+ )
188
+ .select(["url", "title", "language_probability"])
189
+ .limit(1000)
190
+ .to_list()
191
+ )
192
+ print(f"{len(candidates)} candidates; first url: {candidates[0]['url']}")
193
+ ```
194
 
195
+ The result is a plain list of dictionaries, ready to inspect, persist as a manifest of URLs, or hand to the Materialize-a-subset section below for export to a writable local copy. Neither the `text` body nor the `text_embedding` vector is read by this scan, so a 1000-row curation pass against the Hub moves only kilobytes of metadata even though the underlying table is in the billions.
 
 
 
 
 
 
196
 
197
+ ## Evolve
198
 
199
+ Lance stores each column independently, so a new column can be appended without rewriting the existing data. The lightest form is a SQL expression: derive the new column from columns that already exist, and Lance computes it once and persists it. The example below adds a `text_length` and a `long_passage` flag, either of which can then be used directly in `where` clauses without recomputing the predicate on every query.
 
200
 
201
+ > **Note:** Mutations require a local copy of the dataset, since the Hub mount is read-only. See the Materialize-a-subset section at the end of this card for a streaming pattern that downloads only the rows and columns you need, or use `hf download` to pull a larger slice first.
202
 
203
  ```python
204
+ import lancedb
205
+
206
+ db = lancedb.connect("./fineweb-edu/data") # local copy required for writes
207
+ tbl = db.open_table("train")
208
+
209
+ tbl.add_columns({
210
+ "text_length": "length(text)",
211
+ "long_passage": "length(text) >= 1000",
212
+ })
213
  ```
214
 
215
+ If the values you want to attach already live in another table (offline labels, topic classifications, alternate embeddings from a stronger model), merge them in by joining on `url`:
216
 
217
  ```python
218
+ import pyarrow as pa
219
+
220
+ labels = pa.table({
221
+ "url": pa.array(["https://example.com/a", "https://example.com/b"]),
222
+ "topic": pa.array(["math", "history"]),
223
+ })
224
+ tbl.merge(labels, on="url")
225
+ ```
226
+
227
+ The original columns and indices are untouched, so existing code that does not reference the new columns continues to work unchanged. New columns become visible to every reader as soon as the operation commits. For column values that require a Python computation (e.g., running a different embedding model over the text), Lance provides a batch-UDF API — see the [Lance data evolution docs](https://lance.org/guide/data_evolution/).
228
+
229
+ ## Train
230
+
231
+ Projection lets a training loop read only the columns each step actually needs. LanceDB tables expose this through `Permutation.identity(tbl).select_columns([...])`, which plugs straight into the standard `torch.utils.data.DataLoader` so prefetching, shuffling, and batching behave as in any PyTorch pipeline. For language-model pretraining the natural projection is just the `text` column; for a retrieval probe or a reranker on top of frozen features, project the precomputed embedding instead.
232
+
 
 
233
  ```python
234
  import lancedb
235
+ from lancedb.permutation import Permutation
236
+ from torch.utils.data import DataLoader
237
 
238
+ db = lancedb.connect("./fineweb-edu/data")
239
  tbl = db.open_table("train")
240
 
241
+ train_ds = Permutation.identity(tbl).select_columns(["text"])
242
+ loader = DataLoader(train_ds, batch_size=64, shuffle=True, num_workers=8)
 
243
 
244
+ for batch in loader:
245
+ # batch carries only the projected columns; tokenize, forward, backward...
246
+ ...
247
  ```
248
 
249
+ Switching feature sets is a configuration change: passing `["text_embedding"]` to `select_columns(...)` on the next run reads only the 384-d vectors and skips the text body entirely, which is the right shape for training a lightweight retrieval head on cached embeddings. Columns added in Evolve cost nothing per batch until they are explicitly projected.
250
 
251
+ ## Versioning
252
+
253
+ Every mutation to a Lance dataset, whether it adds a column, merges labels, or builds an index, commits a new version. Previous versions remain intact on disk. You can list versions and inspect the history directly from the Hub copy; creating new tags requires a local copy since tags are writes.
 
 
 
 
 
254
 
 
255
  ```python
256
  import lancedb
257
 
258
  db = lancedb.connect("hf://datasets/lance-format/fineweb-edu/data")
259
  tbl = db.open_table("train")
260
 
261
+ print("Current version:", tbl.version)
262
+ print("History:", tbl.list_versions())
263
+ print("Tags:", tbl.tags.list())
 
264
  ```
265
 
266
+ Once you have a local copy, tag a version for reproducibility:
267
 
268
+ ```python
269
+ local_db = lancedb.connect("./fineweb-edu/data")
270
+ local_tbl = local_db.open_table("train")
271
+ local_tbl.tags.create("english-v1", local_tbl.version)
272
+ ```
273
 
274
+ A tagged version can be opened by name, or any version reopened by its number, against either the Hub copy or a local one:
 
 
 
275
 
276
  ```python
277
+ tbl_v1 = db.open_table("train", version="english-v1")
278
+ tbl_v5 = db.open_table("train", version=5)
279
+ ```
280
 
281
+ Pinning supports two workflows. A retrieval system locked to `english-v1` keeps returning stable results while the dataset evolves in parallel — newly added embeddings or labels do not change what the tag resolves to. A training experiment pinned to the same tag can be rerun later against the exact same passages, so changes in metrics reflect model changes rather than data drift. Neither workflow needs shadow copies or external manifest tracking.
 
282
 
283
+ ## Materialize a subset
 
284
 
285
+ At 1.5 B+ rows, very few workflows want the full corpus on local disk. The practical entry point is to stream a filtered query through `.to_batches()` into a new local table; only the projected columns and matching row groups cross the wire, and the bytes never fully materialize in Python memory. The result is a writable LanceDB database scoped to the rows that actually matter for the downstream task, sized to index and iterate cheaply.
 
286
 
287
+ ```python
288
+ import lancedb
289
 
290
+ remote_db = lancedb.connect("hf://datasets/lance-format/fineweb-edu/data")
291
+ remote_tbl = remote_db.open_table("train")
292
+
293
+ batches = (
294
+ remote_tbl.search()
295
+ .where(
296
+ "language = 'en' "
297
+ "AND language_probability > 0.95 "
298
+ "AND length(text) >= 1000"
299
  )
300
+ .select(["url", "title", "text", "language", "language_probability", "text_embedding"])
301
+ .to_batches()
302
+ )
303
 
304
+ local_db = lancedb.connect("./fineweb-edu-en")
305
+ local_db.create_table("train", batches)
306
+ ```
307
+
308
+ The resulting `./fineweb-edu-en` is a first-class LanceDB database. Build the recommended indices on it once (the same `create_index` / `create_fts_index` calls shown in the Pre-built indices section, pointed at the local path), and every snippet in the Search, Evolve, Train, and Versioning sections above works against it by swapping `hf://datasets/lance-format/fineweb-edu/data` for `./fineweb-edu-en`.
309
+
310
+ ## Source & license
311
 
312
+ Converted from [`HuggingFaceFW/fineweb-edu`](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu). FineWeb-Edu is distributed under [ODC-BY 1.0](https://opendatacommons.org/licenses/by/1-0/); individual document content remains subject to the rights of the original publishers. Review the [upstream dataset card](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) before downstream use.
 
 
313
 
314
+ ## Citation
315
+
316
+ ```
317
+ @misc{lozhkov2024finewebedu,
318
+ title = {FineWeb-Edu: the Finest Collection of Educational Content the Web Has to Offer},
319
+ author = {Lozhkov, Anton and Ben Allal, Loubna and von Werra, Leandro and Wolf, Thomas},
320
+ year = {2024},
321
+ url = {https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu}
322
+ }
323
  ```