text
stringlengths
7
1.24M
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
519
# 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/imports.py/0
{ "file_path": "accelerate/src/accelerate/utils/imports.py", "repo_id": "accelerate", "token_count": 5505 }
7
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/deepspeed/test_deepspeed.py/0
{ "file_path": "accelerate/tests/deepspeed/test_deepspeed.py", "repo_id": "accelerate", "token_count": 25822 }
8
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_grad_sync.py/0
{ "file_path": "accelerate/tests/test_grad_sync.py", "repo_id": "accelerate", "token_count": 579 }
9
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_scheduler.py/0
{ "file_path": "accelerate/tests/test_scheduler.py", "repo_id": "accelerate", "token_count": 2538 }
10
compute_environment: LOCAL_MACHINE debug: false distributed_type: FSDP downcast_bf16: 'no' enable_cpu_affinity: false fsdp_config: fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP fsdp_backward_prefetch: BACKWARD_PRE fsdp_cpu_ram_efficient_loading: true fsdp_forward_prefetch: true fsdp_offload_params: false fs...
alignment-handbook/recipes/accelerate_configs/fsdp.yaml/0
{ "file_path": "alignment-handbook/recipes/accelerate_configs/fsdp.yaml", "repo_id": "alignment-handbook", "token_count": 275 }
11
# Instructions to train SmolLM-Instruct We build the [SmolLM-Instruct](https://huggingface.co/collections/HuggingFaceTB/smollm-6695016cad7167254ce15966) (v0.2) models (135M, 360M and 1.7B) by doing SFT on a mix of these datasets: - a dataset of 2k simple everyday conversations we generated by llama3.1-70B [everyday-c...
alignment-handbook/recipes/smollm/README.md/0
{ "file_path": "alignment-handbook/recipes/smollm/README.md", "repo_id": "alignment-handbook", "token_count": 418 }
12
#!/usr/bin/env python # coding=utf-8 # Copyright 2023 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/LI...
alignment-handbook/scripts/run_cpt.py/0
{ "file_path": "alignment-handbook/scripts/run_cpt.py", "repo_id": "alignment-handbook", "token_count": 2745 }
13
# coding=utf-8 # 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 requir...
alignment-handbook/tests/test_data.py/0
{ "file_path": "alignment-handbook/tests/test_data.py", "repo_id": "alignment-handbook", "token_count": 4306 }
14
# Hello world! We will now create the hello world of the ML world, building a model capable of solving MNIST dataset. Open `src/main.rs` and fill in this content: ```rust # extern crate candle_core; use candle_core::{Device, Result, Tensor}; struct Model { first: Tensor, second: Tensor, } impl Model { ...
candle/candle-book/src/guide/hello_world.md/0
{ "file_path": "candle/candle-book/src/guide/hello_world.md", "repo_id": "candle", "token_count": 2069 }
15
# candle Minimalist ML framework for Rust
candle/candle-core/README.md/0
{ "file_path": "candle/candle-core/README.md", "repo_id": "candle", "token_count": 11 }
16
/// Methods for backpropagation of gradients. use crate::op::{BinaryOp, Op, ReduceOp, UnaryOp}; use crate::{Error, Result, Tensor, TensorId}; use std::collections::HashMap; // arg has been reduced to node via reduce_dims, expand it back to arg. // This has to handle keepdims. fn broadcast_back(arg: &Tensor, node: &Ten...
candle/candle-core/src/backprop.rs/0
{ "file_path": "candle/candle-core/src/backprop.rs", "repo_id": "candle", "token_count": 24359 }
17
use crate::op::{BackpropOp, Op}; use crate::tensor::from_storage; use crate::{CpuStorage, CudaStorage, Layout, MetalStorage, Result, Shape, Tensor}; use std::sync::Arc; /// Unary ops that can be defined in user-land. pub trait CustomOp1 { // Box<dyn> does not support const yet, so use a function to get the name. ...
candle/candle-core/src/custom_op.rs/0
{ "file_path": "candle/candle-core/src/custom_op.rs", "repo_id": "candle", "token_count": 5661 }
18
use super::k_quants::{ BlockQ2K, BlockQ3K, BlockQ4K, BlockQ4_0, BlockQ5K, BlockQ6K, BlockQ8K, BlockQ8_0, QK8_0, QK_K, }; use crate::Result; use byteorder::{ByteOrder, LittleEndian}; use half::f16; #[cfg(target_arch = "x86")] use core::arch::x86::*; #[cfg(target_arch = "x86_64")] use core::arch::x86_64::*; #[inlin...
candle/candle-core/src/quantized/avx.rs/0
{ "file_path": "candle/candle-core/src/quantized/avx.rs", "repo_id": "candle", "token_count": 17495 }
19
use crate::backend::BackendStorage; use crate::op::{self, CmpOp, ReduceOp}; use crate::{CpuStorage, CudaStorage, DType, Device, Error, Layout, MetalStorage, Result, Shape}; use crate::{CustomOp1, CustomOp2, CustomOp3, InplaceOp1, InplaceOp2, InplaceOp3}; // We do not want to implement Clone on Storage as cloning may f...
candle/candle-core/src/storage.rs/0
{ "file_path": "candle/candle-core/src/storage.rs", "repo_id": "candle", "token_count": 15585 }
20
import numpy as np x = np.arange(10) # Write a npy file. np.save("test.npy", x) # Write multiple values to a npz file. values = { "x": x, "x_plus_one": x + 1 } np.savez("test.npz", **values)
candle/candle-core/tests/npy.py/0
{ "file_path": "candle/candle-core/tests/npy.py", "repo_id": "candle", "token_count": 83 }
21
pub mod tinystories;
candle/candle-datasets/src/nlp/mod.rs/0
{ "file_path": "candle/candle-datasets/src/nlp/mod.rs", "repo_id": "candle", "token_count": 6 }
22
# candle-blip The [blip-image-captioning](https://huggingface.co/Salesforce/blip-image-captioning-base) model can generate captions for an input image. ## Running on an example ```bash cargo run --example blip --release -- --image candle-examples/examples/yolo-v8/assets/bike.jpg ``` ``` Running on CPU, to run on GP...
candle/candle-examples/examples/blip/README.md/0
{ "file_path": "candle/candle-examples/examples/blip/README.md", "repo_id": "candle", "token_count": 190 }
23
//! Depth Anything V2 //! https://huggingface.co/spaces/depth-anything/Depth-Anything-V2 #[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use std::ffi::OsString; use std::path::PathBuf; use clap::Parser; use candle::DType::{F32, U8}; use candle::{DType,...
candle/candle-examples/examples/depth_anything_v2/main.rs/0
{ "file_path": "candle/candle-examples/examples/depth_anything_v2/main.rs", "repo_id": "candle", "token_count": 2541 }
24
# candle-falcon Falcon is a general large language model.
candle/candle-examples/examples/falcon/README.md/0
{ "file_path": "candle/candle-examples/examples/falcon/README.md", "repo_id": "candle", "token_count": 17 }
25
# candle-jina-bert Jina-Bert is a general large language model with a context size of 8192, [model card](https://huggingface.co/jinaai/jina-embeddings-v2-base-en). In this example it can be used for two different tasks: - Compute sentence embeddings for a prompt. - Compute similarities between a set of sentences. ##...
candle/candle-examples/examples/jina-bert/README.md/0
{ "file_path": "candle/candle-examples/examples/jina-bert/README.md", "repo_id": "candle", "token_count": 663 }
26
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::{Error as E, Result}; use clap::{Parser, ValueEnum}; use candle_transformers::models::mamba::{Config, Model, State}; use candle::{DType, Device, Tensor}; use candle_examples::token_output_stre...
candle/candle-examples/examples/mamba/main.rs/0
{ "file_path": "candle/candle-examples/examples/mamba/main.rs", "repo_id": "candle", "token_count": 4425 }
27
#[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::mobileone; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { S...
candle/candle-examples/examples/mobileone/main.rs/0
{ "file_path": "candle/candle-examples/examples/mobileone/main.rs", "repo_id": "candle", "token_count": 1213 }
28
# candle-quantized-qwen2-instruct [Qwen2]((https://qwenlm.github.io/blog/qwen2/)) is an upgraded version of Qwen1.5, released by Alibaba Cloud. ## Running the example ```bash cargo run --example quantized-qwen2-instruct --release -- --prompt "Write a function to count prime numbers up to N." ``` 0.5b, 1.5b, 7b and ...
candle/candle-examples/examples/quantized-qwen2-instruct/README.md/0
{ "file_path": "candle/candle-examples/examples/quantized-qwen2-instruct/README.md", "repo_id": "candle", "token_count": 129 }
29
#![allow(unused)] #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::Result; use clap::{Parser, Subcommand}; mod gym_env; mod vec_gym_env; mod ddpg; mod dqn; mod policy_gradient; #[derive(Parser)] struct Args { #[command(subcommand)] ...
candle/candle-examples/examples/reinforcement-learning/main.rs/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/main.rs", "repo_id": "candle", "token_count": 287 }
30
use image::{DynamicImage, ImageBuffer}; use serde::Deserialize; use std::collections::HashMap; use candle::{DType, Device, Result, Tensor}; #[derive(Debug, Clone, PartialEq, Deserialize)] pub struct ProcessorConfig { do_resize: bool, height: u32, width: u32, do_rescale: bool, do_normalize: bool, ...
candle/candle-examples/examples/trocr/image_processor.rs/0
{ "file_path": "candle/candle-examples/examples/trocr/image_processor.rs", "repo_id": "candle", "token_count": 2273 }
31
# candle-wuerstchen: Efficient Pretraining of Text-to-Image Models ![anthropomorphic cat dressed as a fire fighter](./assets/cat.jpg) The `wuerstchen` example is a port of the [diffusers implementation](https://github.com/huggingface/diffusers/tree/19edca82f1ff194c07317369a92b470dbae97f34/src/diffusers/pipelines/wuer...
candle/candle-examples/examples/wuerstchen/README.md/0
{ "file_path": "candle/candle-examples/examples/wuerstchen/README.md", "repo_id": "candle", "token_count": 358 }
32
use candle::{Result, Tensor}; // https://github.com/facebookresearch/audiocraft/blob/69fea8b290ad1b4b40d28f92d1dfc0ab01dbab85/audiocraft/data/audio_utils.py#L57 pub fn normalize_loudness( wav: &Tensor, sample_rate: u32, loudness_compressor: bool, ) -> Result<Tensor> { let energy = wav.sqr()?.mean_all()...
candle/candle-examples/src/audio.rs/0
{ "file_path": "candle/candle-examples/src/audio.rs", "repo_id": "candle", "token_count": 458 }
33
/****************************************************************************** * Copyright (c) 2024, Tri Dao. ******************************************************************************/ #pragma once #include <cute/tensor.hpp> #include <cutlass/cutlass.h> #include <cutlass/array.h> #include <cutlass/numeric_ty...
candle/candle-flash-attn/kernels/flash_fwd_kernel.h/0
{ "file_path": "candle/candle-flash-attn/kernels/flash_fwd_kernel.h", "repo_id": "candle", "token_count": 37090 }
34
# candle-kernels This crate contains CUDA kernels used from candle. Some of these implementations come from the [dfdx crate](https://github.com/coreylowman/dfdx).
candle/candle-kernels/README.md/0
{ "file_path": "candle/candle-kernels/README.md", "repo_id": "candle", "token_count": 45 }
35
#define _USE_MATH_DEFINES #include<math.h> #include<stdint.h> #include "cuda_utils.cuh" #define UNARY_OP(TYPENAME, FN_NAME, FUNC) \ extern "C" __global__ void FN_NAME( \ const size_t numel, \ const size_t num_dims, \ const size_t *info, \ const TYPENAME *inp, \ TYPENAME *out \ ) { \ const size_...
candle/candle-kernels/src/unary.cu/0
{ "file_path": "candle/candle-kernels/src/unary.cu", "repo_id": "candle", "token_count": 3677 }
36
#include <metal_stdlib> #include <metal_math> # 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; ...
candle/candle-metal-kernels/src/unary.metal/0
{ "file_path": "candle/candle-metal-kernels/src/unary.metal", "repo_id": "candle", "token_count": 2564 }
37
//! Convolution Layers. use crate::BatchNorm; use candle::{Result, Tensor}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Conv1dConfig { pub padding: usize, pub stride: usize, pub dilation: usize, pub groups: usize, } impl Default for Conv1dConfig { fn default() -> Self { Self { ...
candle/candle-nn/src/conv.rs/0
{ "file_path": "candle/candle-nn/src/conv.rs", "repo_id": "candle", "token_count": 5891 }
38
//! A `VarBuilder` is used to retrieve variables used by a model. These variables can either come //! from a pre-trained checkpoint, e.g. using `VarBuilder::from_mmaped_safetensors`, or initialized //! for training, e.g. using `VarBuilder::from_varmap`. use crate::VarMap; use candle::{safetensors::Load, DType, Device, ...
candle/candle-nn/src/var_builder.rs/0
{ "file_path": "candle/candle-nn/src/var_builder.rs", "repo_id": "candle", "token_count": 10699 }
39
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::test_utils::to_vec2_round; use candle::{DType, Device, NdArray, Result, Tensor}; use candle_onnx::eval::Value; use candle_onnx::onnx::attribute_proto::AttributeType; use candle_onnx::onnx::tenso...
candle/candle-onnx/tests/ops.rs/0
{ "file_path": "candle/candle-onnx/tests/ops.rs", "repo_id": "candle", "token_count": 70691 }
40
# see https://github.com/pytorch/pytorch/blob/main/torch/nn/modules/container.py from .module import Module from typing import ( Any, Dict, Iterable, Iterator, Mapping, Optional, overload, Tuple, TypeVar, Union, ) from collections import OrderedDict, abc as container_abcs import ...
candle/candle-pyo3/py_src/candle/nn/container.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/nn/container.py", "repo_id": "candle", "token_count": 7602 }
41
use pyo3::exceptions::PyValueError; use pyo3::prelude::*; pub fn wrap_err(err: ::candle::Error) -> PyErr { PyErr::new::<PyValueError, _>(format!("{err:?}")) }
candle/candle-pyo3/src/utils.rs/0
{ "file_path": "candle/candle-pyo3/src/utils.rs", "repo_id": "candle", "token_count": 74 }
42
use candle::{DType, Device, IndexOp, Result, Tensor, D}; use candle_nn::{layer_norm, LayerNorm, Linear, Module, VarBuilder}; const IMG_SIZE: usize = 384; const PATCH_SIZE: usize = 16; const NUM_CLASSES: usize = 1000; const WINDOW_SIZE: usize = IMG_SIZE / PATCH_SIZE; // 384 / 16 = 24 const NB_TOKENS: usize = WINDOW_SIZ...
candle/candle-transformers/src/models/beit.rs/0
{ "file_path": "candle/candle-transformers/src/models/beit.rs", "repo_id": "candle", "token_count": 6989 }
43
use super::with_tracing::{layer_norm, linear, LayerNorm, Linear}; use candle::{DType, Device, Result, Tensor}; use candle_nn::{Embedding, Module, VarBuilder}; use serde::Deserialize; pub const DTYPE: DType = DType::F32; fn masked_fill(on_false: &Tensor, mask: &Tensor, on_true: f32) -> Result<Tensor> { let shape =...
candle/candle-transformers/src/models/distilbert.rs/0
{ "file_path": "candle/candle-transformers/src/models/distilbert.rs", "repo_id": "candle", "token_count": 5381 }
44
use super::with_tracing::{linear_no_bias as linear, Linear, RmsNorm}; use candle::{DType, Device, IndexOp, Result, Tensor, D}; use candle_nn::{embedding, Embedding, Module, VarBuilder}; use std::{collections::HashMap, f32::consts::PI}; pub const DEFAULT_MAX_SEQ_LEN: usize = 4096; #[derive(Debug, Clone, serde::Deseria...
candle/candle-transformers/src/models/llama.rs/0
{ "file_path": "candle/candle-transformers/src/models/llama.rs", "repo_id": "candle", "token_count": 9478 }
45
use candle::{Module, Result, Tensor}; use candle_nn as nn; pub struct Qkv { pub q: Tensor, pub k: Tensor, pub v: Tensor, } pub struct Mlp { fc1: nn::Linear, act: nn::Activation, fc2: nn::Linear, } impl Mlp { pub fn new( in_features: usize, hidden_features: usize, v...
candle/candle-transformers/src/models/mmdit/projections.rs/0
{ "file_path": "candle/candle-transformers/src/models/mmdit/projections.rs", "repo_id": "candle", "token_count": 1278 }
46
use std::collections::HashMap; use crate::quantized_nn::RmsNorm; use candle::quantized::QTensor; use candle::quantized::{ggml_file, gguf_file}; use candle::{DType, Device, IndexOp, Result, Tensor}; use candle_nn::{Embedding, Module}; pub const MAX_SEQ_LEN: usize = 4096; // QMatMul wrapper adding some tracing. #[deri...
candle/candle-transformers/src/models/quantized_llama.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_llama.rs", "repo_id": "candle", "token_count": 11045 }
47
use crate::models::with_tracing::{linear, linear_no_bias, Linear, RmsNorm}; use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{Activation, VarBuilder}; use std::sync::Arc; #[derive(Debug, Clone, PartialEq, serde::Deserialize)] pub struct Config { pub vocab_size: usize, pub hidden_size: usi...
candle/candle-transformers/src/models/qwen2_moe.rs/0
{ "file_path": "candle/candle-transformers/src/models/qwen2_moe.rs", "repo_id": "candle", "token_count": 8539 }
48
//! # Denoising Diffusion Implicit Models //! //! The Denoising Diffusion Implicit Models (DDIM) is a simple scheduler //! similar to Denoising Diffusion Probabilistic Models (DDPM). The DDPM //! generative process is the reverse of a Markovian process, DDIM generalizes //! this to non-Markovian guidance. //! //! Denoi...
candle/candle-transformers/src/models/stable_diffusion/ddim.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/ddim.rs", "repo_id": "candle", "token_count": 3953 }
49
use crate::models::with_tracing::{conv2d, linear, linear_no_bias, Conv2d, Linear}; use candle::{IndexOp, Module, Result, Tensor, D}; use candle_nn::{layer_norm, LayerNorm, VarBuilder}; // https://github.com/huggingface/transformers/blob/main/src/transformers/models/vit/configuration_vit.py #[derive(Debug, Clone, serde...
candle/candle-transformers/src/models/vit.rs/0
{ "file_path": "candle/candle-transformers/src/models/vit.rs", "repo_id": "candle", "token_count": 5870 }
50
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 }
51
mod app; pub mod model; pub mod worker; pub use app::App; pub use worker::Worker;
candle/candle-wasm-examples/llama2-c/src/lib.rs/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/src/lib.rs", "repo_id": "candle", "token_count": 29 }
52
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 }
53
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 }
54
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 }
55
[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 }
56
image: repository: huggingface name: chat-ui nodeSelector: role-hub-utils: "true" tolerations: - key: CriticalAddonsOnly operator: Equal serviceAccount: enabled: true create: true name: huggingchat-prod ingress: path: "/chat" annotations: alb.ingress.kubernetes.io/healthcheck-path: "/healt...
chat-ui/chart/env/prod.yaml/0
{ "file_path": "chat-ui/chart/env/prod.yaml", "repo_id": "chat-ui", "token_count": 8591 }
57
# 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 }
58
# 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 }
59
<!DOCTYPE html> <html lang="en" class="h-full"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="theme-color" content="rgb(249, 250, 251)" /> <script> if ( localStorage.theme === "dark" || (!("theme" in localStorage)...
chat-ui/src/app.html/0
{ "file_path": "chat-ui/src/app.html", "repo_id": "chat-ui", "token_count": 677 }
60
<script lang="ts"> import { createEventDispatcher, onDestroy, onMount } from "svelte"; import { cubicOut } from "svelte/easing"; import { fade } from "svelte/transition"; import Portal from "./Portal.svelte"; import { browser } from "$app/environment"; export let width = "max-w-sm"; let backdropEl: HTMLDivElem...
chat-ui/src/lib/components/Modal.svelte/0
{ "file_path": "chat-ui/src/lib/components/Modal.svelte", "repo_id": "chat-ui", "token_count": 675 }
61
<script lang="ts"> import CarbonWikis from "~icons/carbon/wikis"; import CarbonTools from "~icons/carbon/tools"; import CarbonCamera from "~icons/carbon/camera"; import CarbonCode from "~icons/carbon/code"; import CarbonEmail from "~icons/carbon/email"; import CarbonCloud from "~icons/carbon/cloud-upload"; impor...
chat-ui/src/lib/components/ToolLogo.svelte/0
{ "file_path": "chat-ui/src/lib/components/ToolLogo.svelte", "repo_id": "chat-ui", "token_count": 1346 }
62
<script lang="ts"> export let classNames = ""; </script> <svg class={classNames} xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" fill="currentColor" preserveAspectRatio="xMidYMid meet" viewBox="0 0 20 20" > ><path fill-rule="evenodd" d="M1.5 1...
chat-ui/src/lib/components/icons/IconInternet.svelte/0
{ "file_path": "chat-ui/src/lib/components/icons/IconInternet.svelte", "repo_id": "chat-ui", "token_count": 691 }
63
import type { Migration } from "."; import { collections } from "$lib/server/database"; import { ObjectId, type WithId } from "mongodb"; import type { Conversation } from "$lib/types/Conversation"; import type { WebSearchSource } from "$lib/types/WebSearch"; import { MessageUpdateStatus, MessageUpdateType, MessageWe...
chat-ui/src/lib/migrations/routines/04-update-message-updates.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/04-update-message-updates.ts", "repo_id": "chat-ui", "token_count": 1828 }
64
import { makeImageProcessor, type ImageProcessorOptions } from "../images"; import type { EndpointMessage } from "../endpoints"; import type { MessageFile } from "$lib/types/Message"; import type { ImageBlockParam, MessageParam } from "@anthropic-ai/sdk/resources/messages.mjs"; export async function fileToImageBlock( ...
chat-ui/src/lib/server/endpoints/anthropic/utils.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/anthropic/utils.ts", "repo_id": "chat-ui", "token_count": 497 }
65
import { env } from "$env/dynamic/private"; import { buildPrompt } from "$lib/buildPrompt"; import { textGenerationStream } from "@huggingface/inference"; import type { Endpoint, EndpointMessage } from "../endpoints"; import { z } from "zod"; import { createImageProcessorOptionsValidator, makeImageProcessor, type Im...
chat-ui/src/lib/server/endpoints/tgi/endpointTgi.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/tgi/endpointTgi.ts", "repo_id": "chat-ui", "token_count": 1640 }
66
import type { ProcessedModel } from "../models"; import type { Endpoint } from "../endpoints/endpoints"; import type { Conversation } from "$lib/types/Conversation"; import type { Message } from "$lib/types/Message"; import type { Assistant } from "$lib/types/Assistant"; export interface TextGenerationContext { model...
chat-ui/src/lib/server/textGeneration/types.ts/0
{ "file_path": "chat-ui/src/lib/server/textGeneration/types.ts", "repo_id": "chat-ui", "token_count": 190 }
67
/** Remove excess whitespace and newlines */ export const sanitizeString = (str: string) => str .split("\n") .map((s) => s.trim()) .filter(Boolean) .join("\n") .replaceAll(/ +/g, " "); /** Collapses a string into a single line */ export const collapseString = (str: string) => sanitizeString(str.replaceAll(/...
chat-ui/src/lib/server/websearch/markdown/utils/nlp.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/markdown/utils/nlp.ts", "repo_id": "chat-ui", "token_count": 126 }
68
import type { Message } from "$lib/types/Message"; import { format } from "date-fns"; import type { EndpointMessage } from "../../endpoints/endpoints"; import { generateFromDefaultEndpoint } from "../../generateFromDefaultEndpoint"; export async function generateQuery(messages: Message[]) { const currentDate = format...
chat-ui/src/lib/server/websearch/search/generateQuery.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/search/generateQuery.ts", "repo_id": "chat-ui", "token_count": 763 }
69
import type { ObjectId } from "mongodb"; import type { Message } from "./Message"; import type { Timestamps } from "./Timestamps"; import type { User } from "./User"; import type { Assistant } from "./Assistant"; export interface Conversation extends Timestamps { _id: ObjectId; sessionId?: string; userId?: User["_...
chat-ui/src/lib/types/Conversation.ts/0
{ "file_path": "chat-ui/src/lib/types/Conversation.ts", "repo_id": "chat-ui", "token_count": 182 }
70
/* eslint-disable no-shadow */ export enum UrlDependency { ConversationList = "conversation:list", Conversation = "conversation", }
chat-ui/src/lib/types/UrlDependency.ts/0
{ "file_path": "chat-ui/src/lib/types/UrlDependency.ts", "repo_id": "chat-ui", "token_count": 47 }
71
export function isURL(url: string) { try { new URL(url); return true; } catch (e) { return false; } }
chat-ui/src/lib/utils/isUrl.ts/0
{ "file_path": "chat-ui/src/lib/utils/isUrl.ts", "repo_id": "chat-ui", "token_count": 48 }
72
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { describe, expect, it } from "vitest"; import { insertLegacyConversation, insertSideBranchesConversation } from "./treeHelpers.spec"; import type { Message } from "$lib/types/Message"; import { addSibling } from "./addSibli...
chat-ui/src/lib/utils/tree/addSibling.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/addSibling.spec.ts", "repo_id": "chat-ui", "token_count": 950 }
73
import { collections } from "$lib/server/database"; import type { Assistant } from "$lib/types/Assistant"; import type { User } from "$lib/types/User"; import { generateQueryTokens } from "$lib/utils/searchTokens.js"; import type { Filter } from "mongodb"; import { env } from "$env/dynamic/private"; const NUM_PER_PAGE...
chat-ui/src/routes/api/assistants/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/assistants/+server.ts", "repo_id": "chat-ui", "token_count": 730 }
74
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { error } from "@sveltejs/kit"; import { authCondition } from "$lib/server/auth"; import { UrlDependency } from "$lib/types/UrlDependency"; import { convertLegacyConversation } from "$lib/utils/tree/convertLegacyConversation....
chat-ui/src/routes/conversation/[id]/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/+page.server.ts", "repo_id": "chat-ui", "token_count": 1084 }
75
import { base } from "$app/paths"; import { authCondition } from "$lib/server/auth.js"; import { collections } from "$lib/server/database"; import { models } from "$lib/server/models"; import { redirect } from "@sveltejs/kit"; export async function load({ params, locals, parent }) { const model = models.find(({ id })...
chat-ui/src/routes/models/[...model]/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/models/[...model]/+page.server.ts", "repo_id": "chat-ui", "token_count": 324 }
76
import { base } from "$app/paths"; import { requiresUser } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { fail, type Actions, redirect } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; import { z } from "zod"; import { sha256 } from "$lib/utils/sha256"; import sharp fr...
chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/edit/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/edit/+page.server.ts", "repo_id": "chat-ui", "token_count": 2408 }
77
{ "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "data": { "values": "<DVC_METRIC_DATA>" }, "title": "<DVC_METRIC_TITLE>", "mark": "point", "encoding": { "x": { "field": "<DVC_METRIC_X>", "type": "quantitative", "title": "<DVC_ME...
datasets/.dvc/plots/scatter.json/0
{ "file_path": "datasets/.dvc/plots/scatter.json", "repo_id": "datasets", "token_count": 402 }
78
# Load audio data You can load an audio dataset using the [`Audio`] feature that automatically decodes and resamples the audio files when you access the examples. Audio decoding is based on the [`soundfile`](https://github.com/bastibe/python-soundfile) python package, which uses the [`libsndfile`](https://github.com/l...
datasets/docs/source/audio_load.mdx/0
{ "file_path": "datasets/docs/source/audio_load.mdx", "repo_id": "datasets", "token_count": 1529 }
79
# Semantic segmentation Semantic segmentation datasets are used to train a model to classify every pixel in an image. There are a wide variety of applications enabled by these datasets such as background removal from images, stylizing images, or scene understanding for autonomous driving. This guide will show you how ...
datasets/docs/source/semantic_segmentation.mdx/0
{ "file_path": "datasets/docs/source/semantic_segmentation.mdx", "repo_id": "datasets", "token_count": 2142 }
80
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
datasets/src/datasets/__init__.py/0
{ "file_path": "datasets/src/datasets/__init__.py", "repo_id": "datasets", "token_count": 513 }
81
from typing import TypeVar from .arrow_dataset import Dataset, _split_by_node_map_style_dataset from .iterable_dataset import IterableDataset, _split_by_node_iterable_dataset DatasetType = TypeVar("DatasetType", Dataset, IterableDataset) def split_dataset_by_node(dataset: DatasetType, rank: int, world_size: int) -...
datasets/src/datasets/distributed.py/0
{ "file_path": "datasets/src/datasets/distributed.py", "repo_id": "datasets", "token_count": 582 }
82
# Copyright 2021 The HuggingFace 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 # # Unless required by applicable law or agreed to...
datasets/src/datasets/formatting/jax_formatter.py/0
{ "file_path": "datasets/src/datasets/formatting/jax_formatter.py", "repo_id": "datasets", "token_count": 2858 }
83
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class TextDatasetReader(AbstractDatasetReader): def __init__( self, path_or_paths: Nest...
datasets/src/datasets/io/text.py/0
{ "file_path": "datasets/src/datasets/io/text.py", "repo_id": "datasets", "token_count": 961 }
84
import bz2 import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from ._filelock import FileLock from .logging import get_logger ...
datasets/src/datasets/utils/extract.py/0
{ "file_path": "datasets/src/datasets/utils/extract.py", "repo_id": "datasets", "token_count": 5809 }
85
import numpy as np def approximate_mode(class_counts, n_draws, rng): """Computes approximate mode of multivariate hypergeometric. This is an approximation to the mode of the multivariate hypergeometric given by class_counts and n_draws. It shouldn't be off by more than one. It is the mostly likely...
datasets/src/datasets/utils/stratify.py/0
{ "file_path": "datasets/src/datasets/utils/stratify.py", "repo_id": "datasets", "token_count": 1674 }
86
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node NUM_SHARDS = 4 NUM_ITEMS_PER_SHARD = 3 class FailedTestError(RuntimeError): pass def gen(shards: List[str]): ...
datasets/tests/distributed_scripts/run_torch_distributed.py/0
{ "file_path": "datasets/tests/distributed_scripts/run_torch_distributed.py", "repo_id": "datasets", "token_count": 617 }
87
import os import time import uuid from contextlib import contextmanager from typing import Optional import pytest import requests from huggingface_hub.hf_api import HfApi, RepositoryNotFoundError from huggingface_hub.utils import hf_raise_for_status CI_HUB_USER = "__DUMMY_TRANSFORMERS_USER__" CI_HUB_USER_FULL_NAME =...
datasets/tests/fixtures/hub.py/0
{ "file_path": "datasets/tests/fixtures/hub.py", "repo_id": "datasets", "token_count": 2900 }
88
import shutil import textwrap import numpy as np import pytest from datasets import ClassLabel, Features, Image, Value from datasets.builder import InvalidConfigName from datasets.data_files import DataFilesDict, DataFilesList, get_data_patterns from datasets.download.streaming_download_manager import StreamingDownlo...
datasets/tests/packaged_modules/test_imagefolder.py/0
{ "file_path": "datasets/tests/packaged_modules/test_imagefolder.py", "repo_id": "datasets", "token_count": 8893 }
89
import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.download.streaming_download_manager import StreamingDownloadManager from datasets.utils.file_utils import hash_url_to_f...
datasets/tests/test_download_manager.py/0
{ "file_path": "datasets/tests/test_download_manager.py", "repo_id": "datasets", "token_count": 2945 }
90
from tempfile import NamedTemporaryFile import huggingface_hub import pytest import requests from packaging import version from datasets.utils.file_utils import fsspec_get, fsspec_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline, require_not_windows @pytest.mark.integration...
datasets/tests/test_offline_util.py/0
{ "file_path": "datasets/tests/test_offline_util.py", "repo_id": "datasets", "token_count": 738 }
91
<jupyter_start><jupyter_text>Bonus Unit 1: Let's train Huggy the Dog 🐶 to fetch a stick In this notebook, we'll reinforce what we learned in the first Unit by **teaching Huggy the Dog to fetch the stick and then play with it directly in your browser**⬇️ Here is an example of what **you will achieve at the end of the u...
deep-rl-class/notebooks/bonus-unit1/bonus-unit1.ipynb/0
{ "file_path": "deep-rl-class/notebooks/bonus-unit1/bonus-unit1.ipynb", "repo_id": "deep-rl-class", "token_count": 2887 }
92
# Congratulations <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/communication/thumbnail.png" alt="Thumbnail"/> **Congratulations on finishing this course!** With perseverance, hard work, and determination, **you've acquired a solid background in Deep Reinforcement...
deep-rl-class/units/en/communication/conclusion.mdx/0
{ "file_path": "deep-rl-class/units/en/communication/conclusion.mdx", "repo_id": "deep-rl-class", "token_count": 364 }
93
# Two main approaches for solving RL problems [[two-methods]] <Tip> Now that we learned the RL framework, how do we solve the RL problem? </Tip> In other words, how do we build an RL agent that can **select the actions that maximize its expected cumulative reward?** ## The Policy π: the agent’s brain [[policy]] The...
deep-rl-class/units/en/unit1/two-methods.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/two-methods.mdx", "repo_id": "deep-rl-class", "token_count": 1565 }
94
# What is RL? A short recap [[what-is-rl]] In RL, we build an agent that can **make smart decisions**. For instance, an agent that **learns to play a video game.** Or a trading agent that **learns to maximize its benefits** by deciding on **what stocks to buy and when to sell.** <img src="https://huggingface.co/datas...
deep-rl-class/units/en/unit2/what-is-rl.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/what-is-rl.mdx", "repo_id": "deep-rl-class", "token_count": 525 }
95
# (Optional) the Policy Gradient Theorem In this optional section where we're **going to study how we differentiate the objective function that we will use to approximate the policy gradient**. Let's first recap our different formulas: 1. The Objective function <img src="https://huggingface.co/datasets/huggingface-...
deep-rl-class/units/en/unit4/pg-theorem.mdx/0
{ "file_path": "deep-rl-class/units/en/unit4/pg-theorem.mdx", "repo_id": "deep-rl-class", "token_count": 1912 }
96
# Advantage Actor Critic (A2C) using Robotics Simulations with Panda-Gym 🤖 [[hands-on]] <CourseFloatingBanner classNames="absolute z-10 right-0 top-0" notebooks={[ {label: "Google Colab", value: "https://colab.research.google.com/github/huggingface/deep-rl-class/blob/main/notebooks/unit6/unit6.ip...
deep-rl-class/units/en/unit6/hands-on.mdx/0
{ "file_path": "deep-rl-class/units/en/unit6/hands-on.mdx", "repo_id": "deep-rl-class", "token_count": 4616 }
97
# Interesting Environments to try Here we provide a list of interesting environments you can try to train your agents on: ## DIAMBRA Arena <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit12/diambraarena.png" alt="diambraArena"/> DIAMBRA Arena is a software pac...
deep-rl-class/units/en/unitbonus3/envs-to-try.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus3/envs-to-try.mdx", "repo_id": "deep-rl-class", "token_count": 1642 }
98
# Train our robot <Tip> In order to start training, we’ll first need to install the <a href="https://imitation.readthedocs.io/en/latest/getting-started/installation.html">imitation</a> library in the same venv / conda env where you installed Godot RL Agents by using: <code>pip install imitation</code> </Tip> ### Down...
deep-rl-class/units/en/unitbonus5/train-our-robot.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus5/train-our-robot.mdx", "repo_id": "deep-rl-class", "token_count": 1251 }
99
import glob import subprocess import sys from typing import List sys.path.append(".") from benchmark_text_to_image import ALL_T2I_CKPTS # noqa: E402 PATTERN = "benchmark_*.py" class SubprocessCallException(Exception): pass # Taken from `test_examples_utils.py` def run_command(command: List[str], return_std...
diffusers/benchmarks/run_all.py/0
{ "file_path": "diffusers/benchmarks/run_all.py", "repo_id": "diffusers", "token_count": 1527 }
100
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/models/autoencoderkl.md/0
{ "file_path": "diffusers/docs/source/en/api/models/autoencoderkl.md", "repo_id": "diffusers", "token_count": 783 }
101
<!--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/dance_diffusion.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/dance_diffusion.md", "repo_id": "diffusers", "token_count": 369 }
102
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/pipelines/stable_cascade.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_cascade.md", "repo_id": "diffusers", "token_count": 2836 }
103
<!--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/xformers.md/0
{ "file_path": "diffusers/docs/source/en/optimization/xformers.md", "repo_id": "diffusers", "token_count": 447 }
104
<!--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 }
105
<!--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/depth2img.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/depth2img.md", "repo_id": "diffusers", "token_count": 878 }
106