text
stringlengths
5
409k
id
stringlengths
14
178
metadata
dict
__index_level_0__
int64
0
572
# 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/src/accelerate/test_utils/scripts/external_deps/test_pippy.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_pippy.py", "repo_id": "accelerate", "token_count": 1697 }
10
# 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/constants.py/0
{ "file_path": "accelerate/src/accelerate/utils/constants.py", "repo_id": "accelerate", "token_count": 1404 }
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/tqdm.py/0
{ "file_path": "accelerate/src/accelerate/utils/tqdm.py", "repo_id": "accelerate", "token_count": 553 }
12
compute_environment: LOCAL_MACHINE debug: false distributed_type: MULTI_CPU downcast_bf16: 'no' ipex_config: ipex: true machine_rank: 0 main_process_ip: 127.0.0.1 main_process_port: 29500 main_training_function: main mixed_precision: 'no' mpirun_config: mpirun_ccl: '1' mpirun_hostfile: /home/user/hostfile num_mac...
accelerate/tests/test_configs/0_28_0_mpi.yaml/0
{ "file_path": "accelerate/tests/test_configs/0_28_0_mpi.yaml", "repo_id": "accelerate", "token_count": 193 }
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_metrics.py/0
{ "file_path": "accelerate/tests/test_metrics.py", "repo_id": "accelerate", "token_count": 744 }
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/xla_spawn.py/0
{ "file_path": "accelerate/tests/xla_spawn.py", "repo_id": "accelerate", "token_count": 1070 }
15
# Introduction ![Bonus Unit 1 Thumbnail](https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/bonus-unit1/thumbnail.jpg) Welcome to this first **Bonus Unit**, where you'll learn to **fine-tune a Large Language Model (LLM) for function calling**. In terms of LLMs, function calling is quickly be...
agents-course/units/en/bonus-unit1/introduction.mdx/0
{ "file_path": "agents-course/units/en/bonus-unit1/introduction.mdx", "repo_id": "agents-course", "token_count": 773 }
16
--- ### Q1: What is an Agent? Which of the following best describes an AI Agent? <Question choices={[ { text: "A system that solely processes static text, without any inherent mechanism to interact dynamically with its surroundings or execute meaningful actions.", explain: "An Agent must be able to take an action and ...
agents-course/units/en/unit1/quiz1.mdx/0
{ "file_path": "agents-course/units/en/unit1/quiz1.mdx", "repo_id": "agents-course", "token_count": 1564 }
17
{ "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" }, "python.formatting.provider": "none", "python.testing.pytestArgs": [ "candle-pyo3" ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true }
candle/.vscode/settings.json/0
{ "file_path": "candle/.vscode/settings.json", "repo_id": "candle", "token_count": 123 }
18
# Creating a WASM app
candle/candle-book/src/apps/wasm.md/0
{ "file_path": "candle/candle-book/src/apps/wasm.md", "repo_id": "candle", "token_count": 7 }
19
# Fine-tuning
candle/candle-book/src/training/finetuning.md/0
{ "file_path": "candle/candle-book/src/training/finetuning.md", "repo_id": "candle", "token_count": 6 }
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(a: &Tensor) { a.sqrt().unwrap(); } fn run_unary_benchmark(c: &mut Criterion, device: &Device, dtype: DType, name: &...
candle/candle-core/benches/benchmarks/unary.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/unary.rs", "repo_id": "candle", "token_count": 656 }
21
use super::Cpu; use core::arch::wasm32::*; pub struct CurrentCpu {} const STEP: usize = 16; const EPR: usize = 4; const ARR: usize = STEP / EPR; impl Cpu<ARR> for CurrentCpu { type Unit = v128; type Array = [v128; ARR]; const STEP: usize = STEP; const EPR: usize = EPR; fn n() -> usize { ...
candle/candle-core/src/cpu/simd128.rs/0
{ "file_path": "candle/candle-core/src/cpu/simd128.rs", "repo_id": "candle", "token_count": 839 }
22
//! Tensor Layouts including contiguous or sparse strides use crate::{Error, Result, Shape}; #[derive(Debug, PartialEq, Eq, Clone)] pub struct Layout { shape: Shape, // The strides are given in number of elements and not in bytes. stride: Vec<usize>, start_offset: usize, } impl Layout { pub fn new...
candle/candle-core/src/layout.rs/0
{ "file_path": "candle/candle-core/src/layout.rs", "repo_id": "candle", "token_count": 4454 }
23
//! Code for GGML and GGUF files use crate::{Context, CpuStorage, DType, Device, Result, Shape, Storage, Tensor}; use k_quants::*; use std::borrow::Cow; #[cfg(target_feature = "avx")] pub mod avx; mod dummy_cuda; mod dummy_metal; pub mod ggml_file; pub mod gguf_file; pub mod k_quants; #[cfg(feature = "metal")] pub mod...
candle/candle-core/src/quantized/mod.rs/0
{ "file_path": "candle/candle-core/src/quantized/mod.rs", "repo_id": "candle", "token_count": 9452 }
24
use anyhow::Result; use candle_core::{test_device, test_utils, Device, IndexOp, Tensor}; /* This test is based on the following script. import torch torch.manual_seed(4242) t = torch.randn((1, 4, 5)) w = torch.randn((2, 4, 3)) print(t.flatten()) print(w.flatten()) res = torch.nn.functional.conv1d(t, w) print(res.flat...
candle/candle-core/tests/conv_tests.rs/0
{ "file_path": "candle/candle-core/tests/conv_tests.rs", "repo_id": "candle", "token_count": 22766 }
25
# candle-based Experimental, not instruction-tuned small LLM from the Hazy Research group, combining local and linear attention layers. [Blogpost](https://hazyresearch.stanford.edu/blog/2024-03-03-based) [Simple linear attention language models balance the recall-throughput tradeoff](https://arxiv.org/abs/2402.18668...
candle/candle-examples/examples/based/README.md/0
{ "file_path": "candle/candle-examples/examples/based/README.md", "repo_id": "candle", "token_count": 243 }
26
# Colpali [HuggingFace Model Card](https://huggingface.co/vidore/colpali-v1.2-merged) ``` wget https://arxiv.org/pdf/1706.03762.pdf cargo run --features cuda,pdf2image --release --example colpali -- --prompt "What is Positional Encoding" --pdf "1706.03762.pdf" ``` ``` Prompt: what is position encoding? top 3 page nu...
candle/candle-examples/examples/colpali/README.md/0
{ "file_path": "candle/candle-examples/examples/colpali/README.md", "repo_id": "candle", "token_count": 153 }
27
# candle-dinov2 [DINOv2](https://github.com/facebookresearch/dinov2) is a computer vision model. In this example, it is used as an ImageNet classifier: the model returns the probability for the image to belong to each of the 1000 ImageNet categories. ## Running some example ```bash cargo run --example dinov2 --relea...
candle/candle-examples/examples/dinov2/README.md/0
{ "file_path": "candle/candle-examples/examples/dinov2/README.md", "repo_id": "candle", "token_count": 250 }
28
// TODO: Add an offline mode. #[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use anyhow::{Error as E, Result}; use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::generation::LogitsProcessor; use clap::Parser; use h...
candle/candle-examples/examples/falcon/main.rs/0
{ "file_path": "candle/candle-examples/examples/falcon/main.rs", "repo_id": "candle", "token_count": 2723 }
29
#[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::helium::{Config, Model}; use candle::{DType, Device, Tensor}; use candle_examples::token_output_stream::TokenOutputStre...
candle/candle-examples/examples/helium/main.rs/0
{ "file_path": "candle/candle-examples/examples/helium/main.rs", "repo_id": "candle", "token_count": 4118 }
30
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::{Error as E, Result}; use clap::{Parser, ValueEnum}; mod model; use model::{Config, Model}; use candle::{DType, Device, Module, Tensor}; use candle_examples::token_output_stream::TokenOutputSt...
candle/candle-examples/examples/mamba-minimal/main.rs/0
{ "file_path": "candle/candle-examples/examples/mamba-minimal/main.rs", "repo_id": "candle", "token_count": 4087 }
31
// This should reach 91.5% accuracy. #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use rand::prelude::*; use candle::{DType, Result, Tensor, D}; use candle_nn::{loss, ops, Conv2d, Linear, Module, ModuleT, Optimizer, VarB...
candle/candle-examples/examples/mnist-training/main.rs/0
{ "file_path": "candle/candle-examples/examples/mnist-training/main.rs", "repo_id": "candle", "token_count": 4094 }
32
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::{Error as E, Result}; use clap::{Parser, ValueEnum}; use candle_transformers::models::olmo::{Config, Model as OLMo}; use candle::{DType, Device, Tensor}; use candle_examples::token_output_stre...
candle/candle-examples/examples/olmo/main.rs/0
{ "file_path": "candle/candle-examples/examples/olmo/main.rs", "repo_id": "candle", "token_count": 4042 }
33
# candle-quantized-t5 ## Seq2Seq example This example uses a quantized version of the t5 model. ```bash $ cargo run --example quantized-t5 --release -- --prompt "translate to German: A beautiful candle." ... Eine schöne Kerze. ``` ## Generating Quantized weight files The weight file is automatically retrieved fro...
candle/candle-examples/examples/quantized-t5/README.md/0
{ "file_path": "candle/candle-examples/examples/quantized-t5/README.md", "repo_id": "candle", "token_count": 683 }
34
//! Vectorized version of the gym environment. use candle::{DType, Device, Result, Tensor}; use pyo3::prelude::*; #[allow(unused)] #[derive(Debug)] pub struct Step { pub obs: Tensor, pub reward: Tensor, pub is_done: Tensor, } #[allow(unused)] pub struct VecGymEnv { env: PyObject, action_space: usi...
candle/candle-examples/examples/reinforcement-learning/vec_gym_env.rs/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/vec_gym_env.rs", "repo_id": "candle", "token_count": 1572 }
35
#[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use candle_transformers::models::stable_diffusion; use std::ops::Div; use anyhow::{Error as E, Result}; use candle::{DType, Device, IndexOp, Module, Tensor, D}; use clap::Parser; use rand::Rng; use stable_...
candle/candle-examples/examples/stable-diffusion/main.rs/0
{ "file_path": "candle/candle-examples/examples/stable-diffusion/main.rs", "repo_id": "candle", "token_count": 14021 }
36
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::Parser; use candle::{DType, IndexOp, D}; use candle_nn::VarBuilder; use candle_transformers::models::vit; #[derive(Parser)] struct Args { #[arg(long)] model: Option<String>, #[arg(l...
candle/candle-examples/examples/vit/main.rs/0
{ "file_path": "candle/candle-examples/examples/vit/main.rs", "repo_id": "candle", "token_count": 762 }
37
use candle::{DType, Device, IndexOp, Result, Tensor}; use candle_nn::{batch_norm, conv2d, conv2d_no_bias, Func, Module, VarBuilder}; use std::collections::BTreeMap; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; #[derive(Debug)] struct Block { block_type: String, parameters: BTreeMa...
candle/candle-examples/examples/yolo-v3/darknet.rs/0
{ "file_path": "candle/candle-examples/examples/yolo-v3/darknet.rs", "repo_id": "candle", "token_count": 5395 }
38
pub mod audio; pub mod bs1770; pub mod coco_classes; pub mod imagenet; pub mod token_output_stream; pub mod wav; use candle::utils::{cuda_is_available, metal_is_available}; use candle::{Device, Result, Tensor}; pub fn device(cpu: bool) -> Result<Device> { if cpu { Ok(Device::Cpu) } else if cuda_is_avai...
candle/candle-examples/src/lib.rs/0
{ "file_path": "candle/candle-examples/src/lib.rs", "repo_id": "candle", "token_count": 2878 }
39
/****************************************************************************** * Copyright (c) 2024, Tri Dao. ******************************************************************************/ #pragma once #include "cute/tensor.hpp" #include "cutlass/cutlass.h" #include "cutlass/layout/layout.h" #include <cutlass/nu...
candle/candle-flash-attn/kernels/kernel_traits.h/0
{ "file_path": "candle/candle-flash-attn/kernels/kernel_traits.h", "repo_id": "candle", "token_count": 7903 }
40
#include "binary_op_macros.cuh" #include<stdint.h> #if __CUDA_ARCH__ >= 800 BINARY_OP(__nv_bfloat16, badd_bf16, x + y) BINARY_OP(__nv_bfloat16, bdiv_bf16, x / y) BINARY_OP(__nv_bfloat16, bmul_bf16, x * y) BINARY_OP(__nv_bfloat16, bsub_bf16, x - y) BINARY_OP(__nv_bfloat16, bmaximum_bf16, maxg(x, y)) BINARY_OP(__nv_bflo...
candle/candle-kernels/src/binary.cu/0
{ "file_path": "candle/candle-kernels/src/binary.cu", "repo_id": "candle", "token_count": 2144 }
41
use anyhow::Result; use candle_metal_kernels::GemmDType; /// This example contains some simple benchmarks so that it's easy to run them in perf etc. use clap::{Parser, Subcommand}; use half::f16; fn run_gemm(f32: bool, n: usize) -> Result<()> { const WARMUP_ITERS: usize = 2; const MIN_DUR: f64 = 4.; let d...
candle/candle-metal-kernels/examples/metal_benchmarks.rs/0
{ "file_path": "candle/candle-metal-kernels/examples/metal_benchmarks.rs", "repo_id": "candle", "token_count": 1833 }
42
use crate::utils::{BufferOffset, EncoderProvider}; use crate::{set_params, DType, Kernels, MetalKernelError, Source}; use metal::{Buffer, ComputeCommandEncoderRef, Device, MTLResourceOptions, MTLSize}; #[allow(clippy::too_many_arguments)] pub fn call_arg_sort( device: &Device, ep: impl EncoderProvider, ker...
candle/candle-metal-kernels/src/sort.rs/0
{ "file_path": "candle/candle-metal-kernels/src/sort.rs", "repo_id": "candle", "token_count": 4875 }
43
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle::{DType, Device, Tensor}; use candle_nn::ops::softmax_last_dim; use criterion::Throughput; use criterion::{black_box, criterion_group, Criterion}; use std::time::Instant; fn run(input: &Tensor) { let _ = softmax_last_dim(&input).unwrap(); } cons...
candle/candle-nn/benches/benchmarks/softmax.rs/0
{ "file_path": "candle/candle-nn/benches/benchmarks/softmax.rs", "repo_id": "candle", "token_count": 662 }
44
//! Tensor ops. //! use candle::{CpuStorage, DType, Layout, Module, Result, Shape, Tensor, D}; use rayon::prelude::*; /// Applies the softmax function to the input tensor, rescaling the element so that elements on /// a slice of fixed index on dimension `dim` are between 0 and 1 and sum to 1. /// /// ```rust /// use ...
candle/candle-nn/src/ops.rs/0
{ "file_path": "candle/candle-nn/src/ops.rs", "repo_id": "candle", "token_count": 23996 }
45
#[cfg(feature = "metal")] mod metal_sdpa_tests { use candle::{DType, Device, Result, Shape, Tensor}; use rand::SeedableRng; use rand_distr::Distribution; use std::ops::{Div, Mul}; fn randn<S: Into<Shape>>( rng: &mut rand::rngs::StdRng, shape: S, dev: &Device, ) -> Result...
candle/candle-nn/tests/sdpa.rs/0
{ "file_path": "candle/candle-nn/tests/sdpa.rs", "repo_id": "candle", "token_count": 3762 }
46
# Generated content DO NOT EDIT from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence from os import PathLike from candle.typing import _ArrayLike, Device, Scalar, Index, Shape class bf16(DType): pass @staticmethod def cat(tensors: List[Tensor], dim: int) -> Tensor: """ Concatenat...
candle/candle-pyo3/py_src/candle/__init__.pyi/0
{ "file_path": "candle/candle-pyo3/py_src/candle/__init__.pyi", "repo_id": "candle", "token_count": 5844 }
47
# Generated content DO NOT EDIT from .. import utils cuda_is_available = utils.cuda_is_available get_num_threads = utils.get_num_threads has_accelerate = utils.has_accelerate has_mkl = utils.has_mkl load_ggml = utils.load_ggml load_gguf = utils.load_gguf load_safetensors = utils.load_safetensors save_gguf = utils.save...
candle/candle-pyo3/py_src/candle/utils/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/utils/__init__.py", "repo_id": "candle", "token_count": 150 }
48
import candle from candle import Tensor from candle.utils import cuda_is_available from candle.testing import assert_equal import pytest def test_tensor_can_be_constructed(): t = Tensor(42.0) assert t.values() == 42.0 def test_tensor_can_be_constructed_from_list(): t = Tensor([3.0, 1, 4, 1, 5, 9, 2, 6])...
candle/candle-pyo3/tests/native/test_tensor.py/0
{ "file_path": "candle/candle-pyo3/tests/native/test_tensor.py", "repo_id": "candle", "token_count": 4688 }
49
//! Contrastive Language-Image Pre-Training //! //! Contrastive Language-Image Pre-Training (CLIP) is an architecture trained on //! pairs of images with related texts. //! //! - 💻 [GH Link](https://github.com/openai/CLIP) //! - 💻 Transformers Python [reference implementation](https://github.com/huggingface/transform...
candle/candle-transformers/src/models/clip/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/clip/mod.rs", "repo_id": "candle", "token_count": 2243 }
50
//! EnCodec neural audio codec based on the Encodec implementation. //! //! See ["High Fidelity Neural Audio Compression"](https://arxiv.org/abs/2210.13438) //! //! Based on implementation from [huggingface/transformers](https://github.com/huggingface/transformers/blob/main/src/transformers/models/encodec/modeling_enco...
candle/candle-transformers/src/models/encodec.rs/0
{ "file_path": "candle/candle-transformers/src/models/encodec.rs", "repo_id": "candle", "token_count": 12744 }
51
//! Llama inference implementation. //! //! See ["LLaMA: Open and Efficient Foundation Language Models"](https://arxiv.org/abs/2302.13971) //! //! Implementation based on Hugging Face's [transformers](https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/modeling_llama.py) use super::with...
candle/candle-transformers/src/models/llama.rs/0
{ "file_path": "candle/candle-transformers/src/models/llama.rs", "repo_id": "candle", "token_count": 9761 }
52
//! MixFormer (Microsoft's Phi Architecture) //! //! See "Textbooks Are All You Need II: phi-1.5 technical report", Lin et al. 2023 //! - [Arxiv](https://arxiv.org/abs/2309.05463) //! - [Github](https://huggingface.co/microsoft/phi-1_5) //! use crate::models::with_tracing::{linear, Embedding as E, Linear}; /// MixForm...
candle/candle-transformers/src/models/mixformer.rs/0
{ "file_path": "candle/candle-transformers/src/models/mixformer.rs", "repo_id": "candle", "token_count": 8060 }
53
use super::embedding::Model as EmbeddingModel; use crate::models::{ mistral::Config, with_tracing::{layer_norm, linear, linear_no_bias, LayerNorm, Linear}, }; use candle::{DType, Device, Result, Tensor, D}; use candle_nn::{ops::softmax_last_dim, LayerNormConfig, Module, VarBuilder}; // Geglu and feedforward fr...
candle/candle-transformers/src/models/nvembed_v2/model.rs/0
{ "file_path": "candle/candle-transformers/src/models/nvembed_v2/model.rs", "repo_id": "candle", "token_count": 3730 }
54
//! Quantized MetaVoice model implementation. //! //! MetaVoice is a conditional text-to-speech model based on a transformer architecture. //! This implementation provides quantization for reduced memory and compute. //! //! Key characteristics: //! - Transformer-based autoregressive decoder //! - Speaker conditioning ...
candle/candle-transformers/src/models/quantized_metavoice.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_metavoice.rs", "repo_id": "candle", "token_count": 5192 }
55
//! RepVGG inference implementation //! //! Key characteristics: //! - Efficient inference architecture through structural reparameterization //! - Single 3x3 conv layer after fusing 3x3 branch, 1x1 branch and identity branch //! - Different configurations including a0-a2, b0-b3 and variants with group convolutions //!...
candle/candle-transformers/src/models/repvgg.rs/0
{ "file_path": "candle/candle-transformers/src/models/repvgg.rs", "repo_id": "candle", "token_count": 4487 }
56
use super::schedulers::{betas_for_alpha_bar, BetaSchedule, PredictionType}; use candle::{Result, Tensor}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum DDPMVarianceType { FixedSmall, FixedSmallLog, FixedLarge, FixedLargeLog, Learned, } impl Default for DDPMVarianceType { fn default() -> Self...
candle/candle-transformers/src/models/stable_diffusion/ddpm.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/ddpm.rs", "repo_id": "candle", "token_count": 3666 }
57
//! VGG-16 model implementation. //! //! VGG-16 is a convolutional neural network architecture. It consists of 13 //! convolutional layers followed by 3 fully connected layers. //! //! Key characteristics: //! - Conv layers with 3x3 filters //! - Max pooling after every 2-3 conv layers //! - Three fully connected layer...
candle/candle-transformers/src/models/vgg.rs/0
{ "file_path": "candle/candle-transformers/src/models/vgg.rs", "repo_id": "candle", "token_count": 4390 }
58
//! Bounding Boxes and Intersection //! //! This module provides functionality for handling bounding boxes and their manipulation, //! particularly in the context of object detection. It includes tools for calculating //! intersection over union (IoU) and non-maximum suppression (NMS). /// A bounding box around an obj...
candle/candle-transformers/src/object_detection.rs/0
{ "file_path": "candle/candle-transformers/src/object_detection.rs", "repo_id": "candle", "token_count": 1950 }
59
use candle::{Device, Tensor}; use candle_transformers::generation::LogitsProcessor; use candle_wasm_example_llama2::worker::{Model as M, ModelData}; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct Model { inner: M, logits_processor: LogitsProcessor, tokens: Vec<u32>, repeat_penalty: f32, } im...
candle/candle-wasm-examples/llama2-c/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/src/bin/m.rs", "repo_id": "candle", "token_count": 1807 }
60
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Phi 1.5 / Phi 2.0 Rust/WASM</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> ...
candle/candle-wasm-examples/phi/index.html/0
{ "file_path": "candle/candle-wasm-examples/phi/index.html", "repo_id": "candle", "token_count": 9818 }
61
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle T5</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> @import ur...
candle/candle-wasm-examples/t5/index.html/0
{ "file_path": "candle/candle-wasm-examples/t5/index.html", "repo_id": "candle", "token_count": 4724 }
62
pub const LANGUAGES: [(&str, &str); 99] = [ ("en", "english"), ("zh", "chinese"), ("de", "german"), ("es", "spanish"), ("ru", "russian"), ("ko", "korean"), ("fr", "french"), ("ja", "japanese"), ("pt", "portuguese"), ("tr", "turkish"), ("pl", "polish"), ("ca", "catalan"), ...
candle/candle-wasm-examples/whisper/src/languages.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/languages.rs", "repo_id": "candle", "token_count": 1175 }
63
use crate::model::{report_detect, report_pose, Bbox, Multiples, YoloV8, YoloV8Pose}; use candle::{DType, Device, Result, Tensor}; use candle_nn::{Module, VarBuilder}; use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; use yew_agent::{HandlerId, Public, WorkerLink}; #[wasm_bindgen] extern "C" { // U...
candle/candle-wasm-examples/yolo/src/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/worker.rs", "repo_id": "candle", "token_count": 4075 }
64
# Add patterns of files dvc should ignore, which could improve # the performance. Learn more at # https://dvc.org/doc/user-guide/dvcignore
datasets/.dvcignore/0
{ "file_path": "datasets/.dvcignore", "repo_id": "datasets", "token_count": 40 }
65
.PHONY: quality style test check_dirs := tests src benchmarks utils # Check that source code meets quality standards quality: ruff check $(check_dirs) setup.py # linter ruff format --check $(check_dirs) setup.py # formatter # Format source code automatically style: ruff check --fix $(check_dirs) setup.py # lin...
datasets/Makefile/0
{ "file_path": "datasets/Makefile", "repo_id": "datasets", "token_count": 148 }
66
<!--- Copyright 2020 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 ...
datasets/docs/README.md/0
{ "file_path": "datasets/docs/README.md", "repo_id": "datasets", "token_count": 3068 }
67
# Create a dataset Sometimes, you may need to create a dataset if you're working with your own data. Creating a dataset with 🤗 Datasets confers all the advantages of the library to your dataset: fast loading and processing, [stream enormous datasets](stream), [memory-mapping](https://huggingface.co/course/chapter5/4?...
datasets/docs/source/create_dataset.mdx/0
{ "file_path": "datasets/docs/source/create_dataset.mdx", "repo_id": "datasets", "token_count": 2035 }
68
# Load Your data can be stored in various places; they can be on your local machine's disk, in a Github repository, and in in-memory data structures like Python dictionaries and Pandas DataFrames. Wherever a dataset is stored, 🤗 Datasets can help you load it. This guide will show you how to load a dataset from: - T...
datasets/docs/source/loading.mdx/0
{ "file_path": "datasets/docs/source/loading.mdx", "repo_id": "datasets", "token_count": 5921 }
69
# Troubleshooting This guide aims to provide you the tools and knowledge required to navigate some common issues. If the suggestions listed in this guide do not cover your such situation, please refer to the [Asking for Help](#asking-for-help) section to learn where to find help with your specific issue. ## Issues w...
datasets/docs/source/troubleshoot.mdx/0
{ "file_path": "datasets/docs/source/troubleshoot.mdx", "repo_id": "datasets", "token_count": 1470 }
70
# Lint as: python3 """HuggingFace/Datasets is an open library of datasets. Note: VERSION needs to be formatted following the MAJOR.MINOR.PATCH convention (we need to follow this convention to be able to retrieve versioned scripts) Simple check list for release from AllenNLP repo: https://github.com/allenai/all...
datasets/setup.py/0
{ "file_path": "datasets/setup.py", "repo_id": "datasets", "token_count": 3861 }
71
import contextlib import copy import fnmatch import json import math import posixpath import re from io import BytesIO from pathlib import Path from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union import fsspec import numpy as np from fsspec.core import url_to_fs from huggingface_hub import ( ...
datasets/src/datasets/dataset_dict.py/0
{ "file_path": "datasets/src/datasets/dataset_dict.py", "repo_id": "datasets", "token_count": 48673 }
72
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # 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 # # U...
datasets/src/datasets/formatting/__init__.py/0
{ "file_path": "datasets/src/datasets/formatting/__init__.py", "repo_id": "datasets", "token_count": 1900 }
73
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class SparkDatasetReader(AbstractDatasetReader): """A dataset reader that reads from a Spark DataFrame. ...
datasets/src/datasets/io/spark.py/0
{ "file_path": "datasets/src/datasets/io/spark.py", "repo_id": "datasets", "token_count": 787 }
74
from typing import Any, Dict, List, Optional, Union from huggingface_hub.utils import get_session from .. import config from ..exceptions import DatasetsError from .file_utils import ( get_authentication_headers_for_url, ) from .logging import get_logger logger = get_logger(__name__) class DatasetViewerError(...
datasets/src/datasets/utils/_dataset_viewer.py/0
{ "file_path": "datasets/src/datasets/utils/_dataset_viewer.py", "repo_id": "datasets", "token_count": 1901 }
75
{ "language": [ "found", "crowdsourced", "expert-generated", "machine-generated", "other" ], "annotations": [ "found", "crowdsourced", "expert-generated", "machine-generated", "no-annotation", "other" ] }
datasets/src/datasets/utils/resources/creators.json/0
{ "file_path": "datasets/src/datasets/utils/resources/creators.json", "repo_id": "datasets", "token_count": 119 }
76
import os import random import tempfile import unittest import numpy as np import pandas as pd import pyarrow as pa import pytest from absl.testing import parameterized import datasets from datasets.arrow_writer import ArrowWriter from datasets.features import Array2D, Array3D, Array4D, Array5D, Value from datasets.f...
datasets/tests/features/test_array_xd.py/0
{ "file_path": "datasets/tests/features/test_array_xd.py", "repo_id": "datasets", "token_count": 9827 }
77
import contextlib import os import sqlite3 import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def _check_sql_dataset(dataset, expected_f...
datasets/tests/io/test_sql.py/0
{ "file_path": "datasets/tests/io/test_sql.py", "repo_id": "datasets", "token_count": 1628 }
78
import asyncio import contextlib import copy import itertools import json import os import pickle import re import sys import tempfile import time from functools import partial from pathlib import Path from unittest import TestCase from unittest.mock import MagicMock, patch import numpy as np import numpy.testing as n...
datasets/tests/test_arrow_dataset.py/0
{ "file_path": "datasets/tests/test_arrow_dataset.py", "repo_id": "datasets", "token_count": 119548 }
79
import datetime from pathlib import Path from unittest import TestCase import numpy as np import pandas as pd import pyarrow as pa import pytest from datasets import Audio, Features, Image, IterableDataset from datasets.formatting import NumpyFormatter, PandasFormatter, PythonFormatter, query_table from datasets.form...
datasets/tests/test_formatting.py/0
{ "file_path": "datasets/tests/test_formatting.py", "repo_id": "datasets", "token_count": 21450 }
80
import copy import pickle from decimal import Decimal from functools import partial from typing import List, Union from unittest.mock import MagicMock import numpy as np import pyarrow as pa import pytest from datasets.features import Array2D, ClassLabel, Features, Image, LargeList, Sequence, Value from datasets.feat...
datasets/tests/test_table.py/0
{ "file_path": "datasets/tests/test_table.py", "repo_id": "datasets", "token_count": 24661 }
81
import argparse import sys sys.path.append(".") from base_classes import ImageToImageBenchmark, TurboImageToImageBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="Lykon/DreamShaper", choices...
diffusers/benchmarks/benchmark_sd_img.py/0
{ "file_path": "diffusers/benchmarks/benchmark_sd_img.py", "repo_id": "diffusers", "token_count": 403 }
82
<!--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 applicable law or agreed...
diffusers/docs/source/en/api/loaders/single_file.md/0
{ "file_path": "diffusers/docs/source/en/api/loaders/single_file.md", "repo_id": "diffusers", "token_count": 804 }
83
<!--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 applicable law or agreed...
diffusers/docs/source/en/api/pipelines/ddim.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/ddim.md", "repo_id": "diffusers", "token_count": 477 }
84
<!--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 applicable law or agreed...
diffusers/docs/source/en/api/pipelines/stable_diffusion/sdxl_turbo.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/sdxl_turbo.md", "repo_id": "diffusers", "token_count": 677 }
85
<!--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 applicable law or agreed...
diffusers/docs/source/en/api/utilities.md/0
{ "file_path": "diffusers/docs/source/en/api/utilities.md", "repo_id": "diffusers", "token_count": 387 }
86
<!--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 applicable law or agreed...
diffusers/docs/source/en/optimization/mps.md/0
{ "file_path": "diffusers/docs/source/en/optimization/mps.md", "repo_id": "diffusers", "token_count": 1079 }
87
# Adapt a model to a new task Many diffusion systems share the same components, allowing you to adapt a pretrained model for one task to an entirely different task. This guide will show you how to adapt a pretrained text-to-image model for inpainting by initializing and modifying the architecture of a pretrained [`UN...
diffusers/docs/source/en/training/adapt_a_model.md/0
{ "file_path": "diffusers/docs/source/en/training/adapt_a_model.md", "repo_id": "diffusers", "token_count": 802 }
88
<!--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 applicable law or agree...
diffusers/docs/source/en/training/text_inversion.md/0
{ "file_path": "diffusers/docs/source/en/training/text_inversion.md", "repo_id": "diffusers", "token_count": 4395 }
89
<!--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 applicable law or agreed...
diffusers/docs/source/en/using-diffusers/custom_pipeline_overview.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/custom_pipeline_overview.md", "repo_id": "diffusers", "token_count": 6385 }
90
<!--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 applicable law or agreed...
diffusers/docs/source/en/using-diffusers/write_own_pipeline.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/write_own_pipeline.md", "repo_id": "diffusers", "token_count": 4156 }
91
<!--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 applicable law or agreed...
diffusers/docs/source/ko/installation.md/0
{ "file_path": "diffusers/docs/source/ko/installation.md", "repo_id": "diffusers", "token_count": 3689 }
92
# 여러 GPU를 사용한 분산 추론 분산 설정에서는 여러 개의 프롬프트를 동시에 생성할 때 유용한 🤗 [Accelerate](https://huggingface.co/docs/accelerate/index) 또는 [PyTorch Distributed](https://pytorch.org/tutorials/beginner/dist_overview.html)를 사용하여 여러 GPU에서 추론을 실행할 수 있습니다. 이 가이드에서는 분산 추론을 위해 🤗 Accelerate와 PyTorch Distributed를 사용하는 방법을 보여드립니다. ## 🤗 Acceler...
diffusers/docs/source/ko/training/distributed_inference.md/0
{ "file_path": "diffusers/docs/source/ko/training/distributed_inference.md", "repo_id": "diffusers", "token_count": 2616 }
93
<!--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 applicable law or agreed...
diffusers/docs/source/ko/using-diffusers/inpaint.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/inpaint.md", "repo_id": "diffusers", "token_count": 1656 }
94
<!--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 applicable law or agreed...
diffusers/docs/source/pt/index.md/0
{ "file_path": "diffusers/docs/source/pt/index.md", "repo_id": "diffusers", "token_count": 1653 }
95
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 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/LI...
diffusers/examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py/0
{ "file_path": "diffusers/examples/advanced_diffusion_training/train_dreambooth_lora_sd15_advanced.py", "repo_id": "diffusers", "token_count": 39442 }
96
# 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...
diffusers/examples/community/pipeline_animatediff_img2video.py/0
{ "file_path": "diffusers/examples/community/pipeline_animatediff_img2video.py", "repo_id": "diffusers", "token_count": 20616 }
97
# Copyright 2024 The Intel Labs Team Authors and 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 ...
diffusers/examples/community/pipeline_stable_diffusion_upscale_ldm3d.py/0
{ "file_path": "diffusers/examples/community/pipeline_stable_diffusion_upscale_ldm3d.py", "repo_id": "diffusers", "token_count": 17046 }
98
""" modified based on diffusion library from Huggingface: https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py """ import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextMod...
diffusers/examples/community/seed_resize_stable_diffusion.py/0
{ "file_path": "diffusers/examples/community/seed_resize_stable_diffusion.py", "repo_id": "diffusers", "token_count": 7637 }
99
import types from typing import List, Optional, Tuple, Union import torch from transformers import CLIPTextModelWithProjection, CLIPTokenizer from transformers.models.clip.modeling_clip import CLIPTextModelOutput from diffusers.models import PriorTransformer from diffusers.pipelines import DiffusionPipeline, StableDi...
diffusers/examples/community/stable_unclip.py/0
{ "file_path": "diffusers/examples/community/stable_unclip.py", "repo_id": "diffusers", "token_count": 5488 }
100
# ControlNet training example [Adding Conditional Control to Text-to-Image Diffusion Models](https://arxiv.org/abs/2302.05543) by Lvmin Zhang and Maneesh Agrawala. This example is based on the [training example in the original ControlNet repository](https://github.com/lllyasviel/ControlNet/blob/main/docs/train.md). I...
diffusers/examples/controlnet/README.md/0
{ "file_path": "diffusers/examples/controlnet/README.md", "repo_id": "diffusers", "token_count": 6086 }
101
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 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/LI...
diffusers/examples/research_projects/autoencoderkl/train_autoencoderkl.py/0
{ "file_path": "diffusers/examples/research_projects/autoencoderkl/train_autoencoderkl.py", "repo_id": "diffusers", "token_count": 19142 }
102
import argparse import os import random import torch import torchvision import torchvision.transforms as TS from PIL import Image from ram import inference_ram from ram.models import ram from tqdm import tqdm from transformers import ( AutoModelForZeroShotObjectDetection, AutoProcessor, Blip2ForConditional...
diffusers/examples/research_projects/gligen/make_datasets.py/0
{ "file_path": "diffusers/examples/research_projects/gligen/make_datasets.py", "repo_id": "diffusers", "token_count": 2102 }
103
import argparse import itertools import json import os import random import time from pathlib import Path import torch import torch.nn.functional as F from accelerate import Accelerator from accelerate.utils import ProjectConfiguration from ip_adapter.attention_processor_faceid import LoRAAttnProcessor, LoRAIPAttnProc...
diffusers/examples/research_projects/ip_adapter/tutorial_train_faceid.py/0
{ "file_path": "diffusers/examples/research_projects/ip_adapter/tutorial_train_faceid.py", "repo_id": "diffusers", "token_count": 7145 }
104
# RealFill [RealFill](https://arxiv.org/abs/2309.16668) is a method to personalize text2image inpainting models like stable diffusion inpainting given just a few(1~5) images of a scene. The `train_realfill.py` script shows how to implement the training procedure for stable diffusion inpainting. ## Running locally wi...
diffusers/examples/research_projects/realfill/README.md/0
{ "file_path": "diffusers/examples/research_projects/realfill/README.md", "repo_id": "diffusers", "token_count": 1321 }
105
# Stable Diffusion XL for JAX + TPUv5e [TPU v5e](https://cloud.google.com/blog/products/compute/how-cloud-tpu-v5e-accelerates-large-scale-ai-inference) is a new generation of TPUs from Google Cloud. It is the most cost-effective, versatile, and scalable Cloud TPU to date. This makes them ideal for serving and scaling ...
diffusers/examples/research_projects/sdxl_flax/README.md/0
{ "file_path": "diffusers/examples/research_projects/sdxl_flax/README.md", "repo_id": "diffusers", "token_count": 3344 }
106
# T2I-Adapter training example for Stable Diffusion XL (SDXL) The `train_t2i_adapter_sdxl.py` script shows how to implement the [T2I-Adapter training procedure](https://hf.co/papers/2302.08453) for [Stable Diffusion XL](https://huggingface.co/papers/2307.01952). ## Running locally with PyTorch ### Installing the dep...
diffusers/examples/t2i_adapter/README_sdxl.md/0
{ "file_path": "diffusers/examples/t2i_adapter/README_sdxl.md", "repo_id": "diffusers", "token_count": 1551 }
107
import argparse import torch from diffusers import HunyuanDiT2DModel def main(args): state_dict = torch.load(args.pt_checkpoint_path, map_location="cpu") if args.load_key != "none": try: state_dict = state_dict[args.load_key] except KeyError: raise KeyError( ...
diffusers/scripts/convert_hunyuandit_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_hunyuandit_to_diffusers.py", "repo_id": "diffusers", "token_count": 6144 }
108
import argparse import os import torch from huggingface_hub import snapshot_download from safetensors.torch import load_file from transformers import AutoTokenizer from diffusers import AutoencoderKL, FlowMatchEulerDiscreteScheduler, OmniGenPipeline, OmniGenTransformer2DModel def main(args): # checkpoint from h...
diffusers/scripts/convert_omnigen_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_omnigen_to_diffusers.py", "repo_id": "diffusers", "token_count": 4235 }
109