module(name = "examples") bazel_dep(name = "bazel_skylib", version = "1.7.1") bazel_dep(name = "rules_zig", version = "20240913.0-1957d05") bazel_dep(name = "platforms", version = "0.0.11") bazel_dep(name = "zml", version = "0.1.0") bazel_dep(name = "aspect_bazel_lib", version = "2.11.0") bazel_dep(name = "rules_oci", version = "2.0.0") non_module_deps = use_extension("//:third_party/non_module_deps.bzl", "non_module_deps") use_repo(non_module_deps, "com_github_hejsil_clap") oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") oci.pull( name = "distroless_cc_debian12", digest = "sha256:1850aee2ff72864350058d83d681c757d45c885986d15fcca7309b9e5c69f39a", image = "gcr.io/distroless/cc-debian12", platforms = [ "linux/amd64", ], ) use_repo(oci, "distroless_cc_debian12", "distroless_cc_debian12_linux_amd64") oci.pull( name = "distroless_cc_debian12_debug", digest = "sha256:ae6f470336acbf2aeffea3db70ec0e74d69bee7270cdb5fa2f28fe840fad57fe", image = "gcr.io/distroless/cc-debian12", platforms = [ "linux/amd64", ], ) use_repo(oci, "distroless_cc_debian12_debug", "distroless_cc_debian12_debug_linux_amd64") # Mnist weights http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") http_file( name = "com_github_ggerganov_ggml_mnist", downloaded_file_path = "mnist.pt", sha256 = "d8a25252e28915e147720c19223721f0f53e3317493727ca754a2dd672450ba9", url = "https://github.com/ggerganov/ggml/raw/18703ad600cc68dbdb04d57434c876989a841d12/examples/mnist/models/mnist/mnist_model.state_dict", ) http_file( name = "com_github_ggerganov_ggml_mnist_data", downloaded_file_path = "mnist.ylc", sha256 = "0fa7898d509279e482958e8ce81c8e77db3f2f8254e26661ceb7762c4d494ce7", url = "https://github.com/ggerganov/ggml/raw/18703ad600cc68dbdb04d57434c876989a841d12/examples/mnist/models/mnist/t10k-images.idx3-ubyte", ) # Llama 3.2 huggingface = use_extension("@zml//bazel:huggingface.bzl", "huggingface") huggingface.model( name = "Meta-Llama-3.2-1B-Instruct", build_file_content = """\ package(default_visibility = ["//visibility:public"]) filegroup( name = "Meta-Llama-3.2-1B-Instruct", srcs = glob(["*.json", "*.safetensors"]), ) """, commit = "9213176726f574b556790deb65791e0c5aa438b6", includes = [ "*.safetensors", "*.json", ], model = "meta-llama/Llama-3.2-1B-Instruct", ) use_repo(huggingface, "Meta-Llama-3.2-1B-Instruct") huggingface.model( name = "Meta-Llama-3.2-3B-Instruct", build_file_content = """\ package(default_visibility = ["//visibility:public"]) filegroup( name = "Meta-Llama-3.2-3B-Instruct", srcs = glob(["*.json", "*.safetensors"]), ) """, commit = "0cb88a4f764b7a12671c53f0838cd831a0843b95", includes = [ "*.safetensors", "*.json", ], model = "meta-llama/Llama-3.2-3B-Instruct", ) use_repo(huggingface, "Meta-Llama-3.2-3B-Instruct") # Llama 3.1 huggingface.model( name = "Meta-Llama-3.1-8B-Instruct", build_file_content = """\ package(default_visibility = ["//visibility:public"]) filegroup( name = "Meta-Llama-3.1-8B-Instruct", srcs = glob(["*.json", "*.safetensors"]), ) """, commit = "5206a32e0bd3067aef1ce90f5528ade7d866253f", includes = [ "*.safetensors", "*.json", ], model = "meta-llama/Meta-Llama-3.1-8B-Instruct", ) use_repo(huggingface, "Meta-Llama-3.1-8B-Instruct") huggingface.model( name = "Meta-Llama-3.1-70B-Instruct", build_file_content = """\ package(default_visibility = ["//visibility:public"]) filegroup( name = "Meta-Llama-3.1-70B-Instruct", srcs = glob(["*.json", "*.safetensors"]), ) """, commit = "945c8663693130f8be2ee66210e062158b2a9693", includes = [ "*.safetensors", "*.json", ], model = "meta-llama/Meta-Llama-3.1-70B-Instruct", ) use_repo(huggingface, "Meta-Llama-3.1-70B-Instruct") http_file( name = "Karpathy-TinyLlama-Stories15M", downloaded_file_path = "stories15M.tinyllama", sha256 = "cd590644d963867a2b6e5a1107f51fad663c41d79c149fbecbbb1f95fa81f49a", url = "https://huggingface.co/karpathy/tinyllamas/resolve/0bd21da7698eaf29a0d7de3992de8a46ef624add/stories15M.bin?download=true", ) http_file( name = "Karpathy-TinyLlama-Tokenizer", downloaded_file_path = "stories260K.tinyllama", sha256 = "50a52ef822ee9e83de5ce9d0be0a025a773d019437f58b5ff9dcafb063ece361", url = "https://github.com/karpathy/llama2.c/raw/c02865df300f3bd9e567ce061000dc23bf785a17/tokenizer.bin", ) # ModernBERT huggingface.model( name = "ModernBERT-base", build_file_content = """\ package(default_visibility = ["//visibility:public"]) filegroup( name = "model", srcs = ["model.safetensors"], ) filegroup( name = "tokenizer", srcs = ["tokenizer.json"], ) """, commit = "94032bb66234a691cf6248265170006a7ced4970", includes = [ "model.safetensors", "tokenizer.json", ], model = "answerdotai/ModernBERT-base", ) use_repo(huggingface, "ModernBERT-base") huggingface.model( name = "ModernBERT-large", build_file_content = """\ package(default_visibility = ["//visibility:public"]) filegroup( name = "model", srcs = ["model.safetensors"], ) filegroup( name = "tokenizer", srcs = ["tokenizer.json"], ) """, commit = "4bbcbf40bed02ce487125bcb3c897ea9bdc88340", includes = [ "model.safetensors", "tokenizer.json", ], model = "answerdotai/ModernBERT-large", ) use_repo(huggingface, "ModernBERT-large") bazel_dep(name = "rules_rust", version = "0.57.1") rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") rust.toolchain( edition = "2021", versions = ["1.84.0"], extra_target_triples = [ "aarch64-apple-darwin", "x86_64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu", ], ) use_repo(rust, "rust_toolchains") register_toolchains("@rust_toolchains//:all")