--- license: other license_name: pdfa-eng-train license_link: LICENSE task_categories: - image-to-text size_categories: - 10M> dict_keys(['__key__', '__url__', 'json', 'pdf']) ``` Further, a metadata file `_pdfa-english-train-info-minimal.json` contains the list of samples per shard, with same basename and `.json` or `.pdf` extension, as well as the count of files per shard. #### Words and lines document metadata Initially, we started from the readily available ~11TB zip files from PDFA in their initial [data release](https://digitalcorpora.org/corpora/file-corpora/cc-main-2021-31-pdf-untruncated/). From the pdf digital files, we extracted words, bounding boxes and image bounding boxes that are available in the pdf file. This information is then reshaped into lines organized in reading order, under the key `lines`. We keep non-reshaped word and bounding box information under the `word` key, should users want to use their own heuristic. The way we obtain an approximate reading order is simply by looking at the frequency peaks of the leftmost word x-coordinate. A frequency peak means that a high number of lines are starting from the same point. Then, we keep track of the x-coordinate of each such identified column. If no peaks are found, the document is assumed to be readable in plain format. ```python def get_columnar_separators(page, min_prominence=0.3, num_bins=10, kernel_width=1): """ Identifies the x-coordinates that best separate columns by analyzing the derivative of a histogram of the 'left' values (xmin) of bounding boxes. Args: page (dict): Page data with 'bbox' containing bounding boxes of words. min_prominence (float): The required prominence of peaks in the histogram. num_bins (int): Number of bins to use for the histogram. kernel_width (int): The width of the Gaussian kernel used for smoothing the histogram. Returns: separators (list): The x-coordinates that separate the columns, if any. """ try: left_values = [b[0] for b in page['bbox']] hist, bin_edges = np.histogram(left_values, bins=num_bins) hist = scipy.ndimage.gaussian_filter1d(hist, kernel_width) min_val = min(hist) hist = np.insert(hist, [0, len(hist)], min_val) bin_width = bin_edges[1] - bin_edges[0] bin_edges = np.insert(bin_edges, [0, len(bin_edges)], [bin_edges[0] - bin_width, bin_edges[-1] + bin_width]) peaks, _ = scipy.signal.find_peaks(hist, prominence=min_prominence * np.max(hist)) derivatives = np.diff(hist) separators = [] if len(peaks) > 1: # This finds the index of the maximum derivative value between peaks # which indicates peaks after trough --> column for i in range(len(peaks)-1): peak_left = peaks[i] peak_right = peaks[i+1] max_deriv_index = np.argmax(derivatives[peak_left:peak_right]) + peak_left separator_x = bin_edges[max_deriv_index + 1] separators.append(separator_x) except Exception as e: separators = [] return separators ``` For each pdf document, we store statistics on the file size, number of words (as characters separated by spaces), number of pages, as well as the rendering times of each page for a given dpi. #### Filtering process File size and page rendering time are used to set thresholds in the final dataset: the goal is to remove files that are larger than 100 MB, or that take more than 500ms to render on a modern machine, to optimize dataloading at scale. Having "too large" or "too slow" files would add a burden to large-scale training pipelines and we choose to alleviate this in the current release. Finally, a full pass over the dataset is done, trying to open a bytestream We get to 48 million pages kept as valid samples. As a last step, we use XLM-Roberta to restrict the dataset to an english subset, specifically `papluca/xlm-roberta-base-language-detection` , on the first 512 words of the first page of each document. Be aware that some documents may have several languages embedded in them, or that some predictions might be inaccurate. At the end, each document exists as a pairing of a pdf and a json file containing extensive OCR annotation as well as metadata information about rendering times. The filterings and packaging in webdataset format are tailored towards multimodal machine learning at scale, specifically image-to-text tasks. ### Dataset statistics In this dataset, an additional filtering has been done to restrict documents to the english language to 18.6 million pages over 2.16 million documents. This filtering has been done using XLM Further, the metadata for each document has been formatted in this way: TODO add formatting Such a formatting follows the multimodal dataset from the Industry Document Library, `https://huggingface.co/datasets/pixparse/IDL-wds`. ### Data Splits #### Train * `pdfa-eng-train-*.tar` * Downloaded on 2024/01/22 * 1800 shards, 2,159,433 samples, 18,686,346 pages, 5,997,818,991 words ## Additional Information ### Dataset Curators Pablo Montalvo, Ross Wightman ### Disclaimer This dataset, as a corpus, does not represent the intent and purpose from CC-MAIN-2021-31-PDF-UNTRUNCATED. TODO add disclaimer on biases of using that dataset as a faithful representation of existing documents on the web ### Licensing Information Data has been filtered from the original corpus. As a consequence, users should note [Common Crawl's license and terms of use](https://commoncrawl.org/terms-of-use) and the [Digital Corpora project's Terms of Use](https://digitalcorpora.org/about-digitalcorpora/terms-of-use/). ### Citation Information ??