Spaces:
Runtime error
Runtime error
victormiller
commited on
Commit
•
0f14580
1
Parent(s):
706ab04
Update common.py
Browse files
common.py
CHANGED
@@ -26,6 +26,14 @@ table_html_nfc = nfc_examples.to_html(index=False, border=0)
|
|
26 |
table_div_nfc_examples = Div(NotStr(table_html_nfc), style="margin: 40px;")
|
27 |
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
global_div = Div(
|
30 |
Section(
|
31 |
H2("Global Steps"),
|
@@ -49,13 +57,7 @@ global_div = Div(
|
|
49 |
H3("Matching Pairs Generation"),
|
50 |
P("We are using a Jaccard similarity threshold of 0.8 to identify near-duplicate documents. To do this, we divide the MinHashes into 9 bands, each with 13 hashes (also known as the range). To save memory during matching, we first store each band of MinHashes separately on disk. We then process each band individually. Within each band, documents are matched based on their hashes, and the matches are saved as document pairs. A document is considered a match if it matches another document in any of the 9 bands. Since we are looking for near-duplicates, a document may match multiple documents across different bands."),
|
51 |
P("For partitioning and matching the hashes, we utilize Dask's bag data structure to load the document ids and MinHashes. The matching process is simply a group by operation on this bag data structure. This approach allows us to group matches efficiently and distribute the operation to multiple machines. Also doing a group by produces full components (documents that share the same signature) within a band which simplifies the later stages. The algorithm can be expressed using the Dask expression below:"),
|
52 |
-
Code(""
|
53 |
-
dask.bag.from_sequence(doc_file_paths)
|
54 |
-
.map_partitions(stream_docs)
|
55 |
-
.groupby(lambda doc: doc["hash"])
|
56 |
-
.map_partitions(make_doc_pairs)
|
57 |
-
.compute()
|
58 |
-
"""),
|
59 |
P("This step produced 9.2 TB of matching pairs from all bands."),
|
60 |
),
|
61 |
Section(
|
|
|
26 |
table_div_nfc_examples = Div(NotStr(table_html_nfc), style="margin: 40px;")
|
27 |
|
28 |
|
29 |
+
dask_algo = """
|
30 |
+
dask.bag.from_sequence(doc_file_paths)
|
31 |
+
.map_partitions(stream_docs)
|
32 |
+
.groupby(lambda doc: doc["hash"])
|
33 |
+
.map_partitions(make_doc_pairs)
|
34 |
+
.compute()
|
35 |
+
"""
|
36 |
+
|
37 |
global_div = Div(
|
38 |
Section(
|
39 |
H2("Global Steps"),
|
|
|
57 |
H3("Matching Pairs Generation"),
|
58 |
P("We are using a Jaccard similarity threshold of 0.8 to identify near-duplicate documents. To do this, we divide the MinHashes into 9 bands, each with 13 hashes (also known as the range). To save memory during matching, we first store each band of MinHashes separately on disk. We then process each band individually. Within each band, documents are matched based on their hashes, and the matches are saved as document pairs. A document is considered a match if it matches another document in any of the 9 bands. Since we are looking for near-duplicates, a document may match multiple documents across different bands."),
|
59 |
P("For partitioning and matching the hashes, we utilize Dask's bag data structure to load the document ids and MinHashes. The matching process is simply a group by operation on this bag data structure. This approach allows us to group matches efficiently and distribute the operation to multiple machines. Also doing a group by produces full components (documents that share the same signature) within a band which simplifies the later stages. The algorithm can be expressed using the Dask expression below:"),
|
60 |
+
Div(Code(dask_algo), cls= "code-block"),
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
P("This step produced 9.2 TB of matching pairs from all bands."),
|
62 |
),
|
63 |
Section(
|