text
stringlengths
96
319k
id
stringlengths
14
178
metadata
dict
# 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/scripts/grpo.py/0
{ "file_path": "trl/trl/scripts/grpo.py", "repo_id": "trl", "token_count": 1251 }
# 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/dpo_trainer.py/0
{ "file_path": "trl/trl/trainer/dpo_trainer.py", "repo_id": "trl", "token_count": 36273 }
# 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/ppo_config.py/0
{ "file_path": "trl/trl/trainer/ppo_config.py", "repo_id": "trl", "token_count": 1824 }
// File only needed for VSCode users to have proper Docker based interpreters { "name": "accelerate_dev_environment", "build": { // ACTION NEEDED: comment/uncomment the relevant line depending on whether you are in a CPU/GPU environment "dockerfile": "../docker/accelerate-cpu/Dockerfile" // ...
accelerate/.devcontainer/devcontainer.json/0
{ "file_path": "accelerate/.devcontainer/devcontainer.json", "repo_id": "accelerate", "token_count": 459 }
<!--- 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 ...
accelerate/CONTRIBUTING.md/0
{ "file_path": "accelerate/CONTRIBUTING.md", "repo_id": "accelerate", "token_count": 2693 }
# Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/benchmarks/fp8/transformer_engine/distrib_deepspeed.py/0
{ "file_path": "accelerate/benchmarks/fp8/transformer_engine/distrib_deepspeed.py", "repo_id": "accelerate", "token_count": 2964 }
<!--Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/basic_tutorials/overview.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/overview.md", "repo_id": "accelerate", "token_count": 303 }
<!--Copyright 2021 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/package_reference/big_modeling.md/0
{ "file_path": "accelerate/docs/source/package_reference/big_modeling.md", "repo_id": "accelerate", "token_count": 712 }
<!--Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/usage_guides/checkpoint.md/0
{ "file_path": "accelerate/docs/source/usage_guides/checkpoint.md", "repo_id": "accelerate", "token_count": 1150 }
<!--Copyright 2021 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/usage_guides/sagemaker.md/0
{ "file_path": "accelerate/docs/source/usage_guides/sagemaker.md", "repo_id": "accelerate", "token_count": 2220 }
{ "fp16": { "enabled": true, "loss_scale": 0, "loss_scale_window": 1000, "initial_scale_power": 16, "hysteresis": 2, "min_loss_scale": 1 }, "optimizer": { "type": "AdamW", "params": { "lr": "auto", "weight_decay": "auto"...
accelerate/examples/deepspeed_config_templates/zero_stage1_config.json/0
{ "file_path": "accelerate/examples/deepspeed_config_templates/zero_stage1_config.json", "repo_id": "accelerate", "token_count": 614 }
# Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/examples/inference/pippy/t5.py/0
{ "file_path": "accelerate/examples/inference/pippy/t5.py", "repo_id": "accelerate", "token_count": 1023 }
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/manim_animations/dataloaders/stage_2.py/0
{ "file_path": "accelerate/manim_animations/dataloaders/stage_2.py", "repo_id": "accelerate", "token_count": 3396 }
#!/usr/bin/env python # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
accelerate/src/accelerate/commands/config/config.py/0
{ "file_path": "accelerate/src/accelerate/commands/config/config.py", "repo_id": "accelerate", "token_count": 1067 }
#!/usr/bin/env python # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
accelerate/src/accelerate/commands/test.py/0
{ "file_path": "accelerate/src/accelerate/commands/test.py", "repo_id": "accelerate", "token_count": 755 }
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/test_utils/testing.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/testing.py", "repo_id": "accelerate", "token_count": 8669 }
# 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/operations.py/0
{ "file_path": "accelerate/src/accelerate/utils/operations.py", "repo_id": "accelerate", "token_count": 12875 }
# 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": 18483 }
# 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_kwargs_handlers.py/0
{ "file_path": "accelerate/tests/test_kwargs_handlers.py", "repo_id": "accelerate", "token_count": 3261 }
# 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_tracking.py/0
{ "file_path": "accelerate/tests/test_tracking.py", "repo_id": "accelerate", "token_count": 10128 }
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, ...
candle/LICENSE-APACHE/0
{ "file_path": "candle/LICENSE-APACHE", "repo_id": "candle", "token_count": 3168 }
# Simplified ## How its works This program implements a neural network to predict the winner of the second round of elections based on the results of the first round. Basic moments: 1. A multilayer perceptron with two hidden layers is used. The first hidden layer has 4 neurons, the second has 2 neurons. 2. The inpu...
candle/candle-book/src/training/simplified.md/0
{ "file_path": "candle/candle-book/src/training/simplified.md", "repo_id": "candle", "token_count": 530 }
#[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use anyhow::Result; use candle_core::{Device, Tensor}; fn main() -> Result<()> { let device = Device::new_cuda(0)?; let x = Tensor::randn(0f32, 1.0, (8 * 4096, 8 * 4096), &device)? .to_dtyp...
candle/candle-core/examples/cuda_basics.rs/0
{ "file_path": "candle/candle-core/examples/cuda_basics.rs", "repo_id": "candle", "token_count": 477 }
use crate::WithDType; use cudarc; use cudarc::cudnn::safe::{ConvForward, Cudnn}; use cudarc::driver::{CudaSlice, CudaView, DeviceRepr, ValidAsZeroBits}; use std::cell::RefCell; use std::collections::HashMap; use std::sync::Arc; // The cudnn handles are stored per thread here rather than on the CudaDevice as they are n...
candle/candle-core/src/cuda_backend/cudnn.rs/0
{ "file_path": "candle/candle-core/src/cuda_backend/cudnn.rs", "repo_id": "candle", "token_count": 2242 }
//! Implementation of Backend traits for Metal //! use crate::backend::{BackendDevice, BackendStorage}; use crate::conv::{ParamsConv1D, ParamsConv2D, ParamsConvTranspose1D, ParamsConvTranspose2D}; use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT}; use crate::{CpuStorage, CpuStorageRef, DType, Layout, Result, Shape}...
candle/candle-core/src/metal_backend/mod.rs/0
{ "file_path": "candle/candle-core/src/metal_backend/mod.rs", "repo_id": "candle", "token_count": 51267 }
use crate::Result; pub(super) fn nearest_int(v: f32) -> i32 { v.round() as i32 } /// Validates that the input and output are the right size and returns an iterator which maps each /// input region `xs` to its corresponding output block in `ys`. Each output region is guaranteed /// to be `T::BLCK_SIZE` long. pub(s...
candle/candle-core/src/quantized/utils.rs/0
{ "file_path": "candle/candle-core/src/quantized/utils.rs", "repo_id": "candle", "token_count": 5775 }
[package] name = "candle-datasets" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true readme = "README.md" [dependencies] byteorder = { workspace = true } candle = { workspace = true }...
candle/candle-datasets/Cargo.toml/0
{ "file_path": "candle/candle-datasets/Cargo.toml", "repo_id": "candle", "token_count": 201 }
//! BEiT: BERT Pre-Training of Image Transformers //! https://github.com/microsoft/unilm/tree/master/beit #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::Parser; use candle::{DType, Device, IndexOp, Result, Tensor, D}; use candle_nn::{Module,...
candle/candle-examples/examples/beit/main.rs/0
{ "file_path": "candle/candle-examples/examples/beit/main.rs", "repo_id": "candle", "token_count": 1178 }
# candle-convnext [A ConvNet for the 2020s](https://arxiv.org/abs/2201.03545) and [ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders](https://arxiv.org/abs/2301.00808). This candle implementation uses a pre-trained ConvNeXt network for inference. The classification head has been trained on the I...
candle/candle-examples/examples/convnext/README.md/0
{ "file_path": "candle/candle-examples/examples/convnext/README.md", "repo_id": "candle", "token_count": 293 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle_transformers::models::distilbert::{Config, DistilBertModel, DTYPE}; use anyhow::{Error as E, Result}; use candle::{Device, Tensor}; use candle_nn::VarBuilder; use clap::Parser; use hf_hub::{api::...
candle/candle-examples/examples/distilbert/main.rs/0
{ "file_path": "candle/candle-examples/examples/distilbert/main.rs", "repo_id": "candle", "token_count": 1939 }
#[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use candle_transformers::models::{clip, flux, t5}; use anyhow::{Error as E, Result}; use candle::{IndexOp, Module, Tensor}; use candle_nn::VarBuilder; use clap::Parser; use tokenizers::Tokenizer; #[derive...
candle/candle-examples/examples/flux/main.rs/0
{ "file_path": "candle/candle-examples/examples/flux/main.rs", "repo_id": "candle", "token_count": 5445 }
// An implementation of LLaMA https://github.com/facebookresearch/llama // // This is based on nanoGPT in a similar way to: // https://github.com/Lightning-AI/lit-llama/blob/main/lit_llama/model.py // // The tokenizer config can be retrieved from: // https://huggingface.co/hf-internal-testing/llama-tokenizer/raw/main/t...
candle/candle-examples/examples/llama/main.rs/0
{ "file_path": "candle/candle-examples/examples/llama/main.rs", "repo_id": "candle", "token_count": 4888 }
# candle-mobileone [MobileOne: An Improved One millisecond Mobile Backbone](https://arxiv.org/abs/2206.04040). This candle implementation uses a pre-trained MobileOne network for inference. The classification head has been trained on the ImageNet dataset and returns the probabilities for the top-5 classes. ## Runnin...
candle/candle-examples/examples/mobileone/README.md/0
{ "file_path": "candle/candle-examples/examples/mobileone/README.md", "repo_id": "candle", "token_count": 254 }
# candle-qwen: large language model series from Alibaba Cloud Qwen 1.5 is a series of large language models that provide strong performances on English and Chinese. - [Blog post](https://qwenlm.github.io/blog/qwen1.5/) introducing Qwen1.5. - [Model card](https://huggingface.co/Qwen/Qwen1.5-0.5B) on the HuggingFace Hu...
candle/candle-examples/examples/qwen/README.md/0
{ "file_path": "candle/candle-examples/examples/qwen/README.md", "repo_id": "candle", "token_count": 327 }
# candle-resnet A candle implementation of inference using a pre-trained [ResNet](https://arxiv.org/abs/1512.03385). This uses a classification head trained on the ImageNet dataset and returns the probabilities for the top-5 classes. ## Running an example ``` $ cargo run --example resnet --release -- --image tiger.j...
candle/candle-examples/examples/resnet/README.md/0
{ "file_path": "candle/candle-examples/examples/resnet/README.md", "repo_id": "candle", "token_count": 204 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use clap::Parser; use candle::{DType, Tensor}; #[derive(Clone, Debug, Copy, PartialEq, Eq, clap::ValueEnum)] enum Which { #[value(name = "silero")] Silero, } #[derive(Clone, D...
candle/candle-examples/examples/silero-vad/main.rs/0
{ "file_path": "candle/candle-examples/examples/silero-vad/main.rs", "repo_id": "candle", "token_count": 2894 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use std::path::Path; use anyhow::{anyhow, Error as E, Result}; use clap::Parser; use candle_transformers::models::stella_en_v5::{ Config, EmbedDim as StellaEmbedDim, EmbeddingModel, }; use candle::{D...
candle/candle-examples/examples/stella-en-v5/main.rs/0
{ "file_path": "candle/candle-examples/examples/stella-en-v5/main.rs", "repo_id": "candle", "token_count": 6512 }
// https://github.com/openai/whisper/blob/main/whisper/model.py/rgs // TODO: // - Batch size greater than 1. // - More token filters (SuppressBlanks, ApplyTimestampRules). #[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use anyhow::{Error as E, Result};...
candle/candle-examples/examples/whisper/main.rs/0
{ "file_path": "candle/candle-examples/examples/whisper/main.rs", "repo_id": "candle", "token_count": 10862 }
// Build script to run nvcc and generate the C glue code for launching the flash-attention kernel. // The cuda build time is very long so one can set the CANDLE_FLASH_ATTN_BUILD_DIR environment // variable in order to cache the compiled artifacts and avoid recompiling too often. use anyhow::{Context, Result}; use std::...
candle/candle-flash-attn/build.rs/0
{ "file_path": "candle/candle-flash-attn/build.rs", "repo_id": "candle", "token_count": 2163 }
/****************************************************************************** * Copyright (c) 2024, Tri Dao. ******************************************************************************/ #pragma once #include <cute/tensor.hpp> #include "utils.h" ////////////////////////////////////////////////////////////////...
candle/candle-flash-attn/kernels/rotary.h/0
{ "file_path": "candle/candle-flash-attn/kernels/rotary.h", "repo_id": "candle", "token_count": 5052 }
#include "compatibility.cuh" #include<stdint.h> #include<cmath> // TODO: This is often used to check that the data is contiguous so that // kernels can be easily mapped. However this only returns true for row // major, if all the inputs are column major, we could apply the fast path // too (but we wouldn't if some of ...
candle/candle-kernels/src/cuda_utils.cuh/0
{ "file_path": "candle/candle-kernels/src/cuda_utils.cuh", "repo_id": "candle", "token_count": 3947 }
#include <metal_stdlib> using namespace metal; template<typename T> METAL_FUNC void fill_with( device T *out, constant float &value, constant size_t &numel, uint tid [[thread_position_in_grid]] ) { if (tid >= numel) { return; } out[tid] = static_cast<T>(value); } #define FILL_OP(N...
candle/candle-metal-kernels/src/fill.metal/0
{ "file_path": "candle/candle-metal-kernels/src/fill.metal", "repo_id": "candle", "token_count": 638 }
use metal::{Buffer, ComputeCommandEncoderRef, ComputePipelineState, MTLSize}; use std::ffi::c_void; /// Most kernels apply similarly across the tensors /// This creates a strategy that uses the maximum amount of threads per threadgroup (capped at the /// actual total buffer length). /// Then kernels can just do their ...
candle/candle-metal-kernels/src/utils.rs/0
{ "file_path": "candle/candle-metal-kernels/src/utils.rs", "repo_id": "candle", "token_count": 2819 }
//! Convolution Layers. use crate::BatchNorm; use candle::{Result, Tensor}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Conv1dConfig { pub padding: usize, pub stride: usize, pub dilation: usize, pub groups: usize, } impl Default for Conv1dConfig { fn default() -> Self { Self { ...
candle/candle-nn/src/conv.rs/0
{ "file_path": "candle/candle-nn/src/conv.rs", "repo_id": "candle", "token_count": 5891 }
//! A `VarBuilder` for variable retrieval from models //! //! A `VarBuilder` is used to retrieve variables used by a model. These variables can either come //! from a pre-trained checkpoint, e.g. using `VarBuilder::from_mmaped_safetensors`, or initialized //! for training, e.g. using `VarBuilder::from_varmap`. use crat...
candle/candle-nn/src/var_builder.rs/0
{ "file_path": "candle/candle-nn/src/var_builder.rs", "repo_id": "candle", "token_count": 11054 }
use candle::Result; use prost::Message; pub mod onnx { include!(concat!(env!("OUT_DIR"), "/onnx.rs")); } pub mod eval; pub use eval::{dtype, simple_eval}; pub fn read_file<P: AsRef<std::path::Path>>(p: P) -> Result<onnx::ModelProto> { let buf = std::fs::read(p)?; onnx::ModelProto::decode(buf.as_slice())....
candle/candle-onnx/src/lib.rs/0
{ "file_path": "candle/candle-onnx/src/lib.rs", "repo_id": "candle", "token_count": 154 }
use std::collections::HashMap; use crate::utils::wrap_err; use crate::{PyDType, PyTensor}; use candle_onnx::eval::{dtype, get_tensor, simple_eval}; use candle_onnx::onnx::tensor_proto::DataType; use candle_onnx::onnx::tensor_shape_proto::dimension::Value; use candle_onnx::onnx::type_proto::{Tensor as ONNXTensor, Value...
candle/candle-pyo3/src/onnx.rs/0
{ "file_path": "candle/candle-pyo3/src/onnx.rs", "repo_id": "candle", "token_count": 3268 }
//! ConvMixer implementation. //! //! See "Patches Are All You Need?" by Trockman et al. 2022 //! //! - 📝 [Arxiv](https://arxiv.org/abs/2201.09792) //! - 💻 [Github](https://github.com/locuslab/convmixer) //! use candle::Result; use candle_nn::{batch_norm, Conv2dConfig, Module, VarBuilder}; #[allow(clippy::many_singl...
candle/candle-transformers/src/models/convmixer.rs/0
{ "file_path": "candle/candle-transformers/src/models/convmixer.rs", "repo_id": "candle", "token_count": 1504 }
use candle::{DType, IndexOp, Result, Tensor, D}; use candle_nn::{LayerNorm, Linear, RmsNorm, VarBuilder}; // https://github.com/black-forest-labs/flux/blob/727e3a71faf37390f318cf9434f0939653302b60/src/flux/model.py#L12 #[derive(Debug, Clone)] pub struct Config { pub in_channels: usize, pub vec_in_dim: usize, ...
candle/candle-transformers/src/models/flux/model.rs/0
{ "file_path": "candle/candle-transformers/src/models/flux/model.rs", "repo_id": "candle", "token_count": 10740 }
//! Mamba inference implementation. //! //! See ["Mamba: Linear-Time Sequence Modeling with Selective State Spaces"](https://arxiv.org/abs/2312.00752) //! //! Based on reference implementation from the AlbertMamba project //! A fast implementation of mamba for inference only. //! Based on Laurent Mazare's rust implemen...
candle/candle-transformers/src/models/mamba.rs/0
{ "file_path": "candle/candle-transformers/src/models/mamba.rs", "repo_id": "candle", "token_count": 3923 }
use candle::{Module, Result, Tensor}; use candle_nn as nn; pub struct Qkv { pub q: Tensor, pub k: Tensor, pub v: Tensor, } pub struct Mlp { fc1: nn::Linear, act: nn::Activation, fc2: nn::Linear, } impl Mlp { pub fn new( in_features: usize, hidden_features: usize, v...
candle/candle-transformers/src/models/mmdit/projections.rs/0
{ "file_path": "candle/candle-transformers/src/models/mmdit/projections.rs", "repo_id": "candle", "token_count": 1917 }
//! Persimmon Model //! //! A transformer language model for efficient inference and general-purpose tasks. The model uses a standard transformer architecture with: //! - Layer normalization for Q/K attention //! - RoPE embeddings with partial rotary factor //! - ReLU activation //! - Separate number of attention heads...
candle/candle-transformers/src/models/persimmon.rs/0
{ "file_path": "candle/candle-transformers/src/models/persimmon.rs", "repo_id": "candle", "token_count": 1045 }
//! Phi3 model implementation with quantization support. //! //! Phi3 is a language model intended for research purposes. //! This implementation provides quantization for reduced memory usage. //! //! Key characteristics: //! - Multi-head attention //! - RMSNorm for layer normalization //! - Rotary positional embeddin...
candle/candle-transformers/src/models/quantized_phi3.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_phi3.rs", "repo_id": "candle", "token_count": 6108 }
use candle::{IndexOp, Result, Tensor}; use candle_nn::{Module, VarBuilder}; use super::transformer::TwoWayTransformer; #[derive(Debug)] struct MlpMaskDecoder { layers: Vec<super::Linear>, sigmoid_output: bool, span: tracing::Span, } impl MlpMaskDecoder { fn new( input_dim: usize, hidd...
candle/candle-transformers/src/models/segment_anything/mask_decoder.rs/0
{ "file_path": "candle/candle-transformers/src/models/segment_anything/mask_decoder.rs", "repo_id": "candle", "token_count": 4213 }
//! 2D UNet Denoising Models //! //! The 2D Unet models take as input a noisy sample and the current diffusion //! timestep and return a denoised version of the input. use super::embeddings::{TimestepEmbedding, Timesteps}; use super::unet_2d_blocks::*; use crate::models::with_tracing::{conv2d, Conv2d}; use candle::{Res...
candle/candle-transformers/src/models/stable_diffusion/unet_2d.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/unet_2d.rs", "repo_id": "candle", "token_count": 8419 }
use candle::{Module, Result, Tensor}; use candle_nn::VarBuilder; #[derive(Debug, Clone)] pub struct Embedding { inner: candle_nn::Embedding, span: tracing::Span, } impl Embedding { pub fn new(d1: usize, d2: usize, vb: VarBuilder) -> Result<Self> { let inner = candle_nn::embedding(d1, d2, vb)?; ...
candle/candle-transformers/src/models/with_tracing.rs/0
{ "file_path": "candle/candle-transformers/src/models/with_tracing.rs", "repo_id": "candle", "token_count": 2381 }
use candle::{Device, Result, Tensor}; use candle_transformers::generation::LogitsProcessor; #[test] fn sample_with_zero_temperature() -> Result<()> { let mut logits_process = LogitsProcessor::new(1337, None, None); let logits = Tensor::new(&[0.1, 0.2, 0.3, 0.4], &Device::Cpu)?; let token = logits_process.s...
candle/candle-transformers/tests/generation_tests.rs/0
{ "file_path": "candle/candle-transformers/tests/generation_tests.rs", "repo_id": "candle", "token_count": 806 }
use wasm_bindgen::prelude::*; pub mod token_output_stream; #[wasm_bindgen] extern "C" { // Use `js_namespace` here to bind `console.log(..)` instead of just // `log(..)` #[wasm_bindgen(js_namespace = console)] pub fn log(s: &str); } #[macro_export] macro_rules! console_log { // Note that this is u...
candle/candle-wasm-examples/blip/src/lib.rs/0
{ "file_path": "candle/candle-wasm-examples/blip/src/lib.rs", "repo_id": "candle", "token_count": 192 }
## Running [Moondream 2](https://huggingface.co/vikhyatk/moondream2) Model Example ### Vanilla JS and WebWorkers To build and test the UI made in Vanilla JS and WebWorkers, first we need to build the WASM library: ```bash sh build-lib.sh ``` This will bundle the library under `./build` and we can import it inside o...
candle/candle-wasm-examples/moondream/README.md/0
{ "file_path": "candle/candle-wasm-examples/moondream/README.md", "repo_id": "candle", "token_count": 217 }
## Running Whisper Examples Here, we provide two examples of how to run Whisper using a Candle-compiled WASM binary and runtimes. ### Pure Rust UI To build and test the UI made in Rust you will need [Trunk](https://trunkrs.dev/#install) From the `candle-wasm-examples/whisper` directory run: Download assets: ```bas...
candle/candle-wasm-examples/whisper/README.md/0
{ "file_path": "candle/candle-wasm-examples/whisper/README.md", "repo_id": "candle", "token_count": 1023 }
{ "moz:firefoxOptions": { "prefs": { "media.navigator.streams.fake": true, "media.navigator.permission.disabled": true }, "args": [] }, "goog:chromeOptions": { "args": [ "--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream" ] } }
candle/candle-wasm-tests/webdriver.json/0
{ "file_path": "candle/candle-wasm-tests/webdriver.json", "repo_id": "candle", "token_count": 143 }
apiVersion: v1 kind: ConfigMap metadata: labels: {{ include "labels.standard" . | nindent 4 }} name: {{ include "name" . }} namespace: {{ .Release.Namespace }} data: {{- range $key, $value := $.Values.envVars }} {{ $key }}: {{ $value | quote }} {{- end }}
chat-ui/chart/templates/config.yaml/0
{ "file_path": "chat-ui/chart/templates/config.yaml", "repo_id": "chat-ui", "token_count": 96 }
# Anthropic | Feature | Available | | --------------------------- | --------- | | [Tools](../tools) | No | | [Multimodal](../multimodal) | Yes | We also support Anthropic models (including multimodal ones via `multmodal: true`) through the official SDK. You may provide your ...
chat-ui/docs/source/configuration/models/providers/anthropic.md/0
{ "file_path": "chat-ui/docs/source/configuration/models/providers/anthropic.md", "repo_id": "chat-ui", "token_count": 1541 }
# Copy HuggingChat The config file for HuggingChat is stored in the `chart/env/prod.yaml` file. It is the source of truth for the environment variables used for our CI/CD pipeline. For HuggingChat, as we need to customize the app color, as well as the base path, we build a custom docker image. You can find the workflo...
chat-ui/docs/source/developing/copy-huggingchat.md/0
{ "file_path": "chat-ui/docs/source/developing/copy-huggingchat.md", "repo_id": "chat-ui", "token_count": 870 }
import { env } from "$env/dynamic/private"; import { env as envPublic } from "$env/dynamic/public"; import type { Handle, HandleServerError } from "@sveltejs/kit"; import { collections } from "$lib/server/database"; import { base } from "$app/paths"; import { findUser, refreshSessionCookie, requiresUser } from "$lib/se...
chat-ui/src/hooks.server.ts/0
{ "file_path": "chat-ui/src/hooks.server.ts", "repo_id": "chat-ui", "token_count": 3211 }
<script lang="ts"> import { createEventDispatcher, onDestroy, onMount } from "svelte"; import { cubicOut } from "svelte/easing"; import { fade, fly } from "svelte/transition"; import Portal from "./Portal.svelte"; import { browser } from "$app/environment"; interface Props { width?: string; children?: import...
chat-ui/src/lib/components/Modal.svelte/0
{ "file_path": "chat-ui/src/lib/components/Modal.svelte", "repo_id": "chat-ui", "token_count": 734 }
<script lang="ts"> import ToolLogo from "./ToolLogo.svelte"; import { base } from "$app/paths"; import { browser } from "$app/environment"; interface Props { toolId: string; } let { toolId }: Props = $props(); </script> <div class="relative flex items-center justify-center space-x-2 rounded border border-gr...
chat-ui/src/lib/components/ToolBadge.svelte/0
{ "file_path": "chat-ui/src/lib/components/ToolBadge.svelte", "repo_id": "chat-ui", "token_count": 523 }
<script lang="ts"> import { MessageToolUpdateType, type MessageToolUpdate } from "$lib/types/MessageUpdate"; import { isMessageToolCallUpdate, isMessageToolErrorUpdate, isMessageToolResultUpdate, } from "$lib/utils/messageUpdates"; import CarbonTools from "~icons/carbon/tools"; import { ToolResultStatus, ty...
chat-ui/src/lib/components/chat/ToolUpdate.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/ToolUpdate.svelte", "repo_id": "chat-ui", "token_count": 2368 }
import type { Migration } from "."; import { collections } from "$lib/server/database"; import { Collection, FindCursor, ObjectId } from "mongodb"; import { logger } from "$lib/server/logger"; import type { Conversation } from "$lib/types/Conversation"; const BATCH_SIZE = 1000; const DELETE_THRESHOLD_MS = 60 * 60 * 10...
chat-ui/src/lib/migrations/routines/09-delete-empty-conversations.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/09-delete-empty-conversations.ts", "repo_id": "chat-ui", "token_count": 950 }
import { z } from "zod"; import type { Endpoint } from "../endpoints"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import { env } from "$env/dynamic/private"; import { logger } from "$lib/server/logger"; export const endpointCloudflareParametersSchema = z.object({ weight: z.number().int(...
chat-ui/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts", "repo_id": "chat-ui", "token_count": 1621 }
import { error } from "@sveltejs/kit"; import { collections } from "$lib/server/database"; import type { Conversation } from "$lib/types/Conversation"; import type { SharedConversation } from "$lib/types/SharedConversation"; import type { MessageFile } from "$lib/types/Message"; export async function downloadFile( sh...
chat-ui/src/lib/server/files/downloadFile.ts/0
{ "file_path": "chat-ui/src/lib/server/files/downloadFile.ts", "repo_id": "chat-ui", "token_count": 397 }
import { env } from "$env/dynamic/private"; import type { ChatTemplateInput } from "$lib/types/Template"; import { compileTemplate } from "$lib/utils/template"; import { z } from "zod"; import endpoints, { endpointSchema, type Endpoint } from "./endpoints/endpoints"; import { endpointTgi } from "./endpoints/tgi/endpoin...
chat-ui/src/lib/server/models.ts/0
{ "file_path": "chat-ui/src/lib/server/models.ts", "repo_id": "chat-ui", "token_count": 4853 }
import { stringifyMarkdownElementTree } from "$lib/server/websearch/markdown/utils/stringify"; import { scrapeUrl } from "$lib/server/websearch/scrape/scrape"; import type { ConfigTool } from "$lib/types/Tool"; import { ObjectId } from "mongodb"; const fetchUrl: ConfigTool = { _id: new ObjectId("000000000000000000000...
chat-ui/src/lib/server/tools/web/url.ts/0
{ "file_path": "chat-ui/src/lib/server/tools/web/url.ts", "repo_id": "chat-ui", "token_count": 357 }
import { WebSearchProvider, type WebSearchSource } from "$lib/types/WebSearch"; import { env } from "$env/dynamic/private"; import searchSerper from "./endpoints/serper"; import searchSerpApi from "./endpoints/serpApi"; import searchSerpStack from "./endpoints/serpStack"; import searchYouApi from "./endpoints/youApi"; ...
chat-ui/src/lib/server/websearch/search/endpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/search/endpoints.ts", "repo_id": "chat-ui", "token_count": 543 }
import type { ObjectId } from "mongodb"; import type { User } from "./User"; import type { Assistant } from "./Assistant"; import type { Timestamps } from "./Timestamps"; export interface Report extends Timestamps { _id: ObjectId; createdBy: User["_id"] | string; object: "assistant" | "tool"; contentId: Assistant[...
chat-ui/src/lib/types/Report.ts/0
{ "file_path": "chat-ui/src/lib/types/Report.ts", "repo_id": "chat-ui", "token_count": 112 }
type UUID = ReturnType<typeof crypto.randomUUID>; export function randomUUID(): UUID { // Only on old safari / ios if (!("randomUUID" in crypto)) { return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => ( Number(c) ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (Number(c) / 4))...
chat-ui/src/lib/utils/randomUuid.ts/0
{ "file_path": "chat-ui/src/lib/utils/randomUuid.ts", "repo_id": "chat-ui", "token_count": 166 }
import type { Conversation } from "$lib/types/Conversation"; import type { Message } from "$lib/types/Message"; export function buildSubtree( conv: Pick<Conversation, "messages" | "rootMessageId">, id: Message["id"] ): Message[] { if (!conv.rootMessageId) { if (conv.messages.length === 0) return []; // legacy c...
chat-ui/src/lib/utils/tree/buildSubtree.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/buildSubtree.ts", "repo_id": "chat-ui", "token_count": 329 }
import { models } from "$lib/server/models"; export async function GET() { const res = models .filter((m) => m.unlisted == false) .map((model) => ({ id: model.id, name: model.name, websiteUrl: model.websiteUrl ?? "https://huggingface.co", modelUrl: model.modelUrl ?? "https://huggingface.co", tokeni...
chat-ui/src/routes/api/models/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/models/+server.ts", "repo_id": "chat-ui", "token_count": 311 }
import { buildPrompt } from "$lib/buildPrompt"; import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { models } from "$lib/server/models"; import { buildSubtree } from "$lib/utils/tree/buildSubtree"; import { isMessageId } from "$lib/utils/tree/isMessageId"; impor...
chat-ui/src/routes/conversation/[id]/message/[messageId]/prompt/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/message/[messageId]/prompt/+server.ts", "repo_id": "chat-ui", "token_count": 654 }
<script lang="ts"> import { env as envPublic } from "$env/dynamic/public"; import { isHuggingChat } from "$lib/utils/isHuggingChat"; import logo from "../../../../../static/huggingchat/logo.svg?raw"; interface Props { name: string; logoUrl: string | undefined; } let { name, logoUrl }: Props = $props(); </sc...
chat-ui/src/routes/models/[...model]/thumbnail.png/ModelThumbnail.svelte/0
{ "file_path": "chat-ui/src/routes/models/[...model]/thumbnail.png/ModelThumbnail.svelte", "repo_id": "chat-ui", "token_count": 503 }
<script lang="ts"> import type { ActionData, PageData } from "./$types"; import AssistantSettings from "$lib/components/AssistantSettings.svelte"; interface Props { data: PageData; form: ActionData; } let { data, form = $bindable() }: Props = $props(); </script> <AssistantSettings bind:form models={data.mod...
chat-ui/src/routes/settings/(nav)/assistants/new/+page@settings.svelte/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/new/+page@settings.svelte", "repo_id": "chat-ui", "token_count": 108 }
import { sveltekit } from "@sveltejs/kit/vite"; import Icons from "unplugin-icons/vite"; import { promises } from "fs"; import { defineConfig } from "vitest/config"; // used to load fonts server side for thumbnail generation function loadTTFAsArrayBuffer() { return { name: "load-ttf-as-array-buffer", async transf...
chat-ui/vite.config.ts/0
{ "file_path": "chat-ui/vite.config.ts", "repo_id": "chat-ui", "token_count": 393 }
import json import sys def format_json_to_md(input_json_file, output_md_file): with open(input_json_file, encoding="utf-8") as f: results = json.load(f) output_md = ["<details>", "<summary>Show updated benchmarks!</summary>", " "] for benchmark_name in sorted(results): benchmark_res = re...
datasets/benchmarks/format.py/0
{ "file_path": "datasets/benchmarks/format.py", "repo_id": "datasets", "token_count": 746 }
# Create an image dataset There are two methods for creating and sharing an image dataset. This guide will show you how to: * Create an image dataset from local files in python with [`Dataset.push_to_hub`]. This is an easy way that requires only a few steps in python. * Create an image dataset with `ImageFolder` and...
datasets/docs/source/image_dataset.mdx/0
{ "file_path": "datasets/docs/source/image_dataset.mdx", "repo_id": "datasets", "token_count": 5689 }
# Utilities ## Configure logging 🤗 Datasets strives to be transparent and explicit about how it works, but this can be quite verbose at times. We have included a series of logging methods which allow you to easily adjust the level of verbosity of the entire library. Currently the default verbosity of the library is ...
datasets/docs/source/package_reference/utilities.mdx/0
{ "file_path": "datasets/docs/source/package_reference/utilities.mdx", "repo_id": "datasets", "token_count": 725 }
# Use with PyArrow This document is a quick introduction to using `datasets` with PyArrow, with a particular focus on how to process datasets using Arrow compute functions, and how to convert a dataset to PyArrow or from PyArrow. This is particularly useful as it allows fast zero-copy operations, since `datasets` use...
datasets/docs/source/use_with_pyarrow.mdx/0
{ "file_path": "datasets/docs/source/use_with_pyarrow.mdx", "repo_id": "datasets", "token_count": 1257 }
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger HIGHLIGHT_MESSAGE_PRE = """<<<<<<< This should probably be modified because it mentions: """ HIGHLIGHT_MESSAGE_POST = """======= >>>>>>>...
datasets/src/datasets/commands/convert.py/0
{ "file_path": "datasets/src/datasets/commands/convert.py", "repo_id": "datasets", "token_count": 3811 }
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/audio.py/0
{ "file_path": "datasets/src/datasets/features/audio.py", "repo_id": "datasets", "token_count": 5332 }
# 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/info.py/0
{ "file_path": "datasets/src/datasets/info.py", "repo_id": "datasets", "token_count": 8410 }
import itertools from dataclasses import dataclass from typing import Optional import pyarrow as pa import datasets from datasets.features.features import require_storage_cast from datasets.table import table_cast logger = datasets.utils.logging.get_logger(__name__) @dataclass class XmlConfig(datasets.BuilderConf...
datasets/src/datasets/packaged_modules/xml/xml.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/xml/xml.py", "repo_id": "datasets", "token_count": 1167 }
# deprecated, please use the `filelock` package instead from filelock import ( # noqa: F401 # imported for backward compatibility TODO: remove in 3.0.0 BaseFileLock, SoftFileLock, Timeout, UnixFileLock, WindowsFileLock, ) from ._filelock import FileLock # noqa: F401 # imported for backward compa...
datasets/src/datasets/utils/filelock.py/0
{ "file_path": "datasets/src/datasets/utils/filelock.py", "repo_id": "datasets", "token_count": 115 }
"""Utility helpers to handle progress bars in `datasets`. Example: 1. Use `datasets.utils.tqdm` as you would use `tqdm.tqdm` or `tqdm.auto.tqdm`. 2. To disable progress bars, either use `disable_progress_bars()` helper or set the environment variable `HF_DATASETS_DISABLE_PROGRESS_BARS` to 1. 3. To r...
datasets/src/datasets/utils/tqdm.py/0
{ "file_path": "datasets/src/datasets/utils/tqdm.py", "repo_id": "datasets", "token_count": 1662 }
import os import time import uuid from contextlib import contextmanager from typing import Optional import pytest import requests from huggingface_hub.hf_api import HfApi, RepositoryNotFoundError from huggingface_hub.utils import hf_raise_for_status CI_HUB_USER = "__DUMMY_TRANSFORMERS_USER__" CI_HUB_USER_FULL_NAME =...
datasets/tests/fixtures/hub.py/0
{ "file_path": "datasets/tests/fixtures/hub.py", "repo_id": "datasets", "token_count": 2900 }
import shutil import textwrap import numpy as np import pytest from datasets import ClassLabel, Features, Image, Value from datasets.builder import InvalidConfigName from datasets.data_files import DataFilesDict, DataFilesList, get_data_patterns from datasets.download.streaming_download_manager import StreamingDownlo...
datasets/tests/packaged_modules/test_imagefolder.py/0
{ "file_path": "datasets/tests/packaged_modules/test_imagefolder.py", "repo_id": "datasets", "token_count": 8893 }
import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.download.streaming_download_manager import StreamingDownloadManager from datasets.utils.file_utils import hash_url_to_f...
datasets/tests/test_download_manager.py/0
{ "file_path": "datasets/tests/test_download_manager.py", "repo_id": "datasets", "token_count": 2945 }
from tempfile import NamedTemporaryFile import pytest import requests from datasets.utils.file_utils import fsspec_get, fsspec_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline, require_not_windows @pytest.mark.integration @require_not_windows # fsspec get keeps a file hand...
datasets/tests/test_offline_util.py/0
{ "file_path": "datasets/tests/test_offline_util.py", "repo_id": "datasets", "token_count": 641 }
.PHONY: deps_table_update modified_only_fixup extra_style_checks quality style fixup fix-copies test test-examples # make sure to test the local checkout in scripts and not the pre-installed one (don't use quotes!) export PYTHONPATH = src check_dirs := examples scripts src tests utils benchmarks modified_only_fixup:...
diffusers/Makefile/0
{ "file_path": "diffusers/Makefile", "repo_id": "diffusers", "token_count": 929 }
FROM ubuntu:20.04 LABEL maintainer="Hugging Face" LABEL repository="diffusers" ENV DEBIAN_FRONTEND=noninteractive RUN apt-get -y update \ && apt-get install -y software-properties-common \ && add-apt-repository ppa:deadsnakes/ppa RUN apt install -y bash \ build-essential \ git \ git-l...
diffusers/docker/diffusers-flax-cpu/Dockerfile/0
{ "file_path": "diffusers/docker/diffusers-flax-cpu/Dockerfile", "repo_id": "diffusers", "token_count": 652 }
<!-- 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/api/cache.md/0
{ "file_path": "diffusers/docs/source/en/api/cache.md", "repo_id": "diffusers", "token_count": 674 }
<!-- 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/api/models/autoencoder_kl_hunyuan_video.md/0
{ "file_path": "diffusers/docs/source/en/api/models/autoencoder_kl_hunyuan_video.md", "repo_id": "diffusers", "token_count": 383 }