text
stringlengths
7
328k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
459
from dataclasses import dataclass, field from typing import List, Optional from ..core import flatten_dict @dataclass class ModelConfig: """ Arguments which define the model and tokenizer to load. """ model_name_or_path: Optional[str] = field( default=None, metadata={"help": ("The mo...
trl/trl/trainer/model_config.py/0
{ "file_path": "trl/trl/trainer/model_config.py", "repo_id": "trl", "token_count": 1309 }
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 applicable law or agreed...
accelerate/docs/source/basic_tutorials/launch.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/launch.md", "repo_id": "accelerate", "token_count": 2702 }
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/usage_guides/checkpoint.md/0
{ "file_path": "accelerate/docs/source/usage_guides/checkpoint.md", "repo_id": "accelerate", "token_count": 1156 }
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 ...
accelerate/examples/README.md/0
{ "file_path": "accelerate/examples/README.md", "repo_id": "accelerate", "token_count": 4466 }
2
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/examples/cv_example.py/0
{ "file_path": "accelerate/examples/cv_example.py", "repo_id": "accelerate", "token_count": 3205 }
3
#!/bin/bash #SBATCH --job-name=multinode #SBATCH -D . #SBATCH --output=O-%x.%j #SBATCH --error=E-%x.%j #SBATCH --nodes=4 # number of nodes #SBATCH --ntasks-per-node=1 # number of MP tasks #SBATCH --gres=gpu:4 # number of GPUs per node #SBATCH --cpus-per-task=160 # numbe...
accelerate/examples/slurm/submit_multinode.sh/0
{ "file_path": "accelerate/examples/slurm/submit_multinode.sh", "repo_id": "accelerate", "token_count": 519 }
4
#!/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 }
5
#!/usr/bin/env python # 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 # # Unles...
accelerate/src/accelerate/commands/tpu.py/0
{ "file_path": "accelerate/src/accelerate/commands/tpu.py", "repo_id": "accelerate", "token_count": 2114 }
6
# Copyright 2022 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/src/accelerate/test_utils/scripts/external_deps/test_checkpointing.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_checkpointing.py", "repo_id": "accelerate", "token_count": 4189 }
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/constants.py/0
{ "file_path": "accelerate/src/accelerate/utils/constants.py", "repo_id": "accelerate", "token_count": 1126 }
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/tqdm.py/0
{ "file_path": "accelerate/src/accelerate/utils/tqdm.py", "repo_id": "accelerate", "token_count": 433 }
9
echo "hello world" echo "this is a second command"
accelerate/tests/test_samples/test_command_file.sh/0
{ "file_path": "accelerate/tests/test_samples/test_command_file.sh", "repo_id": "accelerate", "token_count": 14 }
10
# Model arguments model_name_or_path: bigcode/starcoder2-15b model_revision: main torch_dtype: bfloat16 use_flash_attention_2: true # Data training arguments chat_template: "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% for message in messages %}{{'<|im_start|>' + me...
alignment-handbook/recipes/starchat2-15b/sft/config_v0.1.yaml/0
{ "file_path": "alignment-handbook/recipes/starchat2-15b/sft/config_v0.1.yaml", "repo_id": "alignment-handbook", "token_count": 565 }
11
# 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": 4702 }
12
repos: - repo: https://github.com/Narsil/pre-commit-rust rev: 2eed6366172ef2a5186e8785ec0e67243d7d73d0 hooks: - id: fmt name: "Rust (fmt)" - id: clippy name: "Rust (clippy)" args: [ "--tests", "--examples", "--", "-D...
candle/.pre-commit-config.yaml/0
{ "file_path": "candle/.pre-commit-config.yaml", "repo_id": "candle", "token_count": 210 }
13
# Creating a REST api webserver
candle/candle-book/src/apps/rest.md/0
{ "file_path": "candle/candle-book/src/apps/rest.md", "repo_id": "candle", "token_count": 8 }
14
//! #A simplified example in Rust of training a neural network and then using it based on the Candle Framework by Hugging Face. //! Author: Evgeny Igumnov 2023 igumnovnsk@gmail.com //! This program implements a neural network to predict the winner of the second round of elections based on the results of the first round...
candle/candle-book/src/simplified.rs/0
{ "file_path": "candle/candle-book/src/simplified.rs", "repo_id": "candle", "token_count": 2903 }
15
#[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use anyhow::Result; use candle_core::{Device, Module, Tensor}; use candle_core::quantized::{QMatMul, QTensor}; fn main() -> Result<()> { let device = Device::new_cuda(0)?; let q = Tensor::randn(0f...
candle/candle-core/examples/cuda_basics.rs/0
{ "file_path": "candle/candle-core/examples/cuda_basics.rs", "repo_id": "candle", "token_count": 550 }
16
use crate::WithDType; use cudarc; use cudarc::cudnn::safe::{Conv2dForward, Cudnn}; use cudarc::driver::{CudaSlice, CudaView, DeviceRepr, ValidAsZeroBits}; use std::cell::RefCell; use std::collections::HashMap; use std::sync::Arc; // The cudnn handles are stored per thread here rather than on the CudaDevice as they are...
candle/candle-core/src/cudnn.rs/0
{ "file_path": "candle/candle-core/src/cudnn.rs", "repo_id": "candle", "token_count": 2214 }
17
use super::{GgmlDType, QStorage}; use crate::{backend::BackendDevice, cuda_backend::WrapErr}; use crate::{CudaDevice, CudaStorage, Result}; use cudarc::driver::{CudaSlice, DeviceSlice}; pub struct QCudaStorage { data: CudaSlice<u8>, dtype: GgmlDType, device: CudaDevice, } pub const WARP_SIZE: usize = 32;...
candle/candle-core/src/quantized/cuda.rs/0
{ "file_path": "candle/candle-core/src/quantized/cuda.rs", "repo_id": "candle", "token_count": 7006 }
18
//! Tensors are N-dimensional matrixes of elements using a single data type. #![allow(clippy::redundant_closure_call)] use crate::backend::{BackendDevice, BackendStorage}; use crate::op::{ BackpropOp, BinaryOp, CmpOp, CustomOp1, CustomOp2, CustomOp3, Op, ReduceOp, UnaryOp, }; use crate::scalar::TensorOrScalar; use ...
candle/candle-core/src/tensor.rs/0
{ "file_path": "candle/candle-core/src/tensor.rs", "repo_id": "candle", "token_count": 47594 }
19
use candle_core::{ bail, quantized::{self, GgmlDType}, test_device, test_utils::to_vec2_round, Device, Module, Result, Tensor, }; use quantized::{k_quants, GgmlType}; use rand::prelude::*; const GGML_TEST_SIZE: usize = 32 * 128; const GGML_MAX_QUANTIZATION_TOTAL_ERROR: f32 = 0.002; const GGML_MAX_...
candle/candle-core/tests/quantized_tests.rs/0
{ "file_path": "candle/candle-core/tests/quantized_tests.rs", "repo_id": "candle", "token_count": 18159 }
20
use candle::Tensor; pub struct Dataset { pub train_images: Tensor, pub train_labels: Tensor, pub test_images: Tensor, pub test_labels: Tensor, pub labels: usize, } pub mod cifar; pub mod mnist;
candle/candle-datasets/src/vision/mod.rs/0
{ "file_path": "candle/candle-datasets/src/vision/mod.rs", "repo_id": "candle", "token_count": 92 }
21
/* * 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 }
22
# 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 }
23
# candle-quantized-t5 ## Seq2Seq example This example uses a quantized version of the t5 model. ```bash $ cargo run --example quantized-t5 --release -- --prompt "translate to German: A beautiful candle." ... Eine schöne Kerze. ``` ## Generating Quantized weight files The weight file is automatically retrieved fro...
candle/candle-examples/examples/quantized-t5/README.md/0
{ "file_path": "candle/candle-examples/examples/quantized-t5/README.md", "repo_id": "candle", "token_count": 683 }
24
# candle-repvgg [RepVGG: Making VGG-style ConvNets Great Again](https://arxiv.org/abs/2101.03697). This candle implementation uses a pre-trained RepVGG network for inference. The classification head has been trained on the ImageNet dataset and returns the probabilities for the top-5 classes. ## Running an example `...
candle/candle-examples/examples/repvgg/README.md/0
{ "file_path": "candle/candle-examples/examples/repvgg/README.md", "repo_id": "candle", "token_count": 254 }
25
[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 }
26
# candle-flash-attn
candle/candle-flash-attn/README.md/0
{ "file_path": "candle/candle-flash-attn/README.md", "repo_id": "candle", "token_count": 8 }
27
use anyhow::Result; use candle::{DType, Device, IndexOp, Tensor, D}; fn to_vec3_round(t: Tensor, digits: i32) -> Result<Vec<Vec<Vec<f32>>>> { let b = 10f32.powi(digits); let t = t.to_vec3::<f32>()?; let t = t .iter() .map(|t| { t.iter() .map(|t| t.iter().map(|t| ...
candle/candle-flash-attn/tests/flash_attn_tests.rs/0
{ "file_path": "candle/candle-flash-attn/tests/flash_attn_tests.rs", "repo_id": "candle", "token_count": 2787 }
28
#include "cuda_utils.cuh" #include<stdint.h> #define WHERE_OP(TYPENAME, ID_TYPENAME, FN_NAME) \ extern "C" __global__ void FN_NAME( \ const size_t numel, \ const size_t num_dims, \ const size_t *info, \ const ID_TYPENAME *ids, \ const TYPENAME *t, \ const TYPENAME *f, \ TYPENAME *out \ ) ...
candle/candle-kernels/src/ternary.cu/0
{ "file_path": "candle/candle-kernels/src/ternary.cu", "repo_id": "candle", "token_count": 1159 }
29
#include <metal_stdlib> #include <metal_math> # using namespace metal; METAL_FUNC uint get_strided_index( uint idx, constant size_t &num_dims, constant size_t *dims, constant size_t *strides ) { uint strided_i = 0; for (uint d = 0; d < num_dims; d++) { uint dim_idx = num_dims - 1 - d; ...
candle/candle-metal-kernels/src/unary.metal/0
{ "file_path": "candle/candle-metal-kernels/src/unary.metal", "repo_id": "candle", "token_count": 2340 }
30
//! Variable initialization. // This is based on: // https://github.com/pytorch/pytorch/blob/07107919297db3f8ab37f11c12666b6d6d5f692e/torch/nn/init.py# use candle::{DType, Device, Result, Shape, Tensor, Var}; /// Number of features as input or output of a layer. /// In Kaiming initialization, choosing `FanIn` preserve...
candle/candle-nn/src/init.rs/0
{ "file_path": "candle/candle-nn/src/init.rs", "repo_id": "candle", "token_count": 2212 }
31
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{test_utils::to_vec3_round, Device, Result, Tensor}; #[test] fn softmax() -> Result<()> { let device = &Device::Cpu; let data = &[[[3f32, 1., 4.], [1., 5., 9.]], [[2., 1., 7.], [8., 2.,...
candle/candle-nn/tests/ops.rs/0
{ "file_path": "candle/candle-nn/tests/ops.rs", "repo_id": "candle", "token_count": 1170 }
32
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 }
33
from typing import TypeVar, Union, Sequence _T = TypeVar("_T") _ArrayLike = Union[ _T, Sequence[_T], Sequence[Sequence[_T]], Sequence[Sequence[Sequence[_T]]], Sequence[Sequence[Sequence[Sequence[_T]]]], ] CPU: str = "cpu" CUDA: str = "cuda" Device = TypeVar("Device", CPU, CUDA) Scalar = Union[i...
candle/candle-pyo3/py_src/candle/typing/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/typing/__init__.py", "repo_id": "candle", "token_count": 166 }
34
from candle import Tensor from candle import rand import pytest def test_absolute_shapes_are_valid(): a = rand((10, 20)) assert a.shape == (10, 20) b = rand(10, 20) assert b.shape == (10, 20) pytest.raises(OverflowError, lambda: rand((10, 20, -1))) pytest.raises(OverflowError, lambda: rand(-1...
candle/candle-pyo3/tests/native/test_shape.py/0
{ "file_path": "candle/candle-pyo3/tests/native/test_shape.py", "repo_id": "candle", "token_count": 385 }
35
use candle::{Result, Tensor, D}; use candle_nn as nn; use nn::{Module, VarBuilder}; // Based on the Python version from torchvision. // https://github.com/pytorch/vision/blob/0d75d9e5516f446c9c0ef93bd4ed9fea13992d06/torchvision/models/efficientnet.py#L47 #[derive(Debug, Clone, Copy)] pub struct MBConvConfig { expa...
candle/candle-transformers/src/models/efficientnet.rs/0
{ "file_path": "candle/candle-transformers/src/models/efficientnet.rs", "repo_id": "candle", "token_count": 5123 }
36
pub mod bert; pub mod bigcode; pub mod blip; pub mod blip_text; pub mod chatglm; pub mod convmixer; pub mod convnext; pub mod dinov2; pub mod distilbert; pub mod efficientnet; pub mod efficientvit; pub mod encodec; pub mod falcon; pub mod gemma; pub mod jina_bert; pub mod llama; pub mod llama2_c; pub mod llama2_c_weigh...
candle/candle-transformers/src/models/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/mod.rs", "repo_id": "candle", "token_count": 441 }
37
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 }
38
// 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 }
39
use crate::models::with_tracing::QMatMul; use crate::quantized_var_builder::VarBuilder; 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, vb: VarBuilder) -> Result<Self>...
candle/candle-transformers/src/quantized_nn.rs/0
{ "file_path": "candle/candle-transformers/src/quantized_nn.rs", "repo_id": "candle", "token_count": 1534 }
40
<!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 }
41
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 }
42
// Audio processing code, adapted from whisper.cpp // https://github.com/ggerganov/whisper.cpp use super::worker; pub trait Float: num_traits::Float + num_traits::FloatConst + num_traits::NumAssign {} impl Float for f32 {} impl Float for f64 {} // https://github.com/ggerganov/whisper.cpp/blob/4774d2feb01a772a15de81f...
candle/candle-wasm-examples/whisper/src/audio.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/audio.rs", "repo_id": "candle", "token_count": 3162 }
43
use yew_agent::PublicWorker; fn main() { console_error_panic_hook::set_once(); candle_wasm_example_yolo::Worker::register(); }
candle/candle-wasm-examples/yolo/src/bin/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/bin/worker.rs", "repo_id": "candle", "token_count": 53 }
44
.DS_Store node_modules /build /.svelte-kit /package .env .env.* !.env.example # Ignore files for PNPM, NPM and YARN pnpm-lock.yaml package-lock.json yarn.lock
chat-ui/.eslintignore/0
{ "file_path": "chat-ui/.eslintignore", "repo_id": "chat-ui", "token_count": 69 }
45
import fs from "fs"; const SECRET_CONFIG = fs.existsSync(".env.SECRET_CONFIG") ? fs.readFileSync(".env.SECRET_CONFIG", "utf8") : process.env.SECRET_CONFIG; if (!SECRET_CONFIG) { throw new Error( "SECRET_CONFIG is not defined. Please provide it either in a file or as an environment variable." ); } // Read the c...
chat-ui/scripts/updateLocalEnv.ts/0
{ "file_path": "chat-ui/scripts/updateLocalEnv.ts", "repo_id": "chat-ui", "token_count": 217 }
46
<script lang="ts"> import { base } from "$app/paths"; import { page } from "$app/stores"; import { PUBLIC_APP_DESCRIPTION, PUBLIC_APP_NAME } from "$env/static/public"; import LogoHuggingFaceBorderless from "$lib/components/icons/LogoHuggingFaceBorderless.svelte"; import Modal from "$lib/components/Modal.svelte"; ...
chat-ui/src/lib/components/LoginModal.svelte/0
{ "file_path": "chat-ui/src/lib/components/LoginModal.svelte", "repo_id": "chat-ui", "token_count": 917 }
47
<script lang="ts"> export let classNames = ""; export let label = "Copied"; export let position = "left-1/2 top-full transform -translate-x-1/2 translate-y-2"; </script> <div class=" pointer-events-none absolute rounded bg-black px-2 py-1 font-normal leading-tight text-white shadow transition-opacity {position...
chat-ui/src/lib/components/Tooltip.svelte/0
{ "file_path": "chat-ui/src/lib/components/Tooltip.svelte", "repo_id": "chat-ui", "token_count": 216 }
48
import { buildPrompt } from "$lib/buildPrompt"; import { textGenerationStream } from "@huggingface/inference"; import { z } from "zod"; import type { Endpoint } from "../endpoints"; export const endpointAwsParametersSchema = z.object({ weight: z.number().int().positive().default(1), model: z.any(), type: z.literal(...
chat-ui/src/lib/server/endpoints/aws/endpointAws.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/aws/endpointAws.ts", "repo_id": "chat-ui", "token_count": 558 }
49
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 }
50
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 }
51
import type { Message } from "./Message"; export type LegacyParamatersTemplateInput = { preprompt?: string; userMessageToken: string; userMessageEndToken: string; assistantMessageToken: string; assistantMessageEndToken: string; }; export type ChatTemplateInput = { messages: Pick<Message, "from" | "content">[]; ...
chat-ui/src/lib/types/Template.ts/0
{ "file_path": "chat-ui/src/lib/types/Template.ts", "repo_id": "chat-ui", "token_count": 105 }
52
// Approximate width from which we disable autofocus const TABLET_VIEWPORT_WIDTH = 768; export function isDesktop(window: Window) { const { innerWidth } = window; return innerWidth > TABLET_VIEWPORT_WIDTH; }
chat-ui/src/lib/utils/isDesktop.ts/0
{ "file_path": "chat-ui/src/lib/utils/isDesktop.ts", "repo_id": "chat-ui", "token_count": 67 }
53
import type { Conversation } from "$lib/types/Conversation"; import type { Message } from "$lib/types/Message"; import { v4 } from "uuid"; export function addSibling( conv: Pick<Conversation, "messages" | "rootMessageId">, message: Omit<Message, "id">, siblingId: Message["id"] ): Message["id"] { if (conv.messages....
chat-ui/src/lib/utils/tree/addSibling.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/addSibling.ts", "repo_id": "chat-ui", "token_count": 439 }
54
import { models } from "$lib/server/models"; export async function GET() { const res = models.map((model) => ({ id: model.id, name: model.name, websiteUrl: model.websiteUrl, modelUrl: model.modelUrl, datasetName: model.datasetName, datasetUrl: model.datasetUrl, displayName: model.displayName, descript...
chat-ui/src/routes/api/models/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/models/+server.ts", "repo_id": "chat-ui", "token_count": 206 }
55
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": 261 }
56
import { collections } from "$lib/server/database"; import { z } from "zod"; import { authCondition } from "$lib/server/auth"; import { DEFAULT_SETTINGS } from "$lib/types/Settings"; export async function POST({ request, locals }) { const body = await request.json(); const { ethicsModalAccepted, ...settings } = z ...
chat-ui/src/routes/settings/(nav)/+server.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/+server.ts", "repo_id": "chat-ui", "token_count": 401 }
57
import { sveltekit } from "@sveltejs/kit/vite"; import { defineConfig, type PluginOption } from "vite"; import Icons from "unplugin-icons/vite"; import { promises } from "fs"; // used to load fonts server side for thumbnail generation function loadTTFAsArrayBuffer(): PluginOption { return { name: "load-ttf-as-array...
chat-ui/vite.config.ts/0
{ "file_path": "chat-ui/vite.config.ts", "repo_id": "chat-ui", "token_count": 276 }
58
{ "license": "Apache-2.0", "creators": [ { "affiliation": "Hugging Face", "name": "Quentin Lhoest" }, { "orcid": "0000-0003-1727-1045", "affiliation": "Hugging Face", "name": "Albert Villanova del Moral" }, { ...
datasets/.zenodo.json/0
{ "file_path": "datasets/.zenodo.json", "repo_id": "datasets", "token_count": 1953 }
59
import json import sys def format_json_to_md(input_json_file, output_md_file): with open(input_json_file, encoding="utf-8") as f: results = json.load(f) output_md = ["<details>", "<summary>Show updated benchmarks!</summary>", " "] for benchmark_name in sorted(results): benchmark_res = re...
datasets/benchmarks/format.py/0
{ "file_path": "datasets/benchmarks/format.py", "repo_id": "datasets", "token_count": 746 }
60
# Batch mapping Combining the utility of [`Dataset.map`] with batch mode is very powerful. It allows you to speed up processing, and freely control the size of the generated dataset. ## Need for speed The primary objective of batch mapping is to speed up processing. Often times, it is faster to work with batches of...
datasets/docs/source/about_map_batch.mdx/0
{ "file_path": "datasets/docs/source/about_map_batch.mdx", "repo_id": "datasets", "token_count": 722 }
61
# Metrics <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> Metrics are important for eval...
datasets/docs/source/how_to_metrics.mdx/0
{ "file_path": "datasets/docs/source/how_to_metrics.mdx", "repo_id": "datasets", "token_count": 3350 }
62
# Loading methods Methods for listing and loading datasets and metrics: ## Datasets [[autodoc]] datasets.list_datasets [[autodoc]] datasets.load_dataset [[autodoc]] datasets.load_from_disk [[autodoc]] datasets.load_dataset_builder [[autodoc]] datasets.get_dataset_config_names [[autodoc]] datasets.get_dataset_in...
datasets/docs/source/package_reference/loading_methods.mdx/0
{ "file_path": "datasets/docs/source/package_reference/loading_methods.mdx", "repo_id": "datasets", "token_count": 809 }
63
# Use with JAX This document is a quick introduction to using `datasets` with JAX, with a particular focus on how to get `jax.Array` objects out of our datasets, and how to use them to train JAX models. <Tip> `jax` and `jaxlib` are required to reproduce to code above, so please make sure you install them as `pip ins...
datasets/docs/source/use_with_jax.mdx/0
{ "file_path": "datasets/docs/source/use_with_jax.mdx", "repo_id": "datasets", "token_count": 2646 }
64
# Copyright 2021 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/chrf/chrf.py/0
{ "file_path": "datasets/metrics/chrf/chrf.py", "repo_id": "datasets", "token_count": 3170 }
65
# 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/f1/f1.py/0
{ "file_path": "datasets/metrics/f1/f1.py", "repo_id": "datasets", "token_count": 2364 }
66
# coding=utf-8 # 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 app...
datasets/metrics/mauve/mauve.py/0
{ "file_path": "datasets/metrics/mauve/mauve.py", "repo_id": "datasets", "token_count": 2588 }
67
# 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/roc_auc/roc_auc.py/0
{ "file_path": "datasets/metrics/roc_auc/roc_auc.py", "repo_id": "datasets", "token_count": 3792 }
68
# 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/squad_v2/squad_v2.py/0
{ "file_path": "datasets/metrics/squad_v2/squad_v2.py", "repo_id": "datasets", "token_count": 2564 }
69
[tool.ruff] line-length = 119 [tool.ruff.lint] # Ignored rules: # "E501" -> line length violation # "F821" -> undefined named in type annotation (e.g. Literal["something"]) # "C901" -> `function_name` is too complex ignore = ["E501", "F821", "C901"] select = ["C", "E", "F", "I", "W"] [tool.ruff.lint.isort] line...
datasets/pyproject.toml/0
{ "file_path": "datasets/pyproject.toml", "repo_id": "datasets", "token_count": 236 }
70
import os import re from functools import partial from glob import has_magic from pathlib import Path, PurePath from typing import Callable, Dict, List, Optional, Set, Tuple, Union import huggingface_hub from fsspec.core import url_to_fs from fsspec.implementations.http import HTTPFileSystem from huggingface_hub impor...
datasets/src/datasets/data_files.py/0
{ "file_path": "datasets/src/datasets/data_files.py", "repo_id": "datasets", "token_count": 13855 }
71
import s3fs from ..utils.deprecation_utils import deprecated @deprecated("Use s3fs.S3FileSystem instead.") class S3FileSystem(s3fs.S3FileSystem): """ `datasets.filesystems.S3FileSystem` is a subclass of [`s3fs.S3FileSystem`](https://s3fs.readthedocs.io/en/latest/api.html). Users can use this class to ac...
datasets/src/datasets/filesystems/s3filesystem.py/0
{ "file_path": "datasets/src/datasets/filesystems/s3filesystem.py", "repo_id": "datasets", "token_count": 2170 }
72
import os from typing import BinaryIO, Optional, Union import fsspec import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAG...
datasets/src/datasets/io/parquet.py/0
{ "file_path": "datasets/src/datasets/io/parquet.py", "repo_id": "datasets", "token_count": 2585 }
73
import abc import copy import dataclasses from dataclasses import dataclass from typing import ClassVar, Dict, Type, TypeVar from ..features import Features T = TypeVar("T", bound="TaskTemplate") @dataclass(frozen=True) class TaskTemplate(abc.ABC): # `task` is not a ClassVar since we want it to be part of the ...
datasets/src/datasets/tasks/base.py/0
{ "file_path": "datasets/src/datasets/tasks/base.py", "repo_id": "datasets", "token_count": 417 }
74
""" Utilities for working with the local dataset cache. This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp Copyright by the AllenNLP authors. """ import copy import io import json import multiprocessing import os import posixpath import re import shutil import sys import time import ...
datasets/src/datasets/utils/file_utils.py/0
{ "file_path": "datasets/src/datasets/utils/file_utils.py", "repo_id": "datasets", "token_count": 11061 }
75
import numpy as np def approximate_mode(class_counts, n_draws, rng): """Computes approximate mode of multivariate hypergeometric. This is an approximation to the mode of the multivariate hypergeometric given by class_counts and n_draws. It shouldn't be off by more than one. It is the mostly likely...
datasets/src/datasets/utils/stratify.py/0
{ "file_path": "datasets/src/datasets/utils/stratify.py", "repo_id": "datasets", "token_count": 1674 }
76
import pytest import datasets import datasets.config # Import fixture modules as plugins pytest_plugins = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"] def pytest_collection_modifyitems(config, items): # Mark tests as "unit" by default if not marked as "integration" (or already marked...
datasets/tests/conftest.py/0
{ "file_path": "datasets/tests/conftest.py", "repo_id": "datasets", "token_count": 957 }
77
import posixpath from pathlib import Path from unittest.mock import patch import pytest from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path from fsspec.registry import _registry as _fsspec_registry class MockFileSystem(AbstractFileSystem): protocol = "mock" def __ini...
datasets/tests/fixtures/fsspec.py/0
{ "file_path": "datasets/tests/fixtures/fsspec.py", "repo_id": "datasets", "token_count": 1757 }
78
import shutil import textwrap import numpy as np import pytest from datasets import ClassLabel, Features, Image, Value from datasets.data_files import DataFilesDict, get_data_patterns from datasets.download.streaming_download_manager import StreamingDownloadManager from datasets.packaged_modules.imagefolder.imagefold...
datasets/tests/packaged_modules/test_imagefolder.py/0
{ "file_path": "datasets/tests/packaged_modules/test_imagefolder.py", "repo_id": "datasets", "token_count": 8692 }
79
import os import zipfile import pytest from datasets.utils.extract import ( Bzip2Extractor, Extractor, GzipExtractor, Lz4Extractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lz4, require_py7zr, require_zstandard @pyte...
datasets/tests/test_extract.py/0
{ "file_path": "datasets/tests/test_extract.py", "repo_id": "datasets", "token_count": 2984 }
80
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def test_offline_with_timeout(): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT): with pytest.raises(Reques...
datasets/tests/test_offline_util.py/0
{ "file_path": "datasets/tests/test_offline_util.py", "repo_id": "datasets", "token_count": 382 }
81
<jupyter_start><jupyter_text>Unit 8 Part 2: Advanced Deep Reinforcement Learning. Using Sample Factory to play Doom from pixelsIn this notebook, we will learn how to train a Deep Neural Network to collect objects in a 3D environment based on the game of Doom, a video of the resulting policy is shown below. We train thi...
deep-rl-class/notebooks/unit8/unit8_part2.ipynb/0
{ "file_path": "deep-rl-class/notebooks/unit8/unit8_part2.ipynb", "repo_id": "deep-rl-class", "token_count": 4950 }
82
# The Reinforcement Learning Framework [[the-reinforcement-learning-framework]] ## The RL Process [[the-rl-process]] <figure> <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit1/RL_process.jpg" alt="The RL process" width="100%"> <figcaption>The RL Process: a loop o...
deep-rl-class/units/en/unit1/rl-framework.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/rl-framework.mdx", "repo_id": "deep-rl-class", "token_count": 2504 }
83
# Introducing Q-Learning [[q-learning]] ## What is Q-Learning? [[what-is-q-learning]] Q-Learning is an **off-policy value-based method that uses a TD approach to train its action-value function:** - *Off-policy*: we'll talk about that at the end of this unit. - *Value-based method*: finds the optimal policy indirectl...
deep-rl-class/units/en/unit2/q-learning.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/q-learning.mdx", "repo_id": "deep-rl-class", "token_count": 2955 }
84
# Glossary This is a community-created glossary. Contributions are welcome! - **Deep Q-Learning:** A value-based deep reinforcement learning algorithm that uses a deep neural network to approximate Q-values for actions in a given state. The goal of Deep Q-learning is to find the optimal policy that maximizes the exp...
deep-rl-class/units/en/unit4/glossary.mdx/0
{ "file_path": "deep-rl-class/units/en/unit4/glossary.mdx", "repo_id": "deep-rl-class", "token_count": 421 }
85
# Additional Readings [[additional-readings]] ## Bias-variance tradeoff in Reinforcement Learning If you want to dive deeper into the question of variance and bias tradeoff in Deep Reinforcement Learning, you can check out these two articles: - [Making Sense of the Bias / Variance Trade-off in (Deep) Reinforcement L...
deep-rl-class/units/en/unit6/additional-readings.mdx/0
{ "file_path": "deep-rl-class/units/en/unit6/additional-readings.mdx", "repo_id": "deep-rl-class", "token_count": 321 }
86
# Introducing the Clipped Surrogate Objective Function ## Recap: The Policy Objective Function Let’s remember what the objective is to optimize in Reinforce: <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/lpg.jpg" alt="Reinforce"/> The idea was that by taking ...
deep-rl-class/units/en/unit8/clipped-surrogate-objective.mdx/0
{ "file_path": "deep-rl-class/units/en/unit8/clipped-surrogate-objective.mdx", "repo_id": "deep-rl-class", "token_count": 1386 }
87
# Optuna Tutorial [[optuna]] The content below comes from [Antonin's Raffin ICRA 2022 presentations](https://araffin.github.io/tools-for-robotic-rl-icra2022/), he's one of the founders of Stable-Baselines and RL-Baselines3-Zoo. ## The theory behind Hyperparameter tuning <Youtube id="AidFTOdGNFQ" /> ## Optuna Tuto...
deep-rl-class/units/en/unitbonus2/optuna.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus2/optuna.mdx", "repo_id": "deep-rl-class", "token_count": 182 }
88
import argparse import sys sys.path.append(".") from base_classes import ImageToImageBenchmark, TurboImageToImageBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="runwayml/stable-diffusion-v1-5", ...
diffusers/benchmarks/benchmark_sd_img.py/0
{ "file_path": "diffusers/benchmarks/benchmark_sd_img.py", "repo_id": "diffusers", "token_count": 415 }
89
<!--- 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...
diffusers/docs/README.md/0
{ "file_path": "diffusers/docs/README.md", "repo_id": "diffusers", "token_count": 3145 }
90
<!--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/pndm.md/0
{ "file_path": "diffusers/docs/source/en/api/schedulers/pndm.md", "repo_id": "diffusers", "token_count": 304 }
91
<!--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/index.md/0
{ "file_path": "diffusers/docs/source/en/index.md", "repo_id": "diffusers", "token_count": 1316 }
92
# Adapt a model to a new task Many diffusion systems share the same components, allowing you to adapt a pretrained model for one task to an entirely different task. This guide will show you how to adapt a pretrained text-to-image model for inpainting by initializing and modifying the architecture of a pretrained [`UN...
diffusers/docs/source/en/training/adapt_a_model.md/0
{ "file_path": "diffusers/docs/source/en/training/adapt_a_model.md", "repo_id": "diffusers", "token_count": 779 }
93
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/training/unconditional_training.md/0
{ "file_path": "diffusers/docs/source/en/training/unconditional_training.md", "repo_id": "diffusers", "token_count": 2949 }
94
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/diffedit.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/diffedit.md", "repo_id": "diffusers", "token_count": 3847 }
95
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/pipeline_overview.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/pipeline_overview.md", "repo_id": "diffusers", "token_count": 327 }
96
- sections: - local: index title: 🧨 Diffusers - local: quicktour title: クイックツアー - local: stable_diffusion title: 有効で効率の良い拡散モデル - local: installation title: インストール title: はじめに - sections: - local: tutorials/tutorial_overview title: 概要 - local: tutorials/autopipeline title: AutoPipe...
diffusers/docs/source/ja/_toctree.yml/0
{ "file_path": "diffusers/docs/source/ja/_toctree.yml", "repo_id": "diffusers", "token_count": 166 }
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/ko/optimization/onnx.md/0
{ "file_path": "diffusers/docs/source/ko/optimization/onnx.md", "repo_id": "diffusers", "token_count": 1437 }
98