text
stringlengths
7
328k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
471
# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build SOURCEDIR = source BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" ...
accelerate/docs/Makefile/0
{ "file_path": "accelerate/docs/Makefile", "repo_id": "accelerate", "token_count": 237 }
0
<!--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/concept_guides/performance.md/0
{ "file_path": "accelerate/docs/source/concept_guides/performance.md", "repo_id": "accelerate", "token_count": 1463 }
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/mps.md/0
{ "file_path": "accelerate/docs/source/usage_guides/mps.md", "repo_id": "accelerate", "token_count": 861 }
3
# 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/big_modeling.py/0
{ "file_path": "accelerate/src/accelerate/big_modeling.py", "repo_id": "accelerate", "token_count": 11237 }
4
# Copyright 2022 The HuggingFace Team and Brian Chao. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requir...
accelerate/src/accelerate/commands/menu/cursor.py/0
{ "file_path": "accelerate/src/accelerate/commands/menu/cursor.py", "repo_id": "accelerate", "token_count": 763 }
5
# 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/scheduler.py/0
{ "file_path": "accelerate/src/accelerate/scheduler.py", "repo_id": "accelerate", "token_count": 1577 }
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/test_utils/scripts/test_script.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/test_script.py", "repo_id": "accelerate", "token_count": 12971 }
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/src/accelerate/utils/modeling.py/0
{ "file_path": "accelerate/src/accelerate/utils/modeling.py", "repo_id": "accelerate", "token_count": 34738 }
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/tests/test_cli.py/0
{ "file_path": "accelerate/tests/test_cli.py", "repo_id": "accelerate", "token_count": 9040 }
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_multigpu.py/0
{ "file_path": "accelerate/tests/test_multigpu.py", "repo_id": "accelerate", "token_count": 2091 }
10
#!/bin/bash #SBATCH --ntasks-per-node=1 #SBATCH --exclusive #SBATCH --gres=gpu:8 #SBATCH --partition=hopper-prod # Adjust this for your cluster #SBATCH --output=/fsx/h4/logs/%x-%j.out # Adjust this for your cluster #SBATCH --err=/fsx/h4/logs/%x-%j.err # Adjust this for your cluster set -x -e source ~/.bashrc cond...
alignment-handbook/recipes/launch.slurm/0
{ "file_path": "alignment-handbook/recipes/launch.slurm", "repo_id": "alignment-handbook", "token_count": 1135 }
11
# Scripts to Train and Evaluate Chat Models ## Fine-tuning In the handbook, we provide three main ways to align LLMs for chat: - Full fine-tuning on a multi-GPU machine with DeepSpeed ZeRO-3 (tested on an 8 x A100 (80GB) node). - LoRA or QLoRA fine-tuning on a single consumer 24GB GPU (tested on an RTX 4090). - LoR...
alignment-handbook/scripts/README.md/0
{ "file_path": "alignment-handbook/scripts/README.md", "repo_id": "alignment-handbook", "token_count": 2967 }
12
# 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": 4290 }
13
[package] name = "candle-book" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true readme = "README.md" [dependencies] accelerate-src = { workspace = true, optional = true } candle = { ...
candle/candle-book/Cargo.toml/0
{ "file_path": "candle/candle-book/Cargo.toml", "repo_id": "candle", "token_count": 467 }
14
# Installation **With Cuda support**: 1. First, make sure that Cuda is correctly installed. - `nvcc --version` should print information about your Cuda compiler driver. - `nvidia-smi --query-gpu=compute_cap --format=csv` should print your GPUs compute capability, e.g. something like: ```bash compute_cap 8.9 ``` You...
candle/candle-book/src/guide/installation.md/0
{ "file_path": "candle/candle-book/src/guide/installation.md", "repo_id": "candle", "token_count": 487 }
15
mod benchmarks; use criterion::criterion_main; criterion_main!( benchmarks::affine::benches, benchmarks::matmul::benches, benchmarks::random::benches, benchmarks::where_cond::benches, benchmarks::conv_transpose2d::benches, );
candle/candle-core/benches/bench_main.rs/0
{ "file_path": "candle/candle-core/benches/bench_main.rs", "repo_id": "candle", "token_count": 88 }
16
#![allow(clippy::excessive_precision)] // Code taken from https://github.com/statrs-dev/statrs //! Provides the [error](https://en.wikipedia.org/wiki/Error_function) and //! related functions mod evaluate { //! Provides functions that don't have a numerical solution and must //! be solved computationally (e.g....
candle/candle-core/src/cpu/erf.rs/0
{ "file_path": "candle/candle-core/src/cpu/erf.rs", "repo_id": "candle", "token_count": 11974 }
17
#![allow(dead_code)] use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT}; use crate::{CpuStorage, DType, Error, Layout, Result, Shape}; #[derive(Debug, Clone)] pub struct CudaDevice; #[derive(Debug)] pub struct CudaStorage; macro_rules! fail { () => { unimplemented!("cuda support has not been enabled, ...
candle/candle-core/src/dummy_cuda_backend.rs/0
{ "file_path": "candle/candle-core/src/dummy_cuda_backend.rs", "repo_id": "candle", "token_count": 2897 }
18
//! Support for the GGML file format. use super::{k_quants, GgmlDType, QStorage}; use crate::{Device, Result}; use byteorder::{LittleEndian, ReadBytesExt}; use std::collections::HashMap; // https://github.com/ggerganov/llama.cpp/blob/468ea24fb4633a0d681f7ac84089566c1c6190cb/llama.h#L37 #[derive(Debug, Clone, Copy, Pa...
candle/candle-core/src/quantized/ggml_file.rs/0
{ "file_path": "candle/candle-core/src/quantized/ggml_file.rs", "repo_id": "candle", "token_count": 4586 }
19
use std::str::FromStr; pub fn get_num_threads() -> usize { // Respond to the same environment variable as rayon. match std::env::var("RAYON_NUM_THREADS") .ok() .and_then(|s| usize::from_str(&s).ok()) { Some(x) if x > 0 => x, Some(_) | None => num_cpus::get(), } } pub fn...
candle/candle-core/src/utils.rs/0
{ "file_path": "candle/candle-core/src/utils.rs", "repo_id": "candle", "token_count": 389 }
20
use candle_core::{test_device, test_utils, DType, Device, IndexOp, Result, Tensor, D}; fn zeros(device: &Device) -> Result<()> { let tensor = Tensor::zeros((5, 2), DType::F32, device)?; let (dim1, dim2) = tensor.dims2()?; assert_eq!(dim1, 5); assert_eq!(dim2, 2); Ok(()) } fn ones(device: &Device) ...
candle/candle-core/tests/tensor_tests.rs/0
{ "file_path": "candle/candle-core/tests/tensor_tests.rs", "repo_id": "candle", "token_count": 24240 }
21
# candle-examples
candle/candle-examples/README.md/0
{ "file_path": "candle/candle-examples/README.md", "repo_id": "candle", "token_count": 6 }
22
/* * Adapted from * https://github.com/NVIDIA/FasterTransformer/blob/release/v5.3_tag/src/fastertransformer/kernels/reduce_kernel_utils.cuh * Copyright (c) 2023, The vLLM team. * Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); ...
candle/candle-examples/examples/custom-ops/kernels/reduction_utils.cuh/0
{ "file_path": "candle/candle-examples/examples/custom-ops/kernels/reduction_utils.cuh", "repo_id": "candle", "token_count": 529 }
23
# candle-metavoice MetaVoice-1B is a text-to-speech model trained on 100K hours of speech, more details on the [model card](https://huggingface.co/metavoiceio/metavoice-1B-v0.1). Note that the current candle implementation suffers from some limitations as of 2024-03-02: - The speaker embeddings are hardcoded. - The g...
candle/candle-examples/examples/metavoice/README.md/0
{ "file_path": "candle/candle-examples/examples/metavoice/README.md", "repo_id": "candle", "token_count": 178 }
24
# candle-phi: 1.3b and 2.7b LLM with state of the art performance for <10b models. [Phi-1.5](https://huggingface.co/microsoft/phi-1_5) and [Phi-2](https://huggingface.co/microsoft/phi-2) are language models using only 1.3 and 2.7 billion parameters but with state of the art performance compared to models with up to 10...
candle/candle-examples/examples/phi/README.md/0
{ "file_path": "candle/candle-examples/examples/phi/README.md", "repo_id": "candle", "token_count": 1011 }
25
#![allow(unused)] //! Vectorized version of the gym environment. use candle::{DType, Device, Result, Tensor}; use pyo3::prelude::*; use pyo3::types::PyDict; #[derive(Debug)] pub struct Step { pub obs: Tensor, pub reward: Tensor, pub is_done: Tensor, } pub struct VecGymEnv { env: PyObject, action_s...
candle/candle-examples/examples/reinforcement-learning/vec_gym_env.rs/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/vec_gym_env.rs", "repo_id": "candle", "token_count": 1569 }
26
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, IndexOp, D}; use candle_nn::{ModuleT, VarBuilder}; use candle_transformers::models::vgg::{Models, Vgg}; use clap::{Parser, ValueEnum}; #[derive(Clone, Copy, Debug, ValueEnum)] enum Whic...
candle/candle-examples/examples/vgg/main.rs/0
{ "file_path": "candle/candle-examples/examples/vgg/main.rs", "repo_id": "candle", "token_count": 967 }
27
use candle::{DType, Device, IndexOp, Result, Tensor}; use candle_nn::{batch_norm, conv2d, conv2d_no_bias, Func, Module, VarBuilder}; use std::collections::BTreeMap; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; #[derive(Debug)] struct Block { block_type: String, parameters: BTreeMa...
candle/candle-examples/examples/yolo-v3/darknet.rs/0
{ "file_path": "candle/candle-examples/examples/yolo-v3/darknet.rs", "repo_id": "candle", "token_count": 5403 }
28
use candle::Result; /// This is a wrapper around a tokenizer to ensure that tokens can be returned to the user in a /// streaming way rather than having to wait for the full decoding. pub struct TokenOutputStream { tokenizer: tokenizers::Tokenizer, tokens: Vec<u32>, prev_index: usize, current_index: us...
candle/candle-examples/src/token_output_stream.rs/0
{ "file_path": "candle/candle-examples/src/token_output_stream.rs", "repo_id": "candle", "token_count": 1295 }
29
/****************************************************************************** * Copyright (c) 2023, Tri Dao. ******************************************************************************/ #pragma once #include <assert.h> #include <stdint.h> #include <stdlib.h> #include <cuda_fp16.h> #if defined(__CUDA_ARCH__) ...
candle/candle-flash-attn/kernels/utils.h/0
{ "file_path": "candle/candle-flash-attn/kernels/utils.h", "repo_id": "candle", "token_count": 6965 }
30
pub const AFFINE: &str = include_str!(concat!(env!("OUT_DIR"), "/affine.ptx")); pub const BINARY: &str = include_str!(concat!(env!("OUT_DIR"), "/binary.ptx")); pub const CAST: &str = include_str!(concat!(env!("OUT_DIR"), "/cast.ptx")); pub const CONV: &str = include_str!(concat!(env!("OUT_DIR"), "/conv.ptx")); pub cons...
candle/candle-kernels/src/lib.rs/0
{ "file_path": "candle/candle-kernels/src/lib.rs", "repo_id": "candle", "token_count": 333 }
31
#include <metal_stdlib> using namespace metal; #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) 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 ...
candle/candle-metal-kernels/src/reduce.metal/0
{ "file_path": "candle/candle-metal-kernels/src/reduce.metal", "repo_id": "candle", "token_count": 7961 }
32
/// This example contains some simple benchmarks so that it's easy to run them in perf etc. #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::quantized::GgmlType; use candle::{CpuStorage, Device, Layout, Module, Result, Shape, Tensor, D}; use c...
candle/candle-nn/examples/cpu_benchmarks.rs/0
{ "file_path": "candle/candle-nn/examples/cpu_benchmarks.rs", "repo_id": "candle", "token_count": 5543 }
33
use candle::{CpuStorage, Layout, Result, Shape, Tensor, D}; use rayon::prelude::*; /// Interleaved variant of rotary embeddings. /// The x0 and x1 value are interleaved on the n_embd (= head_dim) dimension. /// The resulting y0 and y1 are also interleaved with: /// y0 = x0*cos - x1*sin /// y1 = x0*sin + x1*cos #[d...
candle/candle-nn/src/rotary_emb.rs/0
{ "file_path": "candle/candle-nn/src/rotary_emb.rs", "repo_id": "candle", "token_count": 15510 }
34
use candle::Result; use prost::Message; pub mod onnx { include!(concat!(env!("OUT_DIR"), "/onnx.rs")); } pub mod eval; pub use eval::{dtype, simple_eval}; pub fn read_file<P: AsRef<std::path::Path>>(p: P) -> Result<onnx::ModelProto> { let buf = std::fs::read(p)?; onnx::ModelProto::decode(buf.as_slice())....
candle/candle-onnx/src/lib.rs/0
{ "file_path": "candle/candle-onnx/src/lib.rs", "repo_id": "candle", "token_count": 154 }
35
from .module import Module from .container import Sequential, ModuleList, ModuleDict from .sparse import Embedding from .normalization import LayerNorm from .linear import Linear
candle/candle-pyo3/py_src/candle/nn/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/nn/__init__.py", "repo_id": "candle", "token_count": 43 }
36
use std::collections::HashMap; use crate::utils::wrap_err; use crate::{PyDType, PyTensor}; use candle_onnx::eval::{dtype, get_tensor, simple_eval}; use candle_onnx::onnx::tensor_proto::DataType; use candle_onnx::onnx::tensor_shape_proto::dimension::Value; use candle_onnx::onnx::type_proto::{Tensor as ONNXTensor, Value...
candle/candle-pyo3/src/onnx.rs/0
{ "file_path": "candle/candle-pyo3/src/onnx.rs", "repo_id": "candle", "token_count": 3268 }
37
pub mod generation; pub mod models; pub mod object_detection; pub mod pipelines; pub mod quantized_nn; pub mod quantized_var_builder; pub mod utils;
candle/candle-transformers/src/lib.rs/0
{ "file_path": "candle/candle-transformers/src/lib.rs", "repo_id": "candle", "token_count": 47 }
38
use candle::{DType, Device, Result, Tensor, D}; use candle_nn::{embedding, linear_b as linear, Embedding, LayerNorm, Linear, Module, VarBuilder}; use serde::Deserialize; const MAX_SEQ_LEN: usize = 5000; fn layer_norm(size: usize, eps: f64, vb: VarBuilder) -> Result<LayerNorm> { let (weight, bias) = match (vb.get(...
candle/candle-transformers/src/models/falcon.rs/0
{ "file_path": "candle/candle-transformers/src/models/falcon.rs", "repo_id": "candle", "token_count": 8599 }
39
use candle::DType; use serde::Deserialize; pub const DTYPE: DType = DType::F32; #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)] #[serde(rename_all = "lowercase")] pub enum PositionEmbeddingType { Absolute, Alibi, } // https://github.com/huggingface/transformers/blob/main/src/transformers/models/per...
candle/candle-transformers/src/models/persimmon.rs/0
{ "file_path": "candle/candle-transformers/src/models/persimmon.rs", "repo_id": "candle", "token_count": 814 }
40
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": 9128 }
41
use super::schedulers::{betas_for_alpha_bar, BetaSchedule, PredictionType}; use candle::{Result, Tensor}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum DDPMVarianceType { FixedSmall, FixedSmallLog, FixedLarge, FixedLargeLog, Learned, } impl Default for DDPMVarianceType { fn default() -> Self...
candle/candle-transformers/src/models/stable_diffusion/ddpm.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/ddpm.rs", "repo_id": "candle", "token_count": 3662 }
42
// Audio processing code, adapted from whisper.cpp // https://github.com/ggerganov/whisper.cpp use candle::utils::get_num_threads; use std::sync::Arc; use std::thread; pub trait Float: num_traits::Float + num_traits::FloatConst + num_traits::NumAssign + Send + Sync { } impl Float for f32 {} impl Float for f64 {}...
candle/candle-transformers/src/models/whisper/audio.rs/0
{ "file_path": "candle/candle-transformers/src/models/whisper/audio.rs", "repo_id": "candle", "token_count": 5282 }
43
use crate::models::with_tracing::QMatMul; use crate::quantized_var_builder::VarBuilder; use candle::quantized::QTensor; use candle::{Module, Result, Tensor}; #[derive(Debug, Clone)] pub struct Embedding { inner: candle_nn::Embedding, span: tracing::Span, } impl Embedding { pub fn new(d1: usize, d2: usize,...
candle/candle-transformers/src/quantized_nn.rs/0
{ "file_path": "candle/candle-transformers/src/quantized_nn.rs", "repo_id": "candle", "token_count": 1623 }
44
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> @import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@200;300;400&family=Source+Sans+3:wght@100;200;300;400;500;600;700;800;900&display=swap");...
candle/candle-wasm-examples/blip/index.html/0
{ "file_path": "candle/candle-wasm-examples/blip/index.html", "repo_id": "candle", "token_count": 7164 }
45
use crate::model::{Cache, Config, Llama}; use byteorder::{LittleEndian, ReadBytesExt}; use candle::{DType, Device, IndexOp, Result, Shape, Tensor}; use candle_nn::VarBuilder; use candle_transformers::generation::LogitsProcessor; use serde::{Deserialize, Serialize}; use tokenizers::Tokenizer; use wasm_bindgen::prelude::...
candle/candle-wasm-examples/llama2-c/src/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/src/worker.rs", "repo_id": "candle", "token_count": 5770 }
46
export async function extractEmbeddings( worker, weightsURL, tokenizerURL, configURL, modelID, sentences, updateStatus, normalize_embeddings = true ) { return new Promise((resolve, reject) => { worker.postMessage({ weightsURL, tokenizerURL, configURL, modelID, sentenc...
candle/candle-wasm-examples/t5/utils.js/0
{ "file_path": "candle/candle-wasm-examples/t5/utils.js", "repo_id": "candle", "token_count": 2339 }
47
[package] name = "candle-wasm-example-yolo" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true [dependencies] candle = { workspace = true } candle-nn = { workspace = true } num-traits ...
candle/candle-wasm-examples/yolo/Cargo.toml/0
{ "file_path": "candle/candle-wasm-examples/yolo/Cargo.toml", "repo_id": "candle", "token_count": 463 }
48
pub fn add(left: usize, right: usize) -> usize { left + right } #[cfg(test)] mod tests { use super::*; #[test] fn it_works() { let result = add(2, 2); assert_eq!(result, 4); } }
candle/candle-wasm-tests/src/lib.rs/0
{ "file_path": "candle/candle-wasm-tests/src/lib.rs", "repo_id": "candle", "token_count": 108 }
49
ARG INCLUDE_DB=false FROM mongo:latest as mongo FROM node:20-slim as local_db_false FROM node:20-slim as local_db_true RUN apt-get update RUN apt-get install gnupg curl -y COPY --from=mongo /usr/bin/mongo* /usr/bin/ FROM local_db_${INCLUDE_DB} as final ARG INCLUDE_DB=false ENV INCLUDE_DB=${INCLUDE_DB} WORKDIR /ap...
chat-ui/Dockerfile.local/0
{ "file_path": "chat-ui/Dockerfile.local", "repo_id": "chat-ui", "token_count": 278 }
50
export function clickOutside(element: HTMLDialogElement, callbackFunction: () => void) { function onClick(event: MouseEvent) { if (!element.contains(event.target as Node)) { callbackFunction(); } } document.body.addEventListener("click", onClick); return { update(newCallbackFunction: () => void) { cal...
chat-ui/src/lib/actions/clickOutside.ts/0
{ "file_path": "chat-ui/src/lib/actions/clickOutside.ts", "repo_id": "chat-ui", "token_count": 143 }
51
<script lang="ts"> import { base } from "$app/paths"; import { page } from "$app/stores"; import { createEventDispatcher } from "svelte"; import CarbonCheckmark from "~icons/carbon/checkmark"; import CarbonTrashCan from "~icons/carbon/trash-can"; import CarbonClose from "~icons/carbon/close"; import CarbonEdit ...
chat-ui/src/lib/components/NavConversationItem.svelte/0
{ "file_path": "chat-ui/src/lib/components/NavConversationItem.svelte", "repo_id": "chat-ui", "token_count": 1309 }
52
<script lang="ts"> import { createEventDispatcher } from "svelte"; import IconGear from "~icons/bi/gear-fill"; import { base } from "$app/paths"; import type { Assistant } from "$lib/types/Assistant"; import { formatUserCount } from "$lib/utils/formatUserCount"; import IconInternet from "../icons/IconInternet.sve...
chat-ui/src/lib/components/chat/AssistantIntroduction.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/AssistantIntroduction.svelte", "repo_id": "chat-ui", "token_count": 2390 }
53
import { afterEach, assert, describe, expect, it } from "vitest"; import { migrations } from "./routines"; import { acquireLock, isDBLocked, refreshLock, releaseLock } from "./lock"; import { collections } from "$lib/server/database"; const LOCK_KEY = "migrations"; describe("migrations", () => { it("should not have ...
chat-ui/src/lib/migrations/migrations.spec.ts/0
{ "file_path": "chat-ui/src/lib/migrations/migrations.spec.ts", "repo_id": "chat-ui", "token_count": 663 }
54
import type { Conversation } from "$lib/types/Conversation"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import { endpointTgi, endpointTgiParametersSchema } from "./tgi/endpointTgi"; import { z } from "zod"; import endpointAws, { endpointAwsParametersSchema } from "./aws/endpointAws"; impo...
chat-ui/src/lib/server/endpoints/endpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/endpoints.ts", "repo_id": "chat-ui", "token_count": 725 }
55
import { LLM_SUMMERIZATION } from "$env/static/private"; import { generateFromDefaultEndpoint } from "$lib/server/generateFromDefaultEndpoint"; import type { Message } from "$lib/types/Message"; export async function summarize(prompt: string) { if (!LLM_SUMMERIZATION) { return prompt.split(/\s+/g).slice(0, 5).join(...
chat-ui/src/lib/server/summarize.ts/0
{ "file_path": "chat-ui/src/lib/server/summarize.ts", "repo_id": "chat-ui", "token_count": 638 }
56
export function switchTheme() { const { classList } = document.querySelector("html") as HTMLElement; const metaTheme = document.querySelector('meta[name="theme-color"]') as HTMLMetaElement; if (classList.contains("dark")) { classList.remove("dark"); metaTheme.setAttribute("content", "rgb(249, 250, 251)"); loc...
chat-ui/src/lib/switchTheme.ts/0
{ "file_path": "chat-ui/src/lib/switchTheme.ts", "repo_id": "chat-ui", "token_count": 164 }
57
import type { Conversation } from "./Conversation"; export type SharedConversation = Pick< Conversation, | "model" | "embeddingModel" | "title" | "rootMessageId" | "messages" | "preprompt" | "assistantId" | "createdAt" | "updatedAt" > & { _id: string; hash: string; };
chat-ui/src/lib/types/SharedConversation.ts/0
{ "file_path": "chat-ui/src/lib/types/SharedConversation.ts", "repo_id": "chat-ui", "token_count": 114 }
58
import type { Model } from "$lib/types/Model"; import { AutoTokenizer, PreTrainedTokenizer } from "@xenova/transformers"; export async function getTokenizer(_modelTokenizer: Exclude<Model["tokenizer"], undefined>) { if (typeof _modelTokenizer === "string") { // return auto tokenizer return await AutoTokenizer.fro...
chat-ui/src/lib/utils/getTokenizer.ts/0
{ "file_path": "chat-ui/src/lib/utils/getTokenizer.ts", "repo_id": "chat-ui", "token_count": 228 }
59
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { describe, expect, it } from "vitest"; import { insertLegacyConversation, insertSideBranchesConversation } from "./treeHelpers.spec"; import { addChildren } from "./addChildren"; import type { Message } from "$lib/types/Mes...
chat-ui/src/lib/utils/tree/addChildren.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/addChildren.spec.ts", "repo_id": "chat-ui", "token_count": 1301 }
60
import { json } from "@sveltejs/kit"; import type { ConversationStats } from "$lib/types/ConversationStats"; import { CONVERSATION_STATS_COLLECTION, collections } from "$lib/server/database.js"; // Triger like this: // curl -X POST "http://localhost:5173/chat/admin/stats/compute" -H "Authorization: Bearer <ADMIN_API_S...
chat-ui/src/routes/admin/stats/compute/+server.ts/0
{ "file_path": "chat-ui/src/routes/admin/stats/compute/+server.ts", "repo_id": "chat-ui", "token_count": 2379 }
61
import { MESSAGES_BEFORE_LOGIN, ENABLE_ASSISTANTS_RAG } from "$env/static/private"; import { startOfHour } from "date-fns"; import { authCondition, requiresUser } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { models } from "$lib/server/models"; import { ERROR_MESSAGES } from "$li...
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": 6374 }
62
<script lang="ts"> import { PUBLIC_APP_COLOR } from "$env/static/public"; import { isHuggingChat } from "$lib/utils/isHuggingChat"; export let name: string; export let logoUrl: string | undefined; import logo from "../../../../../static/huggingchat/logo.svg?raw"; </script> <div class=" flex h-[648px] w-full fle...
chat-ui/src/routes/models/[...model]/thumbnail.png/ModelThumbnail.svelte/0
{ "file_path": "chat-ui/src/routes/models/[...model]/thumbnail.png/ModelThumbnail.svelte", "repo_id": "chat-ui", "token_count": 475 }
63
<script lang="ts"> import type { ActionData, PageData } from "./$types"; import AssistantSettings from "$lib/components/AssistantSettings.svelte"; export let data: PageData; export let form: ActionData; </script> <AssistantSettings bind:form models={data.models} />
chat-ui/src/routes/settings/(nav)/assistants/new/+page@settings.svelte/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/new/+page@settings.svelte", "repo_id": "chat-ui", "token_count": 80 }
64
{ "background_color": "#ffffff", "name": "HuggingChat", "short_name": "HuggingChat", "display": "standalone", "start_url": "/chat", "icons": [ { "src": "/chat/huggingchat/icon-128x128.png", "sizes": "128x128", "type": "image/png" }, { "src": "/chat/huggingchat/icon-256x256.png", "sizes": "256...
chat-ui/static/huggingchat/manifest.json/0
{ "file_path": "chat-ui/static/huggingchat/manifest.json", "repo_id": "chat-ui", "token_count": 233 }
65
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 }
66
- 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": 1247 }
67
# Create a dataset loading script <Tip> The dataset loading script is likely not needed if your dataset is in one of the following formats: CSV, JSON, JSON lines, text, images, audio or Parquet. With those formats, you should be able to load your dataset automatically with [`~datasets.load_dataset`], as long as your...
datasets/docs/source/dataset_script.mdx/0
{ "file_path": "datasets/docs/source/dataset_script.mdx", "repo_id": "datasets", "token_count": 5380 }
68
# Evaluate predictions <Tip warning={true}> Metrics is deprecated in 🤗 Datasets. To learn more about how to use metrics, take a look at the library 🤗 [Evaluate](https://huggingface.co/docs/evaluate/index)! In addition to metrics, you can find more tools for evaluating models and datasets. </Tip> 🤗 Datasets provi...
datasets/docs/source/metrics.mdx/0
{ "file_path": "datasets/docs/source/metrics.mdx", "repo_id": "datasets", "token_count": 1193 }
69
# Load tabular data A tabular dataset is a generic dataset used to describe any data stored in rows and columns, where the rows represent an example and the columns represent a feature (can be continuous or categorical). These datasets are commonly stored in CSV files, Pandas DataFrames, and in database tables. This g...
datasets/docs/source/tabular_load.mdx/0
{ "file_path": "datasets/docs/source/tabular_load.mdx", "repo_id": "datasets", "token_count": 1868 }
70
# 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/metrics/bleurt/bleurt.py/0
{ "file_path": "datasets/metrics/bleurt/bleurt.py", "repo_id": "datasets", "token_count": 1981 }
71
# 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/metrics/cuad/cuad.py/0
{ "file_path": "datasets/metrics/cuad/cuad.py", "repo_id": "datasets", "token_count": 2242 }
72
# Metric Card for Mahalanobis Distance ## Metric Description Mahalonobis distance is the distance between a point and a distribution (as opposed to the distance between two points), making it the multivariate equivalent of the Euclidean distance. It is often used in multivariate anomaly detection, classification on h...
datasets/metrics/mahalanobis/README.md/0
{ "file_path": "datasets/metrics/mahalanobis/README.md", "repo_id": "datasets", "token_count": 738 }
73
# Metric Card for Precision ## Metric Description Precision is the fraction of correctly labeled positive examples out of all of the examples that were labeled as positive. It is computed via the equation: Precision = TP / (TP + FP) where TP is the True positives (i.e. the examples correctly labeled as positive) and...
datasets/metrics/precision/README.md/0
{ "file_path": "datasets/metrics/precision/README.md", "repo_id": "datasets", "token_count": 1878 }
74
# Metric Card for SQuAD ## Metric description This metric wraps the official scoring script for version 1 of the [Stanford Question Answering Dataset (SQuAD)](https://huggingface.co/datasets/squad). SQuAD is a reading comprehension dataset, consisting of questions posed by crowdworkers on a set of Wikipedia articles...
datasets/metrics/squad/README.md/0
{ "file_path": "datasets/metrics/squad/README.md", "repo_id": "datasets", "token_count": 1494 }
75
# 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/metrics/xnli/xnli.py/0
{ "file_path": "datasets/metrics/xnli/xnli.py", "repo_id": "datasets", "token_count": 1107 }
76
import fnmatch import json import os import shutil import tempfile import xml.etree.ElementTree as ET from argparse import ArgumentParser from pathlib import Path from typing import Optional from datasets import config from datasets.commands import BaseDatasetsCLICommand from datasets.download.download_config import D...
datasets/src/datasets/commands/dummy_data.py/0
{ "file_path": "datasets/src/datasets/commands/dummy_data.py", "repo_id": "datasets", "token_count": 11107 }
77
# 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/features/features.py/0
{ "file_path": "datasets/src/datasets/features/features.py", "repo_id": "datasets", "token_count": 40149 }
78
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": 1473 }
79
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": 1011 }
80
import importlib import inspect from functools import wraps from typing import TYPE_CHECKING, Optional from .download.download_config import DownloadConfig from .download.streaming_download_manager import ( xbasename, xdirname, xet_parse, xexists, xgetsize, xglob, xgzip_open, xisdir, ...
datasets/src/datasets/streaming.py/0
{ "file_path": "datasets/src/datasets/streaming.py", "repo_id": "datasets", "token_count": 2364 }
81
import enum import inspect import warnings from functools import wraps from typing import Callable, Optional from .logging import get_logger _emitted_deprecation_warnings = set() logger = get_logger(__name__) def deprecated(help_message: Optional[str] = None): """Decorator to mark a class or a function as depr...
datasets/src/datasets/utils/deprecation_utils.py/0
{ "file_path": "datasets/src/datasets/utils/deprecation_utils.py", "repo_id": "datasets", "token_count": 1426 }
82
{ "code": "Programming language (C++, Java, Javascript, Python, etc.)", "aa": "Afar", "aaa": "Ghotuo", "aab": "Alumu-Tesu", "aac": "Ari", "aad": "Amal", "aae": "Arbëreshë Albanian", "aaf": "Aranadan", "aag": "Ambrak", "aah": "Abu' Arapesh", "aai": "Arifama-Miniafia", "aak...
datasets/src/datasets/utils/resources/languages.json/0
{ "file_path": "datasets/src/datasets/utils/resources/languages.json", "repo_id": "datasets", "token_count": 111198 }
83
import os import tarfile import pyarrow as pa import pytest from datasets import Dataset, concatenate_datasets, load_dataset from datasets.features import Audio, Features, Sequence, Value from ..utils import ( require_sndfile, ) @pytest.fixture() def tar_wav_path(shared_datadir, tmp_path_factory): audio_pa...
datasets/tests/features/test_audio.py/0
{ "file_path": "datasets/tests/features/test_audio.py", "repo_id": "datasets", "token_count": 11528 }
84
import os import tempfile from unittest import TestCase import numpy as np import pandas as pd import pytest from datasets import load_from_disk from datasets.arrow_dataset import Dataset from datasets.dataset_dict import DatasetDict, IterableDatasetDict from datasets.features import ClassLabel, Features, Sequence, V...
datasets/tests/test_dataset_dict.py/0
{ "file_path": "datasets/tests/test_dataset_dict.py", "repo_id": "datasets", "token_count": 17807 }
85
import pickle from copy import deepcopy from itertools import chain, islice import numpy as np import pandas as pd import pyarrow as pa import pyarrow.compute as pc import pytest from datasets import Dataset, load_dataset from datasets.combine import concatenate_datasets, interleave_datasets from datasets.features im...
datasets/tests/test_iterable_dataset.py/0
{ "file_path": "datasets/tests/test_iterable_dataset.py", "repo_id": "datasets", "token_count": 36328 }
86
import unittest from unittest.mock import patch import pytest from pytest import CaptureFixture from datasets.utils import ( are_progress_bars_disabled, disable_progress_bars, enable_progress_bars, tqdm, ) class TestTqdmUtils(unittest.TestCase): @pytest.fixture(autouse=True) def capsys(self,...
datasets/tests/test_tqdm.py/0
{ "file_path": "datasets/tests/test_tqdm.py", "repo_id": "datasets", "token_count": 1804 }
87
<jupyter_start><jupyter_text>Unit 4: Code your first Deep Reinforcement Learning Algorithm with PyTorch: Reinforce. And test its robustness 💪In this notebook, you'll code your first Deep Reinforcement Learning algorithm from scratch: Reinforce (also called Monte Carlo Policy Gradient).Reinforce is a *Policy-based meth...
deep-rl-class/notebooks/unit4/unit4.ipynb/0
{ "file_path": "deep-rl-class/notebooks/unit4/unit4.ipynb", "repo_id": "deep-rl-class", "token_count": 12740 }
88
# The Exploration/Exploitation trade-off [[exp-exp-tradeoff]] Finally, before looking at the different methods to solve Reinforcement Learning problems, we must cover one more very important topic: *the exploration/exploitation trade-off.* - *Exploration* is exploring the environment by trying random actions in order...
deep-rl-class/units/en/unit1/exp-exp-tradeoff.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/exp-exp-tradeoff.mdx", "repo_id": "deep-rl-class", "token_count": 699 }
89
# Monte Carlo vs Temporal Difference Learning [[mc-vs-td]] The last thing we need to discuss before diving into Q-Learning is the two learning strategies. Remember that an RL agent **learns by interacting with its environment.** The idea is that **given the experience and the received reward, the agent will update it...
deep-rl-class/units/en/unit2/mc-vs-td.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/mc-vs-td.mdx", "repo_id": "deep-rl-class", "token_count": 2316 }
90
# Deep Q-Learning [[deep-q-learning]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit4/thumbnail.jpg" alt="Unit 3 thumbnail" width="100%"> In the last unit, we learned our first reinforcement learning algorithm: Q-Learning, **implemented it from scratch**, and...
deep-rl-class/units/en/unit3/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit3/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 437 }
91
# How do Unity ML-Agents work? [[how-mlagents-works]] Before training our agent, we need to understand **what ML-Agents is and how it works**. ## What is Unity ML-Agents? [[what-is-mlagents]] [Unity ML-Agents](https://github.com/Unity-Technologies/ml-agents) is a toolkit for the game engine Unity that **allows us to...
deep-rl-class/units/en/unit5/how-mlagents-works.mdx/0
{ "file_path": "deep-rl-class/units/en/unit5/how-mlagents-works.mdx", "repo_id": "deep-rl-class", "token_count": 1276 }
92
# Introduction [[introduction]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit0/thumbnail.png" alt="Thumbnail"/> Since the beginning of this course, we learned to train agents in a *single-agent system* where our agent was alone in its environment: it was **no...
deep-rl-class/units/en/unit7/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit7/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 574 }
93
# Introduction [[introduction]] In this bonus unit, we'll reinforce what we learned in the first unit by teaching Huggy the Dog to fetch the stick and then [play with him directly in your browser](https://huggingface.co/spaces/ThomasSimonini/Huggy) 🐶 <img src="https://huggingface.co/datasets/huggingface-deep-rl-cour...
deep-rl-class/units/en/unitbonus1/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus1/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 138 }
94
# Brief introduction to RL documentation In this advanced topic, we address the question: **how should we monitor and keep track of powerful reinforcement learning agents that we are training in the real world and interfacing with humans?** As machine learning systems have increasingly impacted modern life, the **cal...
deep-rl-class/units/en/unitbonus3/rl-documentation.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus3/rl-documentation.mdx", "repo_id": "deep-rl-class", "token_count": 886 }
95
<!--- 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 o...
diffusers/README.md/0
{ "file_path": "diffusers/README.md", "repo_id": "diffusers", "token_count": 5416 }
96
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/loaders/peft.md/0
{ "file_path": "diffusers/docs/source/en/api/loaders/peft.md", "repo_id": "diffusers", "token_count": 320 }
97
<!--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/paint_by_example.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/paint_by_example.md", "repo_id": "diffusers", "token_count": 762 }
98
<!--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/schedulers/lcm.md/0
{ "file_path": "diffusers/docs/source/en/api/schedulers/lcm.md", "repo_id": "diffusers", "token_count": 291 }
99