text
stringlengths
7
328k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
459
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/utils/dataclasses.py/0
{ "file_path": "accelerate/src/accelerate/utils/dataclasses.py", "repo_id": "accelerate", "token_count": 32006 }
9
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/utils/transformer_engine.py/0
{ "file_path": "accelerate/src/accelerate/utils/transformer_engine.py", "repo_id": "accelerate", "token_count": 1481 }
10
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_data_loader.py/0
{ "file_path": "accelerate/tests/test_data_loader.py", "repo_id": "accelerate", "token_count": 8488 }
11
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_scheduler.py/0
{ "file_path": "accelerate/tests/test_scheduler.py", "repo_id": "accelerate", "token_count": 2538 }
12
# Constitutional AI This repo includes the recipe for training the following models: * https://huggingface.co/HuggingFaceH4/mistral-7b-anthropic * https://huggingface.co/HuggingFaceH4/mistral-7b-grok ## Full training examples You will require 8 GPUs (80GB of VRAM) to train the full model. ```shell # Step 1 - SFT ...
alignment-handbook/recipes/constitutional-ai/README.md/0
{ "file_path": "alignment-handbook/recipes/constitutional-ai/README.md", "repo_id": "alignment-handbook", "token_count": 326 }
13
# Instructions to Replicate Zephyr-7b-β As described in the Zephyr [technical report](https://huggingface.co/papers/2310.16944), training this model proceeds in two steps: 1. Apply SFT to fine-tune Mistral 7B on a filtered version of the UltraChat dataset ([link](https://huggingface.co/datasets/HuggingFaceH4/ultrach...
alignment-handbook/recipes/zephyr-7b-beta/README.md/0
{ "file_path": "alignment-handbook/recipes/zephyr-7b-beta/README.md", "repo_id": "alignment-handbook", "token_count": 888 }
14
# 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/data.py/0
{ "file_path": "alignment-handbook/src/alignment/data.py", "repo_id": "alignment-handbook", "token_count": 3848 }
15
{ "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" }, "python.formatting.provider": "none", "python.testing.pytestArgs": [ "candle-pyo3" ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true }
candle/.vscode/settings.json/0
{ "file_path": "candle/.vscode/settings.json", "repo_id": "candle", "token_count": 123 }
16
# Creating a WASM app
candle/candle-book/src/apps/wasm.md/0
{ "file_path": "candle/candle-book/src/apps/wasm.md", "repo_id": "candle", "token_count": 7 }
17
# Fine-tuning
candle/candle-book/src/training/finetuning.md/0
{ "file_path": "candle/candle-book/src/training/finetuning.md", "repo_id": "candle", "token_count": 6 }
18
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use std::str::FromStr; use anyhow::Result; use candle_core::{Device, Tensor}; fn cos_sin(n: usize, device: &Device) -> Result<Tensor> { let thetas: Vec<_> = (0..n).map(|i| (i as f32 / n as f32)).colle...
candle/candle-core/examples/cuda_sum_benchmark.rs/0
{ "file_path": "candle/candle-core/examples/cuda_sum_benchmark.rs", "repo_id": "candle", "token_count": 827 }
19
use crate::backend::BackendDevice; use crate::cpu_backend::CpuDevice; use crate::{CpuStorage, DType, Result, Shape, Storage, WithDType}; /// A `DeviceLocation` represents a physical device whereas multiple `Device` /// can live on the same location (typically for cuda devices). #[derive(Debug, Copy, Clone, PartialEq, ...
candle/candle-core/src/device.rs/0
{ "file_path": "candle/candle-core/src/device.rs", "repo_id": "candle", "token_count": 5149 }
20
#![allow(unused)] use super::GgmlDType; use crate::{CudaDevice, CudaStorage, Error, Result}; pub struct QCudaStorage { dtype: GgmlDType, device: CudaDevice, } impl QCudaStorage { pub fn zeros(_: &CudaDevice, _: usize, _: GgmlDType) -> Result<Self> { Err(Error::NotCompiledWithCudaSupport) } ...
candle/candle-core/src/quantized/dummy_cuda.rs/0
{ "file_path": "candle/candle-core/src/quantized/dummy_cuda.rs", "repo_id": "candle", "token_count": 537 }
21
use crate::{shape::Dim, Error, Result, Shape, Tensor}; impl Tensor { /// Concatenates two or more tensors along a particular dimension. /// /// All tensors must of the same rank, and the output will have /// the same rank /// /// ```rust /// # use candle_core::{Tensor, DType, Device}; /...
candle/candle-core/src/tensor_cat.rs/0
{ "file_path": "candle/candle-core/src/tensor_cat.rs", "repo_id": "candle", "token_count": 5110 }
22
use candle_core::{DType, Result, Tensor}; #[test] fn npy() -> Result<()> { let npy = Tensor::read_npy("tests/test.npy")?; assert_eq!( npy.to_dtype(DType::U8)?.to_vec1::<u8>()?, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ); Ok(()) } #[test] fn npz() -> Result<()> { let npz = Tensor::read_npz("t...
candle/candle-core/tests/serialization_tests.rs/0
{ "file_path": "candle/candle-core/tests/serialization_tests.rs", "repo_id": "candle", "token_count": 333 }
23
[package] name = "candle-examples" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true readme = "README.md" [dependencies] accelerate-src = { workspace = true, optional = true } candle ...
candle/candle-examples/Cargo.toml/0
{ "file_path": "candle/candle-examples/Cargo.toml", "repo_id": "candle", "token_count": 1090 }
24
// This example illustrates how to implement custom operations. These operations can provide their // own forward pass (CPU and GPU versions) as well as their backward pass. // // In this example we add the RMS normalization operation and implement it for f32. #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[rus...
candle/candle-examples/examples/custom-ops/main.rs/0
{ "file_path": "candle/candle-examples/examples/custom-ops/main.rs", "repo_id": "candle", "token_count": 1475 }
25
# candle-jina-bert Jina-Bert is a general large language model with a context size of 8192, [model card](https://huggingface.co/jinaai/jina-embeddings-v2-base-en). In this example it can be used for two different tasks: - Compute sentence embeddings for a prompt. - Compute similarities between a set of sentences. ##...
candle/candle-examples/examples/jina-bert/README.md/0
{ "file_path": "candle/candle-examples/examples/jina-bert/README.md", "repo_id": "candle", "token_count": 663 }
26
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use clap::Parser; use std::io::Write; use candle_transformers::generation::LogitsProcessor; use candle_transformers::models::encodec; use candle_transformers::models::metavoice::{adapte...
candle/candle-examples/examples/metavoice/main.rs/0
{ "file_path": "candle/candle-examples/examples/metavoice/main.rs", "repo_id": "candle", "token_count": 4560 }
27
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use std::io::Write; use std::path::PathBuf; use candle_transformers::models::quantized_t5 as t5; use anyhow::{Error as E, Result}; use candle::{Device, Tensor}; use candle_transformers::generation::LogitsP...
candle/candle-examples/examples/quantized-t5/main.rs/0
{ "file_path": "candle/candle-examples/examples/quantized-t5/main.rs", "repo_id": "candle", "token_count": 3631 }
28
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::repvgg; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { A0, ...
candle/candle-examples/examples/repvgg/main.rs/0
{ "file_path": "candle/candle-examples/examples/repvgg/main.rs", "repo_id": "candle", "token_count": 1525 }
29
#[cfg(feature = "accelerate")] extern crate accelerate_src; #[cfg(feature = "mkl")] extern crate intel_mkl_src; use candle_transformers::models::stable_diffusion; use anyhow::{Error as E, Result}; use candle::{DType, Device, IndexOp, Module, Tensor, D}; use clap::Parser; use tokenizers::Tokenizer; #[derive(Parser)]...
candle/candle-examples/examples/stable-diffusion/main.rs/0
{ "file_path": "candle/candle-examples/examples/stable-diffusion/main.rs", "repo_id": "candle", "token_count": 9556 }
30
# candle-yolo-v8: Object Detection and Pose Estimation This is a port of [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics). The implementation is based on the [tinygrad version](https://github.com/tinygrad/tinygrad/blob/master/examples/yolov8.py) and on the model architecture described in this [issue](h...
candle/candle-examples/examples/yolo-v8/README.md/0
{ "file_path": "candle/candle-examples/examples/yolo-v8/README.md", "repo_id": "candle", "token_count": 562 }
31
// Build script to run nvcc and generate the C glue code for launching the flash-attention kernel. // The cuda build time is very long so one can set the CANDLE_FLASH_ATTN_BUILD_DIR environment // variable in order to cache the compiled artifacts and avoid recompiling too often. use anyhow::{Context, Result}; use std::...
candle/candle-flash-attn/build.rs/0
{ "file_path": "candle/candle-flash-attn/build.rs", "repo_id": "candle", "token_count": 1604 }
32
[package] name = "candle-kernels" version = "0.4.2" edition = "2021" description = "CUDA kernels for Candle" repository = "https://github.com/huggingface/candle" keywords = ["blas", "tensor", "machine-learning"] categories = ["science"] license = "MIT OR Apache-2.0" [dependencies] [build-dependencies] bindgen_cuda =...
candle/candle-kernels/Cargo.toml/0
{ "file_path": "candle/candle-kernels/Cargo.toml", "repo_id": "candle", "token_count": 126 }
33
#define _USE_MATH_DEFINES #include<math.h> #include<stdint.h> #include "cuda_utils.cuh" #define UNARY_OP(TYPENAME, FN_NAME, FUNC) \ 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 size_...
candle/candle-kernels/src/unary.cu/0
{ "file_path": "candle/candle-kernels/src/unary.cu", "repo_id": "candle", "token_count": 3386 }
34
use candle_metal_kernels::{call_affine, Kernels}; 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 kernels = Kernels::new(); let f32_1k = (0..1000).map(|...
candle/candle-metal-kernels/tmp/affine.rs/0
{ "file_path": "candle/candle-metal-kernels/tmp/affine.rs", "repo_id": "candle", "token_count": 1154 }
35
//! Layer Normalization. //! //! This layer applies Layer Normalization over a mini-batch of inputs as described in [`Layer //! Normalization`]. The input is expected to have three dimensions: a batch dimension, a length, //! and a hidden size, the normalization is applied over the last dimension. //! //! # Example //!...
candle/candle-nn/src/layer_norm.rs/0
{ "file_path": "candle/candle-nn/src/layer_norm.rs", "repo_id": "candle", "token_count": 2263 }
36
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::test_utils::{to_vec0_round, to_vec2_round}; use anyhow::Result; use candle::{DType, Device, Tensor, Var}; use candle_nn::{AdamW, Linear, Module, Optimizer, ParamsAdamW, SGD}; #[test] fn sgd_op...
candle/candle-nn/tests/optim.rs/0
{ "file_path": "candle/candle-nn/tests/optim.rs", "repo_id": "candle", "token_count": 2568 }
37
import logging try: from .candle import * except ImportError as e: # If we are in development mode, or we did not bundle the DLLs, we try to locate them here # PyO3 wont give us any information about what DLLs are missing, so we can only try to load # the DLLs and re-import the module logging.warni...
candle/candle-pyo3/py_src/candle/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/__init__.py", "repo_id": "candle", "token_count": 919 }
38
# Generated content DO NOT EDIT from .. import utils cuda_is_available = utils.cuda_is_available get_num_threads = utils.get_num_threads has_accelerate = utils.has_accelerate has_mkl = utils.has_mkl load_ggml = utils.load_ggml load_gguf = utils.load_gguf load_safetensors = utils.load_safetensors save_gguf = utils.save...
candle/candle-pyo3/py_src/candle/utils/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/utils/__init__.py", "repo_id": "candle", "token_count": 150 }
39
import candle from candle import Tensor from candle.utils import cuda_is_available from candle.testing import assert_equal import pytest def test_tensor_can_be_constructed(): t = Tensor(42.0) assert t.values() == 42.0 def test_tensor_can_be_constructed_from_list(): t = Tensor([3.0, 1, 4, 1, 5, 9, 2, 6])...
candle/candle-pyo3/tests/native/test_tensor.py/0
{ "file_path": "candle/candle-pyo3/tests/native/test_tensor.py", "repo_id": "candle", "token_count": 4688 }
40
//! EfficientViT (MSRA) inference implementation based on timm. //! //! See "EfficientViT: Memory Efficient Vision Transformer with Cascaded Group Attention" //! https://arxiv.org/abs/2305.07027 //! https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/efficientvit_msra.py use candle::{Result, Tenso...
candle/candle-transformers/src/models/efficientvit.rs/0
{ "file_path": "candle/candle-transformers/src/models/efficientvit.rs", "repo_id": "candle", "token_count": 6985 }
41
use crate::models::with_tracing::{linear_no_bias, Embedding, Linear}; /// MPT model used by replit-code-v1_5-3b /// https://huggingface.co/replit/replit-code-v1_5-3b/blob/main/modeling_mpt.py use candle::{DType, Device, IndexOp, Module, Result, Tensor, D}; use candle_nn::{layer_norm, LayerNorm, VarBuilder}; // https:/...
candle/candle-transformers/src/models/mpt.rs/0
{ "file_path": "candle/candle-transformers/src/models/mpt.rs", "repo_id": "candle", "token_count": 5485 }
42
//! RepVGG inference implementation //! //! See "RepVGG: Making VGG-style ConvNets Great Again" Ding et al. 2021 //! https://arxiv.org/abs/2101.03697 use candle::{Result, Tensor, D}; use candle_nn::{ batch_norm, conv2d_no_bias, linear, BatchNorm, Conv2d, Conv2dConfig, Func, VarBuilder, }; const CHANNELS_PER_STAGE...
candle/candle-transformers/src/models/repvgg.rs/0
{ "file_path": "candle/candle-transformers/src/models/repvgg.rs", "repo_id": "candle", "token_count": 4371 }
43
use candle::{Result, Tensor, D}; use candle_nn as nn; use candle_nn::Module; #[derive(Debug)] pub struct TimestepEmbedding { linear_1: nn::Linear, linear_2: nn::Linear, } impl TimestepEmbedding { // act_fn: "silu" pub fn new(vs: nn::VarBuilder, channel: usize, time_embed_dim: usize) -> Result<Self> { ...
candle/candle-transformers/src/models/stable_diffusion/embeddings.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/embeddings.rs", "repo_id": "candle", "token_count": 1008 }
44
pub mod audio; pub mod model; pub mod quantized_model; use serde::Deserialize; // The names in comments correspond to the original implementation: // https://github.com/openai/whisper/blob/f572f2161ba831bae131364c3bffdead7af6d210/whisper/model.py#L17 #[derive(Debug, Clone, PartialEq, Deserialize)] pub struct Config {...
candle/candle-transformers/src/models/whisper/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/whisper/mod.rs", "repo_id": "candle", "token_count": 812 }
45
use candle::quantized::QTensor; use candle::{Device, Result, Shape}; use std::sync::Arc; // VarBuilder specialized for QTensors #[derive(Clone)] pub struct VarBuilder { data: Arc<std::collections::HashMap<String, Arc<QTensor>>>, path: Vec<String>, device: Device, } impl VarBuilder { pub fn from_gguf<P...
candle/candle-transformers/src/quantized_var_builder.rs/0
{ "file_path": "candle/candle-transformers/src/quantized_var_builder.rs", "repo_id": "candle", "token_count": 1559 }
46
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::generation::LogitsProcessor; use candle_transformers::models::blip; use candle_transformers::models::quantized_blip; use candle_wasm_example_blip::console_log; use candle_wasm_example_blip::token_output_stream::TokenOutputStream; u...
candle/candle-wasm-examples/blip/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/blip/src/bin/m.rs", "repo_id": "candle", "token_count": 2699 }
47
//load Candle Bert Module wasm module let init, ModelConditionalGeneration; async function fetchArrayBuffer(url) { const cacheName = "t5-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse.arrayBuf...
candle/candle-wasm-examples/t5/T5ModelConditionalGeneration.js/0
{ "file_path": "candle/candle-wasm-examples/t5/T5ModelConditionalGeneration.js", "repo_id": "candle", "token_count": 980 }
48
fn main() { wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); yew::Renderer::<candle_wasm_example_whisper::App>::new().render(); }
candle/candle-wasm-examples/whisper/src/bin/app.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/bin/app.rs", "repo_id": "candle", "token_count": 67 }
49
module.exports = { root: true, parser: "@typescript-eslint/parser", extends: [ "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:svelte/recommended", "prettier", ], plugins: ["@typescript-eslint"], ignorePatterns: ["*.cjs"], overrides: [ { files: ["*.svelte"], parser: "svelte...
chat-ui/.eslintrc.cjs/0
{ "file_path": "chat-ui/.eslintrc.cjs", "repo_id": "chat-ui", "token_count": 419 }
50
engine-strict=true
chat-ui/.npmrc/0
{ "file_path": "chat-ui/.npmrc", "repo_id": "chat-ui", "token_count": 7 }
51
import fs from "fs"; const HF_DEPLOYMENT_TOKEN = process.env.HF_DEPLOYMENT_TOKEN; // token used for pushing to hub const SERPER_API_KEY = process.env.SERPER_API_KEY; const OPENID_CONFIG = process.env.OPENID_CONFIG; const MONGODB_URL = process.env.MONGODB_URL; const HF_TOKEN = process.env.HF_TOKEN ?? process.env.HF_AC...
chat-ui/scripts/updateProdEnv.ts/0
{ "file_path": "chat-ui/scripts/updateProdEnv.ts", "repo_id": "chat-ui", "token_count": 628 }
52
<script lang="ts"> import { navigating } from "$app/stores"; import { createEventDispatcher } from "svelte"; import { browser } from "$app/environment"; import { base } from "$app/paths"; import { page } from "$app/stores"; import CarbonClose from "~icons/carbon/close"; import CarbonTextAlignJustify from "~icon...
chat-ui/src/lib/components/MobileNav.svelte/0
{ "file_path": "chat-ui/src/lib/components/MobileNav.svelte", "repo_id": "chat-ui", "token_count": 692 }
53
<script lang="ts"> import CarbonUpload from "~icons/carbon/upload"; export let classNames = ""; export let files: File[]; let filelist: FileList; $: if (filelist) { files = Array.from(filelist); } </script> <button class="btn relative h-8 rounded-lg border bg-white px-3 py-1 text-sm text-gray-500 shadow-sm ...
chat-ui/src/lib/components/UploadBtn.svelte/0
{ "file_path": "chat-ui/src/lib/components/UploadBtn.svelte", "repo_id": "chat-ui", "token_count": 233 }
54
export const PUBLIC_SEP_TOKEN = "</s>";
chat-ui/src/lib/constants/publicSepToken.ts/0
{ "file_path": "chat-ui/src/lib/constants/publicSepToken.ts", "repo_id": "chat-ui", "token_count": 16 }
55
import type { Conversation } from "$lib/types/Conversation"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import { endpointTgi, endpointTgiParametersSchema } from "./tgi/endpointTgi"; import { z } from "zod"; import endpointAws, { endpointAwsParametersSchema } from "./aws/endpointAws"; impo...
chat-ui/src/lib/server/endpoints/endpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/endpoints.ts", "repo_id": "chat-ui", "token_count": 552 }
56
import { z } from "zod"; import { USAGE_LIMITS, RATE_LIMIT } from "$env/static/private"; import JSON5 from "json5"; // RATE_LIMIT is the legacy way to define messages per minute limit export const usageLimitsSchema = z .object({ conversations: z.coerce.number().optional(), // how many conversations messages: z.co...
chat-ui/src/lib/server/usageLimits.ts/0
{ "file_path": "chat-ui/src/lib/server/usageLimits.ts", "repo_id": "chat-ui", "token_count": 297 }
57
// Ideally shouldn't be needed, see https://github.com/huggingface/chat-ui/pull/88#issuecomment-1523173850 import type { Conversation } from "./Conversation"; import type { Timestamps } from "./Timestamps"; export interface AbortedGeneration extends Timestamps { conversationId: Conversation["_id"]; }
chat-ui/src/lib/types/AbortedGeneration.ts/0
{ "file_path": "chat-ui/src/lib/types/AbortedGeneration.ts", "repo_id": "chat-ui", "token_count": 93 }
58
export interface Timestamps { createdAt: Date; updatedAt: Date; }
chat-ui/src/lib/types/Timestamps.ts/0
{ "file_path": "chat-ui/src/lib/types/Timestamps.ts", "repo_id": "chat-ui", "token_count": 23 }
59
import { PUBLIC_APP_ASSETS } from "$env/static/public"; export const isHuggingChat = PUBLIC_APP_ASSETS === "huggingchat";
chat-ui/src/lib/utils/isHuggingChat.ts/0
{ "file_path": "chat-ui/src/lib/utils/isHuggingChat.ts", "repo_id": "chat-ui", "token_count": 40 }
60
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { describe, expect, it } from "vitest"; import { insertLegacyConversation, insertLinearBranchConversation, insertSideBranchesConversation, } from "./treeHelpers.spec"; import { buildSubtree } from "./buildSubtree"; descr...
chat-ui/src/lib/utils/tree/buildSubtree.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/buildSubtree.spec.ts", "repo_id": "chat-ui", "token_count": 1375 }
61
export async function GET({ locals }) { if (locals.user) { const res = { id: locals.user._id, username: locals.user.username, name: locals.user.name, email: locals.user.email, avatarUrl: locals.user.avatarUrl, hfUserId: locals.user.hfUserId, }; return Response.json(res); } return Response.js...
chat-ui/src/routes/api/user/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/user/+server.ts", "repo_id": "chat-ui", "token_count": 148 }
62
import { base } from "$app/paths"; import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { redirect } from "@sveltejs/kit"; export const actions = { async delete({ locals }) { // double check we have a user to delete conversations for if (locals.user?._id || ...
chat-ui/src/routes/conversations/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/conversations/+page.server.ts", "repo_id": "chat-ui", "token_count": 158 }
63
<script lang="ts"> import { page } from "$app/stores"; import { base } from "$app/paths"; import { PUBLIC_ORIGIN } from "$env/static/public"; import type { BackendModel } from "$lib/server/models"; import { useSettingsStore } from "$lib/stores/settings"; import CopyToClipBoardBtn from "$lib/components/CopyToClipB...
chat-ui/src/routes/settings/(nav)/[...model]/+page.svelte/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/[...model]/+page.svelte", "repo_id": "chat-ui", "token_count": 1518 }
64
# 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 }
65
# 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 }
66
# 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 }
67
# 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 }
68
# 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 }
69
# 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 }
70
# 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 }
71
# 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 }
72
# 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 }
73
# 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 }
74
# 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/all...
datasets/setup.py/0
{ "file_path": "datasets/setup.py", "repo_id": "datasets", "token_count": 4180 }
75
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 fsspec.core import url_to_fs from huggingface_h...
datasets/src/datasets/dataset_dict.py/0
{ "file_path": "datasets/src/datasets/dataset_dict.py", "repo_id": "datasets", "token_count": 47116 }
76
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 }
77
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class SparkDatasetReader(AbstractDatasetReader): """A dataset reader that reads from a Spark DataFrame. ...
datasets/src/datasets/io/spark.py/0
{ "file_path": "datasets/src/datasets/io/spark.py", "repo_id": "datasets", "token_count": 787 }
78
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_util...
datasets/src/datasets/packaged_modules/csv/csv.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/csv/csv.py", "repo_id": "datasets", "token_count": 4003 }
79
import sys from dataclasses import dataclass from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast if TYPE_CHECKING: im...
datasets/src/datasets/packaged_modules/sql/sql.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/sql/sql.py", "repo_id": "datasets", "token_count": 1963 }
80
# deprecated, please use the `filelock` package instead from filelock import ( # noqa: F401 # imported for backward compatibility TODO: remove in 3.0.0 BaseFileLock, SoftFileLock, Timeout, UnixFileLock, WindowsFileLock, ) from ._filelock import FileLock # noqa: F401 # imported for backward compa...
datasets/src/datasets/utils/filelock.py/0
{ "file_path": "datasets/src/datasets/utils/filelock.py", "repo_id": "datasets", "token_count": 115 }
81
# Copyright 2022 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/utils/tf_utils.py/0
{ "file_path": "datasets/src/datasets/utils/tf_utils.py", "repo_id": "datasets", "token_count": 11176 }
82
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node NUM_SHARDS = 4 NUM_ITEMS_PER_SHARD = 3 class FailedTestError(RuntimeError): pass def gen(shards: List[str]): ...
datasets/tests/distributed_scripts/run_torch_distributed.py/0
{ "file_path": "datasets/tests/distributed_scripts/run_torch_distributed.py", "repo_id": "datasets", "token_count": 617 }
83
import os import time import uuid from contextlib import contextmanager from typing import Optional import pytest import requests from huggingface_hub.hf_api import HfApi, RepositoryNotFoundError CI_HUB_USER = "__DUMMY_TRANSFORMERS_USER__" CI_HUB_USER_FULL_NAME = "Dummy User" CI_HUB_USER_TOKEN = "hf_hZEmnoOEYISjraJt...
datasets/tests/fixtures/hub.py/0
{ "file_path": "datasets/tests/fixtures/hub.py", "repo_id": "datasets", "token_count": 2270 }
84
import textwrap import pyarrow as pa import pytest from datasets import Features, Value from datasets.packaged_modules.json.json import Json @pytest.fixture def jsonl_file(tmp_path): filename = tmp_path / "file.jsonl" data = textwrap.dedent( """\ {"col_1": -1} {"col_1": 1, "col_2": 2...
datasets/tests/packaged_modules/test_json.py/0
{ "file_path": "datasets/tests/packaged_modules/test_json.py", "repo_id": "datasets", "token_count": 2009 }
85
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, get_...
datasets/tests/test_file_utils.py/0
{ "file_path": "datasets/tests/test_file_utils.py", "repo_id": "datasets", "token_count": 2016 }
86
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def add_one(i): # picklable for multiprocessing return i + 1 @require_dill_gt_0_3_2 @require_jo...
datasets/tests/test_parallel.py/0
{ "file_path": "datasets/tests/test_parallel.py", "repo_id": "datasets", "token_count": 825 }
87
- 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 }
88
# 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 }
89
# 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": 1097 }
90
# 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 }
91
# 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 }
92
# 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 }
93
# (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 }
94
import argparse import sys sys.path.append(".") from base_classes import InpaintingBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="runwayml/stable-diffusion-v1-5", choices=[ "r...
diffusers/benchmarks/benchmark_sd_inpainting.py/0
{ "file_path": "diffusers/benchmarks/benchmark_sd_inpainting.py", "repo_id": "diffusers", "token_count": 362 }
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/TRANSLATING.md/0
{ "file_path": "diffusers/docs/TRANSLATING.md", "repo_id": "diffusers", "token_count": 1100 }
96
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/models/autoencoder_tiny.md/0
{ "file_path": "diffusers/docs/source/en/api/models/autoencoder_tiny.md", "repo_id": "diffusers", "token_count": 670 }
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/outputs.md/0
{ "file_path": "diffusers/docs/source/en/api/outputs.md", "repo_id": "diffusers", "token_count": 554 }
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/pipelines/dit.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/dit.md", "repo_id": "diffusers", "token_count": 532 }
99
<!--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/stable_diffusion_xl.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.md", "repo_id": "diffusers", "token_count": 1005 }
100
<!--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/installation.md/0
{ "file_path": "diffusers/docs/source/en/installation.md", "repo_id": "diffusers", "token_count": 1585 }
101
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/training/controlnet.md/0
{ "file_path": "diffusers/docs/source/en/training/controlnet.md", "repo_id": "diffusers", "token_count": 4988 }
102
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/training/wuerstchen.md/0
{ "file_path": "diffusers/docs/source/en/training/wuerstchen.md", "repo_id": "diffusers", "token_count": 2904 }
103
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/distilled_sd.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/distilled_sd.md", "repo_id": "diffusers", "token_count": 1680 }
104
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/push_to_hub.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/push_to_hub.md", "repo_id": "diffusers", "token_count": 2083 }
105
<!--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/ja/index.md/0
{ "file_path": "diffusers/docs/source/ja/index.md", "repo_id": "diffusers", "token_count": 2031 }
106
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/ko/optimization/open_vino.md/0
{ "file_path": "diffusers/docs/source/ko/optimization/open_vino.md", "repo_id": "diffusers", "token_count": 920 }
107
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/ko/training/text2image.md/0
{ "file_path": "diffusers/docs/source/ko/training/text2image.md", "repo_id": "diffusers", "token_count": 6015 }
108