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/examples/datasets/tldr_preference.py/0
{ "file_path": "trl/examples/datasets/tldr_preference.py", "repo_id": "trl", "token_count": 1547 }
# 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/research_projects/stack_llama_2/scripts/sft_llama2.py/0
{ "file_path": "trl/examples/research_projects/stack_llama_2/scripts/sft_llama2.py", "repo_id": "trl", "token_count": 2893 }
# 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/gkd.py/0
{ "file_path": "trl/examples/scripts/gkd.py", "repo_id": "trl", "token_count": 1996 }
# 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_callbacks.py/0
{ "file_path": "trl/tests/test_callbacks.py", "repo_id": "trl", "token_count": 7904 }
# 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_kto_trainer.py/0
{ "file_path": "trl/tests/test_kto_trainer.py", "repo_id": "trl", "token_count": 8212 }
# 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/models/modeling_sd_base.py/0
{ "file_path": "trl/trl/models/modeling_sd_base.py", "repo_id": "trl", "token_count": 17406 }
# 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/bco_config.py/0
{ "file_path": "trl/trl/trainer/bco_config.py", "repo_id": "trl", "token_count": 3178 }
# 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/kto_trainer.py/0
{ "file_path": "trl/trl/trainer/kto_trainer.py", "repo_id": "trl", "token_count": 34887 }
# 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/sft_config.py/0
{ "file_path": "trl/trl/trainer/sft_config.py", "repo_id": "trl", "token_count": 2682 }
FROM ghcr.io/azure/msamp RUN pip install transformers evaluate datasets RUN git clone https://github.com/huggingface/accelerate RUN cd accelerate && \ pip install -e . && \ cd benchmarks/fp8 CMD ["bash"]
accelerate/benchmarks/fp8/ms_amp/Dockerfile/0
{ "file_path": "accelerate/benchmarks/fp8/ms_amp/Dockerfile", "repo_id": "accelerate", "token_count": 78 }
<!--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/ipex.md/0
{ "file_path": "accelerate/docs/source/usage_guides/ipex.md", "repo_id": "accelerate", "token_count": 2634 }
# Similar to FSDP, we set the distributed type as DEEPSPEED distributed_type: DEEPSPEED # With DeepSpeed, we utilize a deepspeed config file for the entire configuration deepspeed_config: # Can also be any of the config json's in accelerate/examples/deepspeed_config_templates deepspeed_config_file: ../deepspeed_con...
accelerate/examples/config_yaml_templates/deepspeed.yaml/0
{ "file_path": "accelerate/examples/config_yaml_templates/deepspeed.yaml", "repo_id": "accelerate", "token_count": 239 }
# 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/distributed/florence2.py/0
{ "file_path": "accelerate/examples/inference/distributed/florence2.py", "repo_id": "accelerate", "token_count": 3297 }
# Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/__init__.py/0
{ "file_path": "accelerate/src/accelerate/__init__.py", "repo_id": "accelerate", "token_count": 500 }
#!/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/launch.py/0
{ "file_path": "accelerate/src/accelerate/commands/launch.py", "repo_id": "accelerate", "token_count": 20243 }
# 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/logging.py/0
{ "file_path": "accelerate/src/accelerate/logging.py", "repo_id": "accelerate", "token_count": 1842 }
# 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/environment.py/0
{ "file_path": "accelerate/src/accelerate/utils/environment.py", "repo_id": "accelerate", "token_count": 5668 }
{ "fp16": { "enabled": "auto", "loss_scale": 0, "loss_scale_window": 1000, "initial_scale_power": 16, "hysteresis": 2, "min_loss_scale": 1 }, "bf16": { "enabled": "auto" }, "optimizer": { "type": "AdamW", "params": { ...
accelerate/tests/deepspeed/ds_config_zero2.json/0
{ "file_path": "accelerate/tests/deepspeed/ds_config_zero2.json", "repo_id": "accelerate", "token_count": 680 }
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_quantization.py/0
{ "file_path": "accelerate/tests/test_quantization.py", "repo_id": "accelerate", "token_count": 17702 }
# Summary [Introduction](README.md) # User Guide - [Installation](guide/installation.md) - [Hello World - MNIST](guide/hello_world.md) - [PyTorch cheatsheet](guide/cheatsheet.md) # Reference Guide - [Running a model](inference/inference.md) - [Using the hub](inference/hub.md) - [Error management](error_manage....
candle/candle-book/src/SUMMARY.md/0
{ "file_path": "candle/candle-book/src/SUMMARY.md", "repo_id": "candle", "token_count": 274 }
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle_core::{DType, Device, Tensor}; use criterion::{black_box, criterion_group, Criterion, Throughput}; use std::time::Instant; fn run(a: &Tensor, b: &Tensor) { a.matmul(&b.t().unwrap()).unwrap(); } fn run_bench(c: &mut Criterion, device: &Device) { ...
candle/candle-core/benches/benchmarks/matmul.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/matmul.rs", "repo_id": "candle", "token_count": 551 }
use super::{Cpu, CpuF16}; #[cfg(target_arch = "x86")] use core::arch::x86::*; #[cfg(target_arch = "x86_64")] use core::arch::x86_64::*; use half::f16; pub struct CurrentCpu {} const STEP: usize = 32; const EPR: usize = 8; const ARR: usize = STEP / EPR; impl Cpu<ARR> for CurrentCpu { type Unit = __m256; type...
candle/candle-core/src/cpu/avx.rs/0
{ "file_path": "candle/candle-core/src/cpu/avx.rs", "repo_id": "candle", "token_count": 2094 }
//! Types for elements that can be stored and manipulated using tensors. #![allow(clippy::redundant_closure_call)] use crate::backend::BackendStorage; use crate::{CpuStorage, CpuStorageRef, Error, Result}; /// The different types of elements allowed in tensors. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub en...
candle/candle-core/src/dtype.rs/0
{ "file_path": "candle/candle-core/src/dtype.rs", "repo_id": "candle", "token_count": 3099 }
#![allow(unused)] use super::GgmlDType; use crate::{Error, MetalDevice, MetalStorage, Result}; pub struct QMetalStorage { dtype: GgmlDType, device: MetalDevice, } impl QMetalStorage { pub fn zeros(_: &MetalDevice, _: usize, _: GgmlDType) -> Result<Self> { Err(Error::NotCompiledWithMetalSupport) ...
candle/candle-core/src/quantized/dummy_metal.rs/0
{ "file_path": "candle/candle-core/src/quantized/dummy_metal.rs", "repo_id": "candle", "token_count": 522 }
//! Tensors are N-dimensional matrixes of elements using a single data type. #![allow(clippy::redundant_closure_call)] use crate::backend::{BackendDevice, BackendStorage}; use crate::op::{BackpropOp, BinaryOp, CmpOp, Op, ReduceOp, UnaryOp}; use crate::scalar::TensorOrScalar; use crate::shape::{Dim, Dims}; use crate::{b...
candle/candle-core/src/tensor.rs/0
{ "file_path": "candle/candle-core/src/tensor.rs", "repo_id": "candle", "token_count": 48959 }
/// Regression test for pth files not loading on Windows. #[test] fn test_pth() { let tensors = candle_core::pickle::PthTensors::new("tests/test.pt", None).unwrap(); tensors.get("test").unwrap().unwrap(); } #[test] fn test_pth_with_key() { let tensors = candle_core::pickle::PthTensors::new("tests/t...
candle/candle-core/tests/pth_tests.rs/0
{ "file_path": "candle/candle-core/tests/pth_tests.rs", "repo_id": "candle", "token_count": 440 }
//! The MNIST hand-written digit dataset. //! //! The files can be obtained from the following link: //! <http://yann.lecun.com/exdb/mnist/> use candle::{DType, Device, Error, Result, Tensor}; use hf_hub::{api::sync::Api, Repo, RepoType}; use parquet::file::reader::{FileReader, SerializedFileReader}; use std::fs::File;...
candle/candle-datasets/src/vision/mnist.rs/0
{ "file_path": "candle/candle-datasets/src/vision/mnist.rs", "repo_id": "candle", "token_count": 2133 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, Device, Tensor}; use candle_nn as nn; use candle_transformers::models::chinese_clip::{ChineseClipConfig, ChineseClipModel}; use clap::Parser; use tokenizers::Tokenizer; #[derive(Parser)...
candle/candle-examples/examples/chinese_clip/main.rs/0
{ "file_path": "candle/candle-examples/examples/chinese_clip/main.rs", "repo_id": "candle", "token_count": 3194 }
# candle-dinov2 [Depth Anything V2] is a model for Monocular Depth Estimation (MDE, i.e. just using a single image) which builds on the [DINOv2](https://github.com/facebookresearch/dinov2) vision transformer. This example first instantiates the DINOv2 model and then proceeds to create DepthAnythingV2 and run it. ## ...
candle/candle-examples/examples/depth_anything_v2/README.md/0
{ "file_path": "candle/candle-examples/examples/depth_anything_v2/README.md", "repo_id": "candle", "token_count": 168 }
# candle-eva2 [EVA-02](https://arxiv.org/abs/2303.11331) is a computer vision model. In this example, it is used as an ImageNet classifier: the model returns the probability for the image to belong to each of the 1000 ImageNet categories. ## Running some example ```bash cargo run --example eva2 --release -- --image ...
candle/candle-examples/examples/eva2/README.md/0
{ "file_path": "candle/candle-examples/examples/eva2/README.md", "repo_id": "candle", "token_count": 264 }
# gte-Qwen1.5-7B-instruct gte-Qwen1.5-7B-instruct is a variant of the GTE embedding model family. - [Model card](https://huggingface.co/Alibaba-NLP/gte-Qwen1.5-7B-instruct) on the HuggingFace Hub. - [Technical report](https://arxiv.org/abs/2308.03281) *Towards General Text Embeddings with Multi-stage Contrastive Lear...
candle/candle-examples/examples/gte-qwen/README.md/0
{ "file_path": "candle/candle-examples/examples/gte-qwen/README.md", "repo_id": "candle", "token_count": 229 }
pub mod constants; pub mod conversation; pub mod image_processor; use candle_transformers::generation::{LogitsProcessor, Sampling}; use candle_transformers::models::llama::Cache; use anyhow::{bail, Error as E, Result}; use candle::{DType, Device, IndexOp, Tensor}; use candle_nn::VarBuilder; use candle_transformers::m...
candle/candle-examples/examples/llava/main.rs/0
{ "file_path": "candle/candle-examples/examples/llava/main.rs", "repo_id": "candle", "token_count": 5097 }
# NV-Embed-v2 Candle implementation (inference only) of [NV-Embed-v2](https://huggingface.co/nvidia/NV-Embed-v2), a text embedding model that ranks No. 1 (as of Nov 25 2024) on the [MTEB](https://huggingface.co/spaces/mteb/leaderboard) benchmark with a score of 72.31 across 56 text embedding tasks. ## Running an exam...
candle/candle-examples/examples/nvembed_v2/README.md/0
{ "file_path": "candle/candle-examples/examples/nvembed_v2/README.md", "repo_id": "candle", "token_count": 851 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use std::io::Write; use tokenizers::Tokenizer; use candle::quantized::gguf_file; use candle::Tensor; use candle_transformers::generation::{LogitsProcessor, Sampling}; use ca...
candle/candle-examples/examples/quantized-phi/main.rs/0
{ "file_path": "candle/candle-examples/examples/quantized-phi/main.rs", "repo_id": "candle", "token_count": 5342 }
//! Wrappers around the Python API of Gymnasium (the new version of OpenAI gym) use candle::{Device, Result, Tensor}; use pyo3::prelude::*; use pyo3::types::PyDict; /// The return value for a step. #[derive(Debug)] pub struct Step<A> { pub state: Tensor, pub action: A, pub reward: f64, pub terminated: ...
candle/candle-examples/examples/reinforcement-learning/gym_env.rs/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/gym_env.rs", "repo_id": "candle", "token_count": 1743 }
# candle-segment-anything: Segment-Anything Model This example is based on Meta AI [Segment-Anything Model](https://github.com/facebookresearch/segment-anything). This model provides a robust and fast image segmentation pipeline that can be tweaked via some prompting (requesting some points to be in the target mask, r...
candle/candle-examples/examples/segment-anything/README.md/0
{ "file_path": "candle/candle-examples/examples/segment-anything/README.md", "repo_id": "candle", "token_count": 573 }
use anyhow::{Ok, Result}; use candle_transformers::models::stable_diffusion::vae; pub fn build_sd3_vae_autoencoder(vb: candle_nn::VarBuilder) -> Result<vae::AutoEncoderKL> { let config = vae::AutoEncoderKLConfig { block_out_channels: vec![128, 256, 512, 512], layers_per_block: 2, latent_cha...
candle/candle-examples/examples/stable-diffusion-3/vae.rs/0
{ "file_path": "candle/candle-examples/examples/stable-diffusion-3/vae.rs", "repo_id": "candle", "token_count": 1772 }
## VGG Model Implementation This example demonstrates the implementation of VGG models (VGG13, VGG16, VGG19) using the Candle library. The VGG models are defined in `candle-transformers/src/models/vgg.rs`. The main function in `candle-examples/examples/vgg/main.rs` loads an image, selects the VGG model based on the p...
candle/candle-examples/examples/vgg/README.md/0
{ "file_path": "candle/candle-examples/examples/vgg/README.md", "repo_id": "candle", "token_count": 200 }
# candle-xlm-roberta This example demonstrates how to use the XLM-RoBERTa model in Candle especially known for their use in reranking. It uses the `fill-mask` task to generate a word for a masked token. And a `reranker` task to rerank a list of documents for a given query. ## Usage Fill Mask: ```bash cargo run --exa...
candle/candle-examples/examples/xlm-roberta/Readme.md/0
{ "file_path": "candle/candle-examples/examples/xlm-roberta/Readme.md", "repo_id": "candle", "token_count": 367 }
// Copied from https://github.com/ruuda/bs1770/blob/master/src/lib.rs // BS1770 -- Loudness analysis library conforming to ITU-R BS.1770 // Copyright 2020 Ruud van Asseldonk // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // A copy ...
candle/candle-examples/src/bs1770.rs/0
{ "file_path": "candle/candle-examples/src/bs1770.rs", "repo_id": "candle", "token_count": 7220 }
/****************************************************************************** * Copyright (c) 2023, Tri Dao. ******************************************************************************/ #pragma once // #include <c10/cuda/CUDAException.h> // For C10_CUDA_CHECK and C10_CUDA_KERNEL_LAUNCH_CHECK #include "error.h...
candle/candle-flash-attn/kernels/flash_fwd_launch_template.h/0
{ "file_path": "candle/candle-flash-attn/kernels/flash_fwd_launch_template.h", "repo_id": "candle", "token_count": 10705 }
#define _USE_MATH_DEFINES #include<math.h> #include<stdint.h> #include "cuda_utils.cuh" #define UNARY_OP(TYPENAME, FN_NAME, FUNC) \ extern "C" __global__ void FN_NAME( \ const size_t numel, \ const size_t num_dims, \ const size_t *info, \ const TYPENAME *inp, \ TYPENAME *out \ ) { \ const size_...
candle/candle-kernels/src/unary.cu/0
{ "file_path": "candle/candle-kernels/src/unary.cu", "repo_id": "candle", "token_count": 3677 }
#include <metal_stdlib> #include <metal_limits> using namespace metal; METAL_FUNC uint nonzero(uint n) { return n == 0 ? 1 : n; } template<uint N> constexpr uint nonzero() { return N == 0 ? 1 : N; } template<typename T> constexpr ushort granularity() { return nonzero<vec_elements<T>::value>(); } METAL_F...
candle/candle-metal-kernels/src/reduce.metal/0
{ "file_path": "candle/candle-metal-kernels/src/reduce.metal", "repo_id": "candle", "token_count": 21154 }
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle::{DType, Device, Module, Tensor}; use candle_nn::{Conv2d, Conv2dConfig}; use criterion::{black_box, criterion_group, Criterion}; use std::time::Instant; const B: usize = 1; const C: usize = 1; const M: usize = 128; const K: usize = 128; const K_SIZE:...
candle/candle-nn/benches/benchmarks/conv.rs/0
{ "file_path": "candle/candle-nn/benches/benchmarks/conv.rs", "repo_id": "candle", "token_count": 808 }
//! candle-nn //! //! ## Other Crates //! //! Candle consists of a number of crates. This crate holds structs and functions //! that allow you to build and train neural nets. You may wish //! to look at the docs for the other crates which can be found here: //! //! - [candle-core](https://docs.rs/candle-core/). Core Da...
candle/candle-nn/src/lib.rs/0
{ "file_path": "candle/candle-nn/src/lib.rs", "repo_id": "candle", "token_count": 807 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{test_device, test_utils::to_vec3_round, Device, Result, Tensor}; fn softmax(device: &Device) -> Result<()> { let data = &[[[3f32, 1., 4.], [1., 5., 9.]], [[2., 1., 7.], [8., 2., 8.]]]; ...
candle/candle-nn/tests/ops.rs/0
{ "file_path": "candle/candle-nn/tests/ops.rs", "repo_id": "candle", "token_count": 5198 }
# Generated content DO NOT EDIT from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence from os import PathLike from candle.typing import _ArrayLike, Device, Scalar, Index, Shape from candle import Tensor, DType, QTensor class ONNXModel: """ A wrapper around an ONNX model. """ d...
candle/candle-pyo3/py_src/candle/onnx/__init__.pyi/0
{ "file_path": "candle/candle-pyo3/py_src/candle/onnx/__init__.pyi", "repo_id": "candle", "token_count": 939 }
import candle from candle import Tensor, QTensor from candle.nn import Module, Linear from candle.utils import cuda_is_available import pytest def test_module_can_be_constructed(): class A(Module): pass a = A() assert a is not None assert len(list(a.buffers())) == 0 def test_module_registe...
candle/candle-pyo3/tests/bindings/test_module.py/0
{ "file_path": "candle/candle-pyo3/tests/bindings/test_module.py", "repo_id": "candle", "token_count": 1853 }
//! Chinese contrastive Language-Image Pre-Training //! //! Chinese contrastive Language-Image Pre-Training (CLIP) is an architecture trained on //! pairs of images with related texts. //! //! - 💻 [GH Link](https://github.com/OFA-Sys/Chinese-CLIP) //! - 💻 Transformers Python [reference implementation](https://github....
candle/candle-transformers/src/models/chinese_clip/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/chinese_clip/mod.rs", "repo_id": "candle", "token_count": 3001 }
//! Implementation of EfficientBert, an efficient variant of BERT for computer vision tasks. //! //! See: //! - ["EfficientBERT: Progressively Searching Multilayer Perceptron Architectures for BERT"](https://arxiv.org/abs/2201.00462) //! use candle::{Context, Result, Tensor, D}; use candle_nn as nn; use nn::{Module, Va...
candle/candle-transformers/src/models/efficientnet.rs/0
{ "file_path": "candle/candle-transformers/src/models/efficientnet.rs", "repo_id": "candle", "token_count": 5204 }
//! Hiera inference implementation based on timm. //! //! //! - 💻 [Hiera](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/hiera.py) //! - 📝 [Paper](https://arxiv.org/abs/2306.00989). Hiera: A Hierarchical Vision Transformer without the Bells-and-Whistles use candle::{Result, D}; use candle_...
candle/candle-transformers/src/models/hiera.rs/0
{ "file_path": "candle/candle-transformers/src/models/hiera.rs", "repo_id": "candle", "token_count": 4445 }
// 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::{DType, Device, IndexOp, Module, Result, StreamTensor, StreamingModule, Tensor, D}; use candle_nn::{linear_no_bias, Linear, VarBuilder}; us...
candle/candle-transformers/src/models/mimi/transformer.rs/0
{ "file_path": "candle/candle-transformers/src/models/mimi/transformer.rs", "repo_id": "candle", "token_count": 14210 }
/// Mistral LLM, https://github.com/mistralai/mistral-src use crate::models::{ mistral::Config, with_tracing::{linear_no_bias, Linear, RmsNorm}, }; use crate::utils::repeat_kv; use candle::{DType, Device, Module, Result, Tensor}; use candle_nn::{Activation, VarBuilder}; use std::sync::Arc; #[derive(Debug, Clon...
candle/candle-transformers/src/models/nvembed_v2/embedding.rs/0
{ "file_path": "candle/candle-transformers/src/models/nvembed_v2/embedding.rs", "repo_id": "candle", "token_count": 4768 }
//! Quantized llama model implementation. //! //! This provides a quantized implementation of the llama language model architecture. //! The model implements parameter efficient quantization for reduced memory usage //! while maintaining model quality. //! //! Key characteristics: //! - Transformer decoder architecture...
candle/candle-transformers/src/models/quantized_llama.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_llama.rs", "repo_id": "candle", "token_count": 11486 }
//! Qwen2 model implementation with Mixture of Experts support. //! //! Qwen2 is a large language model using sparse Mixture of Experts (MoE). //! This implementation provides support for sparsely activated MoE layers. //! //! Key characteristics: //! - Mixture of Experts architecture //! - Sparse expert activation //!...
candle/candle-transformers/src/models/qwen2_moe.rs/0
{ "file_path": "candle/candle-transformers/src/models/qwen2_moe.rs", "repo_id": "candle", "token_count": 8732 }
//! Contrastive Language-Image Pre-Training //! //! Contrastive Language-Image Pre-Training (CLIP) is an architecture trained on //! pairs of images with related texts. //! //! - [CLIP](https://github.com/openai/CLIP) use candle::{DType, Device, Result, Tensor, D}; use candle_nn as nn; use candle_nn::Module; #[derive(...
candle/candle-transformers/src/models/stable_diffusion/clip.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/clip.rs", "repo_id": "candle", "token_count": 6983 }
use crate::models::with_tracing::{linear, Linear}; use candle::{DType, Module, Result, Tensor}; use candle_nn::{ embedding, layer_norm, ops::softmax_last_dim, Activation, Embedding, LayerNorm, VarBuilder, }; #[derive(Debug, Clone, serde::Deserialize)] pub struct Config { pub hidden_size: usize, pub layer_n...
candle/candle-transformers/src/models/xlm_roberta.rs/0
{ "file_path": "candle/candle-transformers/src/models/xlm_roberta.rs", "repo_id": "candle", "token_count": 8935 }
use candle_transformers::models::bert; use wasm_bindgen::prelude::*; pub use bert::{BertModel, Config, DTYPE}; pub use tokenizers::{PaddingParams, Tokenizer}; #[wasm_bindgen] extern "C" { // Use `js_namespace` here to bind `console.log(..)` instead of just // `log(..)` #[wasm_bindgen(js_namespace = consol...
candle/candle-wasm-examples/bert/src/lib.rs/0
{ "file_path": "candle/candle-wasm-examples/bert/src/lib.rs", "repo_id": "candle", "token_count": 226 }
use crate::console_log; use crate::worker::{ModelData, Worker, WorkerInput, WorkerOutput}; use std::str::FromStr; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; use yew::{html, Component, Context, Html}; use yew_agent::{Bridge, Bridged}; async fn fetch_url(url: &str) -> Result<Vec<u8>, JsValue> { ...
candle/candle-wasm-examples/llama2-c/src/app.rs/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/src/app.rs", "repo_id": "candle", "token_count": 5448 }
//load Candle Bert Module wasm module let init, ModelEncoder; async function fetchArrayBuffer(url) { const cacheName = "t5-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse.arrayBuffer(); ret...
candle/candle-wasm-examples/t5/T5ModelEncoderWorker.js/0
{ "file_path": "candle/candle-wasm-examples/t5/T5ModelEncoderWorker.js", "repo_id": "candle", "token_count": 873 }
use candle_wasm_example_whisper::worker::{Decoder as D, ModelData}; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct Decoder { decoder: D, } #[wasm_bindgen] impl Decoder { #[wasm_bindgen(constructor)] #[allow(clippy::too_many_arguments)] pub fn new( weights: Vec<u8>, tokenizer:...
candle/candle-wasm-examples/whisper/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/bin/m.rs", "repo_id": "candle", "token_count": 694 }
module.exports = { root: true, parser: "@typescript-eslint/parser", extends: [ "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:svelte/recommended", "prettier", ], plugins: ["@typescript-eslint"], ignorePatterns: ["*.cjs"], overrides: [ { files: ["*.svelte"], parser: "svelte...
chat-ui/.eslintrc.cjs/0
{ "file_path": "chat-ui/.eslintrc.cjs", "repo_id": "chat-ui", "token_count": 420 }
# syntax=docker/dockerfile:1 ARG INCLUDE_DB=false FROM node:20-slim AS base ENV PLAYWRIGHT_SKIP_BROWSER_GC=1 # install dotenv-cli RUN npm install -g dotenv-cli # switch to a user that works for spaces RUN userdel -r node RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH ...
chat-ui/Dockerfile/0
{ "file_path": "chat-ui/Dockerfile", "repo_id": "chat-ui", "token_count": 901 }
apiVersion: v1 kind: Service metadata: name: "{{ include "name" . }}" annotations: {{ toYaml .Values.service.annotations | nindent 4 }} namespace: {{ .Release.Namespace }} labels: {{ include "labels.standard" . | nindent 4 }} spec: ports: - name: http port: 80 protocol: TCP targetPort: http {{...
chat-ui/chart/templates/service.yaml/0
{ "file_path": "chat-ui/chart/templates/service.yaml", "repo_id": "chat-ui", "token_count": 192 }
# OpenAI | Feature | Available | | --------------------------- | --------- | | [Tools](../tools) | No | | [Multimodal](../multimodal) | No | Chat UI can be used with any API server that supports OpenAI API compatibility, for example [text-generation-webui](https://github.co...
chat-ui/docs/source/configuration/models/providers/openai.md/0
{ "file_path": "chat-ui/docs/source/configuration/models/providers/openai.md", "repo_id": "chat-ui", "token_count": 1942 }
{ "name": "chat-ui", "version": "0.9.4", "private": true, "packageManager": "npm@9.5.0", "scripts": { "dev": "vite dev", "build": "vite build", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./ts...
chat-ui/package.json/0
{ "file_path": "chat-ui/package.json", "repo_id": "chat-ui", "token_count": 2082 }
<script lang="ts"> import CarbonContinue from "~icons/carbon/continue"; interface Props { classNames?: string; onClick?: () => void; } let { classNames = "", onClick }: Props = $props(); </script> <button type="button" onclick={onClick} class="btn flex h-8 rounded-lg border bg-white px-3 py-1 text-gray-50...
chat-ui/src/lib/components/ContinueBtn.svelte/0
{ "file_path": "chat-ui/src/lib/components/ContinueBtn.svelte", "repo_id": "chat-ui", "token_count": 190 }
<script lang="ts"> import CarbonRotate360 from "~icons/carbon/rotate-360"; interface Props { classNames?: string; onClick?: () => void; } let { classNames = "", onClick }: Props = $props(); </script> <button type="button" onclick={onClick} class="btn flex h-8 rounded-lg border bg-white px-3 py-1 text-gray...
chat-ui/src/lib/components/RetryBtn.svelte/0
{ "file_path": "chat-ui/src/lib/components/RetryBtn.svelte", "repo_id": "chat-ui", "token_count": 198 }
<script lang="ts"> import { browser } from "$app/environment"; import { createEventDispatcher, onMount } from "svelte"; import HoverTooltip from "$lib/components/HoverTooltip.svelte"; import IconInternet from "$lib/components/icons/IconInternet.svelte"; import IconImageGen from "$lib/components/icons/IconImageGen...
chat-ui/src/lib/components/chat/ChatInput.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/ChatInput.svelte", "repo_id": "chat-ui", "token_count": 4361 }
<script lang="ts"> interface Props { classNames?: string; } let { classNames = "" }: Props = $props(); </script> <div class={"inline-flex h-8 flex-none items-center gap-1 " + classNames}> <div class="h-1 w-1 flex-none animate-bounce rounded-full bg-gray-500 dark:bg-gray-400" style="animation-delay: 0.25s;" ...
chat-ui/src/lib/components/icons/IconLoading.svelte/0
{ "file_path": "chat-ui/src/lib/components/icons/IconLoading.svelte", "repo_id": "chat-ui", "token_count": 254 }
import type { Migration } from "."; import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; const updateAssistantsModels: Migration = { _id: new ObjectId("5f9f3f3f3f3f3f3f3f3f3f3f"), name: "Update deprecated models in assistants with the default model", up: async () => { const mode...
chat-ui/src/lib/migrations/routines/02-update-assistants-models.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/02-update-assistants-models.ts", "repo_id": "chat-ui", "token_count": 519 }
import { z } from "zod"; import type { EmbeddingEndpoint, Embedding } from "../embeddingEndpoints"; import { chunk } from "$lib/utils/chunk"; import { env } from "$env/dynamic/private"; import { logger } from "$lib/server/logger"; export const embeddingEndpointTeiParametersSchema = z.object({ weight: z.number().int()...
chat-ui/src/lib/server/embeddingEndpoints/tei/embeddingEndpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/embeddingEndpoints/tei/embeddingEndpoints.ts", "repo_id": "chat-ui", "token_count": 838 }
import { env } from "$env/dynamic/private"; import { buildPrompt } from "$lib/buildPrompt"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import type { Endpoint } from "../endpoints"; import { z } from "zod"; import { logger } from "$lib/server/logger"; export const endpointLlamacppParamete...
chat-ui/src/lib/server/endpoints/llamacpp/endpointLlamacpp.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/llamacpp/endpointLlamacpp.ts", "repo_id": "chat-ui", "token_count": 1447 }
import { ToolResultStatus, type ToolCall, type Tool, type ToolResult } from "$lib/types/Tool"; import { v4 as uuidV4 } from "uuid"; import { getCallMethod, toolFromConfigs, type BackendToolContext } from "../tools"; import { MessageToolUpdateType, MessageUpdateStatus, MessageUpdateType, type MessageUpdate, } from "...
chat-ui/src/lib/server/textGeneration/tools.ts/0
{ "file_path": "chat-ui/src/lib/server/textGeneration/tools.ts", "repo_id": "chat-ui", "token_count": 3544 }
import { sentences as splitBySentences } from "sbd"; import { MarkdownElementType, type MarkdownElement } from "../types"; export function chunkElements(elements: MarkdownElement[], maxLength: number): MarkdownElement[] { return elements.flatMap((elem) => { // Can't split headers because it would break the tree, an...
chat-ui/src/lib/server/websearch/markdown/utils/chunk.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/markdown/utils/chunk.ts", "repo_id": "chat-ui", "token_count": 801 }
import { env } from "$env/dynamic/private"; import { isURL } from "$lib/utils/isUrl"; import type { WebSearchSource } from "$lib/types/WebSearch"; interface YouWebSearch { hits: YouSearchHit[]; latency: number; } interface YouSearchHit { url: string; title: string; description: string; snippets: string[]; } ex...
chat-ui/src/lib/server/websearch/search/endpoints/youApi.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/search/endpoints/youApi.ts", "repo_id": "chat-ui", "token_count": 402 }
import type { Conversation } from "$lib/types/Conversation"; import { sha256 } from "./sha256"; export async function hashConv(conv: Conversation) { // messages contains the conversation message but only the immutable part const messages = conv.messages.map((message) => { return (({ from, id, content, webSearchId ...
chat-ui/src/lib/utils/hashConv.ts/0
{ "file_path": "chat-ui/src/lib/utils/hashConv.ts", "repo_id": "chat-ui", "token_count": 132 }
<script lang="ts"> import { run } from "svelte/legacy"; import "../styles/main.css"; import { onDestroy, onMount, untrack } from "svelte"; import { goto } from "$app/navigation"; import { base } from "$app/paths"; import { page } from "$app/stores"; import { env as envPublic } from "$env/dynamic/public"; im...
chat-ui/src/routes/+layout.svelte/0
{ "file_path": "chat-ui/src/routes/+layout.svelte", "repo_id": "chat-ui", "token_count": 3266 }
import ChatThumbnail from "./ChatThumbnail.svelte"; import { collections } from "$lib/server/database"; import { error, type RequestHandler } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; import type { SvelteComponent } from "svelte"; import { Resvg } from "@resvg/resvg-js"; import satori from "satori"; im...
chat-ui/src/routes/assistant/[assistantId]/thumbnail.png/+server.ts/0
{ "file_path": "chat-ui/src/routes/assistant/[assistantId]/thumbnail.png/+server.ts", "repo_id": "chat-ui", "token_count": 826 }
import { redirect, error } from "@sveltejs/kit"; import { getOIDCUserData, validateAndParseCsrfToken } from "$lib/server/auth"; import { z } from "zod"; import { base } from "$app/paths"; import { updateUser } from "./updateUser"; import { env } from "$env/dynamic/private"; import JSON5 from "json5"; const allowedUser...
chat-ui/src/routes/login/callback/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/login/callback/+page.server.ts", "repo_id": "chat-ui", "token_count": 827 }
import { collections } from "$lib/server/database"; import { type Actions, fail, redirect } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; import { authCondition } from "$lib/server/auth"; import { base } from "$app/paths"; import { env as envPublic } from "$env/dynamic/public"; import { env } from "$env/dyn...
chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/+page.server.ts", "repo_id": "chat-ui", "token_count": 2712 }
<script lang="ts"> import { run } from "svelte/legacy"; interface Props { type: string; value: string | boolean | number; disabled?: boolean; } let { type, value = $bindable(), disabled = false }: Props = $props(); let innerValue: string | boolean | number = $state( (() => { if (type === "bool") { ...
chat-ui/src/routes/tools/ToolInputComponent.svelte/0
{ "file_path": "chat-ui/src/routes/tools/ToolInputComponent.svelte", "repo_id": "chat-ui", "token_count": 1200 }
.PHONY: quality style test check_dirs := tests src benchmarks utils # Check that source code meets quality standards quality: ruff check $(check_dirs) setup.py # linter ruff format --check $(check_dirs) setup.py # formatter # Format source code automatically style: ruff check --fix $(check_dirs) setup.py # lin...
datasets/Makefile/0
{ "file_path": "datasets/Makefile", "repo_id": "datasets", "token_count": 148 }
# Create a dataset Sometimes, you may need to create a dataset if you're working with your own data. Creating a dataset with 🤗 Datasets confers all the advantages of the library to your dataset: fast loading and processing, [stream enormous datasets](stream), [memory-mapping](https://huggingface.co/course/chapter5/4?...
datasets/docs/source/create_dataset.mdx/0
{ "file_path": "datasets/docs/source/create_dataset.mdx", "repo_id": "datasets", "token_count": 2035 }
# Load Your data can be stored in various places; they can be on your local machine's disk, in a Github repository, and in in-memory data structures like Python dictionaries and Pandas DataFrames. Wherever a dataset is stored, 🤗 Datasets can help you load it. This guide will show you how to load a dataset from: - T...
datasets/docs/source/loading.mdx/0
{ "file_path": "datasets/docs/source/loading.mdx", "repo_id": "datasets", "token_count": 6273 }
# Troubleshooting This guide aims to provide you the tools and knowledge required to navigate some common issues. If the suggestions listed in this guide do not cover your such situation, please refer to the [Asking for Help](#asking-for-help) section to learn where to find help with your specific issue. ## Issues w...
datasets/docs/source/troubleshoot.mdx/0
{ "file_path": "datasets/docs/source/troubleshoot.mdx", "repo_id": "datasets", "token_count": 1470 }
# Lint as: python3 """HuggingFace/Datasets is an open library of datasets. Note: VERSION needs to be formatted following the MAJOR.MINOR.PATCH convention (we need to follow this convention to be able to retrieve versioned scripts) Simple check list for release from AllenNLP repo: https://github.com/allenai/all...
datasets/setup.py/0
{ "file_path": "datasets/setup.py", "repo_id": "datasets", "token_count": 3874 }
import contextlib import copy import fnmatch import json import math import posixpath import re from io import BytesIO from pathlib import Path from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union import fsspec import numpy as np from fsspec.core import url_to_fs from huggingface_hub import ( ...
datasets/src/datasets/dataset_dict.py/0
{ "file_path": "datasets/src/datasets/dataset_dict.py", "repo_id": "datasets", "token_count": 47816 }
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
datasets/src/datasets/formatting/__init__.py/0
{ "file_path": "datasets/src/datasets/formatting/__init__.py", "repo_id": "datasets", "token_count": 1900 }
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class SparkDatasetReader(AbstractDatasetReader): """A dataset reader that reads from a Spark DataFrame. ...
datasets/src/datasets/io/spark.py/0
{ "file_path": "datasets/src/datasets/io/spark.py", "repo_id": "datasets", "token_count": 787 }
from typing import Any, Dict, List, Optional, Union from huggingface_hub.utils import get_session from .. import config from ..exceptions import DatasetsError from .file_utils import ( get_authentication_headers_for_url, ) from .logging import get_logger logger = get_logger(__name__) class DatasetViewerError(...
datasets/src/datasets/utils/_dataset_viewer.py/0
{ "file_path": "datasets/src/datasets/utils/_dataset_viewer.py", "repo_id": "datasets", "token_count": 1901 }
{ "language": [ "found", "crowdsourced", "expert-generated", "machine-generated", "other" ], "annotations": [ "found", "crowdsourced", "expert-generated", "machine-generated", "no-annotation", "other" ] }
datasets/src/datasets/utils/resources/creators.json/0
{ "file_path": "datasets/src/datasets/utils/resources/creators.json", "repo_id": "datasets", "token_count": 119 }
import os import random import tempfile import unittest import numpy as np import pandas as pd import pyarrow as pa import pytest from absl.testing import parameterized import datasets from datasets.arrow_writer import ArrowWriter from datasets.features import Array2D, Array3D, Array4D, Array5D, Value from datasets.f...
datasets/tests/features/test_array_xd.py/0
{ "file_path": "datasets/tests/features/test_array_xd.py", "repo_id": "datasets", "token_count": 9827 }
import contextlib import os import sqlite3 import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def _check_sql_dataset(dataset, expected_f...
datasets/tests/io/test_sql.py/0
{ "file_path": "datasets/tests/io/test_sql.py", "repo_id": "datasets", "token_count": 1628 }
import contextlib import copy import itertools import json import os import pickle import re import sys import tempfile from functools import partial from pathlib import Path from unittest import TestCase from unittest.mock import MagicMock, patch import numpy as np import numpy.testing as npt import pandas as pd impo...
datasets/tests/test_arrow_dataset.py/0
{ "file_path": "datasets/tests/test_arrow_dataset.py", "repo_id": "datasets", "token_count": 119070 }
import datetime from pathlib import Path from unittest import TestCase import numpy as np import pandas as pd import pyarrow as pa import pytest from datasets import Audio, Features, Image, IterableDataset from datasets.formatting import NumpyFormatter, PandasFormatter, PythonFormatter, query_table from datasets.form...
datasets/tests/test_formatting.py/0
{ "file_path": "datasets/tests/test_formatting.py", "repo_id": "datasets", "token_count": 21450 }
import copy import pickle from decimal import Decimal from functools import partial from typing import List, Union from unittest.mock import MagicMock import numpy as np import pyarrow as pa import pytest from datasets.features import Array2D, ClassLabel, Features, Image, LargeList, Sequence, Value from datasets.feat...
datasets/tests/test_table.py/0
{ "file_path": "datasets/tests/test_table.py", "repo_id": "datasets", "token_count": 24661 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/loaders/textual_inversion.md/0
{ "file_path": "diffusers/docs/source/en/api/loaders/textual_inversion.md", "repo_id": "diffusers", "token_count": 340 }
<!--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/cogvideox_transformer3d.md/0
{ "file_path": "diffusers/docs/source/en/api/models/cogvideox_transformer3d.md", "repo_id": "diffusers", "token_count": 394 }
<!--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/flux.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/flux.md", "repo_id": "diffusers", "token_count": 6995 }