text
stringlengths
7
318k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
439
<!--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/basic_tutorials/troubleshooting.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/troubleshooting.md", "repo_id": "accelerate", "token_count": 2832 }
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/ipex.md/0
{ "file_path": "accelerate/docs/source/usage_guides/ipex.md", "repo_id": "accelerate", "token_count": 2313 }
1
import argparse import runhouse as rh import torch from nlp_example import training_function from accelerate.utils import PrepareForLaunch, patch_environment def launch_train(*args): num_processes = torch.cuda.device_count() print(f"Device count: {num_processes}") with patch_environment( world_s...
accelerate/examples/multigpu_remote_launcher.py/0
{ "file_path": "accelerate/examples/multigpu_remote_launcher.py", "repo_id": "accelerate", "token_count": 869 }
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 applicabl...
accelerate/src/accelerate/checkpointing.py/0
{ "file_path": "accelerate/src/accelerate/checkpointing.py", "repo_id": "accelerate", "token_count": 4641 }
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/helpers.py/0
{ "file_path": "accelerate/src/accelerate/commands/menu/helpers.py", "repo_id": "accelerate", "token_count": 505 }
4
#!/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/test_utils/examples.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/examples.py", "repo_id": "accelerate", "token_count": 2747 }
5
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_MODEL_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SAMPLER_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_DISTRIBUTED_OPERATION_TYPES, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) fro...
accelerate/src/accelerate/utils/__init__.py/0
{ "file_path": "accelerate/src/accelerate/utils/__init__.py", "repo_id": "accelerate", "token_count": 2193 }
6
compute_environment: LOCAL_MACHINE deepspeed_config: {} distributed_type: 'NO' downcast_bf16: 'no' fsdp_config: {} gpu_ids: all machine_rank: 0 main_process_ip: null main_process_port: null main_training_function: main megatron_lm_config: {} mixed_precision: 'no' num_machines: 1 num_processes: 1 rdzv_backend: static sa...
accelerate/tests/test_configs/latest.yaml/0
{ "file_path": "accelerate/tests/test_configs/latest.yaml", "repo_id": "accelerate", "token_count": 186 }
7
#!/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_dpo.py/0
{ "file_path": "alignment-handbook/scripts/run_dpo.py", "repo_id": "alignment-handbook", "token_count": 3365 }
8
# Creating apps
candle/candle-book/src/apps/README.md/0
{ "file_path": "candle/candle-book/src/apps/README.md", "repo_id": "candle", "token_count": 4 }
9
# Running a model In order to run an existing model, you will need to download and use existing weights. Most models are already available on https://huggingface.co/ in [`safetensors`](https://github.com/huggingface/safetensors) format. Let's get started by running an old model : `bert-base-uncased`.
candle/candle-book/src/inference/inference.md/0
{ "file_path": "candle/candle-book/src/inference/inference.md", "repo_id": "candle", "token_count": 88 }
10
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle_core::{DType, Device, Tensor}; use criterion::{black_box, criterion_group, Criterion, Throughput}; use std::time::Instant; fn run(a: &Tensor, b: &Tensor, c: &Tensor) { a.where_cond(b, c).unwrap(); } const fn create_cond_arr<const N: usize>() -> ...
candle/candle-core/benches/benchmarks/where_cond.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/where_cond.rs", "repo_id": "candle", "token_count": 942 }
11
use crate::backend::{BackendDevice, BackendStorage}; use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT}; use crate::{DType, Error, IntDType, Layout, Result, Shape, WithDType}; use half::{bf16, f16}; use rayon::prelude::*; const USE_IM2COL_CONV1D: bool = true; const USE_IM2COL_CONV2D: bool = true; // TODO: Maybe we...
candle/candle-core/src/cpu_backend.rs/0
{ "file_path": "candle/candle-core/src/cpu_backend.rs", "repo_id": "candle", "token_count": 68866 }
12
// Just enough pickle support to be able to read PyTorch checkpoints. // This hardcodes objects that are required for tensor reading, we may want to make this a bit more // composable/tensor agnostic at some point. use crate::{DType, Error as E, Layout, Result, Tensor}; use byteorder::{LittleEndian, ReadBytesExt}; use ...
candle/candle-core/src/pickle.rs/0
{ "file_path": "candle/candle-core/src/pickle.rs", "repo_id": "candle", "token_count": 12933 }
13
use crate::{Result, Tensor}; #[macro_export] macro_rules! test_device { // TODO: Switch to generating the two last arguments automatically once concat_idents is // stable. https://github.com/rust-lang/rust/issues/29599 ($fn_name: ident, $test_cpu: ident, $test_cuda: ident, $test_metal: ident) => { ...
candle/candle-core/src/test_utils.rs/0
{ "file_path": "candle/candle-core/src/test_utils.rs", "repo_id": "candle", "token_count": 923 }
14
[package] name = "candle-datasets" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true readme = "README.md" [dependencies] byteorder = { workspace = true } candle = { workspace = true }...
candle/candle-datasets/Cargo.toml/0
{ "file_path": "candle/candle-datasets/Cargo.toml", "repo_id": "candle", "token_count": 201 }
15
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::{Error as E, Result}; use clap::Parser; use candle_transformers::models::bigcode::{Config, GPTBigCode}; use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers:...
candle/candle-examples/examples/bigcode/main.rs/0
{ "file_path": "candle/candle-examples/examples/bigcode/main.rs", "repo_id": "candle", "token_count": 2134 }
16
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle_transformers::models::jina_bert::{BertModel, Config}; use anyhow::Error as E; use candle::{DType, Module, Tensor}; use candle_nn::VarBuilder; use clap::Parser; #[derive(Parser, Debug)] #[comman...
candle/candle-examples/examples/jina-bert/main.rs/0
{ "file_path": "candle/candle-examples/examples/jina-bert/main.rs", "repo_id": "candle", "token_count": 3088 }
17
// This should reach 91.5% accuracy. #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use rand::prelude::*; use candle::{DType, Result, Tensor, D}; use candle_nn::{loss, ops, Conv2d, Linear, Module, ModuleT, Optimizer, VarB...
candle/candle-examples/examples/mnist-training/main.rs/0
{ "file_path": "candle/candle-examples/examples/mnist-training/main.rs", "repo_id": "candle", "token_count": 4094 }
18
#[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": 11119 }
19
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, IndexOp, D}; use candle_nn::{ModuleT, VarBuilder}; use candle_transformers::models::vgg::{Models, Vgg}; use clap::{Parser, ValueEnum}; #[derive(Clone, Copy, Debug, ValueEnum)] enum Whic...
candle/candle-examples/examples/vgg/main.rs/0
{ "file_path": "candle/candle-examples/examples/vgg/main.rs", "repo_id": "candle", "token_count": 960 }
20
[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 }
21
/****************************************************************************** * Copyright (c) 2023, Tri Dao. ******************************************************************************/ #pragma once namespace flash { /////////////////////////////////////////////////////////////////////////////////////////////...
candle/candle-flash-attn/kernels/block_info.h/0
{ "file_path": "candle/candle-flash-attn/kernels/block_info.h", "repo_id": "candle", "token_count": 851 }
22
// Copyright (c) 2023, Tri Dao. // Splitting the different head dimensions to different files to speed up compilation. // This file is auto-generated. See "generate_kernels.py" #include "flash_fwd_launch_template.h" template<> void run_mha_fwd_<cutlass::half_t, 64>(Flash_fwd_params &params, cudaStream_t stream) { ...
candle/candle-flash-attn/kernels/flash_fwd_hdim64_fp16_sm80.cu/0
{ "file_path": "candle/candle-flash-attn/kernels/flash_fwd_hdim64_fp16_sm80.cu", "repo_id": "candle", "token_count": 135 }
23
fn main() { println!("cargo:rerun-if-changed=build.rs"); let builder = bindgen_cuda::Builder::default(); println!("cargo:info={builder:?}"); let bindings = builder.build_ptx().unwrap(); bindings.write("src/lib.rs").unwrap(); }
candle/candle-kernels/build.rs/0
{ "file_path": "candle/candle-kernels/build.rs", "repo_id": "candle", "token_count": 96 }
24
#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": 1462 }
25
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 }
26
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 }
27
# 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 }
28
# 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 }
29
# 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 }
30
# candle-transformers
candle/candle-transformers/README.md/0
{ "file_path": "candle/candle-transformers/README.md", "repo_id": "candle", "token_count": 6 }
31
use super::with_tracing::{linear, Embedding, Linear}; use candle::{Result, Tensor}; use candle_nn::{layer_norm, LayerNorm, VarBuilder}; #[derive(Debug, Clone)] pub struct Config { pub vocab_size: usize, pub decoder_vocab_size: Option<usize>, pub max_position_embeddings: usize, pub encoder_layers: usize...
candle/candle-transformers/src/models/marian.rs/0
{ "file_path": "candle/candle-transformers/src/models/marian.rs", "repo_id": "candle", "token_count": 8917 }
32
use crate::quantized_nn::{layer_norm, linear_no_bias, Embedding, Linear}; pub use crate::quantized_var_builder::VarBuilder; use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{Activation, LayerNorm}; use std::sync::Arc; pub use crate::models::stable_lm::Config; use crate::models::stable_lm::RotaryE...
candle/candle-transformers/src/models/quantized_stable_lm.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_stable_lm.rs", "repo_id": "candle", "token_count": 5319 }
33
//! Ancestral sampling with Euler method steps. //! //! Reference implementation in Rust: //! //! https://github.com/pykeio/diffusers/blob/250b9ad1898af41e76a74c0d8d4292652823338a/src/schedulers/euler_ancestral_discrete.rs //! //! Based on the original [`k-diffusion` implementation by Katherine Crowson][kd]. /// /// [k...
candle/candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs", "repo_id": "candle", "token_count": 4176 }
34
use super::Config; use crate::quantized_nn::{layer_norm, linear, linear_no_bias, Embedding, Linear}; pub use crate::quantized_var_builder::VarBuilder; use candle::{Device, IndexOp, Result, Tensor, D}; use candle_nn::{Conv1d, Conv1dConfig, LayerNorm, Module}; fn conv1d( in_channels: usize, out_channels: usize, ...
candle/candle-transformers/src/models/whisper/quantized_model.rs/0
{ "file_path": "candle/candle-transformers/src/models/whisper/quantized_model.rs", "repo_id": "candle", "token_count": 6739 }
35
use candle::{Device, Result, Tensor}; use candle_transformers::generation::LogitsProcessor; #[test] fn sample_with_zero_temperature() -> Result<()> { let mut logits_process = LogitsProcessor::new(1337, None, None); let logits = Tensor::new(&[0.1, 0.2, 0.3, 0.4], &Device::Cpu)?; let token = logits_process.s...
candle/candle-transformers/tests/generation_tests.rs/0
{ "file_path": "candle/candle-transformers/tests/generation_tests.rs", "repo_id": "candle", "token_count": 408 }
36
cargo build --target wasm32-unknown-unknown --release wasm-bindgen ../../target/wasm32-unknown-unknown/release/m.wasm --out-dir build --target web wasm-bindgen ../../target/wasm32-unknown-unknown/release/m-quantized.wasm --out-dir build --target web
candle/candle-wasm-examples/t5/build-lib.sh/0
{ "file_path": "candle/candle-wasm-examples/t5/build-lib.sh", "repo_id": "candle", "token_count": 84 }
37
use yew_agent::PublicWorker; fn main() { candle_wasm_example_whisper::Worker::register(); }
candle/candle-wasm-examples/whisper/src/bin/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/bin/worker.rs", "repo_id": "candle", "token_count": 38 }
38
use candle::{DType, IndexOp, Result, Tensor, D}; use candle_nn::{ batch_norm, conv2d, conv2d_no_bias, BatchNorm, Conv2d, Conv2dConfig, Module, VarBuilder, }; use image::DynamicImage; // Model architecture from https://github.com/ultralytics/ultralytics/issues/189 // https://github.com/tinygrad/tinygrad/blob/master...
candle/candle-wasm-examples/yolo/src/model.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/model.rs", "repo_id": "candle", "token_count": 14731 }
39
{ "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 }
40
import { COOKIE_NAME, EXPOSE_API, MESSAGES_BEFORE_LOGIN } from "$env/static/private"; import type { Handle } from "@sveltejs/kit"; import { PUBLIC_GOOGLE_ANALYTICS_ID, PUBLIC_ORIGIN, PUBLIC_APP_DISCLAIMER, } from "$env/static/public"; import { collections } from "$lib/server/database"; import { base } from "$app/pat...
chat-ui/src/hooks.server.ts/0
{ "file_path": "chat-ui/src/hooks.server.ts", "repo_id": "chat-ui", "token_count": 1640 }
41
<script lang="ts"> import type { WebSearchUpdate } from "$lib/types/MessageUpdate"; import CarbonError from "~icons/carbon/error-filled"; import EosIconsLoading from "~icons/eos-icons/loading"; import IconInternet from "./icons/IconInternet.svelte"; export let classNames = ""; export let webSearchMessages: WebS...
chat-ui/src/lib/components/OpenWebSearchResults.svelte/0
{ "file_path": "chat-ui/src/lib/components/OpenWebSearchResults.svelte", "repo_id": "chat-ui", "token_count": 1726 }
42
<script lang="ts"> import type { Message } from "$lib/types/Message"; import { createEventDispatcher, onDestroy } from "svelte"; import CarbonSendAltFilled from "~icons/carbon/send-alt-filled"; import CarbonExport from "~icons/carbon/export"; import CarbonStopFilledAlt from "~icons/carbon/stop-filled-alt"; impor...
chat-ui/src/lib/components/chat/ChatWindow.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/ChatWindow.svelte", "repo_id": "chat-ui", "token_count": 4036 }
43
import { z } from "zod"; import type { EmbeddingEndpoint } from "../embeddingEndpoints"; import type { Tensor, Pipeline } from "@xenova/transformers"; import { pipeline } from "@xenova/transformers"; export const embeddingEndpointTransformersJSParametersSchema = z.object({ weight: z.number().int().positive().default(...
chat-ui/src/lib/server/embeddingEndpoints/transformersjs/embeddingEndpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/embeddingEndpoints/transformersjs/embeddingEndpoints.ts", "repo_id": "chat-ui", "token_count": 483 }
44
import type { Message } from "$lib/types/Message"; import { format } from "date-fns"; import { generateFromDefaultEndpoint } from "../generateFromDefaultEndpoint"; import { WEBSEARCH_ALLOWLIST, WEBSEARCH_BLOCKLIST } from "$env/static/private"; import { z } from "zod"; import JSON5 from "json5"; const listSchema = z.ar...
chat-ui/src/lib/server/websearch/generateQuery.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/generateQuery.ts", "repo_id": "chat-ui", "token_count": 898 }
45
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": 164 }
46
import { sum } from "./sum"; export function concatUint8Arrays(arrays: Uint8Array[]): Uint8Array { const totalLength = sum(arrays.map((a) => a.length)); const result = new Uint8Array(totalLength); let offset = 0; for (const array of arrays) { result.set(array, offset); offset += array.length; } return result...
chat-ui/src/lib/utils/concatUint8Arrays.ts/0
{ "file_path": "chat-ui/src/lib/utils/concatUint8Arrays.ts", "repo_id": "chat-ui", "token_count": 117 }
47
<script lang="ts"> import { page } from "$app/stores"; </script> <div class="flex items-center justify-center bg-gradient-to-t from-gray-200 text-gray-800 dark:from-gray-700 dark:text-gray-300" > <div class="align-center -mt-24 flex flex-col justify-center rounded-xl border bg-white px-8 pb-2 pt-4 text-center dar...
chat-ui/src/routes/+error.svelte/0
{ "file_path": "chat-ui/src/routes/+error.svelte", "repo_id": "chat-ui", "token_count": 241 }
48
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { error } from "@sveltejs/kit"; import { authCondition } from "$lib/server/auth"; import { UrlDependency } from "$lib/types/UrlDependency"; export const load = async ({ params, depends, locals }) => { let conversation; let...
chat-ui/src/routes/conversation/[id]/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/+page.server.ts", "repo_id": "chat-ui", "token_count": 597 }
49
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import type { LayoutServerLoad } from "./$types"; export const load = (async ({ locals, parent }) => { const { settings } = await parent(); // find assistants matching the settings assistants const assistants = await collection...
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": 329 }
50
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": 272 }
51
# How to add one new datasets Add datasets directly to the 🤗 Hugging Face Hub! You can share your dataset on https://huggingface.co/datasets directly using your account, see the documentation: * [Create a dataset and upload files on the website](https://huggingface.co/docs/datasets/upload_dataset) * [Advanced guide...
datasets/ADD_NEW_DATASET.md/0
{ "file_path": "datasets/ADD_NEW_DATASET.md", "repo_id": "datasets", "token_count": 113 }
52
# Differences between Dataset and IterableDataset There are two types of dataset objects, a [`Dataset`] and an [`IterableDataset`]. Whichever type of dataset you choose to use or create depends on the size of the dataset. In general, an [`IterableDataset`] is ideal for big datasets (think hundreds of GBs!) due to its ...
datasets/docs/source/about_mapstyle_vs_iterable.mdx/0
{ "file_path": "datasets/docs/source/about_mapstyle_vs_iterable.mdx", "repo_id": "datasets", "token_count": 3261 }
53
# Image classification Image classification datasets are used to train a model to classify an entire image. There are a wide variety of applications enabled by these datasets such as identifying endangered wildlife species or screening for disease in medical images. This guide will show you how to apply transformation...
datasets/docs/source/image_classification.mdx/0
{ "file_path": "datasets/docs/source/image_classification.mdx", "repo_id": "datasets", "token_count": 1043 }
54
# Main classes ## DatasetInfo [[autodoc]] datasets.DatasetInfo ## Dataset The base class [`Dataset`] implements a Dataset backed by an Apache Arrow table. [[autodoc]] datasets.Dataset - add_column - add_item - from_file - from_buffer - from_pandas - from_dict - from_generator - dat...
datasets/docs/source/package_reference/main_classes.mdx/0
{ "file_path": "datasets/docs/source/package_reference/main_classes.mdx", "repo_id": "datasets", "token_count": 1908 }
55
# Use with PyTorch This document is a quick introduction to using `datasets` with PyTorch, with a particular focus on how to get `torch.Tensor` objects out of our datasets, and how to use a PyTorch `DataLoader` and a Hugging Face `Dataset` with the best performance. ## Dataset format By default, datasets return regu...
datasets/docs/source/use_with_pytorch.mdx/0
{ "file_path": "datasets/docs/source/use_with_pytorch.mdx", "repo_id": "datasets", "token_count": 3104 }
56
# Metric Card for Code Eval ## Metric description The CodeEval metric estimates the pass@k metric for code synthesis. It implements the evaluation harness for the HumanEval problem solving dataset described in the paper ["Evaluating Large Language Models Trained on Code"](https://arxiv.org/abs/2107.03374). ## How...
datasets/metrics/code_eval/README.md/0
{ "file_path": "datasets/metrics/code_eval/README.md", "repo_id": "datasets", "token_count": 1698 }
57
# Metric Card for FrugalScore ## Metric Description FrugalScore is a reference-based metric for Natural Language Generation (NLG) model evaluation. It is based on a distillation approach that allows to learn a fixed, low cost version of any expensive NLG metric, while retaining most of its original performance. The ...
datasets/metrics/frugalscore/README.md/0
{ "file_path": "datasets/metrics/frugalscore/README.md", "repo_id": "datasets", "token_count": 2127 }
58
# Metric Card for Mean IoU ## Metric Description IoU (Intersection over Union) is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the ground truth. For binary (two classes) or multi-class segmentation, the *mean IoU* o...
datasets/metrics/mean_iou/README.md/0
{ "file_path": "datasets/metrics/mean_iou/README.md", "repo_id": "datasets", "token_count": 1803 }
59
# Metric Card for ROUGE ## Metric Description ROUGE, or Recall-Oriented Understudy for Gisting Evaluation, is a set of metrics and a software package used for evaluating automatic summarization and machine translation software in natural language processing. The metrics compare an automatically produced summary or tra...
datasets/metrics/rouge/README.md/0
{ "file_path": "datasets/metrics/rouge/README.md", "repo_id": "datasets", "token_count": 2244 }
60
# Metric Card for SuperGLUE ## Metric description This metric is used to compute the SuperGLUE evaluation metric associated to each of the subsets of the [SuperGLUE dataset](https://huggingface.co/datasets/super_glue). SuperGLUE is a new benchmark styled after GLUE with a new set of more difficult language understan...
datasets/metrics/super_glue/README.md/0
{ "file_path": "datasets/metrics/super_glue/README.md", "repo_id": "datasets", "token_count": 1767 }
61
# Lint as: python3 """ HuggingFace/Datasets is an open library of datasets. Note: VERSION needs to be formatted following the MAJOR.MINOR.PATCH convention (we need to follow this convention to be able to retrieve versioned scripts) Simple check list for release from AllenNLP repo: https://github.com/allenai/al...
datasets/setup.py/0
{ "file_path": "datasets/setup.py", "repo_id": "datasets", "token_count": 4173 }
62
import contextlib import copy import fnmatch import json import math import posixpath import re import warnings from io import BytesIO from pathlib import Path from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union import fsspec import numpy as np from huggingface_hub import ( CommitInfo, Co...
datasets/src/datasets/dataset_dict.py/0
{ "file_path": "datasets/src/datasets/dataset_dict.py", "repo_id": "datasets", "token_count": 46956 }
63
import inspect import os import random import shutil import tempfile import weakref from functools import wraps from pathlib import Path from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union import numpy as np import xxhash from . import config from .naming import INVALID_WINDOWS_CHARACT...
datasets/src/datasets/fingerprint.py/0
{ "file_path": "datasets/src/datasets/fingerprint.py", "repo_id": "datasets", "token_count": 8037 }
64
import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import tqdm as hf_tqdm from .abc import AbstractDatasetInputStream if TYPE_CHECKING: import sqlite3 i...
datasets/src/datasets/io/sql.py/0
{ "file_path": "datasets/src/datasets/io/sql.py", "repo_id": "datasets", "token_count": 2040 }
65
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=True) class LanguageModeling(TaskTemplate): task: str = field(default="language-modeling", metadata={"include_in_asdict_even_if_is_default": True}) ...
datasets/src/datasets/tasks/language_modeling.py/0
{ "file_path": "datasets/src/datasets/tasks/language_modeling.py", "repo_id": "datasets", "token_count": 195 }
66
import time from functools import partial from huggingface_hub import HfApi, hf_hub_url from huggingface_hub.hf_api import RepoFile from packaging import version from requests import ConnectionError, HTTPError from .. import config from . import logging logger = logging.get_logger(__name__) # Retry `preupload_lfs_...
datasets/src/datasets/utils/hub.py/0
{ "file_path": "datasets/src/datasets/utils/hub.py", "repo_id": "datasets", "token_count": 1118 }
67
"""Utility helpers to handle progress bars in `datasets`. Example: 1. Use `datasets.utils.tqdm` as you would use `tqdm.tqdm` or `tqdm.auto.tqdm`. 2. To disable progress bars, either use `disable_progress_bars()` helper or set the environment variable `HF_DATASETS_DISABLE_PROGRESS_BARS` to 1. 3. To r...
datasets/src/datasets/utils/tqdm.py/0
{ "file_path": "datasets/src/datasets/utils/tqdm.py", "repo_id": "datasets", "token_count": 1661 }
68
from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def _get_expected_row_ids_and_row_dicts_for_partition_order(df, par...
datasets/tests/packaged_modules/test_spark.py/0
{ "file_path": "datasets/tests/packaged_modules/test_spark.py", "repo_id": "datasets", "token_count": 2054 }
69
import os from datasets.utils._filelock import FileLock def test_long_path(tmpdir): filename = "a" * 1000 + ".lock" lock1 = FileLock(str(tmpdir / filename)) assert lock1.lock_file.endswith(".lock") assert not lock1.lock_file.endswith(filename) assert len(os.path.basename(lock1.lock_file)) <= 255
datasets/tests/test_filelock.py/0
{ "file_path": "datasets/tests/test_filelock.py", "repo_id": "datasets", "token_count": 120 }
70
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def test_patch_submodule(): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname from os.path impor...
datasets/tests/test_patching.py/0
{ "file_path": "datasets/tests/test_patching.py", "repo_id": "datasets", "token_count": 2274 }
71
- title: Unit 0. Welcome to the course sections: - local: unit0/introduction title: Welcome to the course 🤗 - local: unit0/setup title: Setup - local: unit0/discord101 title: Discord 101 - title: Unit 1. Introduction to Deep Reinforcement Learning sections: - local: unit1/introduction title...
deep-rl-class/units/en/_toctree.yml/0
{ "file_path": "deep-rl-class/units/en/_toctree.yml", "repo_id": "deep-rl-class", "token_count": 2743 }
72
# Summary [[summary]] That was a lot of information! Let's summarize: - Reinforcement Learning is a computational approach of learning from actions. We build an agent that learns from the environment **by interacting with it through trial and error** and receiving rewards (negative or positive) as feedback. - The go...
deep-rl-class/units/en/unit1/summary.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/summary.mdx", "repo_id": "deep-rl-class", "token_count": 382 }
73
# Second Quiz [[quiz2]] 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 is Q-Learning? <Question ch...
deep-rl-class/units/en/unit2/quiz2.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/quiz2.mdx", "repo_id": "deep-rl-class", "token_count": 1077 }
74
# Hands on <CourseFloatingBanner classNames="absolute z-10 right-0 top-0" notebooks={[ {label: "Google Colab", value: "https://colab.research.google.com/github/huggingface/deep-rl-class/blob/main/notebooks/unit4/unit4.ipynb"} ]} askForHelpUrl="http://hf.co/join/discord" /> Now ...
deep-rl-class/units/en/unit4/hands-on.mdx/0
{ "file_path": "deep-rl-class/units/en/unit4/hands-on.mdx", "repo_id": "deep-rl-class", "token_count": 13495 }
75
# Advantage Actor-Critic (A2C) [[advantage-actor-critic]] ## Reducing variance with Actor-Critic methods The solution to reducing the variance of the Reinforce algorithm and training our agent faster and better is to use a combination of Policy-Based and Value-Based methods: *the Actor-Critic method*. To understand ...
deep-rl-class/units/en/unit6/advantage-actor-critic.mdx/0
{ "file_path": "deep-rl-class/units/en/unit6/advantage-actor-critic.mdx", "repo_id": "deep-rl-class", "token_count": 1384 }
76
# Conclusion That's all for today. Congrats on finishing this Unit and the tutorial! ⭐️ Now that you've successfully trained your Doom agent, why not try deathmatch? Remember, that's a much more complex level than the one you've just trained, **but it's a nice experiment and I advise you to try it.** If you do it, d...
deep-rl-class/units/en/unit8/conclusion-sf.mdx/0
{ "file_path": "deep-rl-class/units/en/unit8/conclusion-sf.mdx", "repo_id": "deep-rl-class", "token_count": 188 }
77
# (Automatic) Curriculum Learning for RL While most of the RL methods seen in this course work well in practice, there are some cases where using them alone fails. This can happen, for instance, when: - the task to learn is hard and requires an **incremental acquisition of skills** (for instance when one wants to mak...
deep-rl-class/units/en/unitbonus3/curriculum-learning.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus3/curriculum-learning.mdx", "repo_id": "deep-rl-class", "token_count": 1058 }
78
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 }
79
<!--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...
diffusers/docs/source/en/api/models/controlnet.md/0
{ "file_path": "diffusers/docs/source/en/api/models/controlnet.md", "repo_id": "diffusers", "token_count": 771 }
80
<!--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 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": 767 }
81
<!--Copyright 2023 The GLIGEN Authors and 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 a...
diffusers/docs/source/en/api/pipelines/stable_diffusion/gligen.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/gligen.md", "repo_id": "diffusers", "token_count": 1050 }
82
<!--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...
diffusers/docs/source/en/api/pipelines/text_to_video_zero.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/text_to_video_zero.md", "repo_id": "diffusers", "token_count": 4487 }
83
<!--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...
diffusers/docs/source/en/conceptual/contribution.md/0
{ "file_path": "diffusers/docs/source/en/conceptual/contribution.md", "repo_id": "diffusers", "token_count": 10386 }
84
<!--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...
diffusers/docs/source/en/optimization/opt_overview.md/0
{ "file_path": "diffusers/docs/source/en/optimization/opt_overview.md", "repo_id": "diffusers", "token_count": 354 }
85
<!--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...
diffusers/docs/source/en/training/lora.md/0
{ "file_path": "diffusers/docs/source/en/training/lora.md", "repo_id": "diffusers", "token_count": 3289 }
86
<!--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...
diffusers/docs/source/en/using-diffusers/control_brightness.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/control_brightness.md", "repo_id": "diffusers", "token_count": 875 }
87
<!--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...
diffusers/docs/source/en/using-diffusers/loading_overview.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/loading_overview.md", "repo_id": "diffusers", "token_count": 360 }
88
<!--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...
diffusers/docs/source/en/using-diffusers/weighted_prompts.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/weighted_prompts.md", "repo_id": "diffusers", "token_count": 4106 }
89
<!--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...
diffusers/docs/source/ko/optimization/habana.md/0
{ "file_path": "diffusers/docs/source/ko/optimization/habana.md", "repo_id": "diffusers", "token_count": 1912 }
90
<!--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...
diffusers/docs/source/ko/training/instructpix2pix.md/0
{ "file_path": "diffusers/docs/source/ko/training/instructpix2pix.md", "repo_id": "diffusers", "token_count": 5653 }
91
<!--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...
diffusers/docs/source/ko/using-diffusers/inpaint.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/inpaint.md", "repo_id": "diffusers", "token_count": 1657 }
92
<!--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...
diffusers/docs/source/pt/installation.md/0
{ "file_path": "diffusers/docs/source/pt/installation.md", "repo_id": "diffusers", "token_count": 2102 }
93
import inspect from typing import List, Optional, Union import torch from torch import nn from torch.nn import functional as F from torchvision import transforms from transformers import CLIPImageProcessor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, Diffu...
diffusers/examples/community/clip_guided_stable_diffusion.py/0
{ "file_path": "diffusers/examples/community/clip_guided_stable_diffusion.py", "repo_id": "diffusers", "token_count": 6643 }
94
# Copyright 2023 Long Lian, the GLIGEN Authors, and 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...
diffusers/examples/community/llm_grounded_diffusion.py/0
{ "file_path": "diffusers/examples/community/llm_grounded_diffusion.py", "repo_id": "diffusers", "token_count": 33959 }
95
# 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...
diffusers/examples/community/pipeline_prompt2prompt.py/0
{ "file_path": "diffusers/examples/community/pipeline_prompt2prompt.py", "repo_id": "diffusers", "token_count": 16664 }
96
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPipeline, UNet2D...
diffusers/examples/community/stable_diffusion_comparison.py/0
{ "file_path": "diffusers/examples/community/stable_diffusion_comparison.py", "repo_id": "diffusers", "token_count": 7876 }
97
import inspect from typing import List, Optional, Union import PIL.Image import torch from torch.nn import functional as F from transformers import ( CLIPImageProcessor, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionModelWithProjection, ) from diffusers import ( DiffusionPipeline, Imag...
diffusers/examples/community/unclip_image_interpolation.py/0
{ "file_path": "diffusers/examples/community/unclip_image_interpolation.py", "repo_id": "diffusers", "token_count": 10177 }
98
# coding=utf-8 # Copyright 2023 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...
diffusers/examples/dreambooth/test_dreambooth.py/0
{ "file_path": "diffusers/examples/dreambooth/test_dreambooth.py", "repo_id": "diffusers", "token_count": 4467 }
99