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/tracking.py/0
{ "file_path": "accelerate/src/accelerate/tracking.py", "repo_id": "accelerate", "token_count": 17060 }
6
# 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/random.py/0
{ "file_path": "accelerate/src/accelerate/utils/random.py", "repo_id": "accelerate", "token_count": 1885 }
7
- title: Unit 0. Welcome to the RLHF Handbook! sections: - local: chapter0/introduction title: What is this about?
alignment-handbook/chapters/en/_toctree.yml/0
{ "file_path": "alignment-handbook/chapters/en/_toctree.yml", "repo_id": "alignment-handbook", "token_count": 38 }
8
#!/bin/bash # Define an array containing the base configs we wish to fine tune configs=("zephyr" "openhermes") # Define an array of loss types loss_types=("sigmoid" "kto_pair" "ipo") # Define an array of beta values betas=("0.01" "0.1" "0.2" "0.3" "0.4" "0.5" "0.6" "0.7" "0.8" "0.9") # Outer loop for loss types for co...
alignment-handbook/recipes/pref_align_scan/launch_scan.sh/0
{ "file_path": "alignment-handbook/recipes/pref_align_scan/launch_scan.sh", "repo_id": "alignment-handbook", "token_count": 430 }
9
[isort] default_section = FIRSTPARTY ensure_newline_before_comments = True force_grid_wrap = 0 include_trailing_comma = True known_first_party = alignment known_third_party = transformers datasets fugashi git h5py matplotlib nltk numpy packaging pandas psutil pytest r...
alignment-handbook/setup.cfg/0
{ "file_path": "alignment-handbook/setup.cfg", "repo_id": "alignment-handbook", "token_count": 297 }
10
# Using MKL
candle/candle-book/src/advanced/mkl.md/0
{ "file_path": "candle/candle-book/src/advanced/mkl.md", "repo_id": "candle", "token_count": 5 }
11
# Using the hub Install the [`hf-hub`](https://github.com/huggingface/hf-hub) crate: ```bash cargo add hf-hub ``` Then let's start by downloading the [model file](https://huggingface.co/bert-base-uncased/tree/main). ```rust # extern crate candle_core; # extern crate hf_hub; use hf_hub::api::sync::Api; use candle_c...
candle/candle-book/src/inference/hub.md/0
{ "file_path": "candle/candle-book/src/inference/hub.md", "repo_id": "candle", "token_count": 1098 }
12
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle_core::{DType, Device, Tensor}; use criterion::{black_box, criterion_group, Criterion, Throughput}; use std::time::Instant; fn rand_uniform(a: &Tensor) { a.rand_like(-1.0, 123.0).unwrap(); } fn rand_normal(a: &Tensor) { a.randn_like(100.0, 15...
candle/candle-core/benches/benchmarks/random.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/random.rs", "repo_id": "candle", "token_count": 812 }
13
use super::Cpu; use core::arch::wasm32::*; pub struct CurrentCpu {} const STEP: usize = 16; const EPR: usize = 4; const ARR: usize = STEP / EPR; impl Cpu<ARR> for CurrentCpu { type Unit = v128; type Array = [v128; ARR]; const STEP: usize = STEP; const EPR: usize = EPR; fn n() -> usize { ...
candle/candle-core/src/cpu/simd128.rs/0
{ "file_path": "candle/candle-core/src/cpu/simd128.rs", "repo_id": "candle", "token_count": 839 }
14
#![allow(clippy::redundant_closure_call)] use crate::{CpuStorage, CudaStorage, Layout, MetalStorage, Result, Shape, Tensor}; use half::{bf16, f16}; use num_traits::float::Float; #[derive(Clone, Copy, PartialEq, Eq)] pub enum CmpOp { Eq, Ne, Le, Ge, Lt, Gt, } #[derive(Debug, Clone, Copy, Partia...
candle/candle-core/src/op.rs/0
{ "file_path": "candle/candle-core/src/op.rs", "repo_id": "candle", "token_count": 15013 }
15
//! The shape of a tensor is a tuple with the size of each of its dimensions. #![allow(clippy::redundant_closure_call)] use crate::{Error, Result}; #[derive(Clone, PartialEq, Eq)] pub struct Shape(Vec<usize>); pub const SCALAR: Shape = Shape(vec![]); impl std::fmt::Debug for Shape { fn fmt(&self, f: &mut std::fm...
candle/candle-core/src/shape.rs/0
{ "file_path": "candle/candle-core/src/shape.rs", "repo_id": "candle", "token_count": 9806 }
16
use candle_core::{test_device, test_utils, Device, IndexOp, Result, Tensor}; // https://github.com/huggingface/candle/issues/364 fn avg_pool2d(dev: &Device) -> Result<()> { let data: Vec<f32> = vec![ 1., 1., 1., 1., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., ]; let t = Tensor::from_vec(data, (...
candle/candle-core/tests/pool_tests.rs/0
{ "file_path": "candle/candle-core/tests/pool_tests.rs", "repo_id": "candle", "token_count": 2112 }
17
//! Helper functions for the tinystories dataset. This uses the pre-tokenized version as generated //! by the tools from https://github.com/karpathy/llama2.c use candle::{Device, Result, Tensor}; pub struct Dataset { valid_tokens: Vec<memmap2::Mmap>, train_tokens: Vec<memmap2::Mmap>, } fn mmap_file(p: &std::p...
candle/candle-datasets/src/nlp/tinystories.rs/0
{ "file_path": "candle/candle-datasets/src/nlp/tinystories.rs", "repo_id": "candle", "token_count": 2097 }
18
#[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::convnext; #[derive(Clone, Copy, Debug, ValueEnum)] enum Which { At...
candle/candle-examples/examples/convnext/main.rs/0
{ "file_path": "candle/candle-examples/examples/convnext/main.rs", "repo_id": "candle", "token_count": 1926 }
19
# candle-falcon Falcon is a general large language model.
candle/candle-examples/examples/falcon/README.md/0
{ "file_path": "candle/candle-examples/examples/falcon/README.md", "repo_id": "candle", "token_count": 17 }
20
# candle-marian-mt `marian-mt` is a neural machine translation model. In this example it is used to translate text from French to English. See the associated [model card](https://huggingface.co/Helsinki-NLP/opus-mt-tc-big-fr-en) for details on the model itself. ## Running an example ```bash cargo run --example maria...
candle/candle-examples/examples/marian-mt/README.md/0
{ "file_path": "candle/candle-examples/examples/marian-mt/README.md", "repo_id": "candle", "token_count": 497 }
21
use anyhow::Result; use candle::{Device, Tensor}; use clap::{Parser, Subcommand}; #[derive(Subcommand, Debug, Clone)] enum Command { Print { #[arg(long)] file: String, }, SimpleEval { #[arg(long)] file: String, }, } #[derive(Parser, Debug)] #[command(author, version, a...
candle/candle-examples/examples/onnx_basics.rs/0
{ "file_path": "candle/candle-examples/examples/onnx_basics.rs", "repo_id": "candle", "token_count": 2016 }
22
#![allow(unused)] //! Vectorized version of the gym environment. use candle::{DType, Device, Result, Tensor}; use pyo3::prelude::*; use pyo3::types::PyDict; #[derive(Debug)] pub struct Step { pub obs: Tensor, pub reward: Tensor, pub is_done: Tensor, } pub struct VecGymEnv { env: PyObject, action_s...
candle/candle-examples/examples/reinforcement-learning/vec_gym_env.rs/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/vec_gym_env.rs", "repo_id": "candle", "token_count": 1563 }
23
#[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": 967 }
24
use candle::{DType, Device, IndexOp, Result, Tensor}; use candle_nn::{batch_norm, conv2d, conv2d_no_bias, Func, Module, VarBuilder}; use std::collections::BTreeMap; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; #[derive(Debug)] struct Block { block_type: String, parameters: BTreeMa...
candle/candle-examples/examples/yolo-v3/darknet.rs/0
{ "file_path": "candle/candle-examples/examples/yolo-v3/darknet.rs", "repo_id": "candle", "token_count": 5403 }
25
use candle::Result; /// This is a wrapper around a tokenizer to ensure that tokens can be returned to the user in a /// streaming way rather than having to wait for the full decoding. pub struct TokenOutputStream { tokenizer: tokenizers::Tokenizer, tokens: Vec<u32>, prev_index: usize, current_index: us...
candle/candle-examples/src/token_output_stream.rs/0
{ "file_path": "candle/candle-examples/src/token_output_stream.rs", "repo_id": "candle", "token_count": 1295 }
26
/****************************************************************************** * Copyright (c) 2023, Tri Dao. ******************************************************************************/ #pragma once #include <assert.h> #include <stdint.h> #include <stdlib.h> #include <cuda_fp16.h> #if defined(__CUDA_ARCH__) ...
candle/candle-flash-attn/kernels/utils.h/0
{ "file_path": "candle/candle-flash-attn/kernels/utils.h", "repo_id": "candle", "token_count": 6965 }
27
pub const AFFINE: &str = include_str!(concat!(env!("OUT_DIR"), "/affine.ptx")); pub const BINARY: &str = include_str!(concat!(env!("OUT_DIR"), "/binary.ptx")); pub const CAST: &str = include_str!(concat!(env!("OUT_DIR"), "/cast.ptx")); pub const CONV: &str = include_str!(concat!(env!("OUT_DIR"), "/conv.ptx")); pub cons...
candle/candle-kernels/src/lib.rs/0
{ "file_path": "candle/candle-kernels/src/lib.rs", "repo_id": "candle", "token_count": 333 }
28
#include <metal_stdlib> using namespace metal; #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) 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 ...
candle/candle-metal-kernels/src/reduce.metal/0
{ "file_path": "candle/candle-metal-kernels/src/reduce.metal", "repo_id": "candle", "token_count": 8032 }
29
//! Encoding Utilities. (e.g., one-hot/cold encoding) use candle::{bail, DType, Result, Tensor, WithDType}; /// One-hot/cold encoding. /// /// Given an input tensor of indices, this function returns a tensor of the same shape as the input /// tensor with an additional dimension of the given depth size. The values in ...
candle/candle-nn/src/encoding.rs/0
{ "file_path": "candle/candle-nn/src/encoding.rs", "repo_id": "candle", "token_count": 2025 }
30
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use candle::{test_utils, Device, Tensor}; use candle_nn::{LayerNorm, Module}; #[test] fn layer_norm() -> Result<()> { let device = &Device::Cpu; let w = Tensor::new(&[3f32], dev...
candle/candle-nn/tests/layer_norm.rs/0
{ "file_path": "candle/candle-nn/tests/layer_norm.rs", "repo_id": "candle", "token_count": 733 }
31
# Generated content DO NOT EDIT from .. import onnx ONNXModel = onnx.ONNXModel ONNXTensorDescription = onnx.ONNXTensorDescription
candle/candle-pyo3/py_src/candle/onnx/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/onnx/__init__.py", "repo_id": "candle", "token_count": 46 }
32
import candle from candle import Tensor from candle.nn import Linear def test_linear_layer_can_be_constructed(): linear = Linear(10, 10) assert linear is not None def test_linear_layer_can_forward_a_singular_input(): linear = Linear(384, 1536) input_tensor = candle.randn((8, 384)) output = linea...
candle/candle-pyo3/tests/bindings/test_linear.py/0
{ "file_path": "candle/candle-pyo3/tests/bindings/test_linear.py", "repo_id": "candle", "token_count": 431 }
33
//! ConvNeXt implementation. //! //! See "A ConvNet for the 2020s" Liu et al. 2022 //! <https://arxiv.org/abs/2201.03545> //! and //! "ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders" Woo et al. 2023 //! <https://arxiv.org/abs/2301.00808> //! Original code: //! https://github.com/facebookresear...
candle/candle-transformers/src/models/convnext.rs/0
{ "file_path": "candle/candle-transformers/src/models/convnext.rs", "repo_id": "candle", "token_count": 4881 }
34
//! Attention Based Building Blocks use candle::{DType, IndexOp, Result, Tensor, D}; use candle_nn as nn; use candle_nn::Module; #[derive(Debug)] struct GeGlu { proj: nn::Linear, span: tracing::Span, } impl GeGlu { fn new(vs: nn::VarBuilder, dim_in: usize, dim_out: usize) -> Result<Self> { let pro...
candle/candle-transformers/src/models/stable_diffusion/attention.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/attention.rs", "repo_id": "candle", "token_count": 9413 }
35
use crate::models::vit::{Config, Embeddings, Encoder}; use candle::{DType, Result, Tensor}; use candle_nn::{ embedding, layer_norm, linear_no_bias, Embedding, LayerNorm, Linear, Module, VarBuilder, }; fn default_tie_word_embeddings() -> bool { true } fn default_use_learned_position_embeddings() -> bool { t...
candle/candle-transformers/src/models/trocr.rs/0
{ "file_path": "candle/candle-transformers/src/models/trocr.rs", "repo_id": "candle", "token_count": 8465 }
36
/// A bounding box around an object. #[derive(Debug, Clone)] pub struct Bbox<D> { pub xmin: f32, pub ymin: f32, pub xmax: f32, pub ymax: f32, pub confidence: f32, pub data: D, } #[derive(Debug, Clone, Copy, PartialEq)] pub struct KeyPoint { pub x: f32, pub y: f32, pub mask: f32, } ...
candle/candle-transformers/src/object_detection.rs/0
{ "file_path": "candle/candle-transformers/src/object_detection.rs", "repo_id": "candle", "token_count": 894 }
37
use yew_agent::PublicWorker; fn main() { console_error_panic_hook::set_once(); candle_wasm_example_llama2::Worker::register(); }
candle/candle-wasm-examples/llama2-c/src/bin/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/src/bin/worker.rs", "repo_id": "candle", "token_count": 54 }
38
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_wasm_example_sam as sam; use wasm_bindgen::prelude::*; struct Embeddings { original_width: u32, original_height: u32, width: u32, height: u32, data: Tensor, } #[wasm_bindgen] pub struct Model { sam: sam::Sam, embedd...
candle/candle-wasm-examples/segment-anything/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/segment-anything/src/bin/m.rs", "repo_id": "candle", "token_count": 2400 }
39
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Whisper Rust/WASM</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> ...
candle/candle-wasm-examples/whisper/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/whisper/lib-example.html", "repo_id": "candle", "token_count": 6488 }
40
use crate::console_log; use crate::worker::{ModelData, RunData, Worker, WorkerInput, WorkerOutput}; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; use yew::{html, Component, Context, Html}; use yew_agent::{Bridge, Bridged}; async fn fetch_url(url: &str) -> Result<Vec<u8>, JsValue> { use web_sys:...
candle/candle-wasm-examples/yolo/src/app.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/app.rs", "repo_id": "candle", "token_count": 5971 }
41
# Use .env.local to change these variables # DO NOT EDIT THIS FILE WITH SENSITIVE DATA MONGODB_URL=#your mongodb URL here MONGODB_DB_NAME=chat-ui MONGODB_DIRECT_CONNECTION=false COOKIE_NAME=hf-chat HF_TOKEN=#hf_<token> from https://huggingface.co/settings/token HF_API_ROOT=https://api-inference.huggingface.co/models ...
chat-ui/.env/0
{ "file_path": "chat-ui/.env", "repo_id": "chat-ui", "token_count": 2343 }
42
{ "name": "chat-ui", "version": "0.7.0", "private": true, "packageManager": "npm@9.5.0", "scripts": { "dev": "vite dev", "build": "vite build", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./ts...
chat-ui/package.json/0
{ "file_path": "chat-ui/package.json", "repo_id": "chat-ui", "token_count": 1484 }
43
<script lang="ts"> import { onDestroy } from "svelte"; import IconCopy from "./icons/IconCopy.svelte"; import Tooltip from "./Tooltip.svelte"; export let classNames = ""; export let value: string; let isSuccess = false; let timeout: ReturnType<typeof setTimeout>; const handleClick = async () => { // write...
chat-ui/src/lib/components/CopyToClipBoardBtn.svelte/0
{ "file_path": "chat-ui/src/lib/components/CopyToClipBoardBtn.svelte", "repo_id": "chat-ui", "token_count": 433 }
44
<script lang="ts"> export let checked: boolean; export let name: string; </script> <input bind:checked type="checkbox" {name} class="peer pointer-events-none absolute opacity-0" /> <div aria-checked={checked} aria-roledescription="switch" aria-label="switch" role="switch" tabindex="0" class="relative inline-fl...
chat-ui/src/lib/components/Switch.svelte/0
{ "file_path": "chat-ui/src/lib/components/Switch.svelte", "repo_id": "chat-ui", "token_count": 239 }
45
<script lang="ts"> export let classNames = ""; </script> <div class={"inline-flex h-8 flex-none items-center gap-1 " + classNames}> <div class="h-1 w-1 flex-none animate-bounce rounded-full bg-gray-500 dark:bg-gray-400" style="animation-delay: 0.25s;" /> <div class="h-1 w-1 flex-none animate-bounce rounded-f...
chat-ui/src/lib/components/icons/IconLoading.svelte/0
{ "file_path": "chat-ui/src/lib/components/icons/IconLoading.svelte", "repo_id": "chat-ui", "token_count": 223 }
46
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 }
47
import { HF_TOKEN, HF_API_ROOT, MODELS, OLD_MODELS, TASK_MODEL, HF_ACCESS_TOKEN, } from "$env/static/private"; import type { ChatTemplateInput } from "$lib/types/Template"; import { compileTemplate } from "$lib/utils/template"; import { z } from "zod"; import endpoints, { endpointSchema, type Endpoint } from "./e...
chat-ui/src/lib/server/models.ts/0
{ "file_path": "chat-ui/src/lib/server/models.ts", "repo_id": "chat-ui", "token_count": 2084 }
48
import { browser } from "$app/environment"; import { invalidate } from "$app/navigation"; import { base } from "$app/paths"; import { UrlDependency } from "$lib/types/UrlDependency"; import type { ObjectId } from "mongodb"; import { getContext, setContext } from "svelte"; import { type Writable, writable, get } from "s...
chat-ui/src/lib/stores/settings.ts/0
{ "file_path": "chat-ui/src/lib/stores/settings.ts", "repo_id": "chat-ui", "token_count": 983 }
49
import type { ObjectId } from "bson"; import type { Timestamps } from "./Timestamps"; import type { User } from "./User"; export interface Session extends Timestamps { _id: ObjectId; sessionId: string; userId: User["_id"]; userAgent?: string; ip?: string; expiresAt: Date; }
chat-ui/src/lib/types/Session.ts/0
{ "file_path": "chat-ui/src/lib/types/Session.ts", "repo_id": "chat-ui", "token_count": 97 }
50
export function getHref( url: URL | string, modifications: { newKeys?: Record<string, string | undefined | null>; existingKeys?: { behaviour: "delete_except" | "delete"; keys: string[] }; } ) { const newUrl = new URL(url); const { newKeys, existingKeys } = modifications; // exsiting keys logic if (existingK...
chat-ui/src/lib/utils/getHref.ts/0
{ "file_path": "chat-ui/src/lib/utils/getHref.ts", "repo_id": "chat-ui", "token_count": 373 }
51
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { describe, expect, it } from "vitest"; import { insertLegacyConversation, insertSideBranchesConversation } from "./treeHelpers.spec"; import { addChildren } from "./addChildren"; import type { Message } from "$lib/types/Mes...
chat-ui/src/lib/utils/tree/addChildren.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/addChildren.spec.ts", "repo_id": "chat-ui", "token_count": 1301 }
52
import { json } from "@sveltejs/kit"; import type { ConversationStats } from "$lib/types/ConversationStats"; import { CONVERSATION_STATS_COLLECTION, collections } from "$lib/server/database.js"; // Triger like this: // curl -X POST "http://localhost:5173/chat/admin/stats/compute" -H "Authorization: Bearer <ADMIN_API_S...
chat-ui/src/routes/admin/stats/compute/+server.ts/0
{ "file_path": "chat-ui/src/routes/admin/stats/compute/+server.ts", "repo_id": "chat-ui", "token_count": 2379 }
53
import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { error } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; import { z } from "zod"; export async function POST({ params, request, locals }) { const { score } = z .object({ score: z.number().int()...
chat-ui/src/routes/conversation/[id]/message/[messageId]/vote/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/message/[messageId]/vote/+server.ts", "repo_id": "chat-ui", "token_count": 337 }
54
import { redirect } from "@sveltejs/kit"; export const load = async ({ params }) => { throw redirect(302, "../conversation/" + params.id); };
chat-ui/src/routes/r/[id]/+page.ts/0
{ "file_path": "chat-ui/src/routes/r/[id]/+page.ts", "repo_id": "chat-ui", "token_count": 46 }
55
<script lang="ts"> import { base } from "$app/paths"; import { clickOutside } from "$lib/actions/clickOutside"; import { afterNavigate, goto } from "$app/navigation"; import { useSettingsStore } from "$lib/stores/settings"; import CarbonCheckmark from "~icons/carbon/checkmark"; import { fade, fly } from "svelte/...
chat-ui/src/routes/settings/+layout.svelte/0
{ "file_path": "chat-ui/src/routes/settings/+layout.svelte", "repo_id": "chat-ui", "token_count": 513 }
56
import adapter from "@sveltejs/adapter-node"; import { vitePreprocess } from "@sveltejs/kit/vite"; import dotenv from "dotenv"; dotenv.config({ path: "./.env.local" }); dotenv.config({ path: "./.env" }); process.env.PUBLIC_VERSION = process.env.npm_package_version; /** @type {import('@sveltejs/kit').Config} */ const...
chat-ui/svelte.config.js/0
{ "file_path": "chat-ui/svelte.config.js", "repo_id": "chat-ui", "token_count": 253 }
57
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration SPEED_TEST_N_EXAMPLES = 500_000 RESULTS_BASEPATH, RESULTS_FILENAME = os.path.split(__file__) RESULTS_FILE_PATH = os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py", ".json")) @get_d...
datasets/benchmarks/benchmark_indices_mapping.py/0
{ "file_path": "datasets/benchmarks/benchmark_indices_mapping.py", "repo_id": "datasets", "token_count": 677 }
58
# The cache The cache is one of the reasons why 🤗 Datasets is so efficient. It stores previously downloaded and processed datasets so when you need to use them again, they are reloaded directly from the cache. This avoids having to download a dataset all over again, or reapplying processing functions. Even after you ...
datasets/docs/source/about_cache.mdx/0
{ "file_path": "datasets/docs/source/about_cache.mdx", "repo_id": "datasets", "token_count": 909 }
59
# Search index [FAISS](https://github.com/facebookresearch/faiss) and [Elasticsearch](https://www.elastic.co/elasticsearch/) enables searching for examples in a dataset. This can be useful when you want to retrieve specific examples from a dataset that are relevant to your NLP task. For example, if you are working on ...
datasets/docs/source/faiss_es.mdx/0
{ "file_path": "datasets/docs/source/faiss_es.mdx", "repo_id": "datasets", "token_count": 1830 }
60
# Process text data This guide shows specific methods for processing text datasets. Learn how to: - Tokenize a dataset with [`~Dataset.map`]. - Align dataset labels with label ids for NLI datasets. For a guide on how to process any type of dataset, take a look at the <a class="underline decoration-sky-400 decoration...
datasets/docs/source/nlp_process.mdx/0
{ "file_path": "datasets/docs/source/nlp_process.mdx", "repo_id": "datasets", "token_count": 1109 }
61
# Overview Welcome to the 🤗 Datasets tutorials! These beginner-friendly tutorials will guide you through the fundamentals of working with 🤗 Datasets. You'll load and prepare a dataset for training with your machine learning framework of choice. Along the way, you'll learn how to load different dataset configurations...
datasets/docs/source/tutorial.md/0
{ "file_path": "datasets/docs/source/tutorial.md", "repo_id": "datasets", "token_count": 311 }
62
# Copyright 2021 The HuggingFace Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
datasets/metrics/cer/cer.py/0
{ "file_path": "datasets/metrics/cer/cer.py", "repo_id": "datasets", "token_count": 2133 }
63
# Metric Card for Exact Match ## Metric Description A given predicted string's exact match score is 1 if it is the exact same as its reference string, and is 0 otherwise. - **Example 1**: The exact match score of prediction "Happy Birthday!" is 0, given its reference is "Happy New Year!". - **Example 2**: The exact ...
datasets/metrics/exact_match/README.md/0
{ "file_path": "datasets/metrics/exact_match/README.md", "repo_id": "datasets", "token_count": 1508 }
64
# Metric Card for Matthews Correlation Coefficient ## Metric Description The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into account true and false positives and negatives and is generally regarded as a balanced measure wh...
datasets/metrics/matthews_correlation/README.md/0
{ "file_path": "datasets/metrics/matthews_correlation/README.md", "repo_id": "datasets", "token_count": 1251 }
65
# Metric Card for Recall ## Metric Description Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the number of true positives and FN is the number of false negatives. ## How to Use At mini...
datasets/metrics/recall/README.md/0
{ "file_path": "datasets/metrics/recall/README.md", "repo_id": "datasets", "token_count": 1704 }
66
# Copyright 2020 The HuggingFace Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
datasets/metrics/squad/squad.py/0
{ "file_path": "datasets/metrics/squad/squad.py", "repo_id": "datasets", "token_count": 1933 }
67
# Copyright 2022 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/xtreme_s/xtreme_s.py/0
{ "file_path": "datasets/metrics/xtreme_s/xtreme_s.py", "repo_id": "datasets", "token_count": 4467 }
68
import os from argparse import ArgumentParser from pathlib import Path from shutil import copyfile from typing import List from datasets import config from datasets.builder import DatasetBuilder from datasets.commands import BaseDatasetsCLICommand from datasets.download.download_config import DownloadConfig from datas...
datasets/src/datasets/commands/run_beam.py/0
{ "file_path": "datasets/src/datasets/commands/run_beam.py", "repo_id": "datasets", "token_count": 3238 }
69
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class Translation: """`FeatureConnector` for translations with fixed languages per example. Here for ...
datasets/src/datasets/features/translation.py/0
{ "file_path": "datasets/src/datasets/features/translation.py", "repo_id": "datasets", "token_count": 1680 }
70
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.csv.csv import Csv from ..utils import tqdm as hf_tqdm from ..utils.typing import NestedDataStructureLike, PathL...
datasets/src/datasets/io/csv.py/0
{ "file_path": "datasets/src/datasets/io/csv.py", "repo_id": "datasets", "token_count": 2556 }
71
from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder logger = datasets.utils.logging.get_logger(__name__) class AudioFolderConfig(folder_based_builder.FolderBasedBuilderConfig): """Builder Config for AudioFolder.""" ...
datasets/src/datasets/packaged_modules/audiofolder/audiofolder.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/audiofolder/audiofolder.py", "repo_id": "datasets", "token_count": 618 }
72
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast logger = datasets.utils.logging.get_logger(__name__) @dataclass class ParquetConfig(datasets.BuilderConfig): """BuilderCo...
datasets/src/datasets/packaged_modules/parquet/parquet.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/parquet/parquet.py", "repo_id": "datasets", "token_count": 2193 }
73
from typing import Optional from ..utils.logging import get_logger from .audio_classification import AudioClassification from .automatic_speech_recognition import AutomaticSpeechRecognition from .base import TaskTemplate from .image_classification import ImageClassification from .language_modeling import LanguageModel...
datasets/src/datasets/tasks/__init__.py/0
{ "file_path": "datasets/src/datasets/tasks/__init__.py", "repo_id": "datasets", "token_count": 506 }
74
# deprecated, please use datasets.download.download_manager
datasets/src/datasets/utils/download_manager.py/0
{ "file_path": "datasets/src/datasets/utils/download_manager.py", "repo_id": "datasets", "token_count": 13 }
75
name: "" # Filename comes here allow_empty: false allow_empty_text: true subsections: - name: "Dataset Card for X" # First-level markdown heading allow_empty: false allow_empty_text: true subsections: - name: "Table of Contents" allow_empty: false allow_empty_text: false subs...
datasets/src/datasets/utils/resources/readme_structure.yaml/0
{ "file_path": "datasets/src/datasets/utils/resources/readme_structure.yaml", "repo_id": "datasets", "token_count": 1924 }
76
import os import tarfile import warnings from io import BytesIO import numpy as np import pandas as pd import pyarrow as pa import pytest from datasets import Dataset, Features, Image, Sequence, Value, concatenate_datasets, load_dataset from datasets.features.image import encode_np_array, image_to_bytes from ..utils...
datasets/tests/features/test_image.py/0
{ "file_path": "datasets/tests/features/test_image.py", "repo_id": "datasets", "token_count": 11815 }
77
from pathlib import Path import pytest from datasets import load_dataset from datasets.packaged_modules.cache.cache import Cache SAMPLE_DATASET_TWO_CONFIG_IN_METADATA = "hf-internal-testing/audiofolder_two_configs_in_metadata" def test_cache(text_dir: Path): ds = load_dataset(str(text_dir)) hash = Path(ds...
datasets/tests/packaged_modules/test_cache.py/0
{ "file_path": "datasets/tests/packaged_modules/test_cache.py", "repo_id": "datasets", "token_count": 1243 }
78
import os import sys from pathlib import Path import pytest from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node from .utils import execute_subprocess_async, get_torch_dist_unique_port, require_torch def test_split_dataset_by_node_map_style(): full_ds = Dataset.f...
datasets/tests/test_distributed.py/0
{ "file_path": "datasets/tests/test_distributed.py", "repo_id": "datasets", "token_count": 1926 }
79
import re import sys import tempfile import unittest from pathlib import Path import pytest import yaml from huggingface_hub import DatasetCard, DatasetCardData from datasets.config import METADATA_CONFIGS_FIELD from datasets.info import DatasetInfo from datasets.utils.metadata import MetadataConfigs def _dedent(st...
datasets/tests/test_metadata_util.py/0
{ "file_path": "datasets/tests/test_metadata_util.py", "repo_id": "datasets", "token_count": 5453 }
80
import pytest from datasets.utils.version import Version @pytest.mark.parametrize( "other, expected_equality", [ (Version("1.0.0"), True), ("1.0.0", True), (Version("2.0.0"), False), ("2.0.0", False), ("1", False), ("a", False), (1, False), (Non...
datasets/tests/test_version.py/0
{ "file_path": "datasets/tests/test_version.py", "repo_id": "datasets", "token_count": 254 }
81
# Train your first Deep Reinforcement Learning Agent 🤖 [[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/unit1/unit1.ipynb"} ]} ...
deep-rl-class/units/en/unit1/hands-on.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/hands-on.mdx", "repo_id": "deep-rl-class", "token_count": 9469 }
82
# Mid-way Recap [[mid-way-recap]] Before diving into Q-Learning, let's summarize what we've just learned. We have two types of value-based functions: - State-value function: outputs the expected return if **the agent starts at a given state and acts according to the policy forever after.** - Action-value function: o...
deep-rl-class/units/en/unit2/mid-way-recap.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/mid-way-recap.mdx", "repo_id": "deep-rl-class", "token_count": 317 }
83
# Additional Readings These are **optional readings** if you want to go deeper. ## Introduction to Policy Optimization - [Part 3: Intro to Policy Optimization - Spinning Up documentation](https://spinningup.openai.com/en/latest/spinningup/rl_intro3.html) ## Policy Gradient - [https://johnwlambert.github.io/polic...
deep-rl-class/units/en/unit4/additional-readings.mdx/0
{ "file_path": "deep-rl-class/units/en/unit4/additional-readings.mdx", "repo_id": "deep-rl-class", "token_count": 281 }
84
# The Pyramid environment The goal in this environment is to train our agent to **get the gold brick on the top of the Pyramid. To do that, it needs to press a button to spawn a Pyramid, navigate to the Pyramid, knock it over, and move to the gold brick at the top**. <img src="https://huggingface.co/datasets/huggingf...
deep-rl-class/units/en/unit5/pyramids.mdx/0
{ "file_path": "deep-rl-class/units/en/unit5/pyramids.mdx", "repo_id": "deep-rl-class", "token_count": 645 }
85
# Quiz The best way to learn and [to avoid the illusion of competence](https://www.coursera.org/lecture/learning-how-to-learn/illusions-of-competence-BuFzf) **is to test yourself.** This will help you to find **where you need to reinforce your knowledge**. ### Q1: Chose the option which fits better when comparing di...
deep-rl-class/units/en/unit7/quiz.mdx/0
{ "file_path": "deep-rl-class/units/en/unit7/quiz.mdx", "repo_id": "deep-rl-class", "token_count": 1361 }
86
# Let's train and play with Huggy 🐶 [[train]] <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/master/notebooks/bonus-unit1/bonus-unit1.ipynb"} ...
deep-rl-class/units/en/unitbonus1/train.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus1/train.mdx", "repo_id": "deep-rl-class", "token_count": 4009 }
87
# Student Works Since the launch of the Deep Reinforcement Learning Course, **many students have created amazing projects that you should check out and consider participating in**. If you've created an interesting project, don't hesitate to [add it to this list by opening a pull request on the GitHub repository](http...
deep-rl-class/units/en/unitbonus3/student-works.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus3/student-works.mdx", "repo_id": "deep-rl-class", "token_count": 629 }
88
import os import sys import torch from diffusers import ( AutoPipelineForImage2Image, AutoPipelineForInpainting, AutoPipelineForText2Image, ControlNetModel, LCMScheduler, StableDiffusionAdapterPipeline, StableDiffusionControlNetPipeline, StableDiffusionXLAdapterPipeline, StableDiff...
diffusers/benchmarks/base_classes.py/0
{ "file_path": "diffusers/benchmarks/base_classes.py", "repo_id": "diffusers", "token_count": 5600 }
89
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/loaders/textual_inversion.md/0
{ "file_path": "diffusers/docs/source/en/api/loaders/textual_inversion.md", "repo_id": "diffusers", "token_count": 340 }
90
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/pipelines/ddim.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/ddim.md", "repo_id": "diffusers", "token_count": 477 }
91
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/api/pipelines/stable_diffusion/overview.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/overview.md", "repo_id": "diffusers", "token_count": 4759 }
92
<!--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/optimization/xformers.md/0
{ "file_path": "diffusers/docs/source/en/optimization/xformers.md", "repo_id": "diffusers", "token_count": 447 }
93
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/training/t2i_adapters.md/0
{ "file_path": "diffusers/docs/source/en/training/t2i_adapters.md", "repo_id": "diffusers", "token_count": 3502 }
94
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/custom_pipeline_examples.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/custom_pipeline_examples.md", "repo_id": "diffusers", "token_count": 1896 }
95
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/en/using-diffusers/merge_loras.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/merge_loras.md", "repo_id": "diffusers", "token_count": 4459 }
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/using-diffusers/using_safetensors.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/using_safetensors.md", "repo_id": "diffusers", "token_count": 1535 }
97
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/ko/optimization/fp16.md/0
{ "file_path": "diffusers/docs/source/ko/optimization/fp16.md", "repo_id": "diffusers", "token_count": 10776 }
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/ko/training/dreambooth.md/0
{ "file_path": "diffusers/docs/source/ko/training/dreambooth.md", "repo_id": "diffusers", "token_count": 11697 }
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/ko/using-diffusers/img2img.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/img2img.md", "repo_id": "diffusers", "token_count": 2084 }
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/pt/index.md/0
{ "file_path": "diffusers/docs/source/pt/index.md", "repo_id": "diffusers", "token_count": 1653 }
101
from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNet2DConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.schedulers.scheduling_ddpm im...
diffusers/examples/community/bit_diffusion.py/0
{ "file_path": "diffusers/examples/community/bit_diffusion.py", "repo_id": "diffusers", "token_count": 4362 }
102
# Copyright 2024 Stanford University Team 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 # #...
diffusers/examples/community/latent_consistency_img2img.py/0
{ "file_path": "diffusers/examples/community/latent_consistency_img2img.py", "repo_id": "diffusers", "token_count": 16142 }
103
import inspect import os import random import warnings from typing import Any, Callable, Dict, List, Optional, Tuple, Union import matplotlib.pyplot as plt import torch import torch.nn.functional as F from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers.image_processor imp...
diffusers/examples/community/pipeline_demofusion_sdxl.py/0
{ "file_path": "diffusers/examples/community/pipeline_demofusion_sdxl.py", "repo_id": "diffusers", "token_count": 34622 }
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 applicabl...
diffusers/examples/community/sd_text2img_k_diffusion.py/0
{ "file_path": "diffusers/examples/community/sd_text2img_k_diffusion.py", "repo_id": "diffusers", "token_count": 8539 }
105