text
stringlengths
7
328k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
459
// File only needed for VSCode users to have proper Docker based interpreters { "name": "accelerate_dev_environment", "build": { // ACTION NEEDED: comment/uncomment the relevant line depending on whether you are in a CPU/GPU environment "dockerfile": "../docker/accelerate-cpu/Dockerfile" // ...
accelerate/.devcontainer/devcontainer.json/0
{ "file_path": "accelerate/.devcontainer/devcontainer.json", "repo_id": "accelerate", "token_count": 459 }
0
<!--- 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/README.md/0
{ "file_path": "accelerate/README.md", "repo_id": "accelerate", "token_count": 4493 }
1
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/basic_tutorials/tpu.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/tpu.md", "repo_id": "accelerate", "token_count": 629 }
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/fsdp.md/0
{ "file_path": "accelerate/docs/source/usage_guides/fsdp.md", "repo_id": "accelerate", "token_count": 3064 }
3
# 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/examples/by_feature/cross_validation.py/0
{ "file_path": "accelerate/examples/by_feature/cross_validation.py", "repo_id": "accelerate", "token_count": 4458 }
4
{ "fp16": { "enabled": true, "loss_scale": 0, "loss_scale_window": 1000, "initial_scale_power": 16, "hysteresis": 2, "min_loss_scale": 1 }, "optimizer": { "type": "AdamW", "params": { "lr": "auto", "weight_decay": "auto"...
accelerate/examples/deepspeed_config_templates/zero_stage3_config.json/0
{ "file_path": "accelerate/examples/deepspeed_config_templates/zero_stage3_config.json", "repo_id": "accelerate", "token_count": 657 }
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/manim_animations/big_model_inference/stage_4.py/0
{ "file_path": "accelerate/manim_animations/big_model_inference/stage_4.py", "repo_id": "accelerate", "token_count": 2919 }
6
#!/usr/bin/env python # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
accelerate/src/accelerate/commands/config/sagemaker.py/0
{ "file_path": "accelerate/src/accelerate/commands/config/sagemaker.py", "repo_id": "accelerate", "token_count": 4784 }
7
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/inference.py/0
{ "file_path": "accelerate/src/accelerate/inference.py", "repo_id": "accelerate", "token_count": 2991 }
8
# Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
accelerate/src/accelerate/test_utils/scripts/external_deps/test_pippy.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_pippy.py", "repo_id": "accelerate", "token_count": 1729 }
9
# 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/src/accelerate/utils/fsdp_utils.py/0
{ "file_path": "accelerate/src/accelerate/utils/fsdp_utils.py", "repo_id": "accelerate", "token_count": 4830 }
10
{ "fp16": { "enabled": "auto", "loss_scale": 0, "loss_scale_window": 1000, "initial_scale_power": 16, "hysteresis": 2, "min_loss_scale": 1 }, "bf16": { "enabled": "auto" }, "optimizer": { "type": "AdamW", "params": { ...
accelerate/tests/deepspeed/ds_config_zero3.json/0
{ "file_path": "accelerate/tests/deepspeed/ds_config_zero3.json", "repo_id": "accelerate", "token_count": 825 }
11
# 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_hooks.py/0
{ "file_path": "accelerate/tests/test_hooks.py", "repo_id": "accelerate", "token_count": 6551 }
12
# 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_tracking.py/0
{ "file_path": "accelerate/tests/test_tracking.py", "repo_id": "accelerate", "token_count": 10034 }
13
# Model arguments model_name_or_path: mistralai/Mistral-7B-v0.1 model_revision: main torch_dtype: bfloat16 use_flash_attention_2: true # Data training arguments chat_template: "{% for message in messages %}\n{% if message['role'] == 'user' %}\n{{ '<|user|>\n' + message['content'] + eos_token }}\n{% elif message['role'...
alignment-handbook/recipes/constitutional-ai/sft/config_grok.yaml/0
{ "file_path": "alignment-handbook/recipes/constitutional-ai/sft/config_grok.yaml", "repo_id": "alignment-handbook", "token_count": 610 }
14
# Model arguments model_name_or_path: mistralai/Mistral-7B-v0.1 model_revision: main torch_dtype: bfloat16 use_flash_attention_2: true # Data training arguments chat_template: "{% for message in messages %}\n{% if message['role'] == 'user' %}\n{{ '<|user|>\n' + message['content'] + eos_token }}\n{% elif message['role'...
alignment-handbook/recipes/zephyr-7b-beta/sft/config_full.yaml/0
{ "file_path": "alignment-handbook/recipes/zephyr-7b-beta/sft/config_full.yaml", "repo_id": "alignment-handbook", "token_count": 568 }
15
# 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/release.py/0
{ "file_path": "alignment-handbook/src/alignment/release.py", "repo_id": "alignment-handbook", "token_count": 1384 }
16
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, ...
candle/LICENSE-APACHE/0
{ "file_path": "candle/LICENSE-APACHE", "repo_id": "candle", "token_count": 3168 }
17
# Porting a custom kernel
candle/candle-book/src/cuda/porting.md/0
{ "file_path": "candle/candle-book/src/cuda/porting.md", "repo_id": "candle", "token_count": 7 }
18
# Simplified ## How its works This program implements a neural network to predict the winner of the second round of elections based on the results of the first round. Basic moments: 1. A multilayer perceptron with two hidden layers is used. The first hidden layer has 4 neurons, the second has 2 neurons. 2. The inpu...
candle/candle-book/src/training/simplified.md/0
{ "file_path": "candle/candle-book/src/training/simplified.md", "repo_id": "candle", "token_count": 530 }
19
use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT}; use crate::{CpuStorage, DType, Layout, Result, Shape}; pub trait BackendStorage: Sized { type Device: BackendDevice; fn try_clone(&self, _: &Layout) -> Result<Self>; fn dtype(&self) -> DType; fn device(&self) -> &Self::Device; // Maybe this...
candle/candle-core/src/backend.rs/0
{ "file_path": "candle/candle-core/src/backend.rs", "repo_id": "candle", "token_count": 1920 }
20
#![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": 2782 }
21
//! Support for the GGUF file format. //! //! Spec: https://github.com/philpax/ggml/blob/gguf-spec/docs/gguf.md use super::{GgmlDType, QTensor}; use crate::{Device, Result}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use std::collections::HashMap; pub const DEFAULT_ALIGNMENT: u64 = 32; #[derive(Debu...
candle/candle-core/src/quantized/gguf_file.rs/0
{ "file_path": "candle/candle-core/src/quantized/gguf_file.rs", "repo_id": "candle", "token_count": 9397 }
22
// Variables are wrappers around tensors that can be modified, they are typically used for holding // weights and being modified by gradient descent. // We do not expose a public way to create variables as this would break the invariant that the // tensor within a variable is actually with `is_variable` set to `true`. ...
candle/candle-core/src/variable.rs/0
{ "file_path": "candle/candle-core/src/variable.rs", "repo_id": "candle", "token_count": 2057 }
23
# candle-bert Bert is a general large language model. In this example it can be used for two different tasks: - Compute sentence embeddings for a prompt. - Compute similarities between a set of sentences. ## Sentence embeddings Bert is used to compute the sentence embeddings for a prompt. The model weights are down...
candle/candle-examples/examples/bert/README.md/0
{ "file_path": "candle/candle-examples/examples/bert/README.md", "repo_id": "candle", "token_count": 1564 }
24
# candle-distilbert DistilBert is a distiled version of the Bert model. ## Sentence embeddings DistilBert is used to compute the sentence embeddings for a prompt. The model weights are downloaded from the hub on the first run. ```bash cargo run --example distilbert --release -- --prompt "Here is a test sentence" >...
candle/candle-examples/examples/distilbert/README.md/0
{ "file_path": "candle/candle-examples/examples/distilbert/README.md", "repo_id": "candle", "token_count": 367 }
25
// https://github.com/karpathy/llama2.c #[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use candle_transformers::models::llama2_c as model; use candle_transformers::models::llama2_c_weights as weights; use candle_transformers::models::quantized_llama2_c...
candle/candle-examples/examples/llama2-c/main.rs/0
{ "file_path": "candle/candle-examples/examples/llama2-c/main.rs", "repo_id": "candle", "token_count": 6004 }
26
# candle-mixtral: 8x7b LLM using a sparse mixture of experts. Mixtral-8x7B-v0.1 is a pretrained generative LLM with 56 billion parameters. - [Blog post](https://mistral.ai/news/mixtral-of-experts/) from Mistral announcing the model release. - [Model card](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1) on the Hu...
candle/candle-examples/examples/mixtral/README.md/0
{ "file_path": "candle/candle-examples/examples/mixtral/README.md", "repo_id": "candle", "token_count": 322 }
27
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use std::io::Write; use tokenizers::Tokenizer; use candle::quantized::{ggml_file, gguf_file}; use candle::Tensor; use candle_transformers::generation::LogitsProcessor; use c...
candle/candle-examples/examples/quantized/main.rs/0
{ "file_path": "candle/candle-examples/examples/quantized/main.rs", "repo_id": "candle", "token_count": 11416 }
28
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::resnet; use clap::{Parser, ValueEnum}; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { #[val...
candle/candle-examples/examples/resnet/main.rs/0
{ "file_path": "candle/candle-examples/examples/resnet/main.rs", "repo_id": "candle", "token_count": 1288 }
29
// https://github.com/openai/whisper/blob/main/whisper/model.py/rgs // TODO: // - Batch size greater than 1. // - More token filters (SuppressBlanks, ApplyTimestampRules). #[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use anyhow::{Error as E, Result};...
candle/candle-examples/examples/whisper/main.rs/0
{ "file_path": "candle/candle-examples/examples/whisper/main.rs", "repo_id": "candle", "token_count": 10704 }
30
/****************************************************************************** * Copyright (c) 2023, Tri Dao. ******************************************************************************/ #pragma once #include <cuda.h> #include <vector> constexpr int TOTAL_DIM = 0; constexpr int H_DIM = 1; constexpr int D_DIM =...
candle/candle-flash-attn/kernels/flash.h/0
{ "file_path": "candle/candle-flash-attn/kernels/flash.h", "repo_id": "candle", "token_count": 2033 }
31
#include "cuda_utils.cuh" #include<stdint.h> #define AFFINE_OP(TYPENAME, FN_NAME) \ extern "C" __global__ void FN_NAME( \ const size_t numel, \ const size_t num_dims, \ const size_t *info, \ const TYPENAME *inp, \ TYPENAME *out, \ const TYPENAME mul, \ const TYPENAME add \ ) { \ cons...
candle/candle-kernels/src/affine.cu/0
{ "file_path": "candle/candle-kernels/src/affine.cu", "repo_id": "candle", "token_count": 659 }
32
#include <metal_stdlib> METAL_FUNC uint get_strided_index( uint idx, constant size_t &num_dims, constant size_t *dims, constant size_t *strides ) { uint strided_i = 0; for (uint d = 0; d < num_dims; d++) { uint dim_idx = num_dims - 1 - d; strided_i += (idx % dims[dim_idx]) * str...
candle/candle-metal-kernels/src/affine.metal/0
{ "file_path": "candle/candle-metal-kernels/src/affine.metal", "repo_id": "candle", "token_count": 1464 }
33
use candle_metal_kernels::{call_unary_contiguous, call_unary_strided, unary, Kernels}; use half::{bf16, f16}; use metal::objc::rc::autoreleasepool; use metal::{Device, MTLResourceOptions}; use rand; use std::any::type_name; use std::time::Instant; fn main() { let device = Device::system_default().unwrap(); let...
candle/candle-metal-kernels/tmp/unary.rs/0
{ "file_path": "candle/candle-metal-kernels/tmp/unary.rs", "repo_id": "candle", "token_count": 3489 }
34
use candle::{Result, Tensor}; /// The negative log likelihood loss. /// /// Arguments /// /// * [inp]: The input tensor of dimensions `N, C` where `N` is the batch size and `C` the number /// of categories. This is expected to contain log probabilities. /// * [target]: The ground truth labels as a tensor of u...
candle/candle-nn/src/loss.rs/0
{ "file_path": "candle/candle-nn/src/loss.rs", "repo_id": "candle", "token_count": 1040 }
35
# candle-onnx This crate adds ONNX support to candle ## FAQ #### Missing protoc installation when compiling candle-onnx The candle-onnx dependency prost-build no longer comes bundled with prost binaries. This could cause the following error when attempting to compile candle-onnx: ``` error: failed to run custom bu...
candle/candle-onnx/README.md/0
{ "file_path": "candle/candle-onnx/README.md", "repo_id": "candle", "token_count": 180 }
36
# Generated content DO NOT EDIT from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence from os import PathLike from candle.typing import _ArrayLike, Device, Scalar, Index, Shape from candle import Tensor, DType, QTensor @staticmethod def avg_pool2d(tensor: Tensor, ksize: int, stride: int = 1) -...
candle/candle-pyo3/py_src/candle/functional/__init__.pyi/0
{ "file_path": "candle/candle-pyo3/py_src/candle/functional/__init__.pyi", "repo_id": "candle", "token_count": 484 }
37
# This example shows how the candle Python api can be used to replicate llama.cpp. import sys from typing import Dict, Tuple, Any import candle from candle.models.llama import QuantizedLlama from candle import utils MAX_SEQ_LEN = 4096 def gguf_rename(tensor_name: str): if tensor_name == "token_embd.weight": ...
candle/candle-pyo3/quant-llama.py/0
{ "file_path": "candle/candle-pyo3/quant-llama.py", "repo_id": "candle", "token_count": 1318 }
38
# candle-transformers
candle/candle-transformers/README.md/0
{ "file_path": "candle/candle-transformers/README.md", "repo_id": "candle", "token_count": 6 }
39
use std::sync::Arc; use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{linear_b as linear, Linear, VarBuilder}; fn default_max_position_embeddings() -> usize { 4096 } #[derive(serde::Deserialize, Debug, Clone)] pub struct Config { pub attention_bias: bool, pub head_dim: usize, pu...
candle/candle-transformers/src/models/gemma.rs/0
{ "file_path": "candle/candle-transformers/src/models/gemma.rs", "repo_id": "candle", "token_count": 6582 }
40
use super::quantized_blip_text as blip_text; use crate::quantized_nn::{layer_norm, linear, Linear}; pub use crate::quantized_var_builder::VarBuilder; use candle::{Module, Result, Tensor, D}; use candle_nn::{Conv2d, Conv2dConfig, LayerNorm}; pub type VisionConfig = super::blip::VisionConfig; pub type Config = super::bl...
candle/candle-transformers/src/models/quantized_blip.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_blip.rs", "repo_id": "candle", "token_count": 4013 }
41
use super::with_tracing::{layer_norm, linear_no_bias as linear, LayerNorm, Linear}; use candle::{IndexOp, Result, Tensor}; use candle_nn::{embedding, Embedding, Module, VarBuilder}; pub use crate::models::rwkv_v5::{Config, State, Tokenizer}; #[derive(Debug, Clone)] struct SelfAttention { key: Linear, receptan...
candle/candle-transformers/src/models/rwkv_v6.rs/0
{ "file_path": "candle/candle-transformers/src/models/rwkv_v6.rs", "repo_id": "candle", "token_count": 5859 }
42
//! ResNet Building Blocks //! //! Some Residual Network blocks used in UNet models. //! //! Denoising Diffusion Implicit Models, K. He and al, 2015. //! https://arxiv.org/abs/1512.03385 use crate::models::with_tracing::{conv2d, Conv2d}; use candle::{Result, Tensor, D}; use candle_nn as nn; use candle_nn::Module; /// ...
candle/candle-transformers/src/models/stable_diffusion/resnet.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/resnet.rs", "repo_id": "candle", "token_count": 2284 }
43
use candle::{Module, Result, Tensor}; use candle_nn::VarBuilder; #[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> { let inner = candle_nn::embedding(d1, d2, vb)?; ...
candle/candle-transformers/src/models/with_tracing.rs/0
{ "file_path": "candle/candle-transformers/src/models/with_tracing.rs", "repo_id": "candle", "token_count": 2315 }
44
[package] name = "candle-wasm-example-bert" 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 } candle-tran...
candle/candle-wasm-examples/bert/Cargo.toml/0
{ "file_path": "candle/candle-wasm-examples/bert/Cargo.toml", "repo_id": "candle", "token_count": 304 }
45
[package] name = "candle-wasm-example-llama2" 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 } candle-tr...
candle/candle-wasm-examples/llama2-c/Cargo.toml/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/Cargo.toml", "repo_id": "candle", "token_count": 434 }
46
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Phi 1.5 / Phi 2.0 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" /> ...
candle/candle-wasm-examples/phi/index.html/0
{ "file_path": "candle/candle-wasm-examples/phi/index.html", "repo_id": "candle", "token_count": 9818 }
47
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle T5</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> @import ur...
candle/candle-wasm-examples/t5/index.html/0
{ "file_path": "candle/candle-wasm-examples/t5/index.html", "repo_id": "candle", "token_count": 4724 }
48
pub const LANGUAGES: [(&str, &str); 99] = [ ("en", "english"), ("zh", "chinese"), ("de", "german"), ("es", "spanish"), ("ru", "russian"), ("ko", "korean"), ("fr", "french"), ("ja", "japanese"), ("pt", "portuguese"), ("tr", "turkish"), ("pl", "polish"), ("ca", "catalan"), ...
candle/candle-wasm-examples/whisper/src/languages.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/languages.rs", "repo_id": "candle", "token_count": 1175 }
49
use crate::model::{report_detect, report_pose, Bbox, Multiples, YoloV8, YoloV8Pose}; use candle::{DType, Device, Result, Tensor}; use candle_nn::{Module, VarBuilder}; use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; use yew_agent::{HandlerId, Public, WorkerLink}; #[wasm_bindgen] extern "C" { // U...
candle/candle-wasm-examples/yolo/src/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/worker.rs", "repo_id": "candle", "token_count": 4077 }
50
{ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { "source.fixAll": "explicit" }, "eslint.validate": ["javascript", "svelte"] }
chat-ui/.vscode/settings.json/0
{ "file_path": "chat-ui/.vscode/settings.json", "repo_id": "chat-ui", "token_count": 83 }
51
<!DOCTYPE html> <html lang="en" class="h-full"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="theme-color" content="rgb(249, 250, 251)" /> <script> if ( localStorage.theme === "dark" || (!("theme" in localStorage)...
chat-ui/src/app.html/0
{ "file_path": "chat-ui/src/app.html", "repo_id": "chat-ui", "token_count": 677 }
52
<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 }
53
<script lang="ts"> import { isDesktop } from "$lib/utils/isDesktop"; import { createEventDispatcher, onMount } from "svelte"; export let value = ""; export let minRows = 1; export let maxRows: null | number = null; export let placeholder = ""; export let disabled = false; let textareaElement: HTMLTextAreaElem...
chat-ui/src/lib/components/chat/ChatInput.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/ChatInput.svelte", "repo_id": "chat-ui", "token_count": 748 }
54
import { client, collections } from "$lib/server/database"; import { migrations } from "./routines"; import { acquireLock, releaseLock, isDBLocked, refreshLock } from "./lock"; import { isHuggingChat } from "$lib/utils/isHuggingChat"; export async function checkAndRunMigrations() { // make sure all GUIDs are unique ...
chat-ui/src/lib/migrations/migrations.ts/0
{ "file_path": "chat-ui/src/lib/migrations/migrations.ts", "repo_id": "chat-ui", "token_count": 1186 }
55
import { z } from "zod"; import { openAICompletionToTextGenerationStream } from "./openAICompletionToTextGenerationStream"; import { openAIChatToTextGenerationStream } from "./openAIChatToTextGenerationStream"; import { buildPrompt } from "$lib/buildPrompt"; import { OPENAI_API_KEY } from "$env/static/private"; import ...
chat-ui/src/lib/server/endpoints/openai/endpointOai.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/openai/endpointOai.ts", "repo_id": "chat-ui", "token_count": 1108 }
56
import { searchWeb } from "$lib/server/websearch/searchWeb"; import { generateQuery } from "$lib/server/websearch/generateQuery"; import { parseWeb } from "$lib/server/websearch/parseWeb"; import { chunk } from "$lib/utils/chunk"; import { findSimilarSentences } from "$lib/server/sentenceSimilarity"; import { getWebSea...
chat-ui/src/lib/server/websearch/runWebSearch.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/runWebSearch.ts", "repo_id": "chat-ui", "token_count": 2199 }
57
import type { ObjectId } from "mongodb"; import type { Message } from "./Message"; import type { Timestamps } from "./Timestamps"; import type { User } from "./User"; import type { Assistant } from "./Assistant"; export interface Conversation extends Timestamps { _id: ObjectId; sessionId?: string; userId?: User["_...
chat-ui/src/lib/types/Conversation.ts/0
{ "file_path": "chat-ui/src/lib/types/Conversation.ts", "repo_id": "chat-ui", "token_count": 182 }
58
import type { ObjectId } from "mongodb"; import type { Conversation } from "./Conversation"; import type { Timestamps } from "./Timestamps"; export interface WebSearch extends Timestamps { _id?: ObjectId; convId?: Conversation["_id"]; prompt: string; searchQuery: string; results: WebSearchSource[]; context: st...
chat-ui/src/lib/types/WebSearch.ts/0
{ "file_path": "chat-ui/src/lib/types/WebSearch.ts", "repo_id": "chat-ui", "token_count": 306 }
59
export function parseStringToList(links: unknown): string[] { if (typeof links !== "string") { throw new Error("Expected a string"); } return links .split(",") .map((link) => link.trim()) .filter((link) => link.length > 0); }
chat-ui/src/lib/utils/parseStringToList.ts/0
{ "file_path": "chat-ui/src/lib/utils/parseStringToList.ts", "repo_id": "chat-ui", "token_count": 86 }
60
import type { Conversation } from "$lib/types/Conversation"; import type { Message } from "$lib/types/Message"; import { v4 } from "uuid"; export function convertLegacyConversation( conv: Pick<Conversation, "messages" | "rootMessageId" | "preprompt"> ): Pick<Conversation, "messages" | "rootMessageId" | "preprompt"> {...
chat-ui/src/lib/utils/tree/convertLegacyConversation.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/convertLegacyConversation.ts", "repo_id": "chat-ui", "token_count": 354 }
61
import ChatThumbnail from "./ChatThumbnail.svelte"; import { collections } from "$lib/server/database"; import { error, type RequestHandler } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; import type { SvelteComponent } from "svelte"; import { Resvg } from "@resvg/resvg-js"; import satori from "satori"; im...
chat-ui/src/routes/assistant/[assistantId]/thumbnail.png/+server.ts/0
{ "file_path": "chat-ui/src/routes/assistant/[assistantId]/thumbnail.png/+server.ts", "repo_id": "chat-ui", "token_count": 833 }
62
import { assert, it, describe, afterEach, vi, expect } from "vitest"; import type { Cookies } from "@sveltejs/kit"; import { collections } from "$lib/server/database"; import { updateUser } from "./updateUser"; import { ObjectId } from "mongodb"; import { DEFAULT_SETTINGS } from "$lib/types/Settings"; import { defaultM...
chat-ui/src/routes/login/callback/updateUser.spec.ts/0
{ "file_path": "chat-ui/src/routes/login/callback/updateUser.spec.ts", "repo_id": "chat-ui", "token_count": 1408 }
63
<script lang="ts"> import { enhance } from "$app/forms"; import { base } from "$app/paths"; import { page } from "$app/stores"; import { PUBLIC_ORIGIN, PUBLIC_SHARE_PREFIX } from "$env/static/public"; import { useSettingsStore } from "$lib/stores/settings"; import type { PageData } from "./$types"; import Carbo...
chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/+page.svelte/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/+page.svelte", "repo_id": "chat-ui", "token_count": 3055 }
64
{ "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "data": { "values": "<DVC_METRIC_DATA>" }, "title": "<DVC_METRIC_TITLE>", "mark": { "type": "line" }, "encoding": { "x": { "field": "<DVC_METRIC_X>", "type": "quantitative", ...
datasets/.dvc/plots/default.json/0
{ "file_path": "datasets/.dvc/plots/default.json", "repo_id": "datasets", "token_count": 419 }
65
# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of...
datasets/CODE_OF_CONDUCT.md/0
{ "file_path": "datasets/CODE_OF_CONDUCT.md", "repo_id": "datasets", "token_count": 1208 }
66
# Create an audio dataset You can share a dataset with your team or with anyone in the community by creating a dataset repository on the Hugging Face Hub: ```py from datasets import load_dataset dataset = load_dataset("<username>/my_dataset") ``` There are several methods for creating and sharing an audio dataset: ...
datasets/docs/source/audio_dataset.mdx/0
{ "file_path": "datasets/docs/source/audio_dataset.mdx", "repo_id": "datasets", "token_count": 9843 }
67
# Process image data This guide shows specific methods for processing image datasets. Learn how to: - Use [`~Dataset.map`] with image dataset. - Apply data augmentations to a dataset with [`~Dataset.set_transform`]. For a guide on how to process any type of dataset, take a look at the <a class="underline decoration-...
datasets/docs/source/image_process.mdx/0
{ "file_path": "datasets/docs/source/image_process.mdx", "repo_id": "datasets", "token_count": 1031 }
68
# Utilities ## Configure logging 🤗 Datasets strives to be transparent and explicit about how it works, but this can be quite verbose at times. We have included a series of logging methods which allow you to easily adjust the level of verbosity of the entire library. Currently the default verbosity of the library is ...
datasets/docs/source/package_reference/utilities.mdx/0
{ "file_path": "datasets/docs/source/package_reference/utilities.mdx", "repo_id": "datasets", "token_count": 725 }
69
stages: benchmark_array_xd: cmd: python ./benchmarks/benchmark_array_xd.py deps: - ./benchmarks/benchmark_array_xd.py metrics: - ./benchmarks/results/benchmark_array_xd.json: cache: false benchmark_indices_mapping: cmd: python ./benchmarks/benchmark_indices_mapping.py deps: ...
datasets/dvc.yaml/0
{ "file_path": "datasets/dvc.yaml", "repo_id": "datasets", "token_count": 456 }
70
# Metric Card for COMET ## Metric description Crosslingual Optimized Metric for Evaluation of Translation (COMET) is an open-source framework used to train Machine Translation metrics that achieve high levels of correlation with different types of human judgments. ## How to use COMET takes 3 lists of strings as inp...
datasets/metrics/comet/README.md/0
{ "file_path": "datasets/metrics/comet/README.md", "repo_id": "datasets", "token_count": 2148 }
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/glue/glue.py/0
{ "file_path": "datasets/metrics/glue/glue.py", "repo_id": "datasets", "token_count": 2408 }
72
# 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/meteor/meteor.py/0
{ "file_path": "datasets/metrics/meteor/meteor.py", "repo_id": "datasets", "token_count": 1898 }
73
# 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/sacrebleu/sacrebleu.py/0
{ "file_path": "datasets/metrics/sacrebleu/sacrebleu.py", "repo_id": "datasets", "token_count": 3057 }
74
# Metric Card for TER ## Metric Description TER (Translation Edit Rate, also called Translation Error Rate) is a metric to quantify the edit operations that a hypothesis requires to match a reference translation. We use the implementation that is already present in [sacrebleu](https://github.com/mjpost/sacreBLEU#ter),...
datasets/metrics/ter/README.md/0
{ "file_path": "datasets/metrics/ter/README.md", "repo_id": "datasets", "token_count": 2596 }
75
# 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/arrow_reader.py/0
{ "file_path": "datasets/src/datasets/arrow_reader.py", "repo_id": "datasets", "token_count": 11429 }
76
import copy import warnings from dataclasses import InitVar, dataclass, field from pathlib import Path from typing import Any, Dict, Optional, Union from .. import config @dataclass class DownloadConfig: """Configuration for our cached path manager. Attributes: cache_dir (`str` or `Path`, *optional*...
datasets/src/datasets/download/download_config.py/0
{ "file_path": "datasets/src/datasets/download/download_config.py", "repo_id": "datasets", "token_count": 1880 }
77
# Copyright 2021 The HuggingFace Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
datasets/src/datasets/formatting/jax_formatter.py/0
{ "file_path": "datasets/src/datasets/formatting/jax_formatter.py", "repo_id": "datasets", "token_count": 2858 }
78
import copy import itertools import sys import warnings from collections import Counter from copy import deepcopy from dataclasses import dataclass from functools import partial from itertools import cycle, islice from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union import fsspec.as...
datasets/src/datasets/iterable_dataset.py/0
{ "file_path": "datasets/src/datasets/iterable_dataset.py", "repo_id": "datasets", "token_count": 46516 }
79
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=True) class Summarization(TaskTemplate): # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization task...
datasets/src/datasets/tasks/summarization.py/0
{ "file_path": "datasets/src/datasets/tasks/summarization.py", "repo_id": "datasets", "token_count": 254 }
80
# Copyright 2020 Optuna, Hugging Face # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
datasets/src/datasets/utils/logging.py/0
{ "file_path": "datasets/src/datasets/utils/logging.py", "repo_id": "datasets", "token_count": 1934 }
81
import os from typing import Dict, List, Tuple, TypeVar, Union T = TypeVar("T") ListLike = Union[List[T], Tuple[T, ...]] NestedDataStructureLike = Union[T, List[T], Dict[str, T]] PathLike = Union[str, bytes, os.PathLike]
datasets/src/datasets/utils/typing.py/0
{ "file_path": "datasets/src/datasets/utils/typing.py", "repo_id": "datasets", "token_count": 84 }
82
import json import tarfile import numpy as np import pytest from datasets import Audio, DownloadManager, Features, Image, Value from datasets.packaged_modules.webdataset.webdataset import WebDataset from ..utils import require_pil, require_sndfile @pytest.fixture def image_wds_file(tmp_path, image_file): json_...
datasets/tests/packaged_modules/test_webdataset.py/0
{ "file_path": "datasets/tests/packaged_modules/test_webdataset.py", "repo_id": "datasets", "token_count": 2263 }
83
import json import os import pickle import subprocess from functools import partial from pathlib import Path from tempfile import gettempdir from textwrap import dedent from types import FunctionType from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from multiprocess import...
datasets/tests/test_fingerprint.py/0
{ "file_path": "datasets/tests/test_fingerprint.py", "repo_id": "datasets", "token_count": 6783 }
84
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): example_yaml_structure = yaml.safe_load( """\ name: "" allow_empty: false allow_empty_text: true subsections: - name: "Dataset Card for X" #...
datasets/tests/test_readme_util.py/0
{ "file_path": "datasets/tests/test_readme_util.py", "repo_id": "datasets", "token_count": 6733 }
85
<jupyter_start><jupyter_text>Bonus Unit 1: Let's train Huggy the Dog 🐶 to fetch a stick In this notebook, we'll reinforce what we learned in the first Unit by **teaching Huggy the Dog to fetch the stick and then play with it directly in your browser**⬇️ Here is an example of what **you will achieve at the end of the u...
deep-rl-class/notebooks/bonus-unit1/bonus_unit1.ipynb/0
{ "file_path": "deep-rl-class/notebooks/bonus-unit1/bonus_unit1.ipynb", "repo_id": "deep-rl-class", "token_count": 2886 }
86
# Live 1: How the course work, Q&A, and playing with Huggy In this first live stream, we explained how the course work (scope, units, challenges, and more) and answered your questions. And finally, we saw some LunarLander agents you've trained and play with your Huggies 🐶 <Youtube id="JeJIswxyrsM" /> To know when ...
deep-rl-class/units/en/live1/live1.mdx/0
{ "file_path": "deep-rl-class/units/en/live1/live1.mdx", "repo_id": "deep-rl-class", "token_count": 131 }
87
# What is Reinforcement Learning? [[what-is-reinforcement-learning]] To understand Reinforcement Learning, let’s start with the big picture. ## The big picture [[the-big-picture]] The idea behind Reinforcement Learning is that an agent (an AI) will learn from the environment by **interacting with it** (through trial...
deep-rl-class/units/en/unit1/what-is-rl.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/what-is-rl.mdx", "repo_id": "deep-rl-class", "token_count": 624 }
88
# Additional Readings [[additional-readings]] These are **optional readings** if you want to go deeper. - [Foundations of Deep RL Series, L2 Deep Q-Learning by Pieter Abbeel](https://youtu.be/Psrhxy88zww) - [Playing Atari with Deep Reinforcement Learning](https://arxiv.org/abs/1312.5602) - [Double Deep Q-Learning](ht...
deep-rl-class/units/en/unit3/additional-readings.mdx/0
{ "file_path": "deep-rl-class/units/en/unit3/additional-readings.mdx", "repo_id": "deep-rl-class", "token_count": 163 }
89
# Diving deeper into policy-gradient methods ## Getting the big picture We just learned that policy-gradient methods aim to find parameters \\( \theta \\) that **maximize the expected return**. The idea is that we have a *parameterized stochastic policy*. In our case, a neural network outputs a probability distribut...
deep-rl-class/units/en/unit4/policy-gradient.mdx/0
{ "file_path": "deep-rl-class/units/en/unit4/policy-gradient.mdx", "repo_id": "deep-rl-class", "token_count": 2365 }
90
# Introduction [[introduction]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit8/thumbnail.png" alt="Thumbnail"/> In unit 4, we learned about our first Policy-Based algorithm called **Reinforce**. In Policy-Based methods, **we aim to optimize the policy direc...
deep-rl-class/units/en/unit6/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit6/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 427 }
91
# Hands-on: advanced Deep Reinforcement Learning. Using Sample Factory to play Doom from pixels <CourseFloatingBanner classNames="absolute z-10 right-0 top-0" notebooks={[ {label: "Google Colab", value: "https://colab.research.google.com/github/huggingface/deep-rl-class/blob/main/notebooks/unit8/unit8_part2.ipynb"} ...
deep-rl-class/units/en/unit8/hands-on-sf.mdx/0
{ "file_path": "deep-rl-class/units/en/unit8/hands-on-sf.mdx", "repo_id": "deep-rl-class", "token_count": 5955 }
92
# Generalization in Reinforcement Learning Generalization plays a pivotal role in the realm of Reinforcement Learning. While **RL algorithms demonstrate good performance in controlled environments**, the real world presents a **unique challenge due to its non-stationary and open-ended nature**. As a result, the devel...
deep-rl-class/units/en/unitbonus3/generalisation.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus3/generalisation.mdx", "repo_id": "deep-rl-class", "token_count": 250 }
93
cff-version: 1.2.0 title: 'Diffusers: State-of-the-art diffusion models' message: >- If you use this software, please cite it using the metadata from this file. type: software authors: - given-names: Patrick family-names: von Platen - given-names: Suraj family-names: Patil - given-names: Anton fam...
diffusers/CITATION.cff/0
{ "file_path": "diffusers/CITATION.cff", "repo_id": "diffusers", "token_count": 460 }
94
import argparse import sys sys.path.append(".") from base_classes import TextToImageBenchmark, TurboTextToImageBenchmark # noqa: E402 ALL_T2I_CKPTS = [ "runwayml/stable-diffusion-v1-5", "segmind/SSD-1B", "stabilityai/stable-diffusion-xl-base-1.0", "kandinsky-community/kandinsky-2-2-decoder", "w...
diffusers/benchmarks/benchmark_text_to_image.py/0
{ "file_path": "diffusers/benchmarks/benchmark_text_to_image.py", "repo_id": "diffusers", "token_count": 480 }
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/api/models/controlnet.md/0
{ "file_path": "diffusers/docs/source/en/api/models/controlnet.md", "repo_id": "diffusers", "token_count": 770 }
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 to...
diffusers/docs/source/en/api/pipelines/kandinsky3.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/kandinsky3.md", "repo_id": "diffusers", "token_count": 766 }
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/stable_diffusion/upscale.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/upscale.md", "repo_id": "diffusers", "token_count": 475 }
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/singlestep_dpm_solver.md/0
{ "file_path": "diffusers/docs/source/en/api/schedulers/singlestep_dpm_solver.md", "repo_id": "diffusers", "token_count": 574 }
99