text
stringlengths
5
409k
id
stringlengths
14
178
metadata
dict
__index_level_0__
int64
0
572
# Best of N sampling: Alternative ways to get better model output without RL based fine-tuning Within the extras module is the `best-of-n` sampler class that serves as an alternative method of generating better model output. As to how it fares against the RL based fine-tuning, please look in the `examples` directory ...
trl/docs/source/best_of_n.md/0
{ "file_path": "trl/docs/source/best_of_n.md", "repo_id": "trl", "token_count": 841 }
510
<div style="text-align: center"> <img src="https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png"> </div> # TRL - Transformer Reinforcement Learning TRL is a full stack library where we provide a set of tools to train transformer language models with Reinforcement Learning, fro...
trl/docs/source/index.md/0
{ "file_path": "trl/docs/source/index.md", "repo_id": "trl", "token_count": 1901 }
511
# Quickstart ## How does it work? Fine-tuning a language model via PPO consists of roughly three steps: 1. **Rollout**: The language model generates a response or continuation based on a query which could be the start of a sentence. 2. **Evaluation**: The query and response are evaluated with a function, model, huma...
trl/docs/source/quickstart.md/0
{ "file_path": "trl/docs/source/quickstart.md", "repo_id": "trl", "token_count": 1117 }
512
<jupyter_start><jupyter_text>**Best-of-n sampling as an alternative to RLHF**This notebook compares reward-model scores of prompt based responses from 1. a base model (`gpt2-imdb`)2. `RLHF` tuned model based on this base-model 3. the base-model again from which we sample n responses to each prompt, score them and take ...
trl/examples/notebooks/best_of_n.ipynb/0
{ "file_path": "trl/examples/notebooks/best_of_n.ipynb", "repo_id": "trl", "token_count": 1998 }
513
# De-detoxifying language models To run this code, do the following: ```shell ACCELERATE_LOG_LEVEL=info accelerate launch --config_file {CONFIG} examples/research_projects/toxicity/scripts/gpt-j-6b-toxicity.py --log_with wandb ```
trl/examples/research_projects/toxicity/README.md/0
{ "file_path": "trl/examples/research_projects/toxicity/README.md", "repo_id": "trl", "token_count": 79 }
514
# Copyright 2025 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...
trl/examples/scripts/ppo/ppo_tldr.py/0
{ "file_path": "trl/examples/scripts/ppo/ppo_tldr.py", "repo_id": "trl", "token_count": 2726 }
515
# Copyright 2025 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...
trl/scripts/log_reports.py/0
{ "file_path": "trl/scripts/log_reports.py", "repo_id": "trl", "token_count": 2760 }
516
# Copyright 2025 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...
trl/tests/test_cpo_trainer.py/0
{ "file_path": "trl/tests/test_cpo_trainer.py", "repo_id": "trl", "token_count": 2811 }
517
# Copyright 2025 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...
trl/tests/test_orpo_trainer.py/0
{ "file_path": "trl/tests/test_orpo_trainer.py", "repo_id": "trl", "token_count": 2634 }
518
# Copyright 2025 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...
trl/trl/data_utils.py/0
{ "file_path": "trl/trl/data_utils.py", "repo_id": "trl", "token_count": 8352 }
519
# Copyright 2025 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...
trl/trl/trainer/cpo_trainer.py/0
{ "file_path": "trl/trl/trainer/cpo_trainer.py", "repo_id": "trl", "token_count": 22633 }
520
# Copyright 2025 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...
trl/trl/trainer/online_dpo_config.py/0
{ "file_path": "trl/trl/trainer/online_dpo_config.py", "repo_id": "trl", "token_count": 2921 }
521
# Copyright 2025 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...
trl/trl/trainer/xpo_trainer.py/0
{ "file_path": "trl/trl/trainer/xpo_trainer.py", "repo_id": "trl", "token_count": 11292 }
522
# 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/ms_amp/ddp.py/0
{ "file_path": "accelerate/benchmarks/fp8/ms_amp/ddp.py", "repo_id": "accelerate", "token_count": 1938 }
0
<!--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 applicable law or agreed...
accelerate/docs/source/basic_tutorials/troubleshooting.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/troubleshooting.md", "repo_id": "accelerate", "token_count": 3046 }
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/usage_guides/deepspeed.md/0
{ "file_path": "accelerate/docs/source/usage_guides/deepspeed.md", "repo_id": "accelerate", "token_count": 10171 }
2
<!--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/training_zoo.md/0
{ "file_path": "accelerate/docs/source/usage_guides/training_zoo.md", "repo_id": "accelerate", "token_count": 5969 }
3
# 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_4.py/0
{ "file_path": "accelerate/manim_animations/dataloaders/stage_4.py", "repo_id": "accelerate", "token_count": 914 }
4
#!/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_utils.py/0
{ "file_path": "accelerate/src/accelerate/commands/config/config_utils.py", "repo_id": "accelerate", "token_count": 1219 }
5
# 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/src/accelerate/commands/utils.py/0
{ "file_path": "accelerate/src/accelerate/commands/utils.py", "repo_id": "accelerate", "token_count": 1619 }
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/src/accelerate/test_utils/scripts/external_deps/test_ds_multiple_model.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_ds_multiple_model.py", "repo_id": "accelerate", "token_count": 5491 }
7
# 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/tracking.py/0
{ "file_path": "accelerate/src/accelerate/tracking.py", "repo_id": "accelerate", "token_count": 17105 }
8
# 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/other.py/0
{ "file_path": "accelerate/src/accelerate/utils/other.py", "repo_id": "accelerate", "token_count": 4783 }
9
# 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/test_big_modeling.py/0
{ "file_path": "accelerate/tests/test_big_modeling.py", "repo_id": "accelerate", "token_count": 18477 }
10
# 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/tests/test_imports.py/0
{ "file_path": "accelerate/tests/test_imports.py", "repo_id": "accelerate", "token_count": 1442 }
11
# Unit 1 Quiz <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/whiteboard-unit1sub4DONE.jpg" alt="Unit 1 planning"/> Well done on working through the first unit! Let's test your understanding of the key concepts covered so far. When you pass the quiz, proceed to the next se...
agents-course/units/en/unit1/final-quiz.mdx/0
{ "file_path": "agents-course/units/en/unit1/final-quiz.mdx", "repo_id": "agents-course", "token_count": 479 }
12
# Using MKL
candle/candle-book/src/advanced/mkl.md/0
{ "file_path": "candle/candle-book/src/advanced/mkl.md", "repo_id": "candle", "token_count": 5 }
13
# Using the hub Install the [`hf-hub`](https://github.com/huggingface/hf-hub) crate: ```bash cargo add hf-hub ``` Then let's start by downloading the [model file](https://huggingface.co/bert-base-uncased/tree/main). ```rust # extern crate candle_core; # extern crate hf_hub; use hf_hub::api::sync::Api; use candle_c...
candle/candle-book/src/inference/hub.md/0
{ "file_path": "candle/candle-book/src/inference/hub.md", "repo_id": "candle", "token_count": 1098 }
14
pub(crate) mod affine; pub(crate) mod conv_transpose2d; pub(crate) mod matmul; pub(crate) mod qmatmul; pub(crate) mod random; pub(crate) mod reduce; pub(crate) mod unary; pub(crate) mod where_cond; use candle_core::{Device, Result}; pub(crate) trait BenchDevice { fn sync(&self) -> Result<()>; fn bench_name<S...
candle/candle-core/benches/benchmarks/mod.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/mod.rs", "repo_id": "candle", "token_count": 1064 }
15
#![allow(clippy::excessive_precision)] // Code taken from https://github.com/statrs-dev/statrs //! Provides the [error](https://en.wikipedia.org/wiki/Error_function) and //! related functions mod evaluate { //! Provides functions that don't have a numerical solution and must //! be solved computationally (e.g....
candle/candle-core/src/cpu/erf.rs/0
{ "file_path": "candle/candle-core/src/cpu/erf.rs", "repo_id": "candle", "token_count": 11974 }
16
//! Implementation of the Cuda backend when Cuda support has not been compiled in. //! #![allow(dead_code)] use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT}; use crate::{CpuStorage, DType, Error, Layout, Result, Shape}; #[derive(Debug, Clone)] pub struct CudaDevice; #[derive(Debug)] pub struct CudaStorage; macr...
candle/candle-core/src/dummy_cuda_backend.rs/0
{ "file_path": "candle/candle-core/src/dummy_cuda_backend.rs", "repo_id": "candle", "token_count": 3405 }
17
//! Support for the GGML file format. use super::{k_quants, GgmlDType, QStorage}; use crate::{Device, Result}; use byteorder::{LittleEndian, ReadBytesExt}; use std::collections::HashMap; // https://github.com/ggerganov/llama.cpp/blob/468ea24fb4633a0d681f7ac84089566c1c6190cb/llama.h#L37 #[derive(Debug, Clone, Copy, Pa...
candle/candle-core/src/quantized/ggml_file.rs/0
{ "file_path": "candle/candle-core/src/quantized/ggml_file.rs", "repo_id": "candle", "token_count": 4584 }
18
use crate::{shape::Dim, Context, Error, Result, Shape, Tensor}; impl Tensor { /// Concatenates two or more tensors along a particular dimension. /// /// All tensors must of the same rank, and the output will have /// the same rank /// /// ```rust /// # use candle_core::{Tensor, DType, Devic...
candle/candle-core/src/tensor_cat.rs/0
{ "file_path": "candle/candle-core/src/tensor_cat.rs", "repo_id": "candle", "token_count": 6380 }
19
use candle_core::{ bail, quantized::{self, GgmlDType}, test_device, test_utils::to_vec2_round, DType, Device, IndexOp, Module, Result, Tensor, }; use quantized::{k_quants, GgmlType}; use rand::prelude::*; const GGML_TEST_SIZE: usize = 32 * 128; const GGML_MAX_QUANTIZATION_TOTAL_ERROR: f32 = 0.002;...
candle/candle-core/tests/quantized_tests.rs/0
{ "file_path": "candle/candle-core/tests/quantized_tests.rs", "repo_id": "candle", "token_count": 21659 }
20
use candle::Tensor; pub struct Dataset { pub train_images: Tensor, pub train_labels: Tensor, pub test_images: Tensor, pub test_labels: Tensor, pub labels: usize, } pub mod cifar; pub mod mnist;
candle/candle-datasets/src/vision/mod.rs/0
{ "file_path": "candle/candle-datasets/src/vision/mod.rs", "repo_id": "candle", "token_count": 92 }
21
# candle-clip Contrastive Language-Image Pre-Training (CLIP) is an architecture trained on pairs of images with related texts. https://github.com/openai/CLIP https://github.com/huggingface/transformers/tree/f6fa0f0bf0796ac66f201f23bdb8585de1609add/src/transformers/models/clip ## Running on an example on cpu ``` $ ...
candle/candle-examples/examples/clip/README.md/0
{ "file_path": "candle/candle-examples/examples/clip/README.md", "repo_id": "candle", "token_count": 623 }
22
// An implementation of different Granite models https://www.ibm.com/granite #[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use anyhow::{bail, Error as E, Result}; use clap::{Parser, ValueEnum}; use candle::{DType, Tensor}; use candle_nn::VarBuilder; ...
candle/candle-examples/examples/granite/main.rs/0
{ "file_path": "candle/candle-examples/examples/granite/main.rs", "repo_id": "candle", "token_count": 3722 }
23
use std::cmp::min; use candle::{bail, DType, Device, Result, Tensor}; use candle_transformers::models::llava::{ config::{HFPreProcessorConfig, LLaVAConfig}, utils::select_best_resolution, }; use hf_hub::api::sync::Api; use image::{imageops::overlay, DynamicImage, GenericImageView, Rgb, RgbImage}; use serde::{D...
candle/candle-examples/examples/llava/image_processor.rs/0
{ "file_path": "candle/candle-examples/examples/llava/image_processor.rs", "repo_id": "candle", "token_count": 4904 }
24
# candle-mistral: 7b LLM with Apache 2.0 licensed weights Mistral-7B-v0.1 is a pretrained generative LLM with 7 billion parameters. It outperforms all the publicly available 13b models as of 2023-09-28. Weights (and the original Python model code) are released under the permissive Apache 2.0 license. - [Blog post](ht...
candle/candle-examples/examples/mistral/README.md/0
{ "file_path": "candle/candle-examples/examples/mistral/README.md", "repo_id": "candle", "token_count": 829 }
25
use candle::{DType, Device, Result, Tensor, D}; use candle_nn::{ embedding, layer_norm, linear_no_bias, Activation, Embedding, LayerNorm, Linear, Module, VarBuilder, }; use candle_transformers::models::{encodec, t5}; // https://github.com/huggingface/transformers/blob/cd4584e3c809bb9e1392ccd3fe38b40daba5519a/s...
candle/candle-examples/examples/musicgen/musicgen_model.rs/0
{ "file_path": "candle/candle-examples/examples/musicgen/musicgen_model.rs", "repo_id": "candle", "token_count": 7592 }
26
#[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::pixtral::{vision_model, Config, Model}; use candle::{DType, Device, Module, Tensor}; use candle_examples::token_output_...
candle/candle-examples/examples/pixtral/main.rs/0
{ "file_path": "candle/candle-examples/examples/pixtral/main.rs", "repo_id": "candle", "token_count": 5495 }
27
use std::collections::VecDeque; use rand::distributions::Uniform; use rand::{thread_rng, Rng}; use candle::{DType, Device, Module, Result, Tensor}; use candle_nn::loss::mse; use candle_nn::{linear, seq, Activation, AdamW, Optimizer, VarBuilder, VarMap}; use crate::gym_env::GymEnv; const DEVICE: Device = Device::Cpu...
candle/candle-examples/examples/reinforcement-learning/dqn.rs/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/dqn.rs", "repo_id": "candle", "token_count": 2032 }
28
use candle::Device; use candle::Module; use candle_nn::VarBuilder; use candle_transformers::models::segformer::{ Config, ImageClassificationModel, SemanticSegmentationModel, }; use clap::{Args, Parser, Subcommand}; use imageproc::image::Rgb; use imageproc::integral_image::ArrayData; use std::collections::HashMap; u...
candle/candle-examples/examples/segformer/main.rs/0
{ "file_path": "candle/candle-examples/examples/segformer/main.rs", "repo_id": "candle", "token_count": 2229 }
29
use anyhow::{Ok, Result}; use candle::{DType, IndexOp, Tensor}; use candle_transformers::models::flux; use candle_transformers::models::mmdit::model::MMDiT; pub struct SkipLayerGuidanceConfig { pub scale: f64, pub start: f64, pub end: f64, pub layers: Vec<usize>, } #[allow(clippy::too_many_arguments)...
candle/candle-examples/examples/stable-diffusion-3/sampling.rs/0
{ "file_path": "candle/candle-examples/examples/stable-diffusion-3/sampling.rs", "repo_id": "candle", "token_count": 1404 }
30
# candle-trocr `TrOCR` is a transformer OCR Model. In this example it is used to transcribe image text. See the associated [model card](https://huggingface.co/microsoft/trocr-base-printed) for details on the model itself. Supported models include: - `--which base`: small handwritten OCR model. - `--which large`: lar...
candle/candle-examples/examples/trocr/readme.md/0
{ "file_path": "candle/candle-examples/examples/trocr/readme.md", "repo_id": "candle", "token_count": 360 }
31
#[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use candle_transformers::models::stable_diffusion; use candle_transformers::models::wuerstchen; use anyhow::{Error as E, Result}; use candle::{DType, Device, IndexOp, Tensor}; use clap::Parser; use tokeniz...
candle/candle-examples/examples/wuerstchen/main.rs/0
{ "file_path": "candle/candle-examples/examples/wuerstchen/main.rs", "repo_id": "candle", "token_count": 6372 }
32
use candle::{Result, Tensor}; // https://github.com/facebookresearch/audiocraft/blob/69fea8b290ad1b4b40d28f92d1dfc0ab01dbab85/audiocraft/data/audio_utils.py#L57 pub fn normalize_loudness( wav: &Tensor, sample_rate: u32, loudness_compressor: bool, ) -> Result<Tensor> { let energy = wav.sqr()?.mean_all()...
candle/candle-examples/src/audio.rs/0
{ "file_path": "candle/candle-examples/src/audio.rs", "repo_id": "candle", "token_count": 458 }
33
/****************************************************************************** * Copyright (c) 2024, Tri Dao. ******************************************************************************/ #pragma once // #include "philox_unpack.cuh" // For at::cuda::philox::unpack #include <cute/tensor.hpp> #include <cutlass/c...
candle/candle-flash-attn/kernels/flash_fwd_kernel.h/0
{ "file_path": "candle/candle-flash-attn/kernels/flash_fwd_kernel.h", "repo_id": "candle", "token_count": 37133 }
34
[package] name = "candle-kernels" version = "0.8.3" edition = "2021" description = "CUDA kernels for Candle" repository = "https://github.com/huggingface/candle" keywords = ["blas", "tensor", "machine-learning"] categories = ["science"] license = "MIT OR Apache-2.0" [dependencies] [build-dependencies] bindgen_cuda =...
candle/candle-kernels/Cargo.toml/0
{ "file_path": "candle/candle-kernels/Cargo.toml", "repo_id": "candle", "token_count": 126 }
35
#include "cuda_utils.cuh" #include<stdint.h> #define WHERE_OP(TYPENAME, ID_TYPENAME, FN_NAME) \ extern "C" __global__ void FN_NAME( \ const size_t numel, \ const size_t num_dims, \ const size_t *info, \ const ID_TYPENAME *ids, \ const TYPENAME *t, \ const TYPENAME *f, \ TYPENAME *out \ ) ...
candle/candle-kernels/src/ternary.cu/0
{ "file_path": "candle/candle-kernels/src/ternary.cu", "repo_id": "candle", "token_count": 1159 }
36
#include <metal_stdlib> #include <metal_integer> #include <metal_atomic> using namespace metal; // Constants // 2^32 and 1/2^32. Useful for converting between float and uint. static constexpr constant ulong UNIF01_NORM32 = 4294967296; static constexpr constant float UNIF01_INV32 = 2.328306436538696289e-10; // 2 * pi ...
candle/candle-metal-kernels/src/random.metal/0
{ "file_path": "candle/candle-metal-kernels/src/random.metal", "repo_id": "candle", "token_count": 3671 }
37
mod benchmarks; use criterion::criterion_main; criterion_main!( benchmarks::softmax::benches, benchmarks::layer_norm::benches, benchmarks::conv::benches );
candle/candle-nn/benches/bench_main.rs/0
{ "file_path": "candle/candle-nn/benches/bench_main.rs", "repo_id": "candle", "token_count": 58 }
38
//! Layer Normalization. //! //! This layer applies Layer Normalization over a mini-batch of inputs as described in [`Layer //! Normalization`]. The input is expected to have three dimensions: a batch dimension, a length, //! and a hidden size, the normalization is applied over the last dimension. //! //! # Example //!...
candle/candle-nn/src/layer_norm.rs/0
{ "file_path": "candle/candle-nn/src/layer_norm.rs", "repo_id": "candle", "token_count": 2656 }
39
use candle::{Result, Shape, Tensor}; use candle_nn::encoding::one_hot; #[test] fn test_i64_one_hot() -> Result<()> { let device = candle::Device::Cpu; let indices = Tensor::new(vec![vec![0i64, 2], vec![1, -1]], &device)?; let depth = 4; let on_value = 1.0; let off_value = 0.0; let one_hot = ...
candle/candle-nn/tests/one_hot.rs/0
{ "file_path": "candle/candle-nn/tests/one_hot.rs", "repo_id": "candle", "token_count": 1592 }
40
from typing import Union, Sequence class Tensor: """ This contains the type hints for the magic methodes of the `candle.Tensor` class. """ def __add__(self, rhs: Union["Tensor", "Scalar"]) -> "Tensor": """ Add a scalar to a tensor or two tensors together. """ pass ...
candle/candle-pyo3/_additional_typing/__init__.py/0
{ "file_path": "candle/candle-pyo3/_additional_typing/__init__.py", "repo_id": "candle", "token_count": 1174 }
41
# Generated content DO NOT EDIT from .. import onnx ONNXModel = onnx.ONNXModel ONNXTensorDescription = onnx.ONNXTensorDescription
candle/candle-pyo3/py_src/candle/onnx/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/onnx/__init__.py", "repo_id": "candle", "token_count": 46 }
42
import candle from candle import Tensor from candle.nn import Linear def test_linear_layer_can_be_constructed(): linear = Linear(10, 10) assert linear is not None def test_linear_layer_can_forward_a_singular_input(): linear = Linear(384, 1536) input_tensor = candle.randn((8, 384)) output = linea...
candle/candle-pyo3/tests/bindings/test_linear.py/0
{ "file_path": "candle/candle-pyo3/tests/bindings/test_linear.py", "repo_id": "candle", "token_count": 431 }
43
//! Implementation of the ChatGLM2/3 models from THUDM. //! //! - 💻 [Github](https://github.com/THUDM/ChatGLM3) ChatGLM3: Advancing Multilingual Conversational Language Models with High-Quality Data //! - 💻 [Github](https://github.com/THUDM/ChatGLM2-6B) ChatGLM2-6B. //! use crate::models::with_tracing::{linear_b as l...
candle/candle-transformers/src/models/chatglm.rs/0
{ "file_path": "candle/candle-transformers/src/models/chatglm.rs", "repo_id": "candle", "token_count": 10447 }
44
//! Implementation of the DINOv2 revision (4 regularization) //! //! The DINOv2-reg4 model is a variant of DINOv2 that adds 4 regularization tokens to the //! original architecture. This implementation is specifically trained for plant species //! classification on the PlantCLEF2024 dataset with 7,806 classes. //! //! ...
candle/candle-transformers/src/models/dinov2reg4.rs/0
{ "file_path": "candle/candle-transformers/src/models/dinov2reg4.rs", "repo_id": "candle", "token_count": 4809 }
45
//! Granite is a Long Context Transformer Language Model. //! //! A high performance transformer model optimized for efficient processing //! of very long context sequences //! //! Based on implementation from [Nod.ai](https://github.com/nod-ai/granite) use super::with_tracing::{linear_no_bias as linear, Linear, RmsNo...
candle/candle-transformers/src/models/granite.rs/0
{ "file_path": "candle/candle-transformers/src/models/granite.rs", "repo_id": "candle", "token_count": 8417 }
46
// Copyright (c) Kyutai, all rights reserved. // This source code is licensed under the license found in the // LICENSE file in the root directory of this source tree. use candle::{IndexOp, Layout, Result, Shape, Tensor, D}; use candle_nn::{linear, Linear, VarBuilder}; struct CodebookEncode; impl candle::CustomOp2 f...
candle/candle-transformers/src/models/mimi/quantization.rs/0
{ "file_path": "candle/candle-transformers/src/models/mimi/quantization.rs", "repo_id": "candle", "token_count": 6873 }
47
//! MoonDream Model vision-to-text //! //! //! Moondream is a computer-vision model that can answer real-world questions about images. //! It's lightweight with only 1.6B parameters, enabling it to run on mobile phones and edge devices. //! [MoonDream Original Implementation](https://github.com/vikhyat/moondream) //! /...
candle/candle-transformers/src/models/moondream.rs/0
{ "file_path": "candle/candle-transformers/src/models/moondream.rs", "repo_id": "candle", "token_count": 4946 }
48
//! BLIP model implementation with quantization support. //! //! BLIP is a vision-language model for image understanding and generation tasks. //! This implementation provides quantization for reduced memory and compute. //! //! Key characteristics: //! - Vision encoder using ViT architecture //! - Text decoder using B...
candle/candle-transformers/src/models/quantized_blip.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_blip.rs", "repo_id": "candle", "token_count": 4186 }
49
//! T5 model implementation with quantization support. //! //! T5 is an encoder-decoder model pre-trained on a multi-task mixture of supervised //! and unsupervised tasks. This implementation provides quantization for reduced //! memory and compute requirements. //! //! Key characteristics: //! - Encoder-decoder archit...
candle/candle-transformers/src/models/quantized_t5.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_t5.rs", "repo_id": "candle", "token_count": 14169 }
50
//! Siglip model implementation. //! //! Siglip architecture combining vision and language for zero-shot tasks. //! //! References: //! - 🤗 [Model Card](https://huggingface.co/google/siglip-base-patch16-224) //! use crate::models::clip::div_l2_norm; use candle::{IndexOp, Module, Result, Tensor, D}; use candle_nn::{la...
candle/candle-transformers/src/models/siglip.rs/0
{ "file_path": "candle/candle-transformers/src/models/siglip.rs", "repo_id": "candle", "token_count": 11116 }
51
//! StarCoder model implementation with quantization support. //! //! StarCoder is a large language model optimized for code generation. //! This implementation provides quantization for reduced memory and compute. //! //! Key characteristics: //! - Causal self-attention mechanism //! - Multi-query attention (MQA) //! ...
candle/candle-transformers/src/models/starcoder2.rs/0
{ "file_path": "candle/candle-transformers/src/models/starcoder2.rs", "repo_id": "candle", "token_count": 6059 }
52
use super::common::LayerNormNoWeights; use candle::{Module, Result, Tensor}; use candle_nn::VarBuilder; #[derive(Debug)] pub struct MixingResidualBlock { norm1: LayerNormNoWeights, depthwise_conv: candle_nn::Conv2d, norm2: LayerNormNoWeights, channelwise_lin1: candle_nn::Linear, channelwise_lin2: c...
candle/candle-transformers/src/models/wuerstchen/paella_vq.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/paella_vq.rs", "repo_id": "candle", "token_count": 4078 }
53
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Bert</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 u...
candle/candle-wasm-examples/bert/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/bert/lib-example.html", "repo_id": "candle", "token_count": 6066 }
54
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Llama.c 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" /> <style> ...
candle/candle-wasm-examples/llama2-c/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/lib-example.html", "repo_id": "candle", "token_count": 6089 }
55
// Audio processing code, adapted from whisper.cpp // https://github.com/ggerganov/whisper.cpp use super::worker; pub trait Float: num_traits::Float + num_traits::FloatConst + num_traits::NumAssign {} impl Float for f32 {} impl Float for f64 {} // https://github.com/ggerganov/whisper.cpp/blob/4774d2feb01a772a15de81f...
candle/candle-wasm-examples/whisper/src/audio.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/audio.rs", "repo_id": "candle", "token_count": 3162 }
56
use yew_agent::PublicWorker; fn main() { console_error_panic_hook::set_once(); candle_wasm_example_yolo::Worker::register(); }
candle/candle-wasm-examples/yolo/src/bin/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/bin/worker.rs", "repo_id": "candle", "token_count": 53 }
57
{ "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "data": { "values": "<DVC_METRIC_DATA>" }, "title": "<DVC_METRIC_TITLE>", "mark": "rect", "encoding": { "x": { "field": "<DVC_METRIC_X>", "type": "nominal", "sort": "ascending", ...
datasets/.dvc/plots/confusion.json/0
{ "file_path": "datasets/.dvc/plots/confusion.json", "repo_id": "datasets", "token_count": 450 }
58
cff-version: 1.2.0 message: "If you use this software, please cite it as below." title: "huggingface/datasets" authors: - family-names: Lhoest given-names: Quentin - family-names: Villanova del Moral given-names: Albert orcid: "https://orcid.org/0000-0003-1727-1045" - family-names: von Platen given-names: Patri...
datasets/CITATION.cff/0
{ "file_path": "datasets/CITATION.cff", "repo_id": "datasets", "token_count": 1428 }
59
# Load audio data You can load an audio dataset using the [`Audio`] feature that automatically decodes and resamples the audio files when you access the examples. Audio decoding is based on the [`soundfile`](https://github.com/bastibe/python-soundfile) python package, which uses the [`libsndfile`](https://github.com/l...
datasets/docs/source/audio_load.mdx/0
{ "file_path": "datasets/docs/source/audio_load.mdx", "repo_id": "datasets", "token_count": 1529 }
60
# Semantic segmentation Semantic segmentation datasets are used to train a model to classify every pixel in an image. There are a wide variety of applications enabled by these datasets such as background removal from images, stylizing images, or scene understanding for autonomous driving. This guide will show you how ...
datasets/docs/source/semantic_segmentation.mdx/0
{ "file_path": "datasets/docs/source/semantic_segmentation.mdx", "repo_id": "datasets", "token_count": 2142 }
61
# Create a video dataset This guide will show you how to create a video dataset with `VideoFolder` and some metadata. This is a no-code solution for quickly creating a video dataset with several thousand videos. <Tip> You can control access to your dataset by requiring users to share their contact information first....
datasets/docs/source/video_dataset.mdx/0
{ "file_path": "datasets/docs/source/video_dataset.mdx", "repo_id": "datasets", "token_count": 1813 }
62
import platform from argparse import ArgumentParser import fsspec import huggingface_hub import pandas import pyarrow from datasets import __version__ as version from datasets.commands import BaseDatasetsCLICommand def info_command_factory(_): return EnvironmentCommand() class EnvironmentCommand(BaseDatasetsC...
datasets/src/datasets/commands/env.py/0
{ "file_path": "datasets/src/datasets/commands/env.py", "repo_id": "datasets", "token_count": 476 }
63
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.download_config import DownloadConfig from ..table import array_cast from ..utils.file_utils im...
datasets/src/datasets/features/video.py/0
{ "file_path": "datasets/src/datasets/features/video.py", "repo_id": "datasets", "token_count": 5033 }
64
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.csv.csv import Csv from ..utils import tqdm as hf_tqdm from ..utils.typing import NestedDataStructureLike, PathL...
datasets/src/datasets/io/csv.py/0
{ "file_path": "datasets/src/datasets/io/csv.py", "repo_id": "datasets", "token_count": 2556 }
65
# 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/splits.py/0
{ "file_path": "datasets/src/datasets/splits.py", "repo_id": "datasets", "token_count": 9577 }
66
import re import textwrap from collections import Counter from itertools import groupby from operator import itemgetter from typing import Any, ClassVar, Dict, List, Optional, Tuple import yaml from huggingface_hub import DatasetCardData from ..config import METADATA_CONFIGS_FIELD from ..features import Features from...
datasets/src/datasets/utils/metadata.py/0
{ "file_path": "datasets/src/datasets/utils/metadata.py", "repo_id": "datasets", "token_count": 4646 }
67
--- TODO: "Add YAML tags here. Delete these instructions and copy-paste the YAML tags obtained with the online tagging app: https://huggingface.co/spaces/huggingface/datasets-tagging" --- # Dataset Card for [Dataset Name] ## Table of Contents - [Table of Contents](#table-of-contents) - [Dataset Description](#dataset-...
datasets/templates/README.md/0
{ "file_path": "datasets/templates/README.md", "repo_id": "datasets", "token_count": 819 }
68
from unittest.mock import patch import pyspark import pytest from datasets.builder import InvalidConfigName from datasets.data_files import DataFilesList from datasets.packaged_modules.spark.spark import ( Spark, SparkConfig, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import (...
datasets/tests/packaged_modules/test_spark.py/0
{ "file_path": "datasets/tests/packaged_modules/test_spark.py", "repo_id": "datasets", "token_count": 2267 }
69
import os import re from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from fsspec.registry import _registry as _fsspec_registry from fsspec.spec import AbstractBufferedFile, AbstractFileSystem from huggingface_hub.errors import OfflineModeIsEnabled from datasets.download....
datasets/tests/test_file_utils.py/0
{ "file_path": "datasets/tests/test_file_utils.py", "repo_id": "datasets", "token_count": 17517 }
70
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, require_...
datasets/tests/test_search.py/0
{ "file_path": "datasets/tests/test_search.py", "repo_id": "datasets", "token_count": 4553 }
71
# Files for typos # Instruction: https://github.com/marketplace/actions/typos-action#getting-started [default.extend-identifiers] [default.extend-words] NIN="NIN" # NIN is used in scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py nd="np" # nd may be np (numpy) parms="parms" # parms is used in scripts/conver...
diffusers/_typos.toml/0
{ "file_path": "diffusers/_typos.toml", "repo_id": "diffusers", "token_count": 151 }
72
<!--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/internal_classes_overview.md/0
{ "file_path": "diffusers/docs/source/en/api/internal_classes_overview.md", "repo_id": "diffusers", "token_count": 211 }
73
<!--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/models/autoencoderkl.md/0
{ "file_path": "diffusers/docs/source/en/api/models/autoencoderkl.md", "repo_id": "diffusers", "token_count": 783 }
74
<!--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/k_diffusion.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/k_diffusion.md", "repo_id": "diffusers", "token_count": 378 }
75
<!--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/deepcache.md/0
{ "file_path": "diffusers/docs/source/en/optimization/deepcache.md", "repo_id": "diffusers", "token_count": 1917 }
76
<!--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/quantization/overview.md/0
{ "file_path": "diffusers/docs/source/en/quantization/overview.md", "repo_id": "diffusers", "token_count": 544 }
77
<!--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/training/overview.md/0
{ "file_path": "diffusers/docs/source/en/training/overview.md", "repo_id": "diffusers", "token_count": 1545 }
78
<!--Copyright 2024 Marigold 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 Unless required by app...
diffusers/docs/source/en/using-diffusers/marigold_usage.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/marigold_usage.md", "repo_id": "diffusers", "token_count": 9939 }
79
<!--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/using-diffusers/text-img2vid.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/text-img2vid.md", "repo_id": "diffusers", "token_count": 8485 }
80
<!--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/conceptual/evaluation.md/0
{ "file_path": "diffusers/docs/source/ko/conceptual/evaluation.md", "repo_id": "diffusers", "token_count": 16758 }
81
<!--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/training/adapt_a_model.md/0
{ "file_path": "diffusers/docs/source/ko/training/adapt_a_model.md", "repo_id": "diffusers", "token_count": 1850 }
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/ko/using-diffusers/custom_pipeline_overview.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/custom_pipeline_overview.md", "repo_id": "diffusers", "token_count": 2388 }
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/ko/using-diffusers/unconditional_image_generation.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/unconditional_image_generation.md", "repo_id": "diffusers", "token_count": 1740 }
84
import glob import os from typing import Dict, List, Union import safetensors.torch import torch from huggingface_hub import snapshot_download from huggingface_hub.utils import validate_hf_hub_args from diffusers import DiffusionPipeline, __version__ from diffusers.schedulers.scheduling_utils import SCHEDULER_CONFIG_...
diffusers/examples/community/checkpoint_merger.py/0
{ "file_path": "diffusers/examples/community/checkpoint_merger.py", "repo_id": "diffusers", "token_count": 6156 }
85
# Copyright 2025 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/mixture_tiling_sdxl.py/0
{ "file_path": "diffusers/examples/community/mixture_tiling_sdxl.py", "repo_id": "diffusers", "token_count": 28741 }
86