text
stringlengths
7
328k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
459
# coding=utf-8 # Copyright 2018 the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
transformers/tests/trainer/test_trainer_utils.py/0
{ "file_path": "transformers/tests/trainer/test_trainer_utils.py", "repo_id": "transformers", "token_count": 9624 }
399
# coding=utf-8 # Copyright 2021 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
transformers/tests/utils/test_image_utils.py/0
{ "file_path": "transformers/tests/utils/test_image_utils.py", "repo_id": "transformers", "token_count": 13075 }
400
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
transformers/utils/check_doctest_list.py/0
{ "file_path": "transformers/utils/check_doctest_list.py", "repo_id": "transformers", "token_count": 1179 }
401
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
transformers/utils/get_modified_files.py/0
{ "file_path": "transformers/utils/get_modified_files.py", "repo_id": "transformers", "token_count": 448 }
402
import torch from transformers import PreTrainedModel from .custom_configuration import CustomConfig, NoSuperInitConfig class CustomModel(PreTrainedModel): config_class = CustomConfig def __init__(self, config): super().__init__(config) self.linear = torch.nn.Linear(config.hidden_size, conf...
transformers/utils/test_module/custom_modeling.py/0
{ "file_path": "transformers/utils/test_module/custom_modeling.py", "repo_id": "transformers", "token_count": 289 }
403
# How to contribute ## How to get started Before you start contributing make sure you installed all the dev tools: ```bash make dev ``` ## Did you find a bug? * Ensure the bug was not already reported by searching on GitHub under Issues. * If you're unable to find an open issue addressing the problem, open a new o...
trl/CONTRIBUTING.md/0
{ "file_path": "trl/CONTRIBUTING.md", "repo_id": "trl", "token_count": 579 }
404
#!/bin/bash #SBATCH --job-name=trl #SBATCH --partition=hopper-prod #SBATCH --gpus-per-task={{gpus_per_task}} #SBATCH --cpus-per-gpu={{cpus_per_gpu}} #SBATCH --ntasks={{ntasks}} #SBATCH --output=slurm/logs/%x_%j.out #SBATCH --array={{array}} ##SBATCH --exclude=ip-26-0-149-199 module load cuda/12.1 {{nodes}} seeds={{s...
trl/benchmark/trl.slurm_template/0
{ "file_path": "trl/benchmark/trl.slurm_template", "repo_id": "trl", "token_count": 217 }
405
# Installation You can install TRL either from pypi or from source: ## pypi Install the library with pip: ```bash pip install trl ``` ### Source You can also install the latest version from source. First clone the repo and then run the installation with `pip`: ```bash git clone https://github.com/huggingface/trl.gi...
trl/docs/source/installation.mdx/0
{ "file_path": "trl/docs/source/installation.mdx", "repo_id": "trl", "token_count": 147 }
406
# Using LLaMA models with TRL We've begun rolling out examples to use Meta's LLaMA models in `trl` (see [Meta's LLaMA release](https://ai.facebook.com/blog/large-language-model-llama-meta-ai/) for the original LLaMA model). ## Efficient training strategies Even training the smallest LLaMA model requires an enormous ...
trl/docs/source/using_llama_models.mdx/0
{ "file_path": "trl/docs/source/using_llama_models.mdx", "repo_id": "trl", "token_count": 2999 }
407
# Research projects that use TRL Welcome to the research projects folder! Here you can find the scripts used for some research projects that used TRL and maintained by the developers and the community (LM de-toxification, Stack-Llama, etc.). Check out the READMEs in the subfolders for more information! - [De-detoxify...
trl/examples/research_projects/README.md/0
{ "file_path": "trl/examples/research_projects/README.md", "repo_id": "trl", "token_count": 189 }
408
# flake8: noqa # 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 requir...
trl/examples/scripts/chat.py/0
{ "file_path": "trl/examples/scripts/chat.py", "repo_id": "trl", "token_count": 5625 }
409
# 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...
trl/tests/test_modeling_value_head.py/0
{ "file_path": "trl/tests/test_modeling_value_head.py", "repo_id": "trl", "token_count": 9527 }
410
from typing import Any, Callable, List, Optional, Union import torch from transformers import GenerationConfig, PreTrainedTokenizer, PreTrainedTokenizerFast from ..core import set_seed from ..models import SUPPORTED_ARCHITECTURES, PreTrainedModelWrapper class BestOfNSampler: def __init__( self, ...
trl/trl/extras/best_of_n_sampler.py/0
{ "file_path": "trl/trl/extras/best_of_n_sampler.py", "repo_id": "trl", "token_count": 2253 }
411
# KTO Authors: Kawin Ethayarajh, Winnie Xu, Niklas Muennighoff, Dan Jurafsky, and Douwe Kiela # 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 ...
trl/trl/trainer/kto_trainer.py/0
{ "file_path": "trl/trl/trainer/kto_trainer.py", "repo_id": "trl", "token_count": 27065 }
412
<!--- Copyright 2023 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or ...
accelerate/docs/README.md/0
{ "file_path": "accelerate/docs/README.md", "repo_id": "accelerate", "token_count": 2883 }
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/training_tpu.md/0
{ "file_path": "accelerate/docs/source/concept_guides/training_tpu.md", "repo_id": "accelerate", "token_count": 2214 }
1
<!--Copyright 2023 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/usage_guides/quantization.md/0
{ "file_path": "accelerate/docs/source/usage_guides/quantization.md", "repo_id": "accelerate", "token_count": 1962 }
2
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/examples/multigpu_remote_launcher.py/0
{ "file_path": "accelerate/examples/multigpu_remote_launcher.py", "repo_id": "accelerate", "token_count": 1026 }
3
# Copyright 2022 The HuggingFace Team and Brian Chao. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requir...
accelerate/src/accelerate/commands/menu/input.py/0
{ "file_path": "accelerate/src/accelerate/commands/menu/input.py", "repo_id": "accelerate", "token_count": 947 }
4
# 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 }
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/utils/other.py/0
{ "file_path": "accelerate/src/accelerate/utils/other.py", "repo_id": "accelerate", "token_count": 4278 }
6
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 }
7
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_quantization.py/0
{ "file_path": "accelerate/tests/test_quantization.py", "repo_id": "accelerate", "token_count": 17682 }
8
# Model arguments model_name_or_path: alignment-handbook/zephyr-7b-sft-full torch_dtype: null # Data training arguments dataset_mixer: HuggingFaceH4/ultrafeedback_binarized: 1.0 dataset_splits: - train_prefs - test_prefs preprocessing_num_workers: 12 # Training arguments with sensible defaults bf16: true beta: 0.01...
alignment-handbook/recipes/pref_align_scan/dpo/config_zephyr.yaml/0
{ "file_path": "alignment-handbook/recipes/pref_align_scan/dpo/config_zephyr.yaml", "repo_id": "alignment-handbook", "token_count": 359 }
9
#!/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_sft.py/0
{ "file_path": "alignment-handbook/scripts/run_sft.py", "repo_id": "alignment-handbook", "token_count": 3115 }
10
[build] rustflags = ["-C", "target-cpu=native"] [target.wasm32-unknown-unknown] rustflags = ["-C", "target-feature=+simd128"] [target.x86_64-apple-darwin] rustflags = ["-C", "target-feature=-avx,-avx2"]
candle/.cargo/config.toml/0
{ "file_path": "candle/.cargo/config.toml", "repo_id": "candle", "token_count": 84 }
11
# Summary [Introduction](README.md) # User Guide - [Installation](guide/installation.md) - [Hello World - MNIST](guide/hello_world.md) - [PyTorch cheatsheet](guide/cheatsheet.md) # Reference Guide - [Running a model](inference/inference.md) - [Using the hub](inference/hub.md) - [Error management](error_manage....
candle/candle-book/src/SUMMARY.md/0
{ "file_path": "candle/candle-book/src/SUMMARY.md", "repo_id": "candle", "token_count": 274 }
12
# Writing a custom kernel
candle/candle-book/src/inference/cuda/writing.md/0
{ "file_path": "candle/candle-book/src/inference/cuda/writing.md", "repo_id": "candle", "token_count": 6 }
13
pub(crate) mod affine; pub(crate) mod matmul; pub(crate) mod random; pub(crate) mod where_cond; use candle_core::{Device, Result}; pub(crate) trait BenchDevice { fn sync(&self) -> Result<()>; fn bench_name<S: Into<String>>(&self, name: S) -> String; } impl BenchDevice for Device { fn sync(&self) -> Resu...
candle/candle-core/benches/benchmarks/mod.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/mod.rs", "repo_id": "candle", "token_count": 1019 }
14
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 }
15
//! Numpy support for tensors. //! //! The spec for the npy format can be found in //! [npy-format](https://docs.scipy.org/doc/numpy-1.14.2/neps/npy-format.html). //! The functions from this module can be used to read tensors from npy/npz files //! or write tensors to these files. A npy file contains a single tensor (u...
candle/candle-core/src/npy.rs/0
{ "file_path": "candle/candle-core/src/npy.rs", "repo_id": "candle", "token_count": 8717 }
16
use crate::{Result, Tensor, WithDType}; pub enum TensorScalar { Tensor(Tensor), Scalar(Tensor), } pub trait TensorOrScalar { fn to_tensor_scalar(self) -> Result<TensorScalar>; } impl TensorOrScalar for &Tensor { fn to_tensor_scalar(self) -> Result<TensorScalar> { Ok(TensorScalar::Tensor(self....
candle/candle-core/src/scalar.rs/0
{ "file_path": "candle/candle-core/src/scalar.rs", "repo_id": "candle", "token_count": 261 }
17
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 }
18
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 }
19
# candle-convnext [A ConvNet for the 2020s](https://arxiv.org/abs/2201.03545) and [ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders](https://arxiv.org/abs/2301.00808). This candle implementation uses a pre-trained ConvNeXt network for inference. The classification head has been trained on the I...
candle/candle-examples/examples/convnext/README.md/0
{ "file_path": "candle/candle-examples/examples/convnext/README.md", "repo_id": "candle", "token_count": 293 }
20
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use candle::{DType, IndexOp, Tensor}; use candle_nn::VarBuilder; use candle_transformers::models::encodec::{Config, Model}; use clap::{Parser, ValueEnum}; use hf_hub::api::sync::Api; mo...
candle/candle-examples/examples/encodec/main.rs/0
{ "file_path": "candle/candle-examples/examples/encodec/main.rs", "repo_id": "candle", "token_count": 2395 }
21
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{IndexOp, D}; use clap::{Parser, ValueEnum}; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { SqueezeNet, EfficientNet, } #[derive(Parser)] struct Args { #[arg(long)] imag...
candle/candle-examples/examples/onnx/main.rs/0
{ "file_path": "candle/candle-examples/examples/onnx/main.rs", "repo_id": "candle", "token_count": 1042 }
22
use super::gym_env::{GymEnv, Step}; use candle::{DType, Device, Error, Module, Result, Tensor}; use candle_nn::{ linear, ops::log_softmax, ops::softmax, sequential::seq, Activation, AdamW, Optimizer, ParamsAdamW, VarBuilder, VarMap, }; use rand::{distributions::Distribution, rngs::ThreadRng, Rng}; fn new_model...
candle/candle-examples/examples/reinforcement-learning/policy_gradient.rs/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/policy_gradient.rs", "repo_id": "candle", "token_count": 2333 }
23
## VGG Model Implementation This example demonstrates the implementation of VGG models (VGG13, VGG16, VGG19) using the Candle library. The VGG models are defined in `candle-transformers/src/models/vgg.rs`. The main function in `candle-examples/examples/vgg/main.rs` loads an image, selects the VGG model based on the p...
candle/candle-examples/examples/vgg/README.md/0
{ "file_path": "candle/candle-examples/examples/vgg/README.md", "repo_id": "candle", "token_count": 200 }
24
pub mod audio; pub mod bs1770; pub mod coco_classes; pub mod imagenet; pub mod token_output_stream; pub mod wav; use candle::utils::{cuda_is_available, metal_is_available}; use candle::{Device, Result, Tensor}; pub fn device(cpu: bool) -> Result<Device> { if cpu { Ok(Device::Cpu) } else if cuda_is_ava...
candle/candle-examples/src/lib.rs/0
{ "file_path": "candle/candle-examples/src/lib.rs", "repo_id": "candle", "token_count": 2455 }
25
// Inspired by // https://github.com/NVIDIA/DALI/blob/main/include/dali/core/static_switch.h // and https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/Dispatch.h #pragma once /// @param COND - a boolean expression to switch by /// @param CONST_NAME - a name given for the constexpr bool variable. /// @...
candle/candle-flash-attn/kernels/static_switch.h/0
{ "file_path": "candle/candle-flash-attn/kernels/static_switch.h", "repo_id": "candle", "token_count": 1516 }
26
// WARNING: THIS IS ONLY VALID ASSUMING THAT inp IS CONTIGUOUS! // TODO: proper error reporting when ids are larger than v_size. #include "cuda_utils.cuh" #include<stdint.h> template<typename T, typename I> __device__ void index_select( const size_t numel, const size_t num_dims, const size_t *info, con...
candle/candle-kernels/src/indexing.cu/0
{ "file_path": "candle/candle-kernels/src/indexing.cu", "repo_id": "candle", "token_count": 4314 }
27
#include <metal_stdlib> #include <metal_integer> #include <metal_atomic> using namespace metal; // Constants // 2^32 and 1/2^32. Useful for converting between float and uint. static constexpr constant ulong UNIF01_NORM32 = 4294967296; static constexpr constant float UNIF01_INV32 = 2.328306436538696289e-10; // 2 * pi ...
candle/candle-metal-kernels/src/random.metal/0
{ "file_path": "candle/candle-metal-kernels/src/random.metal", "repo_id": "candle", "token_count": 3671 }
28
//! Embedding Layer. use candle::{Result, Tensor}; #[derive(Clone, Debug)] pub struct Embedding { embeddings: Tensor, hidden_size: usize, } impl Embedding { pub fn new(embeddings: Tensor, hidden_size: usize) -> Self { Self { embeddings, hidden_size, } } pub...
candle/candle-nn/src/embedding.rs/0
{ "file_path": "candle/candle-nn/src/embedding.rs", "repo_id": "candle", "token_count": 571 }
29
/* Equivalent PyTorch code. import torch from torch.nn.functional import group_norm t = torch.tensor( [[[-0.3034, 0.2726, -0.9659], [-1.1845, -1.3236, 0.0172], [ 1.9507, 1.2554, -0.8625], [ 1.0682, 0.3604, 0.3985], [-0.4957, -0.4461, -0.9721], [ 1.5157, -0....
candle/candle-nn/tests/group_norm.rs/0
{ "file_path": "candle/candle-nn/tests/group_norm.rs", "repo_id": "candle", "token_count": 2154 }
30
## Installation From the `candle-pyo3` directory, enable a virtual env where you will want the candle package to be installed then run. ```bash maturin develop -r python test.py ``` ## Generating Stub Files for Type Hinting For type hinting support, the `candle-pyo3` package requires `*.pyi` files. You can automa...
candle/candle-pyo3/README.md/0
{ "file_path": "candle/candle-pyo3/README.md", "repo_id": "candle", "token_count": 190 }
31
from .module import Module from typing import Optional, Tuple, Any from candle import Tensor import candle class Embedding(Module): """A simple lookup table that stores embeddings of a fixed dictionary and size. This module is often used to store word embeddings and retrieve them using indices. The input...
candle/candle-pyo3/py_src/candle/nn/sparse.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/nn/sparse.py", "repo_id": "candle", "token_count": 590 }
32
use candle::Result; use candle_nn::{batch_norm, Conv2dConfig, Module, VarBuilder}; #[allow(clippy::many_single_char_names)] fn conv2d_same( i: usize, o: usize, k: usize, c: Conv2dConfig, vb: VarBuilder, ) -> Result<impl Module> { let conv2d = candle_nn::conv2d(i, o, k, c, vb)?; let s = c.st...
candle/candle-transformers/src/models/convmixer.rs/0
{ "file_path": "candle/candle-transformers/src/models/convmixer.rs", "repo_id": "candle", "token_count": 1413 }
33
use crate::{ quantized_nn::{layer_norm, linear_no_bias as linear, Embedding, Linear}, quantized_var_builder::VarBuilder, }; use candle::{IndexOp, Result, Tensor}; use candle_nn::{GroupNorm, LayerNorm, Module}; pub use crate::models::rwkv_v5::{Config, State, Tokenizer}; #[derive(Debug, Clone)] struct SelfAtten...
candle/candle-transformers/src/models/quantized_rwkv_v5.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_rwkv_v5.rs", "repo_id": "candle", "token_count": 5518 }
34
use candle::{Result, Tensor}; use candle_nn::{layer_norm, LayerNorm, Linear, Module, VarBuilder}; #[derive(Debug)] struct Attention { q_proj: Linear, k_proj: Linear, v_proj: Linear, out_proj: Linear, num_heads: usize, } impl Attention { fn new( embedding_dim: usize, num_heads: ...
candle/candle-transformers/src/models/segment_anything/transformer.rs/0
{ "file_path": "candle/candle-transformers/src/models/segment_anything/transformer.rs", "repo_id": "candle", "token_count": 3597 }
35
// T5 Text Model // https://github.com/huggingface/transformers/blob/main/src/transformers/models/t5/modeling_t5.py use crate::models::with_tracing::{linear_no_bias, Embedding, Linear}; use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{Activation, VarBuilder}; use serde::Deserialize; use std::syn...
candle/candle-transformers/src/models/t5.rs/0
{ "file_path": "candle/candle-transformers/src/models/t5.rs", "repo_id": "candle", "token_count": 15016 }
36
use candle::{Device, Tensor}; use candle_transformers::generation::LogitsProcessor; use candle_wasm_example_llama2::worker::{Model as M, ModelData}; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct Model { inner: M, logits_processor: LogitsProcessor, tokens: Vec<u32>, repeat_penalty: f32, } im...
candle/candle-wasm-examples/llama2-c/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/src/bin/m.rs", "repo_id": "candle", "token_count": 1807 }
37
//load the candle SAM Model wasm module import init, { Model } from "./build/m.js"; async function fetchArrayBuffer(url, cacheModel = true) { if (!cacheModel) return new Uint8Array(await (await fetch(url)).arrayBuffer()); const cacheName = "sam-candle-cache"; const cache = await caches.open(cacheName); con...
candle/candle-wasm-examples/segment-anything/samWorker.js/0
{ "file_path": "candle/candle-wasm-examples/segment-anything/samWorker.js", "repo_id": "candle", "token_count": 1747 }
38
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Welcome to Candle!</title> <link data-trunk rel="copy-file" href="mel_filters.safetensors" /> <!-- samples --> <link data-trunk rel="copy-dir" href="audios" /> <!-- tiny.en --> <link data-trunk rel="copy-dir" href="whi...
candle/candle-wasm-examples/whisper/index.html/0
{ "file_path": "candle/candle-wasm-examples/whisper/index.html", "repo_id": "candle", "token_count": 523 }
39
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle YOLOv8 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/yolo/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/yolo/lib-example.html", "repo_id": "candle", "token_count": 9649 }
40
Dockerfile .vscode/ .idea .gitignore LICENSE README.md node_modules/ .svelte-kit/ .env* !.env !.env.local
chat-ui/.dockerignore/0
{ "file_path": "chat-ui/.dockerignore", "repo_id": "chat-ui", "token_count": 51 }
41
<script lang="ts"> import CarbonContinue from "~icons/carbon/continue"; export let classNames = ""; </script> <button type="button" on:click class="btn flex h-8 rounded-lg border bg-white px-3 py-1 text-gray-500 shadow-sm transition-all hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300 d...
chat-ui/src/lib/components/ContinueBtn.svelte/0
{ "file_path": "chat-ui/src/lib/components/ContinueBtn.svelte", "repo_id": "chat-ui", "token_count": 149 }
42
<script lang="ts"> import CarbonStopFilledAlt from "~icons/carbon/stop-filled-alt"; export let classNames = ""; </script> <button type="button" on:click class="btn flex h-8 rounded-lg border bg-white px-3 py-1 shadow-sm transition-all hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-700 dark:hover:bg-gray-600...
chat-ui/src/lib/components/StopGeneratingBtn.svelte/0
{ "file_path": "chat-ui/src/lib/components/StopGeneratingBtn.svelte", "repo_id": "chat-ui", "token_count": 170 }
43
<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 }
44
import { z } from "zod"; import type { EmbeddingEndpoint, Embedding } from "../embeddingEndpoints"; import { chunk } from "$lib/utils/chunk"; export const embeddingEndpointTeiParametersSchema = z.object({ weight: z.number().int().positive().default(1), model: z.any(), type: z.literal("tei"), url: z.string().url(),...
chat-ui/src/lib/server/embeddingEndpoints/tei/embeddingEndpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/embeddingEndpoints/tei/embeddingEndpoints.ts", "repo_id": "chat-ui", "token_count": 664 }
45
import { Address6, Address4 } from "ip-address"; import dns from "node:dns"; export async function isURLLocal(URL: URL): Promise<boolean> { const isLocal = new Promise<boolean>((resolve, reject) => { dns.lookup(URL.hostname, (err, address, family) => { if (err) { reject(err); } if (family === 4) { ...
chat-ui/src/lib/server/isURLLocal.ts/0
{ "file_path": "chat-ui/src/lib/server/isURLLocal.ts", "repo_id": "chat-ui", "token_count": 290 }
46
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 }
47
import type { Timestamps } from "./Timestamps"; export interface Semaphore extends Timestamps { key: string; }
chat-ui/src/lib/types/Semaphore.ts/0
{ "file_path": "chat-ui/src/lib/types/Semaphore.ts", "repo_id": "chat-ui", "token_count": 35 }
48
export function formatUserCount(userCount: number): string { const userCountRanges: { min: number; max: number; label: string }[] = [ { min: 0, max: 1, label: "1" }, { min: 2, max: 9, label: "1-10" }, { min: 10, max: 49, label: "10+" }, { min: 50, max: 99, label: "50+" }, { min: 100, max: 299, label: "100+" ...
chat-ui/src/lib/utils/formatUserCount.ts/0
{ "file_path": "chat-ui/src/lib/utils/formatUserCount.ts", "repo_id": "chat-ui", "token_count": 308 }
49
export const timeout = <T>(prom: Promise<T>, time: number): Promise<T> => { let timer: NodeJS.Timeout; return Promise.race([prom, new Promise<T>((_r, rej) => (timer = setTimeout(rej, time)))]).finally( () => clearTimeout(timer) ); };
chat-ui/src/lib/utils/timeout.ts/0
{ "file_path": "chat-ui/src/lib/utils/timeout.ts", "repo_id": "chat-ui", "token_count": 87 }
50
import { PARQUET_EXPORT_DATASET, PARQUET_EXPORT_HF_TOKEN } from "$env/static/private"; import { collections } from "$lib/server/database"; import type { Message } from "$lib/types/Message"; import { error } from "@sveltejs/kit"; import { pathToFileURL } from "node:url"; import { unlink } from "node:fs/promises"; import...
chat-ui/src/routes/admin/export/+server.ts/0
{ "file_path": "chat-ui/src/routes/admin/export/+server.ts", "repo_id": "chat-ui", "token_count": 1653 }
51
import { buildPrompt } from "$lib/buildPrompt"; import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { models } from "$lib/server/models"; import { buildSubtree } from "$lib/utils/tree/buildSubtree"; import { isMessageId } from "$lib/utils/tree/isMessageId"; impor...
chat-ui/src/routes/conversation/[id]/message/[messageId]/prompt/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/message/[messageId]/prompt/+server.ts", "repo_id": "chat-ui", "token_count": 601 }
52
<script lang="ts"> import { marked } from "marked"; import privacy from "../../../PRIVACY.md?raw"; </script> <div class="overflow-auto p-6"> <div class="prose mx-auto px-4 pb-24 pt-6 dark:prose-invert md:pt-12"> <!-- eslint-disable-next-line svelte/no-at-html-tags --> {@html marked(privacy, { gfm: true })} </d...
chat-ui/src/routes/privacy/+page.svelte/0
{ "file_path": "chat-ui/src/routes/privacy/+page.svelte", "repo_id": "chat-ui", "token_count": 141 }
53
import { collections } from "$lib/server/database"; import type { LayoutServerLoad } from "./$types"; import type { Report } from "$lib/types/Report"; export const load = (async ({ locals, parent }) => { const { assistants } = await parent(); let reportsByUser: string[] = []; const createdBy = locals.user?._id ?? ...
chat-ui/src/routes/settings/+layout.server.ts/0
{ "file_path": "chat-ui/src/routes/settings/+layout.server.ts", "repo_id": "chat-ui", "token_count": 241 }
54
import json import os from dataclasses import dataclass import numpy as np import pyarrow as pa import datasets from utils import get_duration SPEED_TEST_N_EXAMPLES = 100_000_000_000 SPEED_TEST_CHUNK_SIZE = 10_000 RESULTS_BASEPATH, RESULTS_FILENAME = os.path.split(__file__) RESULTS_FILE_PATH = os.path.join(RESULTS...
datasets/benchmarks/benchmark_getitem_100B.py/0
{ "file_path": "datasets/benchmarks/benchmark_getitem_100B.py", "repo_id": "datasets", "token_count": 867 }
55
# Datasets 🤝 Arrow ## What is Arrow? [Arrow](https://arrow.apache.org/) enables large amounts of data to be processed and moved quickly. It is a specific data format that stores data in a columnar memory layout. This provides several significant advantages: * Arrow's standard format allows [zero-copy reads](https:/...
datasets/docs/source/about_arrow.md/0
{ "file_path": "datasets/docs/source/about_arrow.md", "repo_id": "datasets", "token_count": 682 }
56
# 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 }
57
# Load text data This guide shows you how to load text datasets. To learn how to load any type of dataset, take a look at the <a class="underline decoration-sky-400 decoration-2 font-semibold" href="./loading">general loading guide</a>. Text files are one of the most common file types for storing a dataset. By defaul...
datasets/docs/source/nlp_load.mdx/0
{ "file_path": "datasets/docs/source/nlp_load.mdx", "repo_id": "datasets", "token_count": 482 }
58
# Troubleshooting This guide aims to provide you the tools and knowledge required to navigate some common issues. If the suggestions listed in this guide do not cover your such situation, please refer to the [Asking for Help](#asking-for-help) section to learn where to find help with your specific issue. ## Issues w...
datasets/docs/source/troubleshoot.mdx/0
{ "file_path": "datasets/docs/source/troubleshoot.mdx", "repo_id": "datasets", "token_count": 1470 }
59
# Metric Card for CER ## Metric description Character error rate (CER) is a common metric of the performance of an automatic speech recognition (ASR) system. CER is similar to Word Error Rate (WER), but operates on character instead of word. Character error rate can be computed as: `CER = (S + D + I) / N = (S + D...
datasets/metrics/cer/README.md/0
{ "file_path": "datasets/metrics/cer/README.md", "repo_id": "datasets", "token_count": 1192 }
60
"""Official evaluation script for CUAD dataset.""" import argparse import json import re import string import sys import numpy as np IOU_THRESH = 0.5 def get_jaccard(prediction, ground_truth): remove_tokens = [".", ",", ";", ":"] for token in remove_tokens: ground_truth = ground_truth.replace(tok...
datasets/metrics/cuad/evaluate.py/0
{ "file_path": "datasets/metrics/cuad/evaluate.py", "repo_id": "datasets", "token_count": 3035 }
61
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets/metrics/mahalanobis/mahalanobis.py/0
{ "file_path": "datasets/metrics/mahalanobis/mahalanobis.py", "repo_id": "datasets", "token_count": 1363 }
62
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets/metrics/precision/precision.py/0
{ "file_path": "datasets/metrics/precision/precision.py", "repo_id": "datasets", "token_count": 2663 }
63
"""Official evaluation script for v1.1 of the SQuAD dataset.""" import argparse import json import re import string import sys from collections import Counter def normalize_answer(s): """Lower text and remove punctuation, articles and extra whitespace.""" def remove_articles(text): return re.sub(r"\...
datasets/metrics/squad/evaluate.py/0
{ "file_path": "datasets/metrics/squad/evaluate.py", "repo_id": "datasets", "token_count": 1337 }
64
# Metric Card for XTREME-S ## Metric Description The XTREME-S metric aims to evaluate model performance on the Cross-lingual TRansfer Evaluation of Multilingual Encoders for Speech (XTREME-S) benchmark. This benchmark was designed to evaluate speech representations across languages, tasks, domains and data regimes....
datasets/metrics/xtreme_s/README.md/0
{ "file_path": "datasets/metrics/xtreme_s/README.md", "repo_id": "datasets", "token_count": 2218 }
65
import platform from argparse import ArgumentParser import fsspec import huggingface_hub import pandas import pyarrow from datasets import __version__ as version from datasets.commands import BaseDatasetsCLICommand def info_command_factory(_): return EnvironmentCommand() class EnvironmentCommand(BaseDatasetsC...
datasets/src/datasets/commands/env.py/0
{ "file_path": "datasets/src/datasets/commands/env.py", "repo_id": "datasets", "token_count": 476 }
66
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.download_config import DownloadConfig from ..download.streamin...
datasets/src/datasets/features/image.py/0
{ "file_path": "datasets/src/datasets/features/image.py", "repo_id": "datasets", "token_count": 6990 }
67
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class AbstractDatasetReader(ABC): def __init__( self, path_or_paths: ...
datasets/src/datasets/io/abc.py/0
{ "file_path": "datasets/src/datasets/io/abc.py", "repo_id": "datasets", "token_count": 721 }
68
import copy import os from functools import partial from itertools import groupby from typing import TYPE_CHECKING, Callable, Iterator, List, Optional, Tuple, TypeVar, Union import numpy as np import pyarrow as pa import pyarrow.compute as pc import pyarrow.types from . import config from .utils.logging import get_lo...
datasets/src/datasets/table.py/0
{ "file_path": "datasets/src/datasets/table.py", "repo_id": "datasets", "token_count": 41071 }
69
from typing import Callable def is_documented_by(function_with_docstring: Callable): """Decorator to share docstrings across common functions. Args: function_with_docstring (`Callable`): Name of the function with the docstring. """ def wrapper(target_function): target_function.__doc_...
datasets/src/datasets/utils/doc_utils.py/0
{ "file_path": "datasets/src/datasets/utils/doc_utils.py", "repo_id": "datasets", "token_count": 137 }
70
{ "monolingual": "contains a single language", "multilingual": "contains multiple languages", "translation": "contains translated or aligned text", "other": "other type of language distribution" }
datasets/src/datasets/utils/resources/multilingualities.json/0
{ "file_path": "datasets/src/datasets/utils/resources/multilingualities.json", "repo_id": "datasets", "token_count": 55 }
71
# isort: skip_file # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: F401 - this is just for tests import os as renamed_os # noqa: F401 - this is just for tests from os import path # noqa: F401 - this is just for tests from os import path as renamed_path # noqa: F401 - th...
datasets/tests/_test_patching.py/0
{ "file_path": "datasets/tests/_test_patching.py", "repo_id": "datasets", "token_count": 175 }
72
import datetime from typing import List, Tuple from unittest import TestCase from unittest.mock import patch import numpy as np import pandas as pd import pyarrow as pa import pytest from datasets import Array2D from datasets.arrow_dataset import Dataset from datasets.features import Audio, ClassLabel, Features, Imag...
datasets/tests/features/test_features.py/0
{ "file_path": "datasets/tests/features/test_features.py", "repo_id": "datasets", "token_count": 13250 }
73
import shutil import textwrap import librosa import numpy as np import pytest import soundfile as sf from datasets import Audio, ClassLabel, Features, Value from datasets.data_files import DataFilesDict, get_data_patterns from datasets.download.streaming_download_manager import StreamingDownloadManager from datasets....
datasets/tests/packaged_modules/test_audiofolder.py/0
{ "file_path": "datasets/tests/packaged_modules/test_audiofolder.py", "repo_id": "datasets", "token_count": 8594 }
74
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class DatasetListTest(TestCase): def _create_example_records(self): return [ {"col_1": 3, "col_2": "a"}, {"col_1": 2, "col_2": "b"}, {"col_1": 1, "col_2": "c"}...
datasets/tests/test_dataset_list.py/0
{ "file_path": "datasets/tests/test_dataset_list.py", "repo_id": "datasets", "token_count": 875 }
75
import importlib import os import pickle import shutil import tempfile import time from hashlib import sha256 from multiprocessing import Pool from pathlib import Path from unittest import TestCase from unittest.mock import patch import dill import pyarrow as pa import pytest import requests import datasets from data...
datasets/tests/test_load.py/0
{ "file_path": "datasets/tests/test_load.py", "repo_id": "datasets", "token_count": 35068 }
76
import fnmatch import gc import os import shutil import tempfile import textwrap import time import unittest from io import BytesIO from pathlib import Path from unittest.mock import patch import numpy as np import pytest from huggingface_hub import DatasetCard, HfApi from datasets import ( Audio, ClassLabel,...
datasets/tests/test_upstream_hub.py/0
{ "file_path": "datasets/tests/test_upstream_hub.py", "repo_id": "datasets", "token_count": 22798 }
77
<jupyter_start><jupyter_text>Unit 5: An Introduction to ML-Agents In this notebook, you'll learn about ML-Agents and train two agents.- The first one will learn to **shoot snowballs onto spawning targets**.- The second need to press a button to spawn a pyramid, then navigate to the pyramid, knock it over, **and move to...
deep-rl-class/notebooks/unit5/unit5.ipynb/0
{ "file_path": "deep-rl-class/notebooks/unit5/unit5.ipynb", "repo_id": "deep-rl-class", "token_count": 3877 }
78
# Glossary [[glossary]] This is a community-created glossary. Contributions are welcomed! ### Agent An agent learns to **make decisions by trial and error, with rewards and punishments from the surroundings**. ### Environment An environment is a simulated world **where an agent can learn by interacting with it**. ...
deep-rl-class/units/en/unit1/glossary.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/glossary.mdx", "repo_id": "deep-rl-class", "token_count": 775 }
79
# Mid-way Quiz [[mid-way-quiz]] The best way to learn and [to avoid the illusion of competence](https://www.coursera.org/lecture/learning-how-to-learn/illusions-of-competence-BuFzf) **is to test yourself.** This will help you to find **where you need to reinforce your knowledge**. ### Q1: What are the two main appro...
deep-rl-class/units/en/unit2/mid-way-quiz.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/mid-way-quiz.mdx", "repo_id": "deep-rl-class", "token_count": 1100 }
80
# Quiz [[quiz]] The best way to learn and [to avoid the illusion of competence](https://www.coursera.org/lecture/learning-how-to-learn/illusions-of-competence-BuFzf) **is to test yourself.** This will help you to find **where you need to reinforce your knowledge**. ### Q1: We mentioned Q Learning is a tabular method....
deep-rl-class/units/en/unit3/quiz.mdx/0
{ "file_path": "deep-rl-class/units/en/unit3/quiz.mdx", "repo_id": "deep-rl-class", "token_count": 1099 }
81
# An Introduction to Unity ML-Agents [[introduction-to-ml-agents]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit7/thumbnail.png" alt="thumbnail"/> One of the challenges in Reinforcement Learning is **creating environments**. Fortunately for us, we can use game...
deep-rl-class/units/en/unit5/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit5/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 696 }
82
# Designing Multi-Agents systems For this section, you're going to watch this excellent introduction to multi-agents made by <a href="https://www.youtube.com/channel/UCq0imsn84ShAe9PBOFnoIrg"> Brian Douglas </a>. <Youtube id="qgb0gyrpiGk" /> In this video, Brian talked about how to design multi-agent systems. He sp...
deep-rl-class/units/en/unit7/multi-agent-setting.mdx/0
{ "file_path": "deep-rl-class/units/en/unit7/multi-agent-setting.mdx", "repo_id": "deep-rl-class", "token_count": 847 }
83
# Play with Huggy [[play]] Now that you've trained Huggy and pushed it to the Hub. **You will be able to play with him ❤️** For this step it’s simple: - Open the Huggy game in your browser: https://huggingface.co/spaces/ThomasSimonini/Huggy - Click on Play with my Huggy model <img src="https://huggingface.co/datase...
deep-rl-class/units/en/unitbonus1/play.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus1/play.mdx", "repo_id": "deep-rl-class", "token_count": 271 }
84
# Files for typos # Instruction: https://github.com/marketplace/actions/typos-action#getting-started [default.extend-identifiers] [default.extend-words] NIN="NIN" # NIN is used in scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py nd="np" # nd may be np (numpy) parms="parms" # parms is used in scripts/conver...
diffusers/_typos.toml/0
{ "file_path": "diffusers/_typos.toml", "repo_id": "diffusers", "token_count": 151 }
85