text stringlengths 5 409k | id stringlengths 14 178 | metadata dict | __index_level_0__ int64 0 572 |
|---|---|---|---|
# Copyright 2023 The HuggingFace 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
#
# Unless required by applicabl... | accelerate/benchmarks/big_model_inference/measures_util.py/0 | {
"file_path": "accelerate/benchmarks/big_model_inference/measures_util.py",
"repo_id": "accelerate",
"token_count": 1146
} | 0 |
# Copyright 2024 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
#
# Unless required by appl... | accelerate/benchmarks/fp8/transformer_engine/distrib_deepspeed.py/0 | {
"file_path": "accelerate/benchmarks/fp8/transformer_engine/distrib_deepspeed.py",
"repo_id": "accelerate",
"token_count": 3034
} | 1 |
<!--Copyright 2022 The HuggingFace 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
Unless required by applicable law or agreed... | accelerate/docs/source/basic_tutorials/overview.md/0 | {
"file_path": "accelerate/docs/source/basic_tutorials/overview.md",
"repo_id": "accelerate",
"token_count": 303
} | 2 |
<!--Copyright 2021 The HuggingFace 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
Unless required by applicable law or agreed... | accelerate/docs/source/package_reference/big_modeling.md/0 | {
"file_path": "accelerate/docs/source/package_reference/big_modeling.md",
"repo_id": "accelerate",
"token_count": 712
} | 3 |
<!--Copyright 2022 The HuggingFace 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
Unless required by applicable law or agreed... | accelerate/docs/source/usage_guides/checkpoint.md/0 | {
"file_path": "accelerate/docs/source/usage_guides/checkpoint.md",
"repo_id": "accelerate",
"token_count": 1150
} | 4 |
<!--Copyright 2021 The HuggingFace 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
Unless required by applicable law or agreed... | accelerate/docs/source/usage_guides/sagemaker.md/0 | {
"file_path": "accelerate/docs/source/usage_guides/sagemaker.md",
"repo_id": "accelerate",
"token_count": 2220
} | 5 |
{
"fp16": {
"enabled": true,
"loss_scale": 0,
"loss_scale_window": 1000,
"initial_scale_power": 16,
"hysteresis": 2,
"min_loss_scale": 1
},
"optimizer": {
"type": "AdamW",
"params": {
"lr": "auto",
"weight_decay": "auto"... | accelerate/examples/deepspeed_config_templates/zero_stage1_config.json/0 | {
"file_path": "accelerate/examples/deepspeed_config_templates/zero_stage1_config.json",
"repo_id": "accelerate",
"token_count": 614
} | 6 |
# Copyright 2024 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
#
# Unless required by appl... | accelerate/examples/inference/pippy/t5.py/0 | {
"file_path": "accelerate/examples/inference/pippy/t5.py",
"repo_id": "accelerate",
"token_count": 1023
} | 7 |
# Copyright 2024 The HuggingFace 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
#
# Unless required by applicabl... | accelerate/manim_animations/dataloaders/stage_2.py/0 | {
"file_path": "accelerate/manim_animations/dataloaders/stage_2.py",
"repo_id": "accelerate",
"token_count": 3396
} | 8 |
#!/usr/bin/env python
# Copyright 2021 The HuggingFace 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
#
# Unles... | accelerate/src/accelerate/commands/config/config.py/0 | {
"file_path": "accelerate/src/accelerate/commands/config/config.py",
"repo_id": "accelerate",
"token_count": 1067
} | 9 |
#!/usr/bin/env python
# Copyright 2021 The HuggingFace 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
#
# Unles... | accelerate/src/accelerate/commands/test.py/0 | {
"file_path": "accelerate/src/accelerate/commands/test.py",
"repo_id": "accelerate",
"token_count": 755
} | 10 |
# Copyright 2021 The HuggingFace 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
#
# Unless required by applicabl... | accelerate/src/accelerate/test_utils/testing.py/0 | {
"file_path": "accelerate/src/accelerate/test_utils/testing.py",
"repo_id": "accelerate",
"token_count": 8761
} | 11 |
# Copyright 2022 The HuggingFace 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
#
# Unless required by applicabl... | accelerate/src/accelerate/utils/offload.py/0 | {
"file_path": "accelerate/src/accelerate/utils/offload.py",
"repo_id": "accelerate",
"token_count": 3177
} | 12 |
# Copyright 2022 The HuggingFace 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
#
# Unless required by applicabl... | accelerate/tests/fsdp/test_fsdp.py/0 | {
"file_path": "accelerate/tests/fsdp/test_fsdp.py",
"repo_id": "accelerate",
"token_count": 9529
} | 13 |
# Copyright 2021 The HuggingFace 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
#
# Unless required by applicabl... | accelerate/tests/test_grad_sync.py/0 | {
"file_path": "accelerate/tests/test_grad_sync.py",
"repo_id": "accelerate",
"token_count": 579
} | 14 |
# Copyright 2021 The HuggingFace 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
#
# Unless required by applicabl... | accelerate/tests/test_scheduler.py/0 | {
"file_path": "accelerate/tests/test_scheduler.py",
"repo_id": "accelerate",
"token_count": 2536
} | 15 |
import json
from pathlib import Path
from datasets import Dataset
from huggingface_hub import HfApi
ORG_NAME = "agents-course"
def main():
"""Push quiz questions to the Hugging Face Hub"""
for file in Path("data").glob("*.json"):
print(f"Processing {file}")
with open(file, "r") as f:
... | agents-course/quiz/push_questions.py/0 | {
"file_path": "agents-course/quiz/push_questions.py",
"repo_id": "agents-course",
"token_count": 319
} | 16 |
# Conclusion [[conclusion]]
Congratulations on finishing this first Unit 🥳
You've just **mastered the fundamentals of Agents** and you've created your first AI Agent!
It's **normal if you still feel confused by some of these elements**. Agents are a complex topic and it's common to take a while to grasp everything.... | agents-course/units/en/unit1/conclusion.mdx/0 | {
"file_path": "agents-course/units/en/unit1/conclusion.mdx",
"repo_id": "agents-course",
"token_count": 368
} | 17 |
[build]
rustflags = ["-C", "target-cpu=native"]
[target.wasm32-unknown-unknown]
rustflags = ["-C", "target-feature=+simd128"]
[target.x86_64-apple-darwin]
rustflags = ["-C", "target-feature=-avx,-avx2"] | candle/.cargo/config.toml/0 | {
"file_path": "candle/.cargo/config.toml",
"repo_id": "candle",
"token_count": 84
} | 18 |
# Introduction
{{#include ../../README.md:features}}
This book will introduce step by step how to use `candle`.
| candle/candle-book/src/README.md/0 | {
"file_path": "candle/candle-book/src/README.md",
"repo_id": "candle",
"token_count": 34
} | 19 |
# Porting a custom kernel
| candle/candle-book/src/inference/cuda/porting.md/0 | {
"file_path": "candle/candle-book/src/inference/cuda/porting.md",
"repo_id": "candle",
"token_count": 7
} | 20 |
use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{black_box, criterion_group, Criterion, Throughput};
use std::time::Instant;
fn run(
x: &Tensor,
k: &Tensor,
padding: usize,
output_padding: usize,
stride: usize,
dilation: usize,
... | candle/candle-core/benches/benchmarks/conv_transpose2d.rs/0 | {
"file_path": "candle/candle-core/benches/benchmarks/conv_transpose2d.rs",
"repo_id": "candle",
"token_count": 826
} | 21 |
//! Implement conversion traits for tensors
use crate::{DType, Device, Error, Tensor, WithDType};
use half::{bf16, f16, slice::HalfFloatSliceExt};
use std::convert::TryFrom;
impl<T: WithDType> TryFrom<&Tensor> for Vec<T> {
type Error = Error;
fn try_from(tensor: &Tensor) -> Result<Self, Self::Error> {
... | candle/candle-core/src/convert.rs/0 | {
"file_path": "candle/candle-core/src/convert.rs",
"repo_id": "candle",
"token_count": 2242
} | 22 |
//! Pretty printing of tensors
//!
//! This implementation should be in line with the [PyTorch version](https://github.com/pytorch/pytorch/blob/7b419e8513a024e172eae767e24ec1b849976b13/torch/_tensor_str.py).
//!
use crate::{DType, Result, Tensor, WithDType};
use half::{bf16, f16};
impl Tensor {
fn fmt_dt<T: WithDT... | candle/candle-core/src/display.rs/0 | {
"file_path": "candle/candle-core/src/display.rs",
"repo_id": "candle",
"token_count": 9761
} | 23 |
#![allow(unused)]
use super::GgmlDType;
use crate::{CudaDevice, CudaStorage, Error, Result};
pub struct QCudaStorage {
dtype: GgmlDType,
device: CudaDevice,
}
impl QCudaStorage {
pub fn zeros(_: &CudaDevice, _: usize, _: GgmlDType) -> Result<Self> {
Err(Error::NotCompiledWithCudaSupport)
}
... | candle/candle-core/src/quantized/dummy_cuda.rs/0 | {
"file_path": "candle/candle-core/src/quantized/dummy_cuda.rs",
"repo_id": "candle",
"token_count": 594
} | 24 |
use crate::Layout;
/// An iterator over offset position for items of an N-dimensional arrays stored in a
/// flat buffer using some potential strides.
#[derive(Debug)]
pub struct StridedIndex<'a> {
next_storage_index: Option<usize>,
multi_index: Vec<usize>,
dims: &'a [usize],
stride: &'a [usize],
}
im... | candle/candle-core/src/strided_index.rs/0 | {
"file_path": "candle/candle-core/src/strided_index.rs",
"repo_id": "candle",
"token_count": 1094
} | 25 |
import torch
from collections import OrderedDict
# Write a trivial tensor to a pt file
a= torch.tensor([[1,2,3,4], [5,6,7,8]])
o = OrderedDict()
o["test"] = a
# Write a trivial tensor to a pt file
torch.save(o, "test.pt")
###############################################################################################... | candle/candle-core/tests/pth.py/0 | {
"file_path": "candle/candle-core/tests/pth.py",
"repo_id": "candle",
"token_count": 441
} | 26 |
//! The CIFAR-10 dataset.
//!
//! The files can be downloaded from the following page:
//! <https://www.cs.toronto.edu/~kriz/cifar.html>
//! The binary version of the dataset is used.
use crate::vision::Dataset;
use candle::{DType, Device, Error, Result, Tensor};
use hf_hub::{api::sync::Api, Repo, RepoType};
use parque... | candle/candle-datasets/src/vision/cifar.rs/0 | {
"file_path": "candle/candle-datasets/src/vision/cifar.rs",
"repo_id": "candle",
"token_count": 2139
} | 27 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::{Error as E, Result};
use clap::Parser;
use candle_transformers::models::chatglm::{Config, Model};
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::gene... | candle/candle-examples/examples/chatglm/main.rs/0 | {
"file_path": "candle/candle-examples/examples/chatglm/main.rs",
"repo_id": "candle",
"token_count": 3423
} | 28 |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use std::fmt::Display;
use std::path::PathBuf;
use anyhow::bail;
use anyhow::{Error as E, Result};
use candle::{Device, Tensor};
use candle_nn::ops::softmax;
use candle_nn::VarBuilder;
use candle_transform... | candle/candle-examples/examples/debertav2/main.rs/0 | {
"file_path": "candle/candle-examples/examples/debertav2/main.rs",
"repo_id": "candle",
"token_count": 6817
} | 29 |
use anyhow::{Context, Result};
use std::sync::{Arc, Mutex};
pub const SAMPLE_RATE: usize = 24_000;
pub(crate) struct AudioOutputData_ {
resampled_data: std::collections::VecDeque<f32>,
resampler: rubato::FastFixedIn<f32>,
output_buffer: Vec<f32>,
input_buffer: Vec<f32>,
input_len: usize,
}
impl A... | candle/candle-examples/examples/encodec/audio_io.rs/0 | {
"file_path": "candle/candle-examples/examples/encodec/audio_io.rs",
"repo_id": "candle",
"token_count": 4796
} | 30 |
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::generation::LogitsProcessor;
use candle_transformers::models::glm4::*;
use clap::Parser;
use hf_hub::{Repo, RepoType};
use tokenizers::Tokenizer;
struct TextGeneration {
model: Model,
device: Device,
tokenizer: Tokenize... | candle/candle-examples/examples/glm4/main.rs/0 | {
"file_path": "candle/candle-examples/examples/glm4/main.rs",
"repo_id": "candle",
"token_count": 3621
} | 31 |
pub const DEFAULT_IMAGE_TOKEN: &str = "<image>";
pub const DEFAULT_IM_START_TOKEN: &str = "<im_start>";
pub const DEFAULT_IM_END_TOKEN: &str = "<im_end>";
pub const IMAGE_PLACEHOLDER: &str = "<image-placeholder>";
| candle/candle-examples/examples/llava/constants.rs/0 | {
"file_path": "candle/candle-examples/examples/llava/constants.rs",
"repo_id": "candle",
"token_count": 86
} | 32 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 7