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/benchmarks/big_model_inference/big_model_inference.py/0
{ "file_path": "accelerate/benchmarks/big_model_inference/big_model_inference.py", "repo_id": "accelerate", "token_count": 2241 }
0
<!--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...
accelerate/docs/source/basic_tutorials/execution.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/execution.md", "repo_id": "accelerate", "token_count": 1307 }
1
<!--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/torch_wrappers.md/0
{ "file_path": "accelerate/docs/source/package_reference/torch_wrappers.md", "repo_id": "accelerate", "token_count": 381 }
2
<!--Copyright 2022 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/usage_guides/model_size_estimator.md/0
{ "file_path": "accelerate/docs/source/usage_guides/model_size_estimator.md", "repo_id": "accelerate", "token_count": 2030 }
3
# Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/examples/inference/pippy/t5.py/0
{ "file_path": "accelerate/examples/inference/pippy/t5.py", "repo_id": "accelerate", "token_count": 1023 }
4
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/manim_animations/dataloaders/stage_2.py/0
{ "file_path": "accelerate/manim_animations/dataloaders/stage_2.py", "repo_id": "accelerate", "token_count": 3396 }
5
#!/usr/bin/env python # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
accelerate/src/accelerate/commands/config/config.py/0
{ "file_path": "accelerate/src/accelerate/commands/config/config.py", "repo_id": "accelerate", "token_count": 1067 }
6
#!/usr/bin/env python # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
accelerate/src/accelerate/commands/test.py/0
{ "file_path": "accelerate/src/accelerate/commands/test.py", "repo_id": "accelerate", "token_count": 755 }
7
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/test_utils/training.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/training.py", "repo_id": "accelerate", "token_count": 1572 }
8
# 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/other.py/0
{ "file_path": "accelerate/src/accelerate/utils/other.py", "repo_id": "accelerate", "token_count": 4704 }
9
compute_environment: LOCAL_MACHINE debug: false distributed_type: MULTI_CPU downcast_bf16: 'no' ipex_config: ipex: true machine_rank: 0 main_process_ip: 127.0.0.1 main_process_port: 29500 main_training_function: main mixed_precision: 'no' mpirun_config: mpirun_ccl: '1' mpirun_hostfile: /home/user/hostfile num_mac...
accelerate/tests/test_configs/0_28_0_mpi.yaml/0
{ "file_path": "accelerate/tests/test_configs/0_28_0_mpi.yaml", "repo_id": "accelerate", "token_count": 193 }
10
# 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_modeling_utils.py/0
{ "file_path": "accelerate/tests/test_modeling_utils.py", "repo_id": "accelerate", "token_count": 15054 }
11
# Copyright 2022 The HuggingFace Team, the AllenNLP library authors. 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 # ...
accelerate/utils/stale.py/0
{ "file_path": "accelerate/utils/stale.py", "repo_id": "accelerate", "token_count": 1013 }
12
# Language Adaptation through Continued Pretraining This directory shows a base example of how to use continued pretraining and further tuning to adapt a language model to new data (e.g. a new language or domain). Three steps are needed: continued pretraining (`cpt`), supervised finetuning (`sft`), and direct prefere...
alignment-handbook/recipes/gpt2-nl/README.md/0
{ "file_path": "alignment-handbook/recipes/gpt2-nl/README.md", "repo_id": "alignment-handbook", "token_count": 756 }
13
# Instructions to Replicate Zephyr-7b-β As described in the Zephyr [technical report](https://huggingface.co/papers/2310.16944), training this model proceeds in two steps: 1. Apply SFT to fine-tune Mistral 7B on a filtered version of the UltraChat dataset ([link](https://huggingface.co/datasets/HuggingFaceH4/ultrach...
alignment-handbook/recipes/zephyr-7b-beta/README.md/0
{ "file_path": "alignment-handbook/recipes/zephyr-7b-beta/README.md", "repo_id": "alignment-handbook", "token_count": 1150 }
14
# 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/src/alignment/configs.py/0
{ "file_path": "alignment-handbook/src/alignment/configs.py", "repo_id": "alignment-handbook", "token_count": 4470 }
15
# Creating a desktop Tauri app
candle/candle-book/src/apps/desktop.md/0
{ "file_path": "candle/candle-book/src/apps/desktop.md", "repo_id": "candle", "token_count": 8 }
16
#[cfg(test)] pub mod simplified; #[cfg(test)] mod tests { use anyhow::Result; use candle::{DType, Device, Tensor}; use parquet::file::reader::SerializedFileReader; // NOTE: Waiting on https://github.com/rust-lang/mdBook/pull/1856 #[rustfmt::skip] #[tokio::test] async fn book_hub_1() { // A...
candle/candle-book/src/lib.rs/0
{ "file_path": "candle/candle-book/src/lib.rs", "repo_id": "candle", "token_count": 2808 }
17
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle_core::{DType, Device, Tensor}; use criterion::{black_box, criterion_group, Criterion, Throughput}; use std::time::Instant; fn rand_uniform(a: &Tensor) { a.rand_like(-1.0, 123.0).unwrap(); } fn rand_normal(a: &Tensor) { a.randn_like(100.0, 15...
candle/candle-core/benches/benchmarks/random.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/random.rs", "repo_id": "candle", "token_count": 812 }
18
use super::Cpu; #[cfg(target_arch = "arm")] use core::arch::arm::*; #[cfg(target_arch = "aarch64")] use core::arch::aarch64::*; pub struct CurrentCpu {} const STEP: usize = 16; const EPR: usize = 4; const ARR: usize = STEP / EPR; impl CurrentCpu { #[cfg(target_arch = "aarch64")] unsafe fn reduce_one(x: floa...
candle/candle-core/src/cpu/neon.rs/0
{ "file_path": "candle/candle-core/src/cpu/neon.rs", "repo_id": "candle", "token_count": 897 }
19
use crate::{Error, Tensor}; use std::ops::{ Bound, Range, RangeBounds, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive, }; impl Tensor { /// Intended to be use by the trait `.i()` /// /// ``` /// # use candle_core::{Tensor, DType, Device, IndexOp}; /// let a = Tensor::zeros((2, ...
candle/candle-core/src/indexer.rs/0
{ "file_path": "candle/candle-core/src/indexer.rs", "repo_id": "candle", "token_count": 4011 }
20
use super::{GgmlDType, QStorage}; use crate::backend::BackendStorage; use crate::{DType, MetalDevice, MetalStorage, Result, Shape}; use metal::Buffer; use std::sync::Arc; pub struct QMetalStorage { dtype: GgmlDType, device: MetalDevice, buffer: Arc<Buffer>, } impl QMetalStorage { pub fn zeros(device: ...
candle/candle-core/src/quantized/metal.rs/0
{ "file_path": "candle/candle-core/src/quantized/metal.rs", "repo_id": "candle", "token_count": 4704 }
21
// Variables are wrappers around tensors that can be modified, they are typically used for holding // weights and being modified by gradient descent. // We do not expose a public way to create variables as this would break the invariant that the // tensor within a variable is actually with `is_variable` set to `true`. ...
candle/candle-core/src/variable.rs/0
{ "file_path": "candle/candle-core/src/variable.rs", "repo_id": "candle", "token_count": 2150 }
22
#![allow(unused)] use anyhow::{Context, Result}; use std::io::Write; use std::path::PathBuf; struct KernelDirectories { kernel_glob: &'static str, rust_target: &'static str, include_dirs: &'static [&'static str], } const KERNEL_DIRS: [KernelDirectories; 1] = [KernelDirectories { kernel_glob: "examples...
candle/candle-examples/build.rs/0
{ "file_path": "candle/candle-examples/build.rs", "repo_id": "candle", "token_count": 391 }
23
//! EfficientNet implementation. //! //! https://arxiv.org/abs/1905.11946 #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::efficientnet::{EfficientNet,...
candle/candle-examples/examples/efficientnet/main.rs/0
{ "file_path": "candle/candle-examples/examples/efficientnet/main.rs", "repo_id": "candle", "token_count": 1421 }
24
from transformers import AutoModelForCausalLM, AutoTokenizer BASE_MODEL = "google/t5-v1_1-xxl" tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL) # The tokenizer will be saved in /tmp/tokenizer/tokenizer.json tokenizer.save_pretrained("/tmp/tokenizer/")
candle/candle-examples/examples/flux/t5_tokenizer.py/0
{ "file_path": "candle/candle-examples/examples/flux/t5_tokenizer.py", "repo_id": "candle", "token_count": 91 }
25
pub const DEFAULT_IMAGE_TOKEN: &str = "<image>"; pub const DEFAULT_IM_START_TOKEN: &str = "<im_start>"; pub const DEFAULT_IM_END_TOKEN: &str = "<im_end>"; pub const IMAGE_PLACEHOLDER: &str = "<image-placeholder>";
candle/candle-examples/examples/llava/constants.rs/0
{ "file_path": "candle/candle-examples/examples/llava/constants.rs", "repo_id": "candle", "token_count": 86 }
26
## Using ONNX models in Candle This example demonstrates how to run [ONNX](https://github.com/onnx/onnx) based models in Candle. It contains small variants of two models, [SqueezeNet](https://arxiv.org/pdf/1602.07360.pdf) (default) and [EfficientNet](https://arxiv.org/pdf/1905.11946.pdf). You can run the examples wi...
candle/candle-examples/examples/onnx/README.md/0
{ "file_path": "candle/candle-examples/examples/onnx/README.md", "repo_id": "candle", "token_count": 832 }
27
# candle-qwen: large language model series from Alibaba Cloud Qwen 1.5 is a series of large language models that provide strong performances on English and Chinese. - [Blog post](https://qwenlm.github.io/blog/qwen1.5/) introducing Qwen1.5. - [Model card](https://huggingface.co/Qwen/Qwen1.5-0.5B) on the HuggingFace Hu...
candle/candle-examples/examples/qwen/README.md/0
{ "file_path": "candle/candle-examples/examples/qwen/README.md", "repo_id": "candle", "token_count": 327 }
28
# candle-resnet A candle implementation of inference using a pre-trained [ResNet](https://arxiv.org/abs/1512.03385). This uses a classification head trained on the ImageNet dataset and returns the probabilities for the top-5 classes. ## Running an example ``` $ cargo run --example resnet --release -- --image tiger.j...
candle/candle-examples/examples/resnet/README.md/0
{ "file_path": "candle/candle-examples/examples/resnet/README.md", "repo_id": "candle", "token_count": 204 }
29
#[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use anyhow::{Error as E, Result}; use candle::{Device, IndexOp, Tensor}; use candle_nn::{ops::softmax, VarBuilder}; use clap::{Parser, ValueEnum}; use hf_hub::{api::sync::Api, Repo, RepoType}; use rand::{di...
candle/candle-examples/examples/whisper-microphone/main.rs/0
{ "file_path": "candle/candle-examples/examples/whisper-microphone/main.rs", "repo_id": "candle", "token_count": 12127 }
30
[net] # Testing batch=1 subdivisions=1 # Training # batch=64 # subdivisions=16 width= 416 height = 416 channels=3 momentum=0.9 decay=0.0005 angle=0 saturation = 1.5 exposure = 1.5 hue=.1 learning_rate=0.001 burn_in=1000 max_batches = 500200 policy=steps steps=400000,450000 scales=.1,.1 [convolutional] batch_normaliz...
candle/candle-examples/examples/yolo-v3/yolo-v3.cfg/0
{ "file_path": "candle/candle-examples/examples/yolo-v3/yolo-v3.cfg", "repo_id": "candle", "token_count": 3586 }
31
[package] name = "candle-flash-attn" version = "0.6.1" edition = "2021" description = "Flash attention layer for the candle ML framework." repository = "https://github.com/huggingface/candle" keywords = ["blas", "tensor", "machine-learning"] categories = ["science"] license = "MIT OR Apache-2.0" readme = "README.md" ...
candle/candle-flash-attn/Cargo.toml/0
{ "file_path": "candle/candle-flash-attn/Cargo.toml", "repo_id": "candle", "token_count": 266 }
32
// 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 }
33
#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 }
34
#include <metal_stdlib> using namespace metal; METAL_FUNC uint get_strided_index( uint idx, constant size_t &num_dims, constant size_t *dims, constant size_t *strides ) { uint strided_i = 0; for (uint d = 0; d < num_dims; d++) { uint dim_idx = num_dims - 1 - d; strided_i += (idx...
candle/candle-metal-kernels/src/indexing.metal/0
{ "file_path": "candle/candle-metal-kernels/src/indexing.metal", "repo_id": "candle", "token_count": 4001 }
35
# candle-nn
candle/candle-nn/README.md/0
{ "file_path": "candle/candle-nn/README.md", "repo_id": "candle", "token_count": 5 }
36
//! Layer Normalization. //! //! This layer applies Layer Normalization over a mini-batch of inputs as described in [`Layer //! Normalization`]. The input is expected to have three dimensions: a batch dimension, a length, //! and a hidden size, the normalization is applied over the last dimension. //! //! # Example //!...
candle/candle-nn/src/layer_norm.rs/0
{ "file_path": "candle/candle-nn/src/layer_norm.rs", "repo_id": "candle", "token_count": 2546 }
37
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{test_device, test_utils::to_vec3_round, Device, Result, Tensor}; fn softmax(device: &Device) -> Result<()> { let data = &[[[3f32, 1., 4.], [1., 5., 9.]], [[2., 1., 7.], [8., 2., 8.]]]; ...
candle/candle-nn/tests/ops.rs/0
{ "file_path": "candle/candle-nn/tests/ops.rs", "repo_id": "candle", "token_count": 4321 }
38
from candle.utils import load_safetensors, save_gguf, load_gguf from candle.models.bert import BertModel, Config import json from candle import Tensor from tqdm import tqdm from dataclasses import fields import os import time from huggingface_hub import hf_hub_download from transformers import BertTokenizer, AutoModel...
candle/candle-pyo3/e5.py/0
{ "file_path": "candle/candle-pyo3/e5.py", "repo_id": "candle", "token_count": 1778 }
39
import candle from candle import Tensor _UNSIGNED_DTYPES = set([str(candle.u8), str(candle.u32)]) def _assert_tensor_metadata( actual: Tensor, expected: Tensor, check_device: bool = True, check_dtype: bool = True, check_layout: bool = True, check_stride: bool = False, ): if check_device:...
candle/candle-pyo3/py_src/candle/testing/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/testing/__init__.py", "repo_id": "candle", "token_count": 854 }
40
import candle from candle import Tensor from candle.testing import assert_equal, assert_almost_equal import pytest @pytest.mark.parametrize("dtype", [candle.f32, candle.f64, candle.f16, candle.u32, candle.u8, candle.i64]) def test_assert_equal_asserts_correctly(dtype: candle.DType): a = Tensor([1, 2, 3]).to(dtype...
candle/candle-pyo3/tests/bindings/test_testing.py/0
{ "file_path": "candle/candle-pyo3/tests/bindings/test_testing.py", "repo_id": "candle", "token_count": 476 }
41
//! Contrastive Language-Image Pre-Training //! //! Contrastive Language-Image Pre-Training (CLIP) is an architecture trained on //! pairs of images with related texts. //! //! https://github.com/openai/CLIP //! https://github.com/huggingface/transformers/tree/f6fa0f0bf0796ac66f201f23bdb8585de1609add/src/transformers/m...
candle/candle-transformers/src/models/clip/text_model.rs/0
{ "file_path": "candle/candle-transformers/src/models/clip/text_model.rs", "repo_id": "candle", "token_count": 5657 }
42
use candle::{Result, Tensor, D}; use candle_nn::{conv2d, group_norm, Conv2d, GroupNorm, VarBuilder}; // https://github.com/black-forest-labs/flux/blob/727e3a71faf37390f318cf9434f0939653302b60/src/flux/modules/autoencoder.py#L9 #[derive(Debug, Clone)] pub struct Config { pub resolution: usize, pub in_channels: ...
candle/candle-transformers/src/models/flux/autoencoder.rs/0
{ "file_path": "candle/candle-transformers/src/models/flux/autoencoder.rs", "repo_id": "candle", "token_count": 7145 }
43
use super::with_tracing::{linear, Embedding, Linear}; use candle::{Result, Tensor}; use candle_nn::{layer_norm, LayerNorm, VarBuilder}; #[derive(Debug, Clone)] pub struct Config { pub vocab_size: usize, pub decoder_vocab_size: Option<usize>, pub max_position_embeddings: usize, pub encoder_layers: usize...
candle/candle-transformers/src/models/marian.rs/0
{ "file_path": "candle/candle-transformers/src/models/marian.rs", "repo_id": "candle", "token_count": 8917 }
44
use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{linear_b, linear_no_bias, Activation, LayerNorm, Linear, VarBuilder}; use std::sync::Arc; #[derive(Debug, Clone, serde::Deserialize)] pub struct Config { pub vocab_size: usize, pub hidden_size: usize, pub intermediate_size: usize, ...
candle/candle-transformers/src/models/olmo.rs/0
{ "file_path": "candle/candle-transformers/src/models/olmo.rs", "repo_id": "candle", "token_count": 6017 }
45
use std::collections::HashMap; use candle::quantized::gguf_file; use candle::quantized::QTensor; use candle::{DType, Device, IndexOp, Module, Result, Tensor, D}; use candle_nn::{Embedding, LayerNorm}; pub const MAX_SEQ_LEN: usize = 4096; #[derive(Debug, Clone)] struct QLinear { inner: candle::quantized::QMatMul,...
candle/candle-transformers/src/models/quantized_phi.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_phi.rs", "repo_id": "candle", "token_count": 5361 }
46
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 }
47
//! 2D UNet Denoising Models //! //! The 2D Unet models take as input a noisy sample and the current diffusion //! timestep and return a denoised version of the input. use super::embeddings::{TimestepEmbedding, Timesteps}; use super::unet_2d_blocks::*; use crate::models::with_tracing::{conv2d, Conv2d}; use candle::{Res...
candle/candle-transformers/src/models/stable_diffusion/unet_2d.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/unet_2d.rs", "repo_id": "candle", "token_count": 8419 }
48
use candle::{DType, Module, Result, Tensor, D}; use candle_nn::VarBuilder; // https://github.com/huggingface/diffusers/blob/19edca82f1ff194c07317369a92b470dbae97f34/src/diffusers/pipelines/wuerstchen/modeling_wuerstchen_common.py#L22 #[derive(Debug)] pub struct WLayerNorm { eps: f64, } impl WLayerNorm { pub f...
candle/candle-transformers/src/models/wuerstchen/common.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/common.rs", "repo_id": "candle", "token_count": 3219 }
49
## Running [llama2.c](https://github.com/karpathy/llama2.c) Examples Here, we provide two examples of how to run [llama2.c](https://github.com/karpathy/llama2.c) written in Rust 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://trun...
candle/candle-wasm-examples/llama2-c/README.md/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/README.md", "repo_id": "candle", "token_count": 449 }
50
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Moondream Rust/WASM</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link ...
candle/candle-wasm-examples/moondream/index.html/0
{ "file_path": "candle/candle-wasm-examples/moondream/index.html", "repo_id": "candle", "token_count": 6120 }
51
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_wasm_example_sam as sam; use wasm_bindgen::prelude::*; struct Embeddings { original_width: u32, original_height: u32, width: u32, height: u32, data: Tensor, } #[wasm_bindgen] pub struct Model { sam: sam::Sam, embedd...
candle/candle-wasm-examples/segment-anything/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/segment-anything/src/bin/m.rs", "repo_id": "candle", "token_count": 2399 }
52
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Whisper Rust/WASM</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> ...
candle/candle-wasm-examples/whisper/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/whisper/lib-example.html", "repo_id": "candle", "token_count": 6488 }
53
use crate::console_log; use crate::worker::{ModelData, RunData, Worker, WorkerInput, WorkerOutput}; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; use yew::{html, Component, Context, Html}; use yew_agent::{Bridge, Bridged}; async fn fetch_url(url: &str) -> Result<Vec<u8>, JsValue> { use web_sys:...
candle/candle-wasm-examples/yolo/src/app.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/app.rs", "repo_id": "candle", "token_count": 5961 }
54
 backend-test:J  xytest"Relu SingleReluZ x   b y   B
candle/test.onnx/0
{ "file_path": "candle/test.onnx", "repo_id": "candle", "token_count": 76 }
55
.DS_Store node_modules /build /.svelte-kit /package /chart .env .env.* !.env.example # Ignore files for PNPM, NPM and YARN pnpm-lock.yaml package-lock.json yarn.lock
chat-ui/.prettierignore/0
{ "file_path": "chat-ui/.prettierignore", "repo_id": "chat-ui", "token_count": 72 }
56
{{- if and .Values.serviceAccount.enabled .Values.serviceAccount.create }} apiVersion: v1 kind: ServiceAccount automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} metadata: name: "{{ .Values.serviceAccount.name | default (include "name" .) }}" namespace: {{ .Release.Namespace }} ...
chat-ui/chart/templates/service-account.yaml/0
{ "file_path": "chat-ui/chart/templates/service-account.yaml", "repo_id": "chat-ui", "token_count": 154 }
57
# Llama.cpp | Feature | Available | | --------------------------- | --------- | | [Tools](../tools) | No | | [Multimodal](../multimodal) | No | Chat UI supports the llama.cpp API server directly without the need for an adapter. You can do this using the `llamacpp` endpoint ...
chat-ui/docs/source/configuration/models/providers/llamacpp.md/0
{ "file_path": "chat-ui/docs/source/configuration/models/providers/llamacpp.md", "repo_id": "chat-ui", "token_count": 1023 }
58
ENV_LOCAL_PATH=/app/.env.local if test -z "${DOTENV_LOCAL}" ; then if ! test -f "${ENV_LOCAL_PATH}" ; then echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. Make sure to set environment variables properly. " fi; else echo "DOTENV_LOCAL was found in...
chat-ui/entrypoint.sh/0
{ "file_path": "chat-ui/entrypoint.sh", "repo_id": "chat-ui", "token_count": 266 }
59
<script lang="ts"> import { base } from "$app/paths"; import type { ToolLogoColor, ToolLogoIcon } from "$lib/types/Tool"; import { debounce } from "$lib/utils/debounce"; import { onMount } from "svelte"; import ToolLogo from "./ToolLogo.svelte"; import CarbonClose from "~icons/carbon/close"; interface ToolSugg...
chat-ui/src/lib/components/AssistantToolPicker.svelte/0
{ "file_path": "chat-ui/src/lib/components/AssistantToolPicker.svelte", "repo_id": "chat-ui", "token_count": 1468 }
60
<script lang="ts"> import { onMount, onDestroy } from "svelte"; let el: HTMLElement; onMount(() => { el.ownerDocument.body.appendChild(el); }); onDestroy(() => { if (el?.parentNode) { el.parentNode.removeChild(el); } }); </script> <div bind:this={el} class="contents" hidden> <slot /> </div>
chat-ui/src/lib/components/Portal.svelte/0
{ "file_path": "chat-ui/src/lib/components/Portal.svelte", "repo_id": "chat-ui", "token_count": 130 }
61
<script lang="ts"> import { env as envPublic } from "$env/dynamic/public"; import Logo from "$lib/components/icons/Logo.svelte"; import { createEventDispatcher } from "svelte"; import IconGear from "~icons/bi/gear-fill"; import AnnouncementBanner from "../AnnouncementBanner.svelte"; import type { Model } from "$l...
chat-ui/src/lib/components/chat/ChatIntroduction.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/ChatIntroduction.svelte", "repo_id": "chat-ui", "token_count": 1495 }
62
export const PUBLIC_SEP_TOKEN = "</s>";
chat-ui/src/lib/constants/publicSepToken.ts/0
{ "file_path": "chat-ui/src/lib/constants/publicSepToken.ts", "repo_id": "chat-ui", "token_count": 16 }
63
import { env } from "$env/dynamic/private"; import { GridFSBucket, MongoClient } from "mongodb"; import type { Conversation } from "$lib/types/Conversation"; import type { SharedConversation } from "$lib/types/SharedConversation"; import type { AbortedGeneration } from "$lib/types/AbortedGeneration"; import type { Sett...
chat-ui/src/lib/server/database.ts/0
{ "file_path": "chat-ui/src/lib/server/database.ts", "repo_id": "chat-ui", "token_count": 2989 }
64
import { VertexAI, HarmCategory, HarmBlockThreshold, type Content, type TextPart, } from "@google-cloud/vertexai"; import type { Endpoint } from "../endpoints"; import { z } from "zod"; import type { Message } from "$lib/types/Message"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; exp...
chat-ui/src/lib/server/endpoints/google/endpointVertex.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/google/endpointVertex.ts", "repo_id": "chat-ui", "token_count": 1581 }
65
import pino from "pino"; import { dev } from "$app/environment"; import { env } from "$env/dynamic/private"; let options: pino.LoggerOptions = {}; if (dev) { options = { transport: { target: "pino-pretty", options: { colorize: true, }, }, }; } export const logger = pino({ ...options, level: env.LO...
chat-ui/src/lib/server/logger.ts/0
{ "file_path": "chat-ui/src/lib/server/logger.ts", "repo_id": "chat-ui", "token_count": 135 }
66
import { stringifyMarkdownElementTree } from "$lib/server/websearch/markdown/utils/stringify"; import { scrapeUrl } from "$lib/server/websearch/scrape/scrape"; import type { ConfigTool } from "$lib/types/Tool"; import { ObjectId } from "mongodb"; const fetchUrl: ConfigTool = { _id: new ObjectId("000000000000000000000...
chat-ui/src/lib/server/tools/web/url.ts/0
{ "file_path": "chat-ui/src/lib/server/tools/web/url.ts", "repo_id": "chat-ui", "token_count": 357 }
67
import { WebSearchProvider, type WebSearchSource } from "$lib/types/WebSearch"; import { env } from "$env/dynamic/private"; import searchSerper from "./endpoints/serper"; import searchSerpApi from "./endpoints/serpApi"; import searchSerpStack from "./endpoints/serpStack"; import searchYouApi from "./endpoints/youApi"; ...
chat-ui/src/lib/server/websearch/search/endpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/search/endpoints.ts", "repo_id": "chat-ui", "token_count": 543 }
68
import { writable } from "svelte/store"; export const pendingMessage = writable< | { content: string; files: File[]; } | undefined >();
chat-ui/src/lib/stores/pendingMessage.ts/0
{ "file_path": "chat-ui/src/lib/stores/pendingMessage.ts", "repo_id": "chat-ui", "token_count": 56 }
69
import type { ObjectId } from "mongodb"; import type { User } from "./User"; import type { Assistant } from "./Assistant"; import type { Timestamps } from "./Timestamps"; export interface Report extends Timestamps { _id: ObjectId; createdBy: User["_id"] | string; object: "assistant" | "tool"; contentId: Assistant[...
chat-ui/src/lib/types/Report.ts/0
{ "file_path": "chat-ui/src/lib/types/Report.ts", "repo_id": "chat-ui", "token_count": 112 }
70
const file2base64 = (file: File): Promise<string> => { return new Promise<string>((resolve, reject) => { const reader = new FileReader(); reader.readAsDataURL(file); reader.onload = () => { const dataUrl = reader.result as string; const base64 = dataUrl.split(",")[1]; resolve(base64); }; reader.oner...
chat-ui/src/lib/utils/file2base64.ts/0
{ "file_path": "chat-ui/src/lib/utils/file2base64.ts", "repo_id": "chat-ui", "token_count": 142 }
71
export async function sha256(input: string): Promise<string> { const utf8 = new TextEncoder().encode(input); const hashBuffer = await crypto.subtle.digest("SHA-256", utf8); const hashArray = Array.from(new Uint8Array(hashBuffer)); const hashHex = hashArray.map((bytes) => bytes.toString(16).padStart(2, "0")).join(""...
chat-ui/src/lib/utils/sha256.ts/0
{ "file_path": "chat-ui/src/lib/utils/sha256.ts", "repo_id": "chat-ui", "token_count": 119 }
72
import type { Message } from "$lib/types/Message"; export function isMessageId(id: string): id is Message["id"] { return id.split("-").length === 5; }
chat-ui/src/lib/utils/tree/isMessageId.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/isMessageId.ts", "repo_id": "chat-ui", "token_count": 48 }
73
export async function GET({ locals }) { if (locals.user) { const res = { id: locals.user._id, username: locals.user.username, name: locals.user.name, email: locals.user.email, avatarUrl: locals.user.avatarUrl, hfUserId: locals.user.hfUserId, }; return Response.json(res); } return Response.js...
chat-ui/src/routes/api/user/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/user/+server.ts", "repo_id": "chat-ui", "token_count": 148 }
74
import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { error } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; /** * Ideally, we'd be able to detect the client-side abort, see https://github.com/huggingface/chat-ui/pull/88#issuecomment-1523173850 */ e...
chat-ui/src/routes/conversation/[id]/stop-generating/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/stop-generating/+server.ts", "repo_id": "chat-ui", "token_count": 260 }
75
<script lang="ts"> import Modal from "$lib/components/Modal.svelte"; import CarbonClose from "~icons/carbon/close"; import CarbonTrashCan from "~icons/carbon/trash-can"; import CarbonArrowUpRight from "~icons/carbon/arrow-up-right"; import { enhance } from "$app/forms"; import { base } from "$app/paths"; impor...
chat-ui/src/routes/settings/(nav)/+page.svelte/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/+page.svelte", "repo_id": "chat-ui", "token_count": 1448 }
76
// check if user is earlyAccess else redirect to base import { base } from "$app/paths"; import { redirect } from "@sveltejs/kit"; // XXX: feature_flag_tools export async function load({ parent }) { const { user } = await parent(); if (user?.isEarlyAccess) { return {}; } redirect(302, `${base}/`); }
chat-ui/src/routes/tools/+layout.ts/0
{ "file_path": "chat-ui/src/routes/tools/+layout.ts", "repo_id": "chat-ui", "token_count": 105 }
77
import json import os import tempfile import datasets from datasets.arrow_writer import ArrowWriter from datasets.features import Array2D from utils import generate_examples, get_duration SHAPE_TEST_1 = (30, 487) SHAPE_TEST_2 = (36, 1024) SPEED_TEST_SHAPE = (100, 100) SPEED_TEST_N_EXAMPLES = 100 DEFAULT_FEATURES = ...
datasets/benchmarks/benchmark_array_xd.py/0
{ "file_path": "datasets/benchmarks/benchmark_array_xd.py", "repo_id": "datasets", "token_count": 2176 }
78
- sections: - local: index title: 🤗 Datasets - local: quickstart title: Quickstart - local: installation title: Installation title: Get started - sections: - local: tutorial title: Overview - local: load_hub title: Load a dataset from the Hub - local: access title: Know your data...
datasets/docs/source/_toctree.yml/0
{ "file_path": "datasets/docs/source/_toctree.yml", "repo_id": "datasets", "token_count": 1168 }
79
# Depth estimation Depth estimation datasets are used to train a model to approximate the relative distance of every pixel in an image from the camera, also known as depth. The applications enabled by these datasets primarily lie in areas like visual machine perception and perception in robotics. Example applications ...
datasets/docs/source/depth_estimation.mdx/0
{ "file_path": "datasets/docs/source/depth_estimation.mdx", "repo_id": "datasets", "token_count": 2848 }
80
# Object detection Object detection models identify something in an image, and object detection datasets are used for applications such as autonomous driving and detecting natural hazards like wildfire. This guide will show you how to apply transformations to an object detection dataset following the [tutorial](https:...
datasets/docs/source/object_detection.mdx/0
{ "file_path": "datasets/docs/source/object_detection.mdx", "repo_id": "datasets", "token_count": 2299 }
81
# Preprocess In addition to loading datasets, 🤗 Datasets other main goal is to offer a diverse set of preprocessing functions to get a dataset into an appropriate format for training with your machine learning framework. There are many possible ways to preprocess a dataset, and it all depends on your specific datas...
datasets/docs/source/use_dataset.mdx/0
{ "file_path": "datasets/docs/source/use_dataset.mdx", "repo_id": "datasets", "token_count": 3367 }
82
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger HIGHLIGHT_MESSAGE_PRE = """<<<<<<< This should probably be modified because it mentions: """ HIGHLIGHT_MESSAGE_POST = """======= >>>>>>>...
datasets/src/datasets/commands/convert.py/0
{ "file_path": "datasets/src/datasets/commands/convert.py", "repo_id": "datasets", "token_count": 3811 }
83
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.download_config import DownloadConfig from ..table import array_cast from ..utils.file_utils im...
datasets/src/datasets/features/audio.py/0
{ "file_path": "datasets/src/datasets/features/audio.py", "repo_id": "datasets", "token_count": 5332 }
84
# Copyright 2020 The HuggingFace 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 # # Unless required by applicable law or ...
datasets/src/datasets/inspect.py/0
{ "file_path": "datasets/src/datasets/inspect.py", "repo_id": "datasets", "token_count": 6338 }
85
import itertools from dataclasses import dataclass from typing import Optional import pyarrow as pa import datasets from datasets.table import table_cast logger = datasets.utils.logging.get_logger(__name__) @dataclass class ArrowConfig(datasets.BuilderConfig): """BuilderConfig for Arrow.""" features: Opt...
datasets/src/datasets/packaged_modules/arrow/arrow.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/arrow/arrow.py", "repo_id": "datasets", "token_count": 1633 }
86
import itertools import warnings from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class PandasConfig(datasets.BuilderConfig): """BuilderConfig for Pandas.""" features: Optional[datasets.Fe...
datasets/src/datasets/packaged_modules/pandas/pandas.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/pandas/pandas.py", "repo_id": "datasets", "token_count": 1040 }
87
import importlib import inspect from functools import wraps from typing import TYPE_CHECKING, Optional from .download.download_config import DownloadConfig from .utils.file_utils import ( xbasename, xdirname, xet_parse, xexists, xgetsize, xglob, xgzip_open, xisdir, xisfile, xjoi...
datasets/src/datasets/streaming.py/0
{ "file_path": "datasets/src/datasets/streaming.py", "repo_id": "datasets", "token_count": 2362 }
88
from importlib import import_module from .logging import get_logger logger = get_logger(__name__) class _PatchedModuleObj: """Set all the modules components as attributes of the _PatchedModuleObj object.""" def __init__(self, module, attrs=None): attrs = attrs or [] if module is not None: ...
datasets/src/datasets/utils/patching.py/0
{ "file_path": "datasets/src/datasets/utils/patching.py", "repo_id": "datasets", "token_count": 2222 }
89
--- TODO: "Add YAML tags here. Delete these instructions and copy-paste the YAML tags obtained with the online tagging app: https://huggingface.co/spaces/huggingface/datasets-tagging" YAML tags: "Find the full spec here: https://github.com/huggingface/hub-docs/blob/main/datasetcard.md?plain=1" --- # Dataset Card Creat...
datasets/templates/README_guide.md/0
{ "file_path": "datasets/templates/README_guide.md", "repo_id": "datasets", "token_count": 3276 }
90
import fsspec import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, IterableDatasetDict, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.info import DatasetInfo from datasets.io.parquet import ParquetDatasetReader, ParquetData...
datasets/tests/io/test_parquet.py/0
{ "file_path": "datasets/tests/io/test_parquet.py", "repo_id": "datasets", "token_count": 3777 }
91
import json import tarfile import numpy as np import pytest from datasets import Audio, DownloadManager, Features, Image, Sequence, Value from datasets.packaged_modules.webdataset.webdataset import WebDataset from ..utils import require_librosa, require_numpy1_on_windows, require_pil, require_sndfile, require_torch ...
datasets/tests/packaged_modules/test_webdataset.py/0
{ "file_path": "datasets/tests/packaged_modules/test_webdataset.py", "repo_id": "datasets", "token_count": 4039 }
92
import json import os import pickle import subprocess from functools import partial from pathlib import Path from tempfile import gettempdir from textwrap import dedent from types import FunctionType from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from multiprocess import...
datasets/tests/test_fingerprint.py/0
{ "file_path": "datasets/tests/test_fingerprint.py", "repo_id": "datasets", "token_count": 6756 }
93
import json import os import pytest from datasets.download.streaming_download_manager import ( StreamingDownloadManager, xbasename, xglob, xjoin, xopen, ) from datasets.filesystems import COMPRESSION_FILESYSTEMS from .utils import require_lz4, require_zstandard, slow TEST_GG_DRIVE_FILENAME = "t...
datasets/tests/test_streaming_download_manager.py/0
{ "file_path": "datasets/tests/test_streaming_download_manager.py", "repo_id": "datasets", "token_count": 3201 }
94
# The “Deep” in Reinforcement Learning [[deep-rl]] <Tip> What we've talked about so far is Reinforcement Learning. But where does the "Deep" come into play? </Tip> Deep Reinforcement Learning introduces **deep neural networks to solve Reinforcement Learning problems** — hence the name “deep”. For instance, in the ne...
deep-rl-class/units/en/unit1/deep-rl.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/deep-rl.mdx", "repo_id": "deep-rl-class", "token_count": 310 }
95
# Introduction to Q-Learning [[introduction-q-learning]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit3/thumbnail.jpg" alt="Unit 2 thumbnail" width="100%"> In the first unit of this class, we learned about Reinforcement Learning (RL), the RL process, and the ...
deep-rl-class/units/en/unit2/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 466 }
96
# Hands-on [[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/unit3/unit3.ipynb"} ]} askForHelpUrl="http://hf.co/join/discor...
deep-rl-class/units/en/unit3/hands-on.mdx/0
{ "file_path": "deep-rl-class/units/en/unit3/hands-on.mdx", "repo_id": "deep-rl-class", "token_count": 5027 }
97
# 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/unit5/unit5.ipynb"} ]} askForHelpUrl="http://hf.co/join/discord" /> We learned what ML-Agents is and how ...
deep-rl-class/units/en/unit5/hands-on.mdx/0
{ "file_path": "deep-rl-class/units/en/unit5/hands-on.mdx", "repo_id": "deep-rl-class", "token_count": 5172 }
98
# An introduction to Multi-Agents Reinforcement Learning (MARL) ## From single agent to multiple agents In the first unit, we learned to train agents in a single-agent system. When our agent was alone in its environment: **it was not cooperating or collaborating with other agents**. <figure> <img src="https://huggin...
deep-rl-class/units/en/unit7/introduction-to-marl.mdx/0
{ "file_path": "deep-rl-class/units/en/unit7/introduction-to-marl.mdx", "repo_id": "deep-rl-class", "token_count": 982 }
99