This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=utf-8 | |
# Copyright 2020 The HuggingFace Inc. team. All rights reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
import numpy as np | |
import time | |
import pandas as pd | |
from tqdm import tqdm | |
def pack_documents_original(tokenized_documents, block_size: int = 8192, use_tqdm=True): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass, field | |
import torch | |
from torch import LongTensor, Tensor | |
from transformers import ( | |
AutoTokenizer, | |
AutoModel, | |
PreTrainedModel, | |
PreTrainedTokenizer, | |
BatchEncoding, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Counter | |
from datasets import load_dataset | |
from tqdm import tqdm | |
ds = load_dataset("HuggingFaceFW/fineweb-2", "nld_Latn", split="train") | |
ds_size = len(ds) | |
print(f"Dataset size: {ds_size:,}") # | |
counts = Counter(ds["id"]) |
OlderNewer