text
stringlengths
96
319k
id
stringlengths
14
178
metadata
dict
# Testing mixed int8 quantization ![HFxbitsandbytes.png](https://cdn-uploads.huggingface.co/production/uploads/1660567705337-62441d1d9fdefb55a0b7d12c.png) The following is the recipe on how to effectively debug `bitsandbytes` integration on Hugging Face `transformers`. ## Library requirements + `transformers>=4.22....
transformers/tests/quantization/bnb/README.md/0
{ "file_path": "transformers/tests/quantization/bnb/README.md", "repo_id": "transformers", "token_count": 1405 }
# coding=utf-8 # Copyright 2019 HuggingFace Inc. # # 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 ag...
transformers/tests/test_modeling_common.py/0
{ "file_path": "transformers/tests/test_modeling_common.py", "repo_id": "transformers", "token_count": 120034 }
# 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...
transformers/tests/trainer/test_trainer_fsdp.py/0
{ "file_path": "transformers/tests/trainer/test_trainer_fsdp.py", "repo_id": "transformers", "token_count": 2775 }
# coding=utf-8 # Copyright 2019-present, the HuggingFace Inc. team. # # 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 a...
transformers/tests/utils/test_cli.py/0
{ "file_path": "transformers/tests/utils/test_cli.py", "repo_id": "transformers", "token_count": 1250 }
# coding=utf-8 # Copyright 2020 The Hugging Face Team. # # 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...
transformers/tests/utils/test_model_output.py/0
{ "file_path": "transformers/tests/utils/test_model_output.py", "repo_id": "transformers", "token_count": 3188 }
# coding=utf-8 # Copyright 2022 The HuggingFace Inc. team. # # 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...
transformers/utils/check_config_docstrings.py/0
{ "file_path": "transformers/utils/check_config_docstrings.py", "repo_id": "transformers", "token_count": 1326 }
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. # # 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...
transformers/utils/custom_init_isort.py/0
{ "file_path": "transformers/utils/custom_init_isort.py", "repo_id": "transformers", "token_count": 5360 }
import argparse import os past_versions_testing = { "pytorch": { "1.13": { "torch": "1.13.1", "torchvision": "0.14.1", "torchaudio": "0.13.1", "python": 3.9, "cuda": "cu116", "install": ( "python3 -m pip install --no-c...
transformers/utils/past_ci_versions.py/0
{ "file_path": "transformers/utils/past_ci_versions.py", "repo_id": "transformers", "token_count": 2774 }
- sections: - local: index title: TRL - local: installation title: Installation - local: quickstart title: Quickstart title: Getting started - sections: - local: dataset_formats title: Dataset Formats - local: how_to_train title: Training FAQ - local: logging title: Understanding L...
trl/docs/source/_toctree.yml/0
{ "file_path": "trl/docs/source/_toctree.yml", "repo_id": "trl", "token_count": 1007 }
# Examples of using peft with trl to finetune 8-bit models with Low Rank Adaption (LoRA) The notebooks and scripts in this examples show how to use Low Rank Adaptation (LoRA) to fine-tune models in a memory efficient manner. Most of PEFT methods supported in peft library but note that some PEFT methods such as Prompt ...
trl/docs/source/peft_integration.md/0
{ "file_path": "trl/docs/source/peft_integration.md", "repo_id": "trl", "token_count": 2079 }
# 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/ultrafeedback-prompt.py/0
{ "file_path": "trl/examples/datasets/ultrafeedback-prompt.py", "repo_id": "trl", "token_count": 1243 }
# 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/tools/calculator.py/0
{ "file_path": "trl/examples/research_projects/tools/calculator.py", "repo_id": "trl", "token_count": 1430 }
# 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/kto.py/0
{ "file_path": "trl/examples/scripts/kto.py", "repo_id": "trl", "token_count": 1461 }
# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
trl/scripts/add_copyrights.py/0
{ "file_path": "trl/scripts/add_copyrights.py", "repo_id": "trl", "token_count": 1106 }
# 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_cli.py/0
{ "file_path": "trl/tests/test_cli.py", "repo_id": "trl", "token_count": 1240 }
# 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_modeling_geometric_mixture_wrapper.py/0
{ "file_path": "trl/tests/test_modeling_geometric_mixture_wrapper.py", "repo_id": "trl", "token_count": 1095 }
# 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/testing_utils.py/0
{ "file_path": "trl/tests/testing_utils.py", "repo_id": "trl", "token_count": 1120 }
# 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_value_head.py/0
{ "file_path": "trl/trl/models/modeling_value_head.py", "repo_id": "trl", "token_count": 8204 }
# 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_trainer.py/0
{ "file_path": "trl/trl/trainer/bco_trainer.py", "repo_id": "trl", "token_count": 32834 }
# 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/model_config.py/0
{ "file_path": "trl/trl/trainer/model_config.py", "repo_id": "trl", "token_count": 2929 }
# 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_trainer.py/0
{ "file_path": "trl/trl/trainer/sft_trainer.py", "repo_id": "trl", "token_count": 10503 }
# Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/benchmarks/fp8/ms_amp/non_distributed.py/0
{ "file_path": "accelerate/benchmarks/fp8/ms_amp/non_distributed.py", "repo_id": "accelerate", "token_count": 1773 }
<!--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/install.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/install.md", "repo_id": "accelerate", "token_count": 1129 }
<!--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/model_size_estimator.md/0
{ "file_path": "accelerate/docs/source/usage_guides/model_size_estimator.md", "repo_id": "accelerate", "token_count": 2017 }
# This config template is for a multi-node setup. This assumes DDP, but can be interop'd with the other configs in this folder # Generally it's recommended to look at the SLURM config template for a more robust multi-node setup distributed_type: MULTI_GPU # We need to specify the current machine's rank machine_rank: 0 ...
accelerate/examples/config_yaml_templates/multi_node.yaml/0
{ "file_path": "accelerate/examples/config_yaml_templates/multi_node.yaml", "repo_id": "accelerate", "token_count": 216 }
# 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/bert.py/0
{ "file_path": "accelerate/examples/inference/pippy/bert.py", "repo_id": "accelerate", "token_count": 871 }
# 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/manim_animations/big_model_inference/stage_4.py/0
{ "file_path": "accelerate/manim_animations/big_model_inference/stage_4.py", "repo_id": "accelerate", "token_count": 2919 }
# Copyright 2022 The HuggingFace Team and Brian Chao. 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 requir...
accelerate/src/accelerate/commands/menu/input.py/0
{ "file_path": "accelerate/src/accelerate/commands/menu/input.py", "repo_id": "accelerate", "token_count": 947 }
# 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/state.py/0
{ "file_path": "accelerate/src/accelerate/state.py", "repo_id": "accelerate", "token_count": 23024 }
# 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/test_utils/scripts/test_notebook.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/test_notebook.py", "repo_id": "accelerate", "token_count": 1371 }
# 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/megatron_lm.py/0
{ "file_path": "accelerate/src/accelerate/utils/megatron_lm.py", "repo_id": "accelerate", "token_count": 26942 }
# 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/deepspeed/test_deepspeed.py/0
{ "file_path": "accelerate/tests/deepspeed/test_deepspeed.py", "repo_id": "accelerate", "token_count": 26455 }
# 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_examples.py/0
{ "file_path": "accelerate/tests/test_examples.py", "repo_id": "accelerate", "token_count": 4893 }
repos: - repo: https://github.com/Narsil/pre-commit-rust rev: 2eed6366172ef2a5186e8785ec0e67243d7d73d0 hooks: - id: fmt name: "Rust (fmt)" - id: clippy name: "Rust (clippy)" args: [ "--tests", "--examples", "--", "-D...
candle/.pre-commit-config.yaml/0
{ "file_path": "candle/.pre-commit-config.yaml", "repo_id": "candle", "token_count": 210 }
//! #A simplified example in Rust of training a neural network and then using it based on the Candle Framework by Hugging Face. //! Author: Evgeny Igumnov 2023 igumnovnsk@gmail.com //! This program implements a neural network to predict the winner of the second round of elections based on the results of the first round...
candle/candle-book/src/simplified.rs/0
{ "file_path": "candle/candle-book/src/simplified.rs", "repo_id": "candle", "token_count": 2903 }
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle_core::{DType, Device, Tensor}; use criterion::{black_box, criterion_group, Criterion, Throughput}; use half::{bf16, f16}; use std::time::Instant; fn run_sum(a: &Tensor) { a.sum_keepdim(2).unwrap(); } fn run_arg_min(a: &Tensor) { a.argmin_keep...
candle/candle-core/benches/benchmarks/reduce.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/reduce.rs", "repo_id": "candle", "token_count": 2382 }
use super::Cpu; #[cfg(target_arch = "arm")] use core::arch::arm::*; #[cfg(target_arch = "aarch64")] use core::arch::aarch64::*; pub struct CurrentCpu {} const STEP: usize = 16; const EPR: usize = 4; const ARR: usize = STEP / EPR; impl CurrentCpu { #[cfg(target_arch = "aarch64")] unsafe fn reduce_one(x: floa...
candle/candle-core/src/cpu/neon.rs/0
{ "file_path": "candle/candle-core/src/cpu/neon.rs", "repo_id": "candle", "token_count": 897 }
use crate::{Error, Tensor}; use std::ops::{ Bound, Range, RangeBounds, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive, }; impl Tensor { /// Intended to be use by the trait `.i()` /// /// ``` /// # use candle_core::{Tensor, DType, Device, IndexOp}; /// let a = Tensor::zeros((2, ...
candle/candle-core/src/indexer.rs/0
{ "file_path": "candle/candle-core/src/indexer.rs", "repo_id": "candle", "token_count": 4032 }
use super::{GgmlDType, QStorage}; use crate::backend::BackendStorage; use crate::{DType, MetalDevice, MetalStorage, Result, Shape}; use metal::Buffer; use std::sync::Arc; pub struct QMetalStorage { dtype: GgmlDType, device: MetalDevice, buffer: Arc<Buffer>, } impl QMetalStorage { pub fn zeros(device: ...
candle/candle-core/src/quantized/metal.rs/0
{ "file_path": "candle/candle-core/src/quantized/metal.rs", "repo_id": "candle", "token_count": 4704 }
// Variables are wrappers around tensors that can be modified, they are typically used for holding // weights and being modified by gradient descent. // We do not expose a public way to create variables as this would break the invariant that the // tensor within a variable is actually with `is_variable` set to `true`. ...
candle/candle-core/src/variable.rs/0
{ "file_path": "candle/candle-core/src/variable.rs", "repo_id": "candle", "token_count": 2150 }
#![allow(unused)] use anyhow::{Context, Result}; use std::io::Write; use std::path::PathBuf; struct KernelDirectories { kernel_glob: &'static str, rust_target: &'static str, include_dirs: &'static [&'static str], } const KERNEL_DIRS: [KernelDirectories; 1] = [KernelDirectories { kernel_glob: "examples...
candle/candle-examples/build.rs/0
{ "file_path": "candle/candle-examples/build.rs", "repo_id": "candle", "token_count": 391 }
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::generation::LogitsProcessor; use candle_transformers::models::codegeex4_9b::*; use clap::Parser; use hf_hub::{Repo, RepoType}; use tokenizers::Tokenizer; struct TextGeneration { model: Model, device: Device, tokenizer:...
candle/candle-examples/examples/codegeex4-9b/main.rs/0
{ "file_path": "candle/candle-examples/examples/codegeex4-9b/main.rs", "repo_id": "candle", "token_count": 3921 }
//! DINOv2: Learning Robust Visual Features without Supervision //! https://github.com/facebookresearch/dinov2 #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::Parser; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use c...
candle/candle-examples/examples/dinov2/main.rs/0
{ "file_path": "candle/candle-examples/examples/dinov2/main.rs", "repo_id": "candle", "token_count": 791 }
# candle-fastvit [FastViT: A Fast Hybrid Vision Transformer using Structural Reparameterization](https://arxiv.org/abs/2303.14189). This candle implementation uses a pre-trained FastViT network for inference. The classification head has been trained on the ImageNet dataset and returns the probabilities for the top-5 c...
candle/candle-examples/examples/fastvit/README.md/0
{ "file_path": "candle/candle-examples/examples/fastvit/README.md", "repo_id": "candle", "token_count": 258 }
# hiera [Hiera: A Hierarchical Vision Transformer without the Bells-and-Whistles](https://arxiv.org/abs/2306.00989) This candle implementation uses pre-trained Hiera models from timm for inference. The classification head has been trained on the ImageNet dataset and returns the probabilities for the top-5 classes. ##...
candle/candle-examples/examples/hiera/README.md/0
{ "file_path": "candle/candle-examples/examples/hiera/README.md", "repo_id": "candle", "token_count": 260 }
/// This follows the lines of: /// https://github.com/johnma2006/mamba-minimal/blob/master/model.py /// Simple, minimal implementation of Mamba in one file of PyTorch. use candle::{IndexOp, Module, Result, Tensor, D}; use candle_nn::{RmsNorm, VarBuilder}; use candle_transformers::models::with_tracing::{linear, linear_...
candle/candle-examples/examples/mamba-minimal/model.rs/0
{ "file_path": "candle/candle-examples/examples/mamba-minimal/model.rs", "repo_id": "candle", "token_count": 3488 }
# candle-mobileclip MobileCLIP is family of efficient CLIP-like models using FastViT-based image encoders. See [MobileCLIP: Fast Image-Text Models through Multi-Modal Reinforced Training](https://arxiv.org/abs/2311.17049) ## Running on an example on cpu ``` $ cargo run --example mobileclip --release -- --images "c...
candle/candle-examples/examples/mobileclip/README.md/0
{ "file_path": "candle/candle-examples/examples/mobileclip/README.md", "repo_id": "candle", "token_count": 379 }
## Using ONNX models in Candle This example demonstrates how to run [ONNX](https://github.com/onnx/onnx) based models in Candle. It contains small variants of two models, [SqueezeNet](https://arxiv.org/pdf/1602.07360.pdf) (default) and [EfficientNet](https://arxiv.org/pdf/1905.11946.pdf). You can run the examples wi...
candle/candle-examples/examples/onnx/README.md/0
{ "file_path": "candle/candle-examples/examples/onnx/README.md", "repo_id": "candle", "token_count": 832 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use std::io::Write; use std::path::PathBuf; use candle_transformers::models::quantized_t5 as t5; use anyhow::{Error as E, Result}; use candle::{Device, Tensor}; use candle_transformers::generation::LogitsP...
candle/candle-examples/examples/quantized-t5/main.rs/0
{ "file_path": "candle/candle-examples/examples/quantized-t5/main.rs", "repo_id": "candle", "token_count": 3631 }
# candle-replit-code: code completion specialized model. [replit-code-v1_5-3b](https://huggingface.co/replit/replit-code-v1_5-3b) is a language model specialized for code completion. This model uses 3.3B parameters in `bfloat16` (so the GPU version will only work on recent nvidia cards). ## Running some example ```b...
candle/candle-examples/examples/replit-code/README.md/0
{ "file_path": "candle/candle-examples/examples/replit-code/README.md", "repo_id": "candle", "token_count": 426 }
//! SAM: Segment Anything Model //! https://github.com/facebookresearch/segment-anything #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::DType; use candle_nn::VarBuilder; use candle_transformers::models::segment_anything::sam; use clap::Pars...
candle/candle-examples/examples/segment-anything/main.rs/0
{ "file_path": "candle/candle-examples/examples/segment-anything/main.rs", "repo_id": "candle", "token_count": 3137 }
# candle-stable-lm StableLM-3B-4E1T is a 3 billion parameter decoder-only language model pre-trained on 1 trillion tokens of diverse English and code datasets for 4 epochs. See the [HuggingFace Hub Model Card](https://huggingface.co/stabilityai/stablelm-3b-4e1t). Note that this model is gated so you will have to requ...
candle/candle-examples/examples/stable-lm/README.md/0
{ "file_path": "candle/candle-examples/examples/stable-lm/README.md", "repo_id": "candle", "token_count": 432 }
#[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use anyhow::{Error as E, Result}; use candle::{Device, IndexOp, Tensor}; use candle_nn::{ops::softmax, VarBuilder}; use clap::{Parser, ValueEnum}; use hf_hub::{api::sync::Api, Repo, RepoType}; use rand::{di...
candle/candle-examples/examples/whisper-microphone/main.rs/0
{ "file_path": "candle/candle-examples/examples/whisper-microphone/main.rs", "repo_id": "candle", "token_count": 12459 }
/****************************************************************************** * Copyright (c) 2023, Tri Dao. ******************************************************************************/ #pragma once #include "cute/algorithm/copy.hpp" #include "cutlass/cutlass.h" #include "cutlass/layout/layout.h" #include <cu...
candle/candle-flash-attn/kernels/kernel_traits_sm90.h/0
{ "file_path": "candle/candle-flash-attn/kernels/kernel_traits_sm90.h", "repo_id": "candle", "token_count": 3269 }
#include "cuda_utils.cuh" #define BINARY_OP_OUT(TYPENAME, OUT_TYPENAME, FN_NAME, FUNC) \ extern "C" __global__ void FN_NAME( \ const size_t numel, \ const size_t num_dims, \ const size_t *dims_and_strides, \ const TYPENAME *lhs, \ const TYPENAME *rhs, \ OUT_TYPENAME *out \ ) { \ const size_...
candle/candle-kernels/src/binary_op_macros.cuh/0
{ "file_path": "candle/candle-kernels/src/binary_op_macros.cuh", "repo_id": "candle", "token_count": 1561 }
#include <metal_stdlib> METAL_FUNC uint get_strided_index( uint idx, constant size_t &num_dims, constant size_t *dims, constant size_t *strides ) { uint strided_i = 0; for (uint d = 0; d < num_dims; d++) { uint dim_idx = num_dims - 1 - d; strided_i += (idx % dims[dim_idx]) * str...
candle/candle-metal-kernels/src/affine.metal/0
{ "file_path": "candle/candle-metal-kernels/src/affine.metal", "repo_id": "candle", "token_count": 1498 }
#include <metal_stdlib> using namespace metal; METAL_FUNC uint get_strided_index( uint idx, constant size_t &num_dims, constant size_t *dims, constant size_t *strides ) { uint strided_i = 0; for (uint d = 0; d < num_dims; d++) { uint dim_idx = num_dims - 1 - d; strided_i += (idx...
candle/candle-metal-kernels/src/ternary.metal/0
{ "file_path": "candle/candle-metal-kernels/src/ternary.metal", "repo_id": "candle", "token_count": 2256 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, Device, Result, Tensor}; use candle_nn::{linear, AdamW, Linear, Module, Optimizer, ParamsAdamW, VarBuilder, VarMap}; fn gen_data() -> Result<(Tensor, Tensor)> { // Generate some sam...
candle/candle-nn/examples/basic_optimizer.rs/0
{ "file_path": "candle/candle-nn/examples/basic_optimizer.rs", "repo_id": "candle", "token_count": 595 }
//! Various optimization algorithms. use candle::{Result, Tensor, Var}; /// The interface optimizers should implement. pub trait Optimizer: Sized { type Config: Sized; fn new(vars: Vec<Var>, config: Self::Config) -> Result<Self>; fn step(&mut self, grads: &candle::backprop::GradStore) -> Result<()>; ...
candle/candle-nn/src/optim.rs/0
{ "file_path": "candle/candle-nn/src/optim.rs", "repo_id": "candle", "token_count": 2798 }
[package] name = "candle-onnx" version = "0.8.2" edition = "2021" description = "ONNX support for Candle" repository = "https://github.com/huggingface/candle" keywords = ["blas", "tensor", "machine-learning"] categories = ["science"] license = "MIT OR Apache-2.0" [dependencies] candle = { path = "../candle-core", pac...
candle/candle-onnx/Cargo.toml/0
{ "file_path": "candle/candle-onnx/Cargo.toml", "repo_id": "candle", "token_count": 242 }
# Generated content DO NOT EDIT from .. import functional avg_pool2d = functional.avg_pool2d gelu = functional.gelu max_pool2d = functional.max_pool2d relu = functional.relu silu = functional.silu softmax = functional.softmax tanh = functional.tanh
candle/candle-pyo3/py_src/candle/functional/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/functional/__init__.py", "repo_id": "candle", "token_count": 84 }
# 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 @staticmethod def cuda_is_available() -> bool: """ Returns true if ...
candle/candle-pyo3/py_src/candle/utils/__init__.pyi/0
{ "file_path": "candle/candle-pyo3/py_src/candle/utils/__init__.pyi", "repo_id": "candle", "token_count": 654 }
import candle from candle import Tensor, QTensor from candle.utils import load_safetensors, save_gguf, load_gguf, save_safetensors from pathlib import Path TEST_DIR = Path(__file__).parent.parent / "_workdir" TEST_DIR.mkdir(exist_ok=True) def test_can_roundtrip_safetensors(): tensors = { "a": candle.rand...
candle/candle-pyo3/tests/native/test_utils.py/0
{ "file_path": "candle/candle-pyo3/tests/native/test_utils.py", "repo_id": "candle", "token_count": 774 }
//! Contrastive Language-Image Pre-Training //! //! Contrastive Language-Image Pre-Training (CLIP) is an architecture trained on //! pairs of images with related texts. //! //! - [GH](https://github.com/openai/CLIP) //! - [Code](https://github.com/huggingface/transformers/tree/f6fa0f0bf0796ac66f201f23bdb8585de1609add/s...
candle/candle-transformers/src/models/clip/text_model.rs/0
{ "file_path": "candle/candle-transformers/src/models/clip/text_model.rs", "repo_id": "candle", "token_count": 5660 }
//! Falcon language model inference implementation //! //! See ["Falcon: a new approach to large language models"](https://huggingface.co/blog/falcon) //! //! Based on implementation from [Huggingface Transformers](https://github.com/huggingface/transformers/blob/main/src/transformers/models/falcon) use candle::{DType...
candle/candle-transformers/src/models/falcon.rs/0
{ "file_path": "candle/candle-transformers/src/models/falcon.rs", "repo_id": "candle", "token_count": 8880 }
//! Llama2 inference implementation. //! //! See ["LLaMA 2: Open Foundation and Fine-Tuned Chat Models"](https://arxiv.org/abs/2307.09288) //! //! Based on the [llama2.c](https://github.com/karpathy/llama2.c) implementation use byteorder::{LittleEndian, ReadBytesExt}; use candle::{DType, Device, IndexOp, Result, Shape...
candle/candle-transformers/src/models/llama2_c_weights.rs/0
{ "file_path": "candle/candle-transformers/src/models/llama2_c_weights.rs", "repo_id": "candle", "token_count": 3405 }
use candle::{Module, Result, Tensor, D}; use candle_nn as nn; use super::projections::{AttnProjections, Mlp, Qkv, QkvOnlyAttnProjections}; pub struct ModulateIntermediates { gate_msa: Tensor, shift_mlp: Tensor, scale_mlp: Tensor, gate_mlp: Tensor, } pub struct DiTBlock { norm1: LayerNormNoAffine,...
candle/candle-transformers/src/models/mmdit/blocks.rs/0
{ "file_path": "candle/candle-transformers/src/models/mmdit/blocks.rs", "repo_id": "candle", "token_count": 8057 }
//! Open Contrastive Language-Image Pre-Training //! //! Open Contrastive Language-Image Pre-Training (OpenCLIP) is an architecture trained on //! pairs of images with related texts. //! //! - 💻 [GH Link](https://github.com/mlfoundations/open_clip) //! - 📝 [Paper](https://arxiv.org/abs/2212.07143) //! //! ## Overview...
candle/candle-transformers/src/models/openclip/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/openclip/mod.rs", "repo_id": "candle", "token_count": 154 }
//! Module containing quantized MixFormer model implementation. //! //! MixFormer is an efficient transformer variant for text generation that uses //! mixture-of-experts and parallel attention/feed-forward blocks. //! This implementation provides quantization for reduced memory usage. //! //! Key features: //! - Paral...
candle/candle-transformers/src/models/quantized_mixformer.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_mixformer.rs", "repo_id": "candle", "token_count": 6503 }
//! RWKV v5 model implementation. //! //! The [RWKV model](https://wiki.rwkv.com/) is a recurrent neural network model //! with performance on par with transformer architectures. Several variants are //! available, candle implements the v5 and v6 versions and can be used with //! Eagle 7B([blog post](https://blog.rwkv....
candle/candle-transformers/src/models/rwkv_v5.rs/0
{ "file_path": "candle/candle-transformers/src/models/rwkv_v5.rs", "repo_id": "candle", "token_count": 8119 }
//! Ancestral sampling with Euler method steps. //! //! Based on the original [`k-diffusion` implementation by Katherine Crowson]( https://github.com/crowsonkb/k-diffusion/blob/481677d114f6ea445aa009cf5bd7a9cdee909e47/k_diffusion/sampling.py#L72). //! use super::{ schedulers::{ betas_for_alpha_bar, BetaSche...
candle/candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs", "repo_id": "candle", "token_count": 4097 }
import init, { Model } from "./build/m.js"; async function fetchArrayBuffer(url, cacheFile = true) { if (!cacheFile) return new Uint8Array(await (await fetch(url)).arrayBuffer()); const cacheName = "blip-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); ...
candle/candle-wasm-examples/blip/blipWorker.js/0
{ "file_path": "candle/candle-wasm-examples/blip/blipWorker.js", "repo_id": "candle", "token_count": 815 }
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::generation::LogitsProcessor; use candle_transformers::models::mixformer::{Config, MixFormerSequentialForCausalLM as MixFormer}; use candle_transformers::models::quantized_mixformer::MixFormerSequentialForCausalLM as QMixFormer; use...
candle/candle-wasm-examples/phi/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/phi/src/bin/m.rs", "repo_id": "candle", "token_count": 2646 }
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::generation::LogitsProcessor; pub use candle_transformers::models::t5::{Config, T5EncoderModel, T5ForConditionalGeneration}; use candle_wasm_example_t5::console_log; use tokenizers::Tokenizer; use wasm_bindgen::prelude::*; #[wasm_bi...
candle/candle-wasm-examples/t5/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/t5/src/bin/m.rs", "repo_id": "candle", "token_count": 3593 }
use crate::languages::LANGUAGES; use anyhow::Error as E; use candle::{safetensors::Load, DType, Device, IndexOp, Tensor, D}; use candle_nn::{ops::softmax, VarBuilder}; pub use candle_transformers::models::whisper::{self as m, Config}; use rand::{distributions::Distribution, rngs::StdRng, SeedableRng}; use serde::{Deser...
candle/candle-wasm-examples/whisper/src/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/worker.rs", "repo_id": "candle", "token_count": 8825 }
[package] name = "candle-wasm-tests" version.workspace = true edition.workspace = true description = "WASM tests for candle" keywords.workspace = true categories.workspace = true [dependencies] candle = { workspace = true } rand = { workspace = true } getrandom = { version = "0.2", features = ["js"] } [dev-dependenci...
candle/candle-wasm-tests/Cargo.toml/0
{ "file_path": "candle/candle-wasm-tests/Cargo.toml", "repo_id": "candle", "token_count": 122 }
# Chat UI **Find the docs at [hf.co/docs/chat-ui](https://huggingface.co/docs/chat-ui/index).** ![Chat UI repository thumbnail](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chatui-websearch.png) A chat interface using open source models, eg OpenAssistant or Llama. It is a SvelteKit a...
chat-ui/README.md/0
{ "file_path": "chat-ui/README.md", "repo_id": "chat-ui", "token_count": 14260 }
# Text Embedding Models By default (for backward compatibility), when `TEXT_EMBEDDING_MODELS` environment variable is not defined, [transformers.js](https://huggingface.co/docs/transformers.js) embedding models will be used for embedding tasks, specifically, the [Xenova/gte-small](https://huggingface.co/Xenova/gte-sma...
chat-ui/docs/source/configuration/embeddings.md/0
{ "file_path": "chat-ui/docs/source/configuration/embeddings.md", "repo_id": "chat-ui", "token_count": 1568 }
# Configuration Overview Chat UI handles configuration with environment variables. The default config for Chat UI is stored in the `.env` file, which you may use as a reference. You will need to override some values to get Chat UI to run locally. This can be done in `.env.local` or via your environment. The bare minim...
chat-ui/docs/source/configuration/overview.md/0
{ "file_path": "chat-ui/docs/source/configuration/overview.md", "repo_id": "chat-ui", "token_count": 130 }
import fs from "fs"; import yaml from "js-yaml"; const file = fs.readFileSync("chart/env/prod.yaml", "utf8"); // have to do a weird stringify/parse because of some node error const prod = JSON.parse(JSON.stringify(yaml.load(file))); const vars = prod.envVars as Record<string, string>; let PUBLIC_CONFIG = ""; Object....
chat-ui/scripts/updateLocalEnv.ts/0
{ "file_path": "chat-ui/scripts/updateLocalEnv.ts", "repo_id": "chat-ui", "token_count": 288 }
<script lang="ts"> interface Props { label?: string; position?: "top" | "bottom" | "left" | "right"; TooltipClassNames?: string; children?: import("svelte").Snippet; } let { label = "", position = "bottom", TooltipClassNames = "", children }: Props = $props(); const positionClasses = { top: "bottom-full...
chat-ui/src/lib/components/HoverTooltip.svelte/0
{ "file_path": "chat-ui/src/lib/components/HoverTooltip.svelte", "repo_id": "chat-ui", "token_count": 380 }
<script lang="ts"> interface Props { checked: boolean; name: string; } let { checked = $bindable(), name }: Props = $props(); </script> <input bind:checked type="checkbox" {name} class="peer pointer-events-none absolute opacity-0" /> <div aria-checked={checked} aria-roledescription="switch" aria-label="swit...
chat-ui/src/lib/components/Switch.svelte/0
{ "file_path": "chat-ui/src/lib/components/Switch.svelte", "repo_id": "chat-ui", "token_count": 267 }
<script lang="ts"> import { createBubbler } from "svelte/legacy"; const bubble = createBubbler(); import { useSettingsStore } from "$lib/stores/settings"; import { documentParserToolId } from "$lib/utils/toolIds"; import CarbonImage from "~icons/carbon/image"; interface Props { // import EosIconsLoading from ...
chat-ui/src/lib/components/chat/FileDropzone.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/FileDropzone.svelte", "repo_id": "chat-ui", "token_count": 1191 }
import type { Migration } from "."; import { collections } from "$lib/server/database"; import { ObjectId, type WithId } from "mongodb"; import type { Conversation } from "$lib/types/Conversation"; import { MessageUpdateType, MessageWebSearchUpdateType, type MessageUpdate, } from "$lib/types/MessageUpdate"; import t...
chat-ui/src/lib/migrations/routines/06-trim-message-updates.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/06-trim-message-updates.ts", "repo_id": "chat-ui", "token_count": 703 }
import { z } from "zod"; import type { Endpoint } from "../endpoints"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import { createImageProcessorOptionsValidator } from "../images"; import { endpointMessagesToAnthropicMessages } from "./utils"; import type { MessageParam } from "@anthropic-...
chat-ui/src/lib/server/endpoints/anthropic/endpointAnthropicVertex.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/anthropic/endpointAnthropicVertex.ts", "repo_id": "chat-ui", "token_count": 1193 }
import type { TextGenerationStreamOutput } from "@huggingface/inference"; import type OpenAI from "openai"; import type { Stream } from "openai/streaming"; /** * Transform a stream of OpenAI.Completions.Completion into a stream of TextGenerationStreamOutput */ export async function* openAICompletionToTextGenerationS...
chat-ui/src/lib/server/endpoints/openai/openAICompletionToTextGenerationStream.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/openai/openAICompletionToTextGenerationStream.ts", "repo_id": "chat-ui", "token_count": 325 }
import { isURLLocal } from "./isURLLocal"; import { describe, expect, it } from "vitest"; describe("isURLLocal", async () => { it("should return true for localhost", async () => { expect(await isURLLocal(new URL("http://localhost"))).toBe(true); }); it("should return true for 127.0.0.1", async () => { expect(aw...
chat-ui/src/lib/server/isURLLocal.spec.ts/0
{ "file_path": "chat-ui/src/lib/server/isURLLocal.spec.ts", "repo_id": "chat-ui", "token_count": 492 }
import { MessageUpdateType } from "$lib/types/MessageUpdate"; import { ToolColor, ToolIcon, ToolOutputComponents, type BackendCall, type BaseTool, type ConfigTool, type ToolInput, } from "$lib/types/Tool"; import type { TextGenerationContext } from "../textGeneration/types"; import { z } from "zod"; import JSON...
chat-ui/src/lib/server/tools/index.ts/0
{ "file_path": "chat-ui/src/lib/server/tools/index.ts", "repo_id": "chat-ui", "token_count": 3696 }
import type { SerializedHTMLElement } from "./types"; interface DBSCANOptions<T> { dataset: T[]; epsilon?: number; epsilonCompare?: (distance: number, epsilon: number) => boolean; minimumPoints?: number; distanceFunction: (a: T, b: T) => number; } export function spatialParser() { /** * Implementation for dbs...
chat-ui/src/lib/server/websearch/scrape/parser.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/scrape/parser.ts", "repo_id": "chat-ui", "token_count": 6106 }
import { base } from "$app/paths"; import { ERROR_MESSAGES, error } from "$lib/stores/errors"; import { share } from "./utils/share"; import { page } from "$app/stores"; import { get } from "svelte/store"; import { getShareUrl } from "./utils/getShareUrl"; export async function shareConversation(id: string, title: stri...
chat-ui/src/lib/shareConversation.ts/0
{ "file_path": "chat-ui/src/lib/shareConversation.ts", "repo_id": "chat-ui", "token_count": 363 }
import type { ObjectId } from "mongodb"; import type { Conversation } from "./Conversation"; import type { Timestamps } from "./Timestamps"; import type { HeaderElement } from "$lib/server/websearch/markdown/types"; export interface WebSearch extends Timestamps { _id?: ObjectId; convId?: Conversation["_id"]; promp...
chat-ui/src/lib/types/WebSearch.ts/0
{ "file_path": "chat-ui/src/lib/types/WebSearch.ts", "repo_id": "chat-ui", "token_count": 348 }
type Gen<T, TReturn> = AsyncGenerator<T, TReturn, undefined>; type GenPromiseMap<T, TReturn> = Map< Gen<T, TReturn>, Promise<{ gen: Gen<T, TReturn> } & IteratorResult<T, TReturn>> >; /** Merges multiple async generators into a single async generator that yields values from all of them in parallel. */ export async f...
chat-ui/src/lib/utils/mergeAsyncGenerators.ts/0
{ "file_path": "chat-ui/src/lib/utils/mergeAsyncGenerators.ts", "repo_id": "chat-ui", "token_count": 407 }
import type { Conversation } from "$lib/types/Conversation"; import type { Message } from "$lib/types/Message"; import { v4 } from "uuid"; export function addChildren( conv: Pick<Conversation, "messages" | "rootMessageId">, message: Omit<Message, "id">, parentId?: Message["id"] ): Message["id"] { // if this is the...
chat-ui/src/lib/utils/tree/addChildren.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/addChildren.ts", "repo_id": "chat-ui", "token_count": 501 }
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; export async function GET({ params }) { const id = params.id; const assistantId = new ObjectId(id); const assistant = await collections.assistants.findOne({ _id: assistantId, }); if (assistant) { return Response.json(ass...
chat-ui/src/routes/api/assistant/[id]/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/assistant/[id]/+server.ts", "repo_id": "chat-ui", "token_count": 133 }
import type { RequestHandler } from "./$types"; import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { error, redirect } from "@sveltejs/kit"; import { base } from "$app/paths"; import { z } from "zod"; import type { Message } from "$lib/types/Message"; import { models, validat...
chat-ui/src/routes/conversation/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/+server.ts", "repo_id": "chat-ui", "token_count": 1252 }
<script lang="ts"> import type { PageData } from "./$types"; import { env as envPublic } from "$env/dynamic/public"; import { isHuggingChat } from "$lib/utils/isHuggingChat"; import { base } from "$app/paths"; import { page } from "$app/state"; import CarbonHelpFilled from "~icons/carbon/help-filled"; import ...
chat-ui/src/routes/models/+page.svelte/0
{ "file_path": "chat-ui/src/routes/models/+page.svelte", "repo_id": "chat-ui", "token_count": 2588 }
import { collections } from "$lib/server/database"; import { error, type RequestHandler } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; export const GET: RequestHandler = async ({ params }) => { const assistant = await collections.assistants.findOne({ _id: new ObjectId(params.assistantId), }); if (!a...
chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/avatar.jpg/+server.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/avatar.jpg/+server.ts", "repo_id": "chat-ui", "token_count": 420 }
import { base } from "$app/paths"; import { requiresUser } from "$lib/server/auth.js"; import { collections } from "$lib/server/database.js"; import { editableToolSchema } from "$lib/server/tools/index.js"; import { generateSearchTokens } from "$lib/utils/searchTokens.js"; import { error, fail, redirect } from "@svelte...
chat-ui/src/routes/tools/[toolId]/edit/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/tools/[toolId]/edit/+page.server.ts", "repo_id": "chat-ui", "token_count": 650 }
import json import os from dataclasses import dataclass import numpy as np import pyarrow as pa import datasets from utils import get_duration SPEED_TEST_N_EXAMPLES = 100_000_000_000 SPEED_TEST_CHUNK_SIZE = 10_000 RESULTS_BASEPATH, RESULTS_FILENAME = os.path.split(__file__) RESULTS_FILE_PATH = os.path.join(RESULTS...
datasets/benchmarks/benchmark_getitem_100B.py/0
{ "file_path": "datasets/benchmarks/benchmark_getitem_100B.py", "repo_id": "datasets", "token_count": 867 }
# Datasets 🤝 Arrow ## What is Arrow? [Arrow](https://arrow.apache.org/) enables large amounts of data to be processed and moved quickly. It is a specific data format that stores data in a columnar memory layout. This provides several significant advantages: * Arrow's standard format allows [zero-copy reads](https:/...
datasets/docs/source/about_arrow.md/0
{ "file_path": "datasets/docs/source/about_arrow.md", "repo_id": "datasets", "token_count": 682 }