LoginSignup
1
0

論文紹介:The Stack v2

Last updated at Posted at 2024-03-12

概要

データセット本体:bigcode/the-stack-v2 · Datasets at Hugging Face
論文:StarCoder 2 and The Stack v2: The Next Generation

The Stackは、2023-09-14までのGitHubアーカイブデータを使用している。
Software Heritageという団体とパートナーシップのもと、この団体のコードアーカイブを使用している。

この団体はフランスの国立デジタル科学技術研究所によって設立され、ユネスコなどの支援を受けている。

The Stack v2によって、StarCoder2モデル(3B、7B、15B)は訓練されている。

ライセンスとしては、CreativeML Open RAIL-Mが適応され、SoftWare Heritage persistent IDentifierというソフトウェア成果物への識別子により、透明性を確保している。

v1とv2の比較

The Stackは2バージョン作られている。

v1 v2
full 6.4TB 67.5TB
dedup 2.9TB 32.1TB
train (full) ~2,000億トークン ~900億トークン

v2のデータセットの種類

データセットには4つの種類があり、一部には事前処理がされている。

  • bigcode/the-stack-v2
    • フルのデータセット
  • bigcode/the-stack-v2-dedup
    • フルデータセットから重複排除したデータセット
  • bigcode/the-stack-v2-train-full-ids
    • 重複削除したデータセットから、ヒューリスティックでさらにフィルタリングされており、600以上のプログラミング言語にまたがっている。
  • bigcode/the-stack-v2-train-smol-ids
    • 重複削除したデータセットから、ヒューリスティックでさらにフィルタリングされており、17のプログラミング言語にまたがっている。
    • Ant Build System, AsciiDoc, C, C#, C++, CMake, Dockerfile, Go, Go Module, Gradle, Groovy, HTML, INI, Java, Java Properties, JavaScript, JSON, JSON with Comments, Kotlin, Lua, M4Sugar, Makefile, Markdown, Maven POM, PHP, Python, R, RDoc, reStructuredText, RMarkdown, Ruby, Rust, Shell, SQL, Swift, Text, TOML, TypeScript, YAML

データセットの内容

The Stack v2ではGithubコード、Githubイシュー、Githubプルリク、ジュピターノートブック、Kaggleノートブック、パッケージマネージャのドキュメント、教科書、数学とコーディングに関する小規模な高品質データ、自然言語データが含まれており、それぞれ事前処理が施されている。

データの引用元

事前フィルタリング処理

Githubコード
1. 共通の事前処理パイプライン
2. 長文フィルタ:100k行を超えるファイルなどを削除
3. 自動生成フィルタ:自動生成と分類されたファイルを削除
4. アルファベットフィルタ:アルファベットが25%未満のファイルを削除
5. エンコードファイルフィルタ:Base64文字列などエンコードデータが1024文字より長いファイルを削除

共通の事前処理パイプライン
1. 重複除去(ブログポスト
2. 個人情報のマスキング
3. 汚染除去:評価データセットの回答が含まれないように訓練データより削除
4. マルウェアの除去
5. オプトアウトの削除:「Am I in the stack」というツールによって、自分のコードがデータセットに含まれるかどうか確認できるようにし、削除要請があったコード削除]

サンプルコード

!pip install datasets smart_open[s3]
import boto3
from datasets import load_dataset
from google.colab import userdata
from smart_open import open

# 定数の定義
LANG_FILTER = ["Python"]
BYTES_LIMIT = 12220

# AWSセッションとS3クライアントの設定
def setup_aws_session():
    session = boto3.Session(
        aws_access_key_id=userdata.get("AWS_ACCESS_KEY_ID"),
        aws_secret_access_key=userdata.get("AWS_SECRET_ACCESS_KEY"))
    return session.client("s3")

# データセットのロード
def load_huggingface_dataset(token):
    return load_dataset("bigcode/the-stack-v2-train-smol-ids", split="train", streaming=True, token=token)

# コンテンツをダウンロードする
def download_content(s3, blob_id, src_encoding):
    s3_url = f"s3://softwareheritage/content/{blob_id}"
    with open(s3_url, "rb", compression=".gz", transport_params={"client": s3}) as fin:
        content = fin.read().decode(src_encoding)
    return content

# ファイルのダウンロードと内容の取得
def download_files_and_get_contents(files, s3, total_bytes):
    contents = []
    for file in files:
        if file["language"] not in LANG_FILTER or total_bytes > BYTES_LIMIT:
            continue
        content = download_content(s3, file["blob_id"], file["src_encoding"])
        contents.append(content)
        total_bytes += file["length_bytes"]
        if total_bytes > BYTES_LIMIT:
            break
    return contents, total_bytes

def main():
    s3 = setup_aws_session()
    access_token = userdata.get("HUGGING_FACE_TOKEN")
    ds = load_huggingface_dataset(access_token)

    total_bytes = 0
    for row in ds:
        contents, total_bytes = download_files_and_get_contents(row["files"], s3, total_bytes)
        for content in contents:
            print(content)
        if total_bytes > BYTES_LIMIT:
            break

if __name__ == "__main__":
    main()
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0