text
stringlengths
7
324k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
463
#include "binary_op_macros.cuh" #include<stdint.h> #if __CUDA_ARCH__ >= 800 BINARY_OP(__nv_bfloat16, badd_bf16, x + y) BINARY_OP(__nv_bfloat16, bdiv_bf16, x / y) BINARY_OP(__nv_bfloat16, bmul_bf16, x * y) BINARY_OP(__nv_bfloat16, bsub_bf16, x - y) BINARY_OP(__nv_bfloat16, bmaximum_bf16, maxg(x, y)) BINARY_OP(__nv_bflo...
candle/candle-kernels/src/binary.cu/0
{ "file_path": "candle/candle-kernels/src/binary.cu", "repo_id": "candle", "token_count": 2144 }
33
#include <metal_stdlib> #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 < num_dims; d++) { ...
candle/candle-metal-kernels/src/binary.metal/0
{ "file_path": "candle/candle-metal-kernels/src/binary.metal", "repo_id": "candle", "token_count": 1688 }
34
[package] name = "candle-nn" 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 = { wo...
candle/candle-nn/Cargo.toml/0
{ "file_path": "candle/candle-nn/Cargo.toml", "repo_id": "candle", "token_count": 325 }
35
use candle::{CpuStorage, Layout, Result, Shape, Tensor}; use rayon::prelude::*; /// Applies the softmax function to the input tensor, rescaling the element so that elements on /// a slice of fixed index on dimension `dim` are between 0 and 1 and sum to 1. /// /// ```rust /// use candle::{Tensor, Device, test_utils::to...
candle/candle-nn/src/ops.rs/0
{ "file_path": "candle/candle-nn/src/ops.rs", "repo_id": "candle", "token_count": 5225 }
36
use std::io::Result; fn main() -> Result<()> { prost_build::compile_protos(&["src/onnx.proto3"], &["src/"])?; Ok(()) }
candle/candle-onnx/build.rs/0
{ "file_path": "candle/candle-onnx/build.rs", "repo_id": "candle", "token_count": 60 }
37
from dataclasses import dataclass from typing import Optional from candle.nn import Module, Embedding, LayerNorm, Linear, ModuleList from candle import Tensor import candle import candle.functional as F from typing import Tuple, Optional @dataclass class Config: vocab_size: int = 30522 hidden_size: int = 768 ...
candle/candle-pyo3/py_src/candle/models/bert.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/models/bert.py", "repo_id": "candle", "token_count": 3528 }
38
#![allow(clippy::redundant_closure_call)] use pyo3::exceptions::{PyTypeError, PyValueError}; use pyo3::prelude::*; use pyo3::pyclass::CompareOp; use pyo3::types::{IntoPyDict, PyDict, PyTuple}; use pyo3::ToPyObject; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::os::raw::c_long; u...
candle/candle-pyo3/src/lib.rs/0
{ "file_path": "candle/candle-pyo3/src/lib.rs", "repo_id": "candle", "token_count": 29539 }
39
use candle::{DType, Error, Result, Tensor}; use rand::{distributions::Distribution, SeedableRng}; pub struct LogitsProcessor { rng: rand::rngs::StdRng, temperature: Option<f64>, top_p: Option<f64>, } impl LogitsProcessor { pub fn new(seed: u64, temperature: Option<f64>, top_p: Option<f64>) -> Self { ...
candle/candle-transformers/src/generation/mod.rs/0
{ "file_path": "candle/candle-transformers/src/generation/mod.rs", "repo_id": "candle", "token_count": 1507 }
40
use super::with_tracing::{linear, linear_no_bias, Embedding, Linear}; use candle::{DType, Device, IndexOp, Result, Tensor, D}; use candle_nn::{layer_norm, LayerNorm, Module, VarBuilder}; use serde::Deserialize; pub const DTYPE: DType = DType::F32; #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)] #[serde(rena...
candle/candle-transformers/src/models/jina_bert.rs/0
{ "file_path": "candle/candle-transformers/src/models/jina_bert.rs", "repo_id": "candle", "token_count": 5806 }
41
use crate::models::with_tracing::QMatMul; use crate::quantized_nn::{layer_norm, linear, Embedding, Linear}; pub use crate::quantized_var_builder::VarBuilder; use candle::{Module, Result, Tensor, D}; use candle_nn::LayerNorm; pub type Config = super::blip_text::Config; #[derive(Debug, Clone)] struct TextEmbeddings { ...
candle/candle-transformers/src/models/quantized_blip_text.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_blip_text.rs", "repo_id": "candle", "token_count": 7022 }
42
use crate::models::with_tracing::{conv2d, linear, Conv2d, Linear}; use candle::{Module, ModuleT, Result, Tensor, D}; use candle_nn::{conv2d_no_bias, layer_norm, Activation, Conv2dConfig, VarBuilder}; use serde::Deserialize; use std::collections::HashMap; // https://github.com/huggingface/transformers/blob/main/src/tra...
candle/candle-transformers/src/models/segformer.rs/0
{ "file_path": "candle/candle-transformers/src/models/segformer.rs", "repo_id": "candle", "token_count": 11365 }
43
#![allow(dead_code)] //! # Diffusion pipelines and models //! //! Noise schedulers can be used to set the trade-off between //! inference speed and quality. use candle::{Result, Tensor}; pub trait SchedulerConfig: std::fmt::Debug { fn build(&self, inference_steps: usize) -> Result<Box<dyn Scheduler>>; } /// This ...
candle/candle-transformers/src/models/stable_diffusion/schedulers.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/schedulers.rs", "repo_id": "candle", "token_count": 930 }
44
use candle::{Module, Result, Tensor}; use candle_nn::{linear, Linear, VarBuilder}; // A simplified version of: // https://github.com/huggingface/diffusers/blob/119ad2c3dc8a8fb8446a83f4bf6f20929487b47f/src/diffusers/models/attention_processor.py#L38 #[derive(Debug)] pub struct Attention { to_q: Linear, to_k: Li...
candle/candle-transformers/src/models/wuerstchen/attention_processor.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/attention_processor.rs", "repo_id": "candle", "token_count": 2076 }
45
## Running [llama2.c](https://github.com/karpathy/llama2.c) Examples Here, we provide two examples of how to run [llama2.c](https://github.com/karpathy/llama2.c) written in Rust using a Candle-compiled WASM binary and runtimes. ### Pure Rust UI To build and test the UI made in Rust you will need [Trunk](https://trun...
candle/candle-wasm-examples/llama2-c/README.md/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/README.md", "repo_id": "candle", "token_count": 449 }
46
import init, { Model } from "./build/m.js"; async function fetchArrayBuffer(url) { const cacheName = "phi-mixformer-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse.arrayBuffer(); return new...
candle/candle-wasm-examples/phi/phiWorker.js/0
{ "file_path": "candle/candle-wasm-examples/phi/phiWorker.js", "repo_id": "candle", "token_count": 1667 }
47
use candle::{Device, Tensor}; use candle_transformers::generation::LogitsProcessor; pub use candle_transformers::models::quantized_t5::{ Config, T5EncoderModel, T5ForConditionalGeneration, VarBuilder, }; use candle_wasm_example_t5::console_log; use tokenizers::Tokenizer; use wasm_bindgen::prelude::*; const DEVICE:...
candle/candle-wasm-examples/t5/src/bin/m-quantized.rs/0
{ "file_path": "candle/candle-wasm-examples/t5/src/bin/m-quantized.rs", "repo_id": "candle", "token_count": 3555 }
48
pub const WITH_TIMER: bool = true; struct Timer { label: &'static str, } // impl Timer { // fn new(label: &'static str) -> Self { // if WITH_TIMER { // web_sys::console::time_with_label(label); // } // Self { label } // } // } impl Drop for Timer { fn drop(&mut sel...
candle/candle-wasm-examples/whisper/src/lib.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/lib.rs", "repo_id": "candle", "token_count": 252 }
49
//load the candle yolo wasm module import init, { Model, ModelPose } from "./build/m.js"; async function fetchArrayBuffer(url) { const cacheName = "yolo-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedR...
candle/candle-wasm-examples/yolo/yoloWorker.js/0
{ "file_path": "candle/candle-wasm-examples/yolo/yoloWorker.js", "repo_id": "candle", "token_count": 756 }
50
{ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { "source.fixAll": "explicit" }, "eslint.validate": ["javascript", "svelte"] }
chat-ui/.vscode/settings.json/0
{ "file_path": "chat-ui/.vscode/settings.json", "repo_id": "chat-ui", "token_count": 83 }
51
<!DOCTYPE html> <html lang="en" class="h-full"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="theme-color" content="rgb(249, 250, 251)" /> <script> if ( localStorage.theme === "dark" || (!("theme" in localStorage)...
chat-ui/src/app.html/0
{ "file_path": "chat-ui/src/app.html", "repo_id": "chat-ui", "token_count": 677 }
52
<script lang="ts"> import { base } from "$app/paths"; import { page } from "$app/stores"; import { createEventDispatcher } from "svelte"; import CarbonCheckmark from "~icons/carbon/checkmark"; import CarbonTrashCan from "~icons/carbon/trash-can"; import CarbonClose from "~icons/carbon/close"; import CarbonEdit ...
chat-ui/src/lib/components/NavConversationItem.svelte/0
{ "file_path": "chat-ui/src/lib/components/NavConversationItem.svelte", "repo_id": "chat-ui", "token_count": 1309 }
53
<script lang="ts"> import { isDesktop } from "$lib/utils/isDesktop"; import { createEventDispatcher, onMount } from "svelte"; export let value = ""; export let minRows = 1; export let maxRows: null | number = null; export let placeholder = ""; export let disabled = false; let textareaElement: HTMLTextAreaElem...
chat-ui/src/lib/components/chat/ChatInput.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/ChatInput.svelte", "repo_id": "chat-ui", "token_count": 748 }
54
import { client, collections } from "$lib/server/database"; import { migrations } from "./routines"; import { acquireLock, releaseLock, isDBLocked, refreshLock } from "./lock"; import { isHuggingChat } from "$lib/utils/isHuggingChat"; export async function checkAndRunMigrations() { // make sure all GUIDs are unique ...
chat-ui/src/lib/migrations/migrations.ts/0
{ "file_path": "chat-ui/src/lib/migrations/migrations.ts", "repo_id": "chat-ui", "token_count": 1186 }
55
import type { TextGenerationStreamOutput } from "@huggingface/inference"; import type OpenAI from "openai"; import type { Stream } from "openai/streaming"; /** * Transform a stream of OpenAI.Chat.ChatCompletion into a stream of TextGenerationStreamOutput */ export async function* openAIChatToTextGenerationStream( c...
chat-ui/src/lib/server/endpoints/openai/openAIChatToTextGenerationStream.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/openai/openAIChatToTextGenerationStream.ts", "repo_id": "chat-ui", "token_count": 320 }
56
import { JSDOM, VirtualConsole } from "jsdom"; export async function searchWebLocal(query: string) { const abortController = new AbortController(); setTimeout(() => abortController.abort(), 10000); const htmlString = await fetch("https://www.google.com/search?hl=en&q=" + query, { signal: abortController.signal, ...
chat-ui/src/lib/server/websearch/searchWebLocal.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/searchWebLocal.ts", "repo_id": "chat-ui", "token_count": 438 }
57
import type { Session } from "./Session"; import type { Timestamps } from "./Timestamps"; import type { User } from "./User"; export interface MessageEvent extends Pick<Timestamps, "createdAt"> { userId: User["_id"] | Session["sessionId"]; ip?: string; }
chat-ui/src/lib/types/MessageEvent.ts/0
{ "file_path": "chat-ui/src/lib/types/MessageEvent.ts", "repo_id": "chat-ui", "token_count": 80 }
58
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 }
59
export async function share(url: string, title: string) { if (navigator.share) { navigator.share({ url, title }); } else { await navigator.clipboard.writeText(url); } }
chat-ui/src/lib/utils/share.ts/0
{ "file_path": "chat-ui/src/lib/utils/share.ts", "repo_id": "chat-ui", "token_count": 63 }
60
<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 }
61
import type { RequestHandler } from "./$types"; import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { error, redirect } from "@sveltejs/kit"; import { base } from "$app/paths"; import { z } from "zod"; import type { Message } from "$lib/types/Message"; import { models, validat...
chat-ui/src/routes/conversation/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/+server.ts", "repo_id": "chat-ui", "token_count": 1158 }
62
import { base } from "$app/paths"; import { authCondition } from "$lib/server/auth.js"; import { collections } from "$lib/server/database.js"; import { models } from "$lib/server/models"; import { redirect } from "@sveltejs/kit"; export async function load({ params, locals, parent }) { const model = models.find(({ id...
chat-ui/src/routes/models/[...model]/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/models/[...model]/+page.server.ts", "repo_id": "chat-ui", "token_count": 326 }
63
import { base } from "$app/paths"; import { requiresUser } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { fail, type Actions, redirect } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; import { z } from "zod"; import { sha256 } from "$lib/utils/sha256"; import sharp fr...
chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/edit/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/edit/+page.server.ts", "repo_id": "chat-ui", "token_count": 1608 }
64
{ "background_color": "#ffffff", "name": "Chat UI", "short_name": "Chat UI", "display": "standalone", "start_url": "/", "icons": [ { "src": "/chatui/icon-128x128.png", "sizes": "128x128", "type": "image/png" }, { "src": "/chatui/icon-256x256.png", "sizes": "256x256", "type": "image/png" ...
chat-ui/static/chatui/manifest.json/0
{ "file_path": "chat-ui/static/chatui/manifest.json", "repo_id": "chat-ui", "token_count": 218 }
65
.PHONY: quality style test check_dirs := tests src benchmarks metrics utils # Check that source code meets quality standards quality: ruff check $(check_dirs) setup.py # linter ruff format --check $(check_dirs) setup.py # formatter # Format source code automatically style: ruff check --fix $(check_dirs) setup....
datasets/Makefile/0
{ "file_path": "datasets/Makefile", "repo_id": "datasets", "token_count": 149 }
66
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def get_duration(func): def wrapper(*args, **kwargs): starttime = timeit.default_timer() _ = func(*args, **kwargs) delta = timeit.default_timer()...
datasets/benchmarks/utils.py/0
{ "file_path": "datasets/benchmarks/utils.py", "repo_id": "datasets", "token_count": 927 }
67
# Beam Datasets <Tip warning={true}> The Beam API is deprecated and will be removed in the next major release. </Tip> Some datasets are too large to be processed on a single machine. Instead, you can process them with [Apache Beam](https://beam.apache.org/), a library for parallel data processing. The processing p...
datasets/docs/source/beam.mdx/0
{ "file_path": "datasets/docs/source/beam.mdx", "repo_id": "datasets", "token_count": 594 }
68
# Datasets <img class="float-left !m-0 !border-0 !dark:border-0 !shadow-none !max-w-lg w-[150px]" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/datasets_logo.png"/> 🤗 Datasets is a library for easily accessing and sharing datasets for Audio, Computer Vision, and Natural ...
datasets/docs/source/index.mdx/0
{ "file_path": "datasets/docs/source/index.mdx", "repo_id": "datasets", "token_count": 1014 }
69
# Structure your repository To host and share your dataset, create a dataset repository on the Hugging Face Hub and upload your data files. This guide will show you how to structure your dataset repository when you upload it. A dataset with a supported structure and file format (`.txt`, `.csv`, `.parquet`, `.jsonl`, ...
datasets/docs/source/repository_structure.mdx/0
{ "file_path": "datasets/docs/source/repository_structure.mdx", "repo_id": "datasets", "token_count": 2588 }
70
# Metric Card for BERT Score ## Metric description BERTScore is an automatic evaluation metric for text generation that computes a similarity score for each token in the candidate sentence with each token in the reference sentence. It leverages the pre-trained contextual embeddings from [BERT](https://huggingface.co/...
datasets/metrics/bertscore/README.md/0
{ "file_path": "datasets/metrics/bertscore/README.md", "repo_id": "datasets", "token_count": 1908 }
71
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
datasets/metrics/competition_math/competition_math.py/0
{ "file_path": "datasets/metrics/competition_math/competition_math.py", "repo_id": "datasets", "token_count": 1181 }
72
# Metric Card for IndicGLUE ## Metric description This metric is used to compute the evaluation metric for the [IndicGLUE dataset](https://huggingface.co/datasets/indic_glue). IndicGLUE is a natural language understanding benchmark for Indian languages. It contains a wide variety of tasks and covers 11 major Indian ...
datasets/metrics/indic_glue/README.md/0
{ "file_path": "datasets/metrics/indic_glue/README.md", "repo_id": "datasets", "token_count": 1527 }
73
# Metric Card for Pearson Correlation Coefficient (pearsonr) ## Metric Description Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each data...
datasets/metrics/pearsonr/README.md/0
{ "file_path": "datasets/metrics/pearsonr/README.md", "repo_id": "datasets", "token_count": 1387 }
74
# Metric Card for seqeval ## Metric description seqeval is a Python framework for sequence labeling evaluation. seqeval can evaluate the performance of chunking tasks such as named-entity recognition, part-of-speech tagging, semantic role labeling and so on. ## How to use Seqeval produces labelling scores along ...
datasets/metrics/seqeval/README.md/0
{ "file_path": "datasets/metrics/seqeval/README.md", "repo_id": "datasets", "token_count": 2355 }
75
# 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/wer/wer.py/0
{ "file_path": "datasets/metrics/wer/wer.py", "repo_id": "datasets", "token_count": 1452 }
76
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interle...
datasets/src/datasets/combine.py/0
{ "file_path": "datasets/src/datasets/combine.py", "repo_id": "datasets", "token_count": 4607 }
77
import glob import io import os import posixpath import re import tarfile import time import xml.dom.minidom import zipfile from asyncio import TimeoutError from io import BytesIO from itertools import chain from pathlib import Path, PurePosixPath from typing import Any, Callable, Dict, Generator, Iterable, List, Optio...
datasets/src/datasets/download/streaming_download_manager.py/0
{ "file_path": "datasets/src/datasets/download/streaming_download_manager.py", "repo_id": "datasets", "token_count": 18794 }
78
# Copyright 2020 The HuggingFace Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
datasets/src/datasets/formatting/tf_formatter.py/0
{ "file_path": "datasets/src/datasets/formatting/tf_formatter.py", "repo_id": "datasets", "token_count": 1885 }
79
# 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 a...
datasets/src/datasets/metric.py/0
{ "file_path": "datasets/src/datasets/metric.py", "repo_id": "datasets", "token_count": 11908 }
80
from typing import List import datasets from datasets.tasks import ImageClassification from ..folder_based_builder import folder_based_builder logger = datasets.utils.logging.get_logger(__name__) class ImageFolderConfig(folder_based_builder.FolderBasedBuilderConfig): """BuilderConfig for ImageFolder.""" ...
datasets/src/datasets/packaged_modules/imagefolder/imagefolder.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/imagefolder/imagefolder.py", "repo_id": "datasets", "token_count": 883 }
81
from .parallel import parallel_backend, parallel_map, ParallelBackendConfig # noqa F401
datasets/src/datasets/parallel/__init__.py/0
{ "file_path": "datasets/src/datasets/parallel/__init__.py", "repo_id": "datasets", "token_count": 25 }
82
from typing import Any, Dict, List, Optional, Union from .. import config from ..exceptions import DatasetsError from .file_utils import ( get_authentication_headers_for_url, http_get, ) from .logging import get_logger logger = get_logger(__name__) class DatasetsServerError(DatasetsError): """Dataset-s...
datasets/src/datasets/utils/_datasets_server.py/0
{ "file_path": "datasets/src/datasets/utils/_datasets_server.py", "repo_id": "datasets", "token_count": 1946 }
83
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
datasets/src/datasets/utils/py_utils.py/0
{ "file_path": "datasets/src/datasets/utils/py_utils.py", "repo_id": "datasets", "token_count": 10570 }
84
--- YAML tags (full spec here: https://github.com/huggingface/hub-docs/blob/main/datasetcard.md?plain=1): - copy-paste the tags obtained with the online tagging app: https://huggingface.co/spaces/huggingface/datasets-tagging --- # Dataset Card Creation Guide ## Table of Contents - [Dataset Card Creation Guide](#datas...
datasets/templates/README_guide.md/0
{ "file_path": "datasets/templates/README_guide.md", "repo_id": "datasets", "token_count": 3254 }
85
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def _check_json_dataset(dataset, expected...
datasets/tests/io/test_json.py/0
{ "file_path": "datasets/tests/io/test_json.py", "repo_id": "datasets", "token_count": 5153 }
86
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Array...
datasets/tests/test_arrow_writer.py/0
{ "file_path": "datasets/tests/test_arrow_writer.py", "repo_id": "datasets", "token_count": 6236 }
87
from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("repo_id", ["canonical_dataset_name", "org-name/dataset-name"]) @pytest.mark.parametrize("filename", ["filename.csv", "filename with blanks.csv"]) @pytest.mark.parametrize("revision", [None, "v2"]) def te...
datasets/tests/test_hub.py/0
{ "file_path": "datasets/tests/test_hub.py", "repo_id": "datasets", "token_count": 219 }
88
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict", [ SplitDict(), SplitDict({"train": SplitInfo(name="train", num_bytes=1337, num_examples=42, dataset_name="my_dataset")}), SplitDict({"train...
datasets/tests/test_splits.py/0
{ "file_path": "datasets/tests/test_splits.py", "repo_id": "datasets", "token_count": 622 }
89
<jupyter_start><jupyter_text>Bonus Unit 1: Let's train Huggy the Dog 🐶 to fetch a stick In this notebook, we'll reinforce what we learned in the first Unit by **teaching Huggy the Dog to fetch the stick and then play with it directly in your browser**⬇️ Here is an example of what **you will achieve at the end of the u...
deep-rl-class/notebooks/bonus-unit1/bonus_unit1.ipynb/0
{ "file_path": "deep-rl-class/notebooks/bonus-unit1/bonus_unit1.ipynb", "repo_id": "deep-rl-class", "token_count": 2886 }
90
# Live 1: How the course work, Q&A, and playing with Huggy In this first live stream, we explained how the course work (scope, units, challenges, and more) and answered your questions. And finally, we saw some LunarLander agents you've trained and play with your Huggies 🐶 <Youtube id="JeJIswxyrsM" /> To know when ...
deep-rl-class/units/en/live1/live1.mdx/0
{ "file_path": "deep-rl-class/units/en/live1/live1.mdx", "repo_id": "deep-rl-class", "token_count": 131 }
91
# What is Reinforcement Learning? [[what-is-reinforcement-learning]] To understand Reinforcement Learning, let’s start with the big picture. ## The big picture [[the-big-picture]] The idea behind Reinforcement Learning is that an agent (an AI) will learn from the environment by **interacting with it** (through trial...
deep-rl-class/units/en/unit1/what-is-rl.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/what-is-rl.mdx", "repo_id": "deep-rl-class", "token_count": 624 }
92
# Additional Readings [[additional-readings]] These are **optional readings** if you want to go deeper. - [Foundations of Deep RL Series, L2 Deep Q-Learning by Pieter Abbeel](https://youtu.be/Psrhxy88zww) - [Playing Atari with Deep Reinforcement Learning](https://arxiv.org/abs/1312.5602) - [Double Deep Q-Learning](ht...
deep-rl-class/units/en/unit3/additional-readings.mdx/0
{ "file_path": "deep-rl-class/units/en/unit3/additional-readings.mdx", "repo_id": "deep-rl-class", "token_count": 163 }
93
# Diving deeper into policy-gradient methods ## Getting the big picture We just learned that policy-gradient methods aim to find parameters \\( \theta \\) that **maximize the expected return**. The idea is that we have a *parameterized stochastic policy*. In our case, a neural network outputs a probability distribut...
deep-rl-class/units/en/unit4/policy-gradient.mdx/0
{ "file_path": "deep-rl-class/units/en/unit4/policy-gradient.mdx", "repo_id": "deep-rl-class", "token_count": 2365 }
94
# Introduction [[introduction]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit8/thumbnail.png" alt="Thumbnail"/> In unit 4, we learned about our first Policy-Based algorithm called **Reinforce**. In Policy-Based methods, **we aim to optimize the policy direc...
deep-rl-class/units/en/unit6/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit6/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 427 }
95
# Hands-on: advanced Deep Reinforcement Learning. Using Sample Factory to play Doom from pixels <CourseFloatingBanner classNames="absolute z-10 right-0 top-0" notebooks={[ {label: "Google Colab", value: "https://colab.research.google.com/github/huggingface/deep-rl-class/blob/main/notebooks/unit8/unit8_part2.ipynb"} ...
deep-rl-class/units/en/unit8/hands-on-sf.mdx/0
{ "file_path": "deep-rl-class/units/en/unit8/hands-on-sf.mdx", "repo_id": "deep-rl-class", "token_count": 5955 }
96
# Generalization in Reinforcement Learning Generalization plays a pivotal role in the realm of Reinforcement Learning. While **RL algorithms demonstrate good performance in controlled environments**, the real world presents a **unique challenge due to its non-stationary and open-ended nature**. As a result, the devel...
deep-rl-class/units/en/unitbonus3/generalisation.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus3/generalisation.mdx", "repo_id": "deep-rl-class", "token_count": 250 }
97
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 }
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/TRANSLATING.md/0
{ "file_path": "diffusers/docs/TRANSLATING.md", "repo_id": "diffusers", "token_count": 1100 }
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/models/autoencoder_tiny.md/0
{ "file_path": "diffusers/docs/source/en/api/models/autoencoder_tiny.md", "repo_id": "diffusers", "token_count": 670 }
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/api/outputs.md/0
{ "file_path": "diffusers/docs/source/en/api/outputs.md", "repo_id": "diffusers", "token_count": 554 }
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/api/pipelines/dit.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/dit.md", "repo_id": "diffusers", "token_count": 532 }
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/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 }
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/installation.md/0
{ "file_path": "diffusers/docs/source/en/installation.md", "repo_id": "diffusers", "token_count": 1585 }
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/training/controlnet.md/0
{ "file_path": "diffusers/docs/source/en/training/controlnet.md", "repo_id": "diffusers", "token_count": 4988 }
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/en/training/wuerstchen.md/0
{ "file_path": "diffusers/docs/source/en/training/wuerstchen.md", "repo_id": "diffusers", "token_count": 2904 }
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/en/using-diffusers/distilled_sd.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/distilled_sd.md", "repo_id": "diffusers", "token_count": 1680 }
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/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 }
108
<!--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 }
109
<!--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 }
110
<!--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 }
111
<!--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/other-formats.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/other-formats.md", "repo_id": "diffusers", "token_count": 6827 }
112
import inspect from typing import List, Optional, Union import numpy as np import PIL.Image import torch from torch import nn from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( Autoe...
diffusers/examples/community/clip_guided_stable_diffusion_img2img.py/0
{ "file_path": "diffusers/examples/community/clip_guided_stable_diffusion_img2img.py", "repo_id": "diffusers", "token_count": 9396 }
113
import inspect import re from typing import Any, Callable, Dict, List, Optional, Union import numpy as np import PIL.Image import torch from packaging import version from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.configuration_utils imp...
diffusers/examples/community/lpw_stable_diffusion.py/0
{ "file_path": "diffusers/examples/community/lpw_stable_diffusion.py", "repo_id": "diffusers", "token_count": 30900 }
114
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": 7381 }
115
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": 9334 }
116
# coding=utf-8 # Copyright 2024 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": 4466 }
117
# Kandinsky2.2 text-to-image fine-tuning Kandinsky 2.2 includes a prior pipeline that generates image embeddings from text prompts, and a decoder pipeline that generates the output image based on the image embeddings. We provide `train_text_to_image_prior.py` and `train_text_to_image_decoder.py` scripts to show you ho...
diffusers/examples/kandinsky2_2/text_to_image/README.md/0
{ "file_path": "diffusers/examples/kandinsky2_2/text_to_image/README.md", "repo_id": "diffusers", "token_count": 4394 }
118
#!/usr/bin/env python # coding=utf-8 # Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
diffusers/examples/research_projects/controlnet/train_controlnet_webdataset.py/0
{ "file_path": "diffusers/examples/research_projects/controlnet/train_controlnet_webdataset.py", "repo_id": "diffusers", "token_count": 25995 }
119
# InstructPix2Pix text-to-edit-image fine-tuning This extended LoRA training script was authored by [Aiden-Frost](https://github.com/Aiden-Frost). This is an experimental LoRA extension of [this example](https://github.com/huggingface/diffusers/blob/main/examples/instruct_pix2pix/train_instruct_pix2pix.py). This script...
diffusers/examples/research_projects/instructpix2pix_lora/README.md/0
{ "file_path": "diffusers/examples/research_projects/instructpix2pix_lora/README.md", "repo_id": "diffusers", "token_count": 1124 }
120
import argparse import itertools import json import logging import math import uuid import warnings from os import environ, listdir, makedirs from os.path import basename, join from pathlib import Path from typing import List import datasets import numpy as np import torch import torch.nn.functional as F import torch....
diffusers/examples/research_projects/multi_subject_dreambooth/train_multi_subject_dreambooth.py/0
{ "file_path": "diffusers/examples/research_projects/multi_subject_dreambooth/train_multi_subject_dreambooth.py", "repo_id": "diffusers", "token_count": 21727 }
121
#!/usr/bin/env python # coding=utf-8 # Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
diffusers/examples/research_projects/onnxruntime/textual_inversion/textual_inversion.py/0
{ "file_path": "diffusers/examples/research_projects/onnxruntime/textual_inversion/textual_inversion.py", "repo_id": "diffusers", "token_count": 15802 }
122
# Show best practices for SDXL JAX import time import jax import jax.numpy as jnp import numpy as np from flax.jax_utils import replicate # Let's cache the model compilation, so that it doesn't take as long the next time around. from jax.experimental.compilation_cache import compilation_cache as cc from diffusers im...
diffusers/examples/research_projects/sdxl_flax/sdxl_single.py/0
{ "file_path": "diffusers/examples/research_projects/sdxl_flax/sdxl_single.py", "repo_id": "diffusers", "token_count": 1341 }
123
#!/usr/bin/env python # coding=utf-8 # Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
diffusers/examples/text_to_image/train_text_to_image_flax.py/0
{ "file_path": "diffusers/examples/text_to_image/train_text_to_image_flax.py", "repo_id": "diffusers", "token_count": 10030 }
124
import argparse import inspect import logging import math import os import shutil from datetime import timedelta from pathlib import Path import accelerate import datasets import torch import torch.nn.functional as F from accelerate import Accelerator, InitProcessGroupKwargs from accelerate.logging import get_logger f...
diffusers/examples/unconditional_image_generation/train_unconditional.py/0
{ "file_path": "diffusers/examples/unconditional_image_generation/train_unconditional.py", "repo_id": "diffusers", "token_count": 13301 }
125
import math import os import urllib import warnings from argparse import ArgumentParser import torch import torch.nn as nn import torch.nn.functional as F from huggingface_hub.utils import insecure_hashlib from safetensors.torch import load_file as stl from tqdm import tqdm from diffusers import AutoencoderKL, Consis...
diffusers/scripts/convert_consistency_decoder.py/0
{ "file_path": "diffusers/scripts/convert_consistency_decoder.py", "repo_id": "diffusers", "token_count": 21911 }
126
# coding=utf-8 # Copyright 2024, Haofan Wang, Qixun Wang, 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 re...
diffusers/scripts/convert_lora_safetensor_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_lora_safetensor_to_diffusers.py", "repo_id": "diffusers", "token_count": 2129 }
127
import argparse import os import shutil from pathlib import Path import onnx import onnx_graphsurgeon as gs import torch from onnx import shape_inference from packaging import version from polygraphy.backend.onnx.loader import fold_constants from torch.onnx import export from diffusers import ( ControlNetModel, ...
diffusers/scripts/convert_stable_diffusion_controlnet_to_onnx.py/0
{ "file_path": "diffusers/scripts/convert_stable_diffusion_controlnet_to_onnx.py", "repo_id": "diffusers", "token_count": 8995 }
128
# 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/src/diffusers/loaders/lora.py/0
{ "file_path": "diffusers/src/diffusers/loaders/lora.py", "repo_id": "diffusers", "token_count": 28664 }
129
# 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/src/diffusers/models/autoencoders/autoencoder_asym_kl.py/0
{ "file_path": "diffusers/src/diffusers/models/autoencoders/autoencoder_asym_kl.py", "repo_id": "diffusers", "token_count": 3208 }
130
# coding=utf-8 # Copyright 2024 The HuggingFace Inc. team. # # 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...
diffusers/src/diffusers/models/modeling_pytorch_flax_utils.py/0
{ "file_path": "diffusers/src/diffusers/models/modeling_pytorch_flax_utils.py", "repo_id": "diffusers", "token_count": 3050 }
131
# 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/src/diffusers/models/unet_1d_blocks.py/0
{ "file_path": "diffusers/src/diffusers/models/unet_1d_blocks.py", "repo_id": "diffusers", "token_count": 3632 }
132