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/tests/test_rloo_trainer.py/0
{ "file_path": "trl/tests/test_rloo_trainer.py", "repo_id": "trl", "token_count": 4153 }
# 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/import_utils.py/0
{ "file_path": "trl/trl/import_utils.py", "repo_id": "trl", "token_count": 1598 }
# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
trl/trl/scripts/utils.py/0
{ "file_path": "trl/trl/scripts/utils.py", "repo_id": "trl", "token_count": 3753 }
# 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/grpo_config.py/0
{ "file_path": "trl/trl/trainer/grpo_config.py", "repo_id": "trl", "token_count": 4561 }
# 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/prm_trainer.py/0
{ "file_path": "trl/trl/trainer/prm_trainer.py", "repo_id": "trl", "token_count": 7231 }
<!--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/notebook.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/notebook.md", "repo_id": "accelerate", "token_count": 5694 }
<!--Copyright 2021 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/package_reference/accelerator.md/0
{ "file_path": "accelerate/docs/source/package_reference/accelerator.md", "repo_id": "accelerate", "token_count": 289 }
<!--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/big_modeling.md/0
{ "file_path": "accelerate/docs/source/usage_guides/big_modeling.md", "repo_id": "accelerate", "token_count": 1618 }
<!--Copyright 2023 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/usage_guides/quantization.md/0
{ "file_path": "accelerate/docs/source/usage_guides/quantization.md", "repo_id": "accelerate", "token_count": 1998 }
# Copyright 2021 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/cv_example.py/0
{ "file_path": "accelerate/examples/cv_example.py", "repo_id": "accelerate", "token_count": 3215 }
#!/usr/bin/env python # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
accelerate/src/accelerate/commands/config/cluster.py/0
{ "file_path": "accelerate/src/accelerate/commands/config/cluster.py", "repo_id": "accelerate", "token_count": 19323 }
#!/usr/bin/env python # 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 # # Unles...
accelerate/src/accelerate/commands/merge.py/0
{ "file_path": "accelerate/src/accelerate/commands/merge.py", "repo_id": "accelerate", "token_count": 776 }
# 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_sync.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/test_sync.py", "repo_id": "accelerate", "token_count": 7926 }
# 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/offload.py/0
{ "file_path": "accelerate/src/accelerate/utils/offload.py", "repo_id": "accelerate", "token_count": 3177 }
# 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_accelerator.py/0
{ "file_path": "accelerate/tests/test_accelerator.py", "repo_id": "accelerate", "token_count": 15183 }
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_imports.py/0
{ "file_path": "accelerate/tests/test_imports.py", "repo_id": "accelerate", "token_count": 1442 }
[workspace] members = [ "candle-core", "candle-datasets", "candle-examples", "candle-book", "candle-nn", "candle-pyo3", "candle-transformers", "candle-wasm-examples/*", "candle-wasm-tests", "tensor-tools", ] exclude = [ "candle-flash-attn", "candle-kernels", "candle-meta...
candle/Cargo.toml/0
{ "file_path": "candle/Cargo.toml", "repo_id": "candle", "token_count": 1246 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use candle_core::{Device, Tensor}; fn main() -> Result<()> { let a = Tensor::new(&[[0.0f32, 1.0, 2.0], [3.0, 4.0, 5.0]], &Device::Cpu)?; let b = Tensor::new(&[[88.0f32, 99.0]], ...
candle/candle-core/examples/basics.rs/0
{ "file_path": "candle/candle-core/examples/basics.rs", "repo_id": "candle", "token_count": 287 }
/// Helper functions to write CPU kernels. use crate::backend::BackendStorage; use crate::{Error, Layout, Result, WithDType}; type C = super::CpuStorage; pub trait Map1 { fn f<T: WithDType>(&self, vs: &[T], layout: &Layout) -> Result<Vec<T>>; fn map(&self, vs: &C, layout: &Layout) -> Result<C> { match...
candle/candle-core/src/cpu_backend/utils.rs/0
{ "file_path": "candle/candle-core/src/cpu_backend/utils.rs", "repo_id": "candle", "token_count": 9033 }
use crate::{DType, Result}; use candle_metal_kernels::Kernels; use metal::{Buffer, CommandBuffer, CommandQueue, MTLResourceOptions, NSUInteger}; use std::collections::HashMap; use std::path::Path; use std::sync::{Arc, Mutex, RwLock}; use super::MetalError; /// Unique identifier for cuda devices. #[derive(Clone, Copy,...
candle/candle-core/src/metal_backend/device.rs/0
{ "file_path": "candle/candle-core/src/metal_backend/device.rs", "repo_id": "candle", "token_count": 5226 }
use super::k_quants::{BlockQ2K, BlockQ4K, BlockQ4_0, BlockQ6K, BlockQ8K, BlockQ8_0, QK8_0, QK_K}; use crate::Result; use byteorder::{ByteOrder, LittleEndian}; use half::f16; use core::arch::wasm32::*; #[inline(always)] pub(crate) fn vec_dot_q4_0_q8_0(n: usize, xs: &[BlockQ4_0], ys: &[BlockQ8_0]) -> Result<f32> { ...
candle/candle-core/src/quantized/simd128.rs/0
{ "file_path": "candle/candle-core/src/quantized/simd128.rs", "repo_id": "candle", "token_count": 11617 }
use anyhow::Result; use candle_core::{DType, Device::Cpu, Tensor}; #[test] fn display_scalar() -> Result<()> { let t = Tensor::new(1234u32, &Cpu)?; let s = format!("{t}"); assert_eq!(&s, "[1234]\nTensor[[], u32]"); let t = t.to_dtype(DType::F32)?.neg()?; let s = format!("{}", (&t / 10.0)?); ass...
candle/candle-core/tests/display_tests.rs/0
{ "file_path": "candle/candle-core/tests/display_tests.rs", "repo_id": "candle", "token_count": 1395 }
# candle-distilbert DistilBert is a distiled version of the Bert model. ## Sentence embeddings DistilBert is used to compute the sentence embeddings for a prompt. The model weights are downloaded from the hub on the first run. ```bash cargo run --example distilbert --release -- --prompt "Here is a test sentence" >...
candle/candle-examples/examples/distilbert/README.md/0
{ "file_path": "candle/candle-examples/examples/distilbert/README.md", "repo_id": "candle", "token_count": 367 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle_transformers::models::jina_bert::{BertModel, Config, PositionEmbeddingType}; use anyhow::Error as E; use candle::{DType, Module, Tensor}; use candle_nn::VarBuilder; use clap::Parser; #[derive(P...
candle/candle-examples/examples/jina-bert/main.rs/0
{ "file_path": "candle/candle-examples/examples/jina-bert/main.rs", "repo_id": "candle", "token_count": 3414 }
# candle-marian-mt `marian-mt` is a neural machine translation model. In this example it is used to translate text from French to English. See the associated [model card](https://huggingface.co/Helsinki-NLP/opus-mt-tc-big-fr-en) for details on the model itself. ## Running an example ```bash cargo run --example maria...
candle/candle-examples/examples/marian-mt/README.md/0
{ "file_path": "candle/candle-examples/examples/marian-mt/README.md", "repo_id": "candle", "token_count": 497 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::mobilenetv4; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { ...
candle/candle-examples/examples/mobilenetv4/main.rs/0
{ "file_path": "candle/candle-examples/examples/mobilenetv4/main.rs", "repo_id": "candle", "token_count": 1443 }
# PaliGemma [HuggingFace Model Card](https://huggingface.co/google/paligemma-3b-pt-224) - [Model Page](https://ai.google.dev/gemma/docs/paligemma) ```bash cargo run --features cuda --release --example paligemma -- \ --prompt "caption fr" --image candle-examples/examples/yolo-v8/assets/bike.jpg ``` ``` loaded ima...
candle/candle-examples/examples/paligemma/README.md/0
{ "file_path": "candle/candle-examples/examples/paligemma/README.md", "repo_id": "candle", "token_count": 339 }
#[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::{ggml_file, gguf_file}; use candle::Tensor; use candle_transformers::generation::{LogitsProcessor, Sampl...
candle/candle-examples/examples/quantized/main.rs/0
{ "file_path": "candle/candle-examples/examples/quantized/main.rs", "repo_id": "candle", "token_count": 13386 }
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::repvgg; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { A0, ...
candle/candle-examples/examples/repvgg/main.rs/0
{ "file_path": "candle/candle-examples/examples/repvgg/main.rs", "repo_id": "candle", "token_count": 1525 }
# silero-vad: Voice Activity Detection [Silero VAD (v5)](https://github.com/snakers4/silero-vad) detects voice activity in streaming audio. This example uses the models available in the hugging face [onnx-community/silero-vad](https://huggingface.co/onnx-community/silero-vad). ## Running the example ```bash $ areco...
candle/candle-examples/examples/silero-vad/README.md/0
{ "file_path": "candle/candle-examples/examples/silero-vad/README.md", "repo_id": "candle", "token_count": 155 }
# candle-stella-en-v5: Implementation of [stella_en_1.5B_v5](https://huggingface.co/dunzhang/stella_en_1.5B_v5) embedding model As of 7th Oct 2024, *Stella_en_1.5B_v5* is one of the top ranking model on `retrieval` and `reranking` tasks in [MTEB](https://huggingface.co/spaces/mteb/leaderboard) leaderboard. [Model car...
candle/candle-examples/examples/stella-en-v5/README.md/0
{ "file_path": "candle/candle-examples/examples/stella-en-v5/README.md", "repo_id": "candle", "token_count": 1143 }
# Get the checkpoint from # https://openaipublic.azureedge.net/main/whisper/models/d3dd57d32accea0b295c96e26691aa14d8822fac7d9d27d5dc00b4ca2826dd03/tiny.en.pt import torch from safetensors.torch import save_file data = torch.load("tiny.en.pt") weights = {} for k, v in data["model_state_dict"].items(): weights[k] ...
candle/candle-examples/examples/whisper/extract_weights.py/0
{ "file_path": "candle/candle-examples/examples/whisper/extract_weights.py", "repo_id": "candle", "token_count": 183 }
# candle-yolo-v8: Object Detection and Pose Estimation This is a port of [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics). The implementation is based on the [tinygrad version](https://github.com/tinygrad/tinygrad/blob/master/examples/yolov8.py) and on the model architecture described in this [issue](h...
candle/candle-examples/examples/yolo-v8/README.md/0
{ "file_path": "candle/candle-examples/examples/yolo-v8/README.md", "repo_id": "candle", "token_count": 562 }
// Pytorch also has an implementation of Philox RNG: https://github.com/pytorch/pytorch/blob/8ca3c881db3e3510fcb7725389f6a0633c9b992c/torch/csrc/jit/tensorexpr/cuda_random.h #pragma once // Philox CUDA. namespace flash { struct ull2 { unsigned long long x; unsigned long long y; }; __forceinline__ __device__ ...
candle/candle-flash-attn/kernels/philox.cuh/0
{ "file_path": "candle/candle-flash-attn/kernels/philox.cuh", "repo_id": "candle", "token_count": 770 }
#include "cuda_utils.cuh" #include<stdint.h> // Naive implementation of conv1d. template <typename T, typename A> __device__ void conv1d( const size_t src_numel, const size_t l_out, const size_t stride, const size_t padding, const size_t dilation, const size_t *info, const T *src, const...
candle/candle-kernels/src/conv.cu/0
{ "file_path": "candle/candle-kernels/src/conv.cu", "repo_id": "candle", "token_count": 11728 }
#include <metal_stdlib> using namespace metal; #define MAX(x, y) ((x) > (y) ? (x) : (y)) template <typename T> METAL_FUNC void im2col( constant size_t &dst_numel, constant size_t &h_out, constant size_t &w_out, constant size_t &h_k, constant size_t &w_k, constant size_t &stride, constant ...
candle/candle-metal-kernels/src/conv.metal/0
{ "file_path": "candle/candle-metal-kernels/src/conv.metal", "repo_id": "candle", "token_count": 8944 }
#pragma once #include <metal_stdlib> 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_FUNC uint ne...
candle/candle-metal-kernels/src/utils.metal/0
{ "file_path": "candle/candle-metal-kernels/src/utils.metal", "repo_id": "candle", "token_count": 453 }
//! Batch Normalization. //! //! This layer applies Batch Normalization over a mini-batch of inputs as described in [`Batch //! Normalization`]. The input is expected to have at least three dimensions. //! //! Note that this implementation is for inference only, there is no possibility to track the //! running stats. /...
candle/candle-nn/src/batch_norm.rs/0
{ "file_path": "candle/candle-nn/src/batch_norm.rs", "repo_id": "candle", "token_count": 5325 }
//! Sequential Layer //! //! A sequential layer used to chain multiple layers and closures. use candle::{Module, Result, Tensor}; /// A sequential layer combining multiple other layers. pub struct Sequential { layers: Vec<Box<dyn Module>>, } /// Creates a new empty sequential layer. pub fn seq() -> Sequential { ...
candle/candle-nn/src/sequential.rs/0
{ "file_path": "candle/candle-nn/src/sequential.rs", "repo_id": "candle", "token_count": 714 }
use crate::onnx::attribute_proto::AttributeType; use crate::onnx::tensor_proto::DataType; use crate::onnx::{self, GraphProto}; use candle::{bail, DType, Device, Result, Tensor}; use std::collections::{HashMap, HashSet}; pub type Value = Tensor; pub fn dtype(dt: DataType) -> Option<DType> { match dt { Data...
candle/candle-onnx/src/eval.rs/0
{ "file_path": "candle/candle-onnx/src/eval.rs", "repo_id": "candle", "token_count": 53114 }
import candle from typing import Dict, Tuple, Any from candle import Tensor, QTensor, utils, nn from candle.nn import Module, ModuleList def masked_fill(on_false: Tensor, mask: Tensor, on_true: Tensor): shape = mask.shape on_true = candle.tensor(on_true).broadcast_as(shape) return mask.where_cond(on_true,...
candle/candle-pyo3/py_src/candle/models/llama.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/models/llama.py", "repo_id": "candle", "token_count": 2981 }
#![allow(clippy::redundant_closure_call)] use pyo3::exceptions::{PyTypeError, PyValueError}; use pyo3::prelude::*; use pyo3::pyclass::CompareOp; use pyo3::types::{IntoPyDict, PyDict, PyTuple}; use pyo3::ToPyObject; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::sync::Arc; use ha...
candle/candle-pyo3/src/lib.rs/0
{ "file_path": "candle/candle-pyo3/src/lib.rs", "repo_id": "candle", "token_count": 29668 }
//! Logit Processing and Sampling //! //! Functionality for modeling sampling strategies and logits processing in text generation //! with support for temperature-based sampling, top-k filtering, nucleus sampling (top-p), //! and combinations thereof. use candle::{Context, DType, Error, Result, Tensor}; use rand::{dist...
candle/candle-transformers/src/generation/mod.rs/0
{ "file_path": "candle/candle-transformers/src/generation/mod.rs", "repo_id": "candle", "token_count": 2975 }
//! Colpali Model for text/image similarity scoring. //! //! Colpali combines a vision encoder with an efficient LM for retrieving content. //! use candle::{Module, Result, Tensor}; use candle_nn::VarBuilder; use super::paligemma; use candle_nn::{linear, Linear}; pub struct Model { pub model: paligemma::Model, ...
candle/candle-transformers/src/models/colpali.rs/0
{ "file_path": "candle/candle-transformers/src/models/colpali.rs", "repo_id": "candle", "token_count": 648 }
//! Flux Model //! //! Flux is a 12B rectified flow transformer capable of generating images from text descriptions. //! //! - 🤗 [Hugging Face Model](https://huggingface.co/black-forest-labs/FLUX.1-schnell) //! - 💻 [GitHub Repository](https://github.com/black-forest-labs/flux) //! - 📝 [Blog Post](https://blackfores...
candle/candle-transformers/src/models/flux/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/flux/mod.rs", "repo_id": "candle", "token_count": 530 }
pub fn get_anyres_image_grid_shape( image_size: (u32, u32), grid_pinpoints: &[(u32, u32)], patch_size: u32, ) -> (u32, u32) { let (width, height) = select_best_resolution(image_size, grid_pinpoints); (width / patch_size, height / patch_size) } pub fn select_best_resolution( original_size: (u32,...
candle/candle-transformers/src/models/llava/utils.rs/0
{ "file_path": "candle/candle-transformers/src/models/llava/utils.rs", "repo_id": "candle", "token_count": 689 }
// Implement the MMDiT model originally introduced for Stable Diffusion 3 (https://arxiv.org/abs/2403.03206), // as well as the MMDiT-X variant introduced for Stable Diffusion 3.5-medium (https://huggingface.co/stabilityai/stable-diffusion-3.5-medium) // This follows the implementation of the MMDiT model in the ComfyUI...
candle/candle-transformers/src/models/mmdit/model.rs/0
{ "file_path": "candle/candle-transformers/src/models/mmdit/model.rs", "repo_id": "candle", "token_count": 4203 }
//! Parler Model implementation for parler_tts text-to-speech synthesis //! //! Implements a transformer-based decoder architecture for generating audio tokens //! from text using discrete tokens. The model converts text into audio segments //! using multiple codebooks of quantized audio tokens. //! //! The model archi...
candle/candle-transformers/src/models/parler_tts.rs/0
{ "file_path": "candle/candle-transformers/src/models/parler_tts.rs", "repo_id": "candle", "token_count": 8561 }
//! Phi2 model implementation with quantization support. //! //! Phi2 is a 2.7B parameter language model using scaled-up Transformer decoder architecture. //! This implementation provides quantization for reduced memory and compute usage. //! //! Key characteristics: //! - Partial attention with learned mixing to reduc...
candle/candle-transformers/src/models/quantized_phi.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_phi.rs", "repo_id": "candle", "token_count": 5545 }
use candle::{DType, IndexOp, Result, Tensor}; use candle_nn::{layer_norm, LayerNorm, Module, VarBuilder}; #[derive(Debug)] struct PatchEmbed { proj: candle_nn::Conv2d, span: tracing::Span, } impl PatchEmbed { fn new( in_chans: usize, embed_dim: usize, k_size: usize, stride:...
candle/candle-transformers/src/models/segment_anything/image_encoder.rs/0
{ "file_path": "candle/candle-transformers/src/models/segment_anything/image_encoder.rs", "repo_id": "candle", "token_count": 8848 }
#![allow(dead_code)] //! # Diffusion pipelines and models //! //! Noise schedulers can be used to set the trade-off between //! inference speed and quality. use candle::{Result, Tensor}; pub trait SchedulerConfig: std::fmt::Debug + Send + Sync { fn build(&self, inference_steps: usize) -> Result<Box<dyn Scheduler>>...
candle/candle-transformers/src/models/stable_diffusion/schedulers.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/schedulers.rs", "repo_id": "candle", "token_count": 940 }
//! Apply penalty and repeat_kv use candle::{Result, Tensor}; pub fn apply_repeat_penalty(logits: &Tensor, penalty: f32, context: &[u32]) -> Result<Tensor> { let device = logits.device(); let mut logits = logits.to_dtype(candle::DType::F32)?.to_vec1::<f32>()?; let mut already_seen = std::collections::Hash...
candle/candle-transformers/src/utils.rs/0
{ "file_path": "candle/candle-transformers/src/utils.rs", "repo_id": "candle", "token_count": 642 }
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::generation::LogitsProcessor; use candle_transformers::models::blip; use candle_transformers::models::quantized_blip; use candle_wasm_example_blip::console_log; use candle_wasm_example_blip::token_output_stream::TokenOutputStream; u...
candle/candle-wasm-examples/blip/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/blip/src/bin/m.rs", "repo_id": "candle", "token_count": 2698 }
## Running Yolo Examples Here, we provide two examples of how to run YOLOv8 using a Candle-compiled WASM binary and runtimes. ### Pure Rust UI To build and test the UI made in Rust you will need [Trunk](https://trunkrs.dev/#install) From the `candle-wasm-examples/yolo` directory run: Download assets: ```bash wget ...
candle/candle-wasm-examples/yolo/README.md/0
{ "file_path": "candle/candle-wasm-examples/yolo/README.md", "repo_id": "candle", "token_count": 412 }
#![allow(unused)] use candle::{ quantized::{self, k_quants, GgmlDType, GgmlType}, test_utils::to_vec2_round, Device, Module, Result, Tensor, }; use wasm_bindgen_test::*; wasm_bindgen_test_configure!(run_in_browser); #[wasm_bindgen_test] fn quantized_matmul_neg() -> Result<()> { let cpu = &Device::Cpu;...
candle/candle-wasm-tests/tests/quantized_tests.rs/0
{ "file_path": "candle/candle-wasm-tests/tests/quantized_tests.rs", "repo_id": "candle", "token_count": 3151 }
{{- define "name" -}} {{- default $.Release.Name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "app.name" -}} chat-ui {{- end -}} {{- define "labels.standard" -}} release: {{ $.Release.Name | quote }} heritage: {{ $.Release.Service | quote }} chart: "{{ include "name" . }}" app: "{{ include "app.name" . }}" ...
chat-ui/chart/templates/_helpers.tpl/0
{ "file_path": "chat-ui/chart/templates/_helpers.tpl", "repo_id": "chat-ui", "token_count": 202 }
# Models Overview You can customize the parameters passed to the model or even use a new model by updating the `MODELS` variable in your `.env.local`. The default one can be found in `.env` and looks like this : ```ini MODELS=`[ { "name": "mistralai/Mistral-7B-Instruct-v0.2", "displayName": "mistralai/Mistr...
chat-ui/docs/source/configuration/models/overview.md/0
{ "file_path": "chat-ui/docs/source/configuration/models/overview.md", "repo_id": "chat-ui", "token_count": 1993 }
# Architecture This document discusses the high level overview of the Chat UI codebase. If you're looking to contribute or just want to understand how the codebase works, this is the place for you! ## Overview Chat UI provides a simple interface connecting LLMs to external information and tools. The project uses [Mo...
chat-ui/docs/source/developing/architecture.md/0
{ "file_path": "chat-ui/docs/source/developing/architecture.md", "repo_id": "chat-ui", "token_count": 409 }
<!doctype html> <html lang="en" class="h-full"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="theme-color" content="rgb(249, 250, 251)" /> <script> if ( localStorage.theme === "dark" || (!("theme" in localStorage) && window.matchMe...
chat-ui/src/app.html/0
{ "file_path": "chat-ui/src/app.html", "repo_id": "chat-ui", "token_count": 668 }
<!-- @migration task: review uses of `navigating` --> <script lang="ts"> import { run } from "svelte/legacy"; import { navigating } from "$app/state"; import { createEventDispatcher } from "svelte"; import { browser } from "$app/environment"; import { base } from "$app/paths"; import { page } from "$app/stores";...
chat-ui/src/lib/components/MobileNav.svelte/0
{ "file_path": "chat-ui/src/lib/components/MobileNav.svelte", "repo_id": "chat-ui", "token_count": 862 }
<script lang="ts"> import type { Model } from "$lib/types/Model"; import { getTokenizer } from "$lib/utils/getTokenizer"; import type { PreTrainedTokenizer } from "@huggingface/transformers"; import { untrack } from "svelte"; interface Props { classNames?: string; prompt?: string; modelTokenizer: Exclude<Mo...
chat-ui/src/lib/components/TokensCounter.svelte/0
{ "file_path": "chat-ui/src/lib/components/TokensCounter.svelte", "repo_id": "chat-ui", "token_count": 449 }
<script lang="ts"> import MarkdownRenderer from "./MarkdownRenderer.svelte"; import CarbonCaretDown from "~icons/carbon/caret-down"; interface Props { summary: string; content: string; loading?: boolean; } let { summary, content, loading = false }: Props = $props(); </script> <details class="group flex w...
chat-ui/src/lib/components/chat/OpenReasoningResults.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/OpenReasoningResults.svelte", "repo_id": "chat-ui", "token_count": 1760 }
<script lang="ts"> import CarbonPause from "~icons/carbon/pause"; import CarbonPlay from "~icons/carbon/play"; interface Props { src: string; name: string; } let { src, name }: Props = $props(); let time = $state(0); let duration = $state(0); let paused = $state(true); function format(time: number) { ...
chat-ui/src/lib/components/players/AudioPlayer.svelte/0
{ "file_path": "chat-ui/src/lib/components/players/AudioPlayer.svelte", "repo_id": "chat-ui", "token_count": 909 }
import type { Session } from "$lib/types/Session"; import type { User } from "$lib/types/User"; import type { Conversation } from "$lib/types/Conversation"; import { ObjectId } from "mongodb"; import { deleteConversations } from "./09-delete-empty-conversations"; import { afterAll, afterEach, beforeAll, describe, expec...
chat-ui/src/lib/migrations/routines/09-delete-empty-conversations.spec.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/09-delete-empty-conversations.spec.ts", "repo_id": "chat-ui", "token_count": 2019 }
import { z } from "zod"; import type { Endpoint } from "../endpoints"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import { createImageProcessorOptionsValidator, makeImageProcessor } from "../images"; import type { EndpointMessage } from "../endpoints"; import type { MessageFile } from "$l...
chat-ui/src/lib/server/endpoints/aws/endpointBedrock.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/aws/endpointBedrock.ts", "repo_id": "chat-ui", "token_count": 2027 }
import { randomUUID } from "$lib/utils/randomUuid"; import { timeout } from "$lib/utils/timeout"; import { logger } from "./logger"; type ExitHandler = () => void | Promise<void>; type ExitHandlerUnsubscribe = () => void; const listeners = new Map<string, ExitHandler>(); export function onExit(cb: ExitHandler): Exit...
chat-ui/src/lib/server/exitHandler.ts/0
{ "file_path": "chat-ui/src/lib/server/exitHandler.ts", "repo_id": "chat-ui", "token_count": 402 }
import { collectDefaultMetrics, Registry, Counter, Summary } from "prom-client"; import express from "express"; import { logger } from "$lib/server/logger"; import { env } from "$env/dynamic/private"; import type { Model } from "$lib/types/Model"; import { onExit } from "./exitHandler"; import { promisify } from "util"...
chat-ui/src/lib/server/metrics.ts/0
{ "file_path": "chat-ui/src/lib/server/metrics.ts", "repo_id": "chat-ui", "token_count": 2367 }
import type { ConfigTool } from "$lib/types/Tool"; import { ObjectId } from "mongodb"; import { runWebSearch } from "../../websearch/runWebSearch"; const websearch: ConfigTool = { _id: new ObjectId("00000000000000000000000A"), type: "config", description: "Search the web for answers to the user's query", color: "b...
chat-ui/src/lib/server/tools/web/search.ts/0
{ "file_path": "chat-ui/src/lib/server/tools/web/search.ts", "repo_id": "chat-ui", "token_count": 480 }
import type { BackendModel } from "$lib/server/models"; export type Model = Pick< BackendModel, | "id" | "name" | "displayName" | "websiteUrl" | "datasetName" | "promptExamples" | "parameters" | "description" | "logoUrl" | "modelUrl" | "tokenizer" | "datasetUrl" | "preprompt" | "multimodal" | "multimod...
chat-ui/src/lib/types/Model.ts/0
{ "file_path": "chat-ui/src/lib/types/Model.ts", "repo_id": "chat-ui", "token_count": 175 }
/** * A debounce function that works in both browser and Nodejs. * For pure Nodejs work, prefer the `Debouncer` class. */ export function debounce<T extends unknown[]>( callback: (...rest: T) => unknown, limit: number ): (...rest: T) => void { let timer: ReturnType<typeof setTimeout>; return function (...rest) ...
chat-ui/src/lib/utils/debounce.ts/0
{ "file_path": "chat-ui/src/lib/utils/debounce.ts", "repo_id": "chat-ui", "token_count": 138 }
export function parseStringToList(links: unknown): string[] { if (typeof links !== "string") { throw new Error("Expected a string"); } return links .split(",") .map((link) => link.trim()) .filter((link) => link.length > 0); }
chat-ui/src/lib/utils/parseStringToList.ts/0
{ "file_path": "chat-ui/src/lib/utils/parseStringToList.ts", "repo_id": "chat-ui", "token_count": 86 }
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { describe, expect, it } from "vitest"; import { insertLegacyConversation, insertLinearBranchConversation, insertSideBranchesConversation, } from "./treeHelpers.spec"; import { buildSubtree } from "./buildSubtree"; descr...
chat-ui/src/lib/utils/tree/buildSubtree.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/buildSubtree.spec.ts", "repo_id": "chat-ui", "token_count": 1375 }
import { collections } from "$lib/server/database"; import { models } from "$lib/server/models"; import { authCondition } from "$lib/server/auth"; import type { Conversation } from "$lib/types/Conversation"; import { CONV_NUM_PER_PAGE } from "$lib/constants/pagination"; export async function GET({ locals, url }) { co...
chat-ui/src/routes/api/conversations/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/conversations/+server.ts", "repo_id": "chat-ui", "token_count": 510 }
import { env } from "$env/dynamic/private"; import { startOfHour } from "date-fns"; import { authCondition, requiresUser } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { models, validModelIdSchema } from "$lib/server/models"; import { ERROR_MESSAGES } from "$lib/stores/errors"; im...
chat-ui/src/routes/conversation/[id]/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/+server.ts", "repo_id": "chat-ui", "token_count": 6234 }
import ModelThumbnail from "./ModelThumbnail.svelte"; import { redirect, type RequestHandler } from "@sveltejs/kit"; import type { SvelteComponent } from "svelte"; import { Resvg } from "@resvg/resvg-js"; import satori from "satori"; import { html } from "satori-html"; import InterRegular from "$lib/server/fonts/Inte...
chat-ui/src/routes/models/[...model]/thumbnail.png/+server.ts/0
{ "file_path": "chat-ui/src/routes/models/[...model]/thumbnail.png/+server.ts", "repo_id": "chat-ui", "token_count": 520 }
<script lang="ts"> import Modal from "$lib/components/Modal.svelte"; import ToolEdit from "../ToolEdit.svelte"; let { form = $bindable() } = $props(); </script> <Modal on:close={() => window.history.back()} width="h-[95dvh] w-[90dvw] overflow-hidden rounded-2xl bg-white shadow-2xl outline-none sm:h-[85dvh] xl:w-...
chat-ui/src/routes/tools/new/+page.svelte/0
{ "file_path": "chat-ui/src/routes/tools/new/+page.svelte", "repo_id": "chat-ui", "token_count": 176 }
{ "extends": "./.svelte-kit/tsconfig.json", "compilerOptions": { "allowJs": true, "checkJs": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, "strict": true, "target": "ES2018" }, "exclude": ["vite.config.t...
chat-ui/tsconfig.json/0
{ "file_path": "chat-ui/tsconfig.json", "repo_id": "chat-ui", "token_count": 211 }
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration SPEED_TEST_N_EXAMPLES = 500_000 RESULTS_BASEPATH, RESULTS_FILENAME = os.path.split(__file__) RESULTS_FILE_PATH = os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py...
datasets/benchmarks/benchmark_map_filter.py/0
{ "file_path": "datasets/benchmarks/benchmark_map_filter.py", "repo_id": "datasets", "token_count": 996 }
# Image classification Image classification datasets are used to train a model to classify an entire image. There are a wide variety of applications enabled by these datasets such as identifying endangered wildlife species or screening for disease in medical images. This guide will show you how to apply transformation...
datasets/docs/source/image_classification.mdx/0
{ "file_path": "datasets/docs/source/image_classification.mdx", "repo_id": "datasets", "token_count": 1043 }
# Table Classes Each `Dataset` object is backed by a PyArrow Table. A Table can be loaded from either the disk (memory mapped) or in memory. Several Table types are available, and they all inherit from [`table.Table`]. ## Table [[autodoc]] datasets.table.Table - validate - equals - to_batches - to_py...
datasets/docs/source/package_reference/table_classes.mdx/0
{ "file_path": "datasets/docs/source/package_reference/table_classes.mdx", "repo_id": "datasets", "token_count": 1029 }
# Use with Polars This document is a quick introduction to using `datasets` with Polars, with a particular focus on how to process datasets using Polars functions, and how to convert a dataset to Polars or from Polars. This is particularly useful as it allows fast zero-copy operations, since both `datasets` and Polar...
datasets/docs/source/use_with_polars.mdx/0
{ "file_path": "datasets/docs/source/use_with_polars.mdx", "repo_id": "datasets", "token_count": 1831 }
from abc import ABC, abstractmethod from argparse import ArgumentParser class BaseDatasetsCLICommand(ABC): @staticmethod @abstractmethod def register_subcommand(parser: ArgumentParser): raise NotImplementedError() @abstractmethod def run(self): raise NotImplementedError()
datasets/src/datasets/commands/__init__.py/0
{ "file_path": "datasets/src/datasets/commands/__init__.py", "repo_id": "datasets", "token_count": 107 }
__all__ = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "LargeList", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", "Video", ] from .audio import Audio from .features import Array2D, Array3D, Array4D...
datasets/src/datasets/features/__init__.py/0
{ "file_path": "datasets/src/datasets/features/__init__.py", "repo_id": "datasets", "token_count": 181 }
import time from itertools import chain from typing import Optional, Union from huggingface_hub import ( CommitInfo, CommitOperationAdd, CommitOperationDelete, DatasetCard, DatasetCardData, HfApi, HfFileSystem, ) from huggingface_hub.utils import HfHubHTTPError import datasets.config from ...
datasets/src/datasets/hub.py/0
{ "file_path": "datasets/src/datasets/hub.py", "repo_id": "datasets", "token_count": 4128 }
import inspect import re from typing import Dict, List, Tuple from huggingface_hub.utils import insecure_hashlib from .arrow import arrow from .audiofolder import audiofolder from .cache import cache from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parq...
datasets/src/datasets/packaged_modules/__init__.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/__init__.py", "repo_id": "datasets", "token_count": 1752 }
import io import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import pyarrow.json as paj import datasets import datasets.config from datasets.table import table_cast from datasets.utils.file_utils import readline logger = datasets.utils.logging.get...
datasets/src/datasets/packaged_modules/json/json.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/json/json.py", "repo_id": "datasets", "token_count": 4543 }
""" Utilities for working with the local dataset cache. This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp Copyright by the AllenNLP authors. """ import asyncio import glob import io import json import multiprocessing import os import posixpath import re import shutil import sys impo...
datasets/src/datasets/utils/file_utils.py/0
{ "file_path": "datasets/src/datasets/utils/file_utils.py", "repo_id": "datasets", "token_count": 22628 }
# Copyright 2022 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/utils/tf_utils.py/0
{ "file_path": "datasets/src/datasets/utils/tf_utils.py", "repo_id": "datasets", "token_count": 10951 }
import posixpath from pathlib import Path from unittest.mock import patch import pytest from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path from fsspec.registry import _registry as _fsspec_registry class MockFileSystem(AbstractFileSystem): protocol = "mock" def __ini...
datasets/tests/fixtures/fsspec.py/0
{ "file_path": "datasets/tests/fixtures/fsspec.py", "repo_id": "datasets", "token_count": 1757 }
import importlib import shutil import textwrap import pytest from datasets import ClassLabel, DownloadManager, Features, Value from datasets.builder import InvalidConfigName from datasets.data_files import DataFilesDict, DataFilesList, get_data_patterns from datasets.download.streaming_download_manager import Streami...
datasets/tests/packaged_modules/test_folder_based_builder.py/0
{ "file_path": "datasets/tests/packaged_modules/test_folder_based_builder.py", "repo_id": "datasets", "token_count": 9076 }
import os import sys from pathlib import Path import pytest from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node from .utils import execute_subprocess_async, get_torch_dist_unique_port, require_torch def test_split_dataset_by_node_map_style(): full_ds = Dataset.f...
datasets/tests/test_distributed.py/0
{ "file_path": "datasets/tests/test_distributed.py", "repo_id": "datasets", "token_count": 2244 }
import re import sys import tempfile import unittest from pathlib import Path import pytest import yaml from huggingface_hub import DatasetCard, DatasetCardData from datasets.config import METADATA_CONFIGS_FIELD from datasets.features import Features, Value from datasets.info import DatasetInfo from datasets.utils.me...
datasets/tests/test_metadata_util.py/0
{ "file_path": "datasets/tests/test_metadata_util.py", "repo_id": "datasets", "token_count": 5718 }
<!--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/attnprocessor.md/0
{ "file_path": "diffusers/docs/source/en/api/attnprocessor.md", "repo_id": "diffusers", "token_count": 1472 }
<!--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/controlnet_union.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/controlnet_union.md", "repo_id": "diffusers", "token_count": 462 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/optimization/habana.md/0
{ "file_path": "diffusers/docs/source/en/optimization/habana.md", "repo_id": "diffusers", "token_count": 1405 }
<!--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/quicktour.md/0
{ "file_path": "diffusers/docs/source/en/quicktour.md", "repo_id": "diffusers", "token_count": 4860 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/training/t2i_adapters.md/0
{ "file_path": "diffusers/docs/source/en/training/t2i_adapters.md", "repo_id": "diffusers", "token_count": 3502 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/controlnet.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/controlnet.md", "repo_id": "diffusers", "token_count": 8675 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/other-formats.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/other-formats.md", "repo_id": "diffusers", "token_count": 8552 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/weighted_prompts.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/weighted_prompts.md", "repo_id": "diffusers", "token_count": 7825 }