text
stringlengths
7
1.24M
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
519
# candle-flash-attn
candle/candle-flash-attn/README.md/0
{ "file_path": "candle/candle-flash-attn/README.md", "repo_id": "candle", "token_count": 8 }
37
/****************************************************************************** * Copyright (c) 2024, Tri Dao. ******************************************************************************/ #pragma once #include <cute/tensor.hpp> #include "utils.h" ////////////////////////////////////////////////////////////////...
candle/candle-flash-attn/kernels/rotary.h/0
{ "file_path": "candle/candle-flash-attn/kernels/rotary.h", "repo_id": "candle", "token_count": 5052 }
38
#include "compatibility.cuh" #include<stdint.h> #include<cmath> // TODO: This is often used to check that the data is contiguous so that // kernels can be easily mapped. However this only returns true for row // major, if all the inputs are column major, we could apply the fast path // too (but we wouldn't if some of ...
candle/candle-kernels/src/cuda_utils.cuh/0
{ "file_path": "candle/candle-kernels/src/cuda_utils.cuh", "repo_id": "candle", "token_count": 3947 }
39
use metal::{ Buffer, CompileOptions, ComputeCommandEncoderRef, ComputePipelineState, Device, Function, FunctionConstantValues, Library, MTLDataType, MTLSize, NSUInteger, }; use std::collections::HashMap; use std::ffi::c_void; use std::sync::RwLock; mod utils; pub use utils::BufferOffset; use utils::{get_block_...
candle/candle-metal-kernels/src/lib.rs/0
{ "file_path": "candle/candle-metal-kernels/src/lib.rs", "repo_id": "candle", "token_count": 31139 }
40
mod benchmarks; use criterion::criterion_main; criterion_main!(benchmarks::layer_norm::benches, benchmarks::conv::benches);
candle/candle-nn/benches/bench_main.rs/0
{ "file_path": "candle/candle-nn/benches/bench_main.rs", "repo_id": "candle", "token_count": 38 }
41
pub mod activation; pub mod batch_norm; pub mod conv; pub mod embedding; pub mod encoding; pub mod func; pub mod group_norm; pub mod init; pub mod kv_cache; pub mod layer_norm; pub mod linear; pub mod loss; pub mod ops; pub mod optim; pub mod rnn; pub mod rotary_emb; pub mod sequential; pub mod var_builder; pub mod var...
candle/candle-nn/src/lib.rs/0
{ "file_path": "candle/candle-nn/src/lib.rs", "repo_id": "candle", "token_count": 486 }
42
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::test_utils::{to_vec0_round, to_vec2_round}; use anyhow::Result; use candle::{DType, Device, Tensor, Var}; use candle_nn::{AdamW, Linear, Module, Optimizer, ParamsAdamW, SGD}; #[test] fn sgd_op...
candle/candle-nn/tests/optim.rs/0
{ "file_path": "candle/candle-nn/tests/optim.rs", "repo_id": "candle", "token_count": 2568 }
43
import logging try: from .candle import * except ImportError as e: # If we are in development mode, or we did not bundle the DLLs, we try to locate them here # PyO3 wont give us any information about what DLLs are missing, so we can only try to load # the DLLs and re-import the module logging.warni...
candle/candle-pyo3/py_src/candle/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/__init__.py", "repo_id": "candle", "token_count": 919 }
44
from typing import TypeVar, Union, Sequence _T = TypeVar("_T") _ArrayLike = Union[ _T, Sequence[_T], Sequence[Sequence[_T]], Sequence[Sequence[Sequence[_T]]], Sequence[Sequence[Sequence[Sequence[_T]]]], ] CPU: str = "cpu" CUDA: str = "cuda" Device = TypeVar("Device", CPU, CUDA) Scalar = Union[i...
candle/candle-pyo3/py_src/candle/typing/__init__.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/typing/__init__.py", "repo_id": "candle", "token_count": 166 }
45
from candle import Tensor from candle import rand import pytest def test_absolute_shapes_are_valid(): a = rand((10, 20)) assert a.shape == (10, 20) b = rand(10, 20) assert b.shape == (10, 20) pytest.raises(OverflowError, lambda: rand((10, 20, -1))) pytest.raises(OverflowError, lambda: rand(-1...
candle/candle-pyo3/tests/native/test_shape.py/0
{ "file_path": "candle/candle-pyo3/tests/native/test_shape.py", "repo_id": "candle", "token_count": 385 }
46
//! Contrastive Language-Image Pre-Training //! //! Contrastive Language-Image Pre-Training (CLIP) is an architecture trained on //! pairs of images with related texts. //! //! https://github.com/openai/CLIP //! https://github.com/huggingface/transformers/tree/f6fa0f0bf0796ac66f201f23bdb8585de1609add/src/transformers/m...
candle/candle-transformers/src/models/clip/vision_model.rs/0
{ "file_path": "candle/candle-transformers/src/models/clip/vision_model.rs", "repo_id": "candle", "token_count": 2831 }
47
pub mod autoencoder; pub mod model; pub mod sampling;
candle/candle-transformers/src/models/flux/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/flux/mod.rs", "repo_id": "candle", "token_count": 18 }
48
use candle::{DType, Device, Error as E, IndexOp, Module, Result, Tensor, D}; use candle_nn::{embedding, linear_b, rms_norm, Embedding, Linear, RmsNorm, VarBuilder}; // Equivalent to torch.repeat_interleave pub(crate) fn repeat_interleave(img: &Tensor, repeats: usize, dim: usize) -> Result<Tensor> { let img = img.u...
candle/candle-transformers/src/models/metavoice.rs/0
{ "file_path": "candle/candle-transformers/src/models/metavoice.rs", "repo_id": "candle", "token_count": 21694 }
49
pub mod text_model;
candle/candle-transformers/src/models/openclip/mod.rs/0
{ "file_path": "candle/candle-transformers/src/models/openclip/mod.rs", "repo_id": "candle", "token_count": 7 }
50
use std::collections::HashMap; use candle::quantized::gguf_file; use candle::quantized::QTensor; use candle::{DType, Device, IndexOp, Module, Result, Tensor, D}; use candle_nn::{kv_cache::KvCache, Embedding, RmsNorm}; #[derive(Debug, Clone)] struct QLinear { inner: candle::quantized::QMatMul, span: tracing::S...
candle/candle-transformers/src/models/quantized_phi3.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_phi3.rs", "repo_id": "candle", "token_count": 5978 }
51
use candle::{IndexOp, Result, Tensor}; use candle_nn::{Module, VarBuilder}; use super::transformer::TwoWayTransformer; #[derive(Debug)] struct MlpMaskDecoder { layers: Vec<super::Linear>, sigmoid_output: bool, span: tracing::Span, } impl MlpMaskDecoder { fn new( input_dim: usize, hidd...
candle/candle-transformers/src/models/segment_anything/mask_decoder.rs/0
{ "file_path": "candle/candle-transformers/src/models/segment_anything/mask_decoder.rs", "repo_id": "candle", "token_count": 4213 }
52
//! 2D UNet Building Blocks //! use super::attention::{ AttentionBlock, AttentionBlockConfig, SpatialTransformer, SpatialTransformerConfig, }; use super::resnet::{ResnetBlock2D, ResnetBlock2DConfig}; use crate::models::with_tracing::{conv2d, Conv2d}; use candle::{Module, Result, Tensor, D}; use candle_nn as nn; #[...
candle/candle-transformers/src/models/stable_diffusion/unet_2d_blocks.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/unet_2d_blocks.rs", "repo_id": "candle", "token_count": 13813 }
53
use candle::{Result, Tensor}; #[derive(Debug, Clone)] pub struct DDPMWSchedulerConfig { scaler: f64, s: f64, } impl Default for DDPMWSchedulerConfig { fn default() -> Self { Self { scaler: 1f64, s: 0.008f64, } } } pub struct DDPMWScheduler { init_alpha_cump...
candle/candle-transformers/src/models/wuerstchen/ddpm.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/ddpm.rs", "repo_id": "candle", "token_count": 1537 }
54
//load Candle Bert Module wasm module import init, { Model } from "./build/m.js"; async function fetchArrayBuffer(url) { const cacheName = "bert-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse....
candle/candle-wasm-examples/bert/bertWorker.js/0
{ "file_path": "candle/candle-wasm-examples/bert/bertWorker.js", "repo_id": "candle", "token_count": 779 }
55
import init, { Model } from "./build/m.js"; async function fetchArrayBuffer(url, cacheModel = true) { if (!cacheModel) return new Uint8Array(await (await fetch(url)).arrayBuffer()); const cacheName = "moondream-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.ma...
candle/candle-wasm-examples/moondream/moondreamWorker.js/0
{ "file_path": "candle/candle-wasm-examples/moondream/moondreamWorker.js", "repo_id": "candle", "token_count": 2273 }
56
import init, { run_app } from './pkg/candle_wasm_example_whisper.js'; async function main() { await init('/pkg/candle_wasm_example_whisper_bg.wasm'); run_app(); } main()
candle/candle-wasm-examples/whisper/main.js/0
{ "file_path": "candle/candle-wasm-examples/whisper/main.js", "repo_id": "candle", "token_count": 73 }
57
fn main() { wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); console_error_panic_hook::set_once(); yew::Renderer::<candle_wasm_example_yolo::App>::new().render(); }
candle/candle-wasm-examples/yolo/src/bin/app.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/bin/app.rs", "repo_id": "candle", "token_count": 82 }
58
Dockerfile .vscode/ .idea .gitignore LICENSE README.md node_modules/ .svelte-kit/ .env* !.env .env.local
chat-ui/.dockerignore/0
{ "file_path": "chat-ui/.dockerignore", "repo_id": "chat-ui", "token_count": 51 }
59
{ "useTabs": true, "trailingComma": "es5", "printWidth": 100, "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], "pluginSearchDirs": ["."], "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] }
chat-ui/.prettierrc/0
{ "file_path": "chat-ui/.prettierrc", "repo_id": "chat-ui", "token_count": 104 }
60
{{- if $.Values.monitoring.enabled }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: {{ include "labels.standard" . | nindent 4 }} name: {{ include "name" . }} namespace: {{ .Release.Namespace }} spec: selector: matchLabels: {{ include "labels.standard" . | nindent 6 }} endpoi...
chat-ui/chart/templates/service-monitor.yaml/0
{ "file_path": "chat-ui/chart/templates/service-monitor.yaml", "repo_id": "chat-ui", "token_count": 144 }
61
# Ollama | Feature | Available | | --------------------------- | --------- | | [Tools](../tools) | No | | [Multimodal](../multimodal) | No | We also support the Ollama inference server. Spin up a model with ```bash ollama run mistral ``` Then specify the endpoints like so...
chat-ui/docs/source/configuration/models/providers/ollama.md/0
{ "file_path": "chat-ui/docs/source/configuration/models/providers/ollama.md", "repo_id": "chat-ui", "token_count": 468 }
62
<script lang="ts"> import { afterUpdate } from "svelte"; import CopyToClipBoardBtn from "./CopyToClipBoardBtn.svelte"; import DOMPurify from "isomorphic-dompurify"; export let code = ""; export let lang = ""; $: highlightedCode = ""; afterUpdate(async () => { const { default: hljs } = await import("highligh...
chat-ui/src/lib/components/CodeBlock.svelte/0
{ "file_path": "chat-ui/src/lib/components/CodeBlock.svelte", "repo_id": "chat-ui", "token_count": 442 }
63
<script lang="ts"> import CarbonRotate360 from "~icons/carbon/rotate-360"; export let classNames = ""; </script> <button type="button" on:click class="btn flex h-8 rounded-lg border bg-white px-3 py-1 text-gray-500 shadow-sm transition-all hover:bg-gray-100 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-30...
chat-ui/src/lib/components/RetryBtn.svelte/0
{ "file_path": "chat-ui/src/lib/components/RetryBtn.svelte", "repo_id": "chat-ui", "token_count": 157 }
64
<script lang="ts"> import { marked, type MarkedOptions } from "marked"; import markedKatex from "marked-katex-extension"; import type { Message } from "$lib/types/Message"; import { afterUpdate, createEventDispatcher, tick } from "svelte"; import { deepestChild } from "$lib/utils/deepestChild"; import { page } fr...
chat-ui/src/lib/components/chat/ChatMessage.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/ChatMessage.svelte", "repo_id": "chat-ui", "token_count": 7678 }
65
import { Database } from "$lib/server/database"; import { acquireLock, refreshLock } from "$lib/migrations/lock"; import type { ObjectId } from "mongodb"; import { subDays } from "date-fns"; import { logger } from "$lib/server/logger"; const LOCK_KEY = "assistants.count"; let hasLock = false; let lockId: ObjectId | n...
chat-ui/src/lib/jobs/refresh-assistants-counts.ts/0
{ "file_path": "chat-ui/src/lib/jobs/refresh-assistants-counts.ts", "repo_id": "chat-ui", "token_count": 970 }
66
import { z } from "zod"; import { embeddingEndpointTei, embeddingEndpointTeiParametersSchema, } from "./tei/embeddingEndpoints"; import { embeddingEndpointTransformersJS, embeddingEndpointTransformersJSParametersSchema, } from "./transformersjs/embeddingEndpoints"; import { embeddingEndpointOpenAI, embeddingEndpo...
chat-ui/src/lib/server/embeddingEndpoints/embeddingEndpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/embeddingEndpoints/embeddingEndpoints.ts", "repo_id": "chat-ui", "token_count": 544 }
67
import type { Sharp } from "sharp"; import sharp from "sharp"; import type { MessageFile } from "$lib/types/Message"; import { z, type util } from "zod"; export interface ImageProcessorOptions<TMimeType extends string = string> { supportedMimeTypes: TMimeType[]; preferredMimeType: TMimeType; maxSizeInMB: number; m...
chat-ui/src/lib/server/endpoints/images.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/images.ts", "repo_id": "chat-ui", "token_count": 2311 }
68
import { collectDefaultMetrics, Registry, Counter, Summary } from "prom-client"; import express from "express"; import { logger } from "$lib/server/logger"; import { env } from "$env/dynamic/private"; import type { Model } from "$lib/types/Model"; import { onExit } from "./exitHandler"; import { promisify } from "util"...
chat-ui/src/lib/server/metrics.ts/0
{ "file_path": "chat-ui/src/lib/server/metrics.ts", "repo_id": "chat-ui", "token_count": 2179 }
69
import { z } from "zod"; import { env } from "$env/dynamic/private"; import JSON5 from "json5"; // RATE_LIMIT is the legacy way to define messages per minute limit export const usageLimitsSchema = z .object({ conversations: z.coerce.number().optional(), // how many conversations messages: z.coerce.number().option...
chat-ui/src/lib/server/usageLimits.ts/0
{ "file_path": "chat-ui/src/lib/server/usageLimits.ts", "repo_id": "chat-ui", "token_count": 309 }
70
import type { WebSearchSource } from "$lib/types/WebSearch"; import { env } from "$env/dynamic/private"; export default async function search(query: string): Promise<WebSearchSource[]> { // const params = { // q: query, // // You can add other parameters if needed, like 'count', 'offset', etc. // }; cons...
chat-ui/src/lib/server/websearch/search/endpoints/bing.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/search/endpoints/bing.ts", "repo_id": "chat-ui", "token_count": 425 }
71
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": 999 }
72
import type { Timestamps } from "./Timestamps"; export interface Semaphore extends Timestamps { key: string; }
chat-ui/src/lib/types/Semaphore.ts/0
{ "file_path": "chat-ui/src/lib/types/Semaphore.ts", "repo_id": "chat-ui", "token_count": 35 }
73
export function formatUserCount(userCount: number): string { const userCountRanges: { min: number; max: number; label: string }[] = [ { min: 0, max: 1, label: "1" }, { min: 2, max: 9, label: "1-10" }, { min: 10, max: 49, label: "10+" }, { min: 50, max: 99, label: "50+" }, { min: 100, max: 299, label: "100+" ...
chat-ui/src/lib/utils/formatUserCount.ts/0
{ "file_path": "chat-ui/src/lib/utils/formatUserCount.ts", "repo_id": "chat-ui", "token_count": 404 }
74
import { browser } from "$app/environment"; export async function share(url: string, title: string, appendLeafId: boolean = false) { if (!browser) return; // Retrieve the leafId from localStorage const leafId = localStorage.getItem("leafId"); if (appendLeafId && leafId) { // Use URL and URLSearchParams to add ...
chat-ui/src/lib/utils/share.ts/0
{ "file_path": "chat-ui/src/lib/utils/share.ts", "repo_id": "chat-ui", "token_count": 231 }
75
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { describe, expect, it } from "vitest"; // function used to insert conversations used for testing export const insertLegacyConversation = async () => { const res = await collections.conversations.insertOne({ _id: new Obj...
chat-ui/src/lib/utils/tree/treeHelpers.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/treeHelpers.spec.ts", "repo_id": "chat-ui", "token_count": 1864 }
76
import { authCondition } from "$lib/server/auth"; import type { Conversation } from "$lib/types/Conversation"; import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; export async function GET({ locals }) { if (locals.user?._id || locals.sessionId) { const settings = await collection...
chat-ui/src/routes/api/user/assistants/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/user/assistants/+server.ts", "repo_id": "chat-ui", "token_count": 509 }
77
import { base } from "$app/paths"; import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { redirect } from "@sveltejs/kit"; export const actions = { async delete({ locals }) { // double check we have a user to delete conversations for if (locals.user?._id || ...
chat-ui/src/routes/conversations/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/conversations/+page.server.ts", "repo_id": "chat-ui", "token_count": 158 }
78
import { collections } from "$lib/server/database"; import { z } from "zod"; import { authCondition } from "$lib/server/auth"; import { DEFAULT_SETTINGS, type SettingsEditable } from "$lib/types/Settings"; import { toolFromConfigs } from "$lib/server/tools/index.js"; import { ObjectId } from "mongodb"; export async fu...
chat-ui/src/routes/settings/(nav)/+server.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/+server.ts", "repo_id": "chat-ui", "token_count": 772 }
79
import { authCondition } from "$lib/server/auth.js"; import { Database, collections } from "$lib/server/database.js"; import { toolFromConfigs } from "$lib/server/tools/index.js"; import { SortKey } from "$lib/types/Assistant.js"; import type { CommunityToolDB } from "$lib/types/Tool.js"; import type { User } from "$li...
chat-ui/src/routes/tools/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/tools/+page.server.ts", "repo_id": "chat-ui", "token_count": 1028 }
80
import adapter from "@sveltejs/adapter-node"; import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; 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').Conf...
chat-ui/svelte.config.js/0
{ "file_path": "chat-ui/svelte.config.js", "repo_id": "chat-ui", "token_count": 258 }
81
import json import os from dataclasses import dataclass import numpy as np import pyarrow as pa import datasets from utils import get_duration SPEED_TEST_N_EXAMPLES = 100_000_000_000 SPEED_TEST_CHUNK_SIZE = 10_000 RESULTS_BASEPATH, RESULTS_FILENAME = os.path.split(__file__) RESULTS_FILE_PATH = os.path.join(RESULTS...
datasets/benchmarks/benchmark_getitem_100B.py/0
{ "file_path": "datasets/benchmarks/benchmark_getitem_100B.py", "repo_id": "datasets", "token_count": 867 }
82
# Datasets 🤝 Arrow ## What is Arrow? [Arrow](https://arrow.apache.org/) enables large amounts of data to be processed and moved quickly. It is a specific data format that stores data in a columnar memory layout. This provides several significant advantages: * Arrow's standard format allows [zero-copy reads](https:/...
datasets/docs/source/about_arrow.md/0
{ "file_path": "datasets/docs/source/about_arrow.md", "repo_id": "datasets", "token_count": 682 }
83
# 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 }
84
# Builder classes ## Builders 🤗 Datasets relies on two main classes during the dataset building process: [`DatasetBuilder`] and [`BuilderConfig`]. [[autodoc]] datasets.DatasetBuilder [[autodoc]] datasets.GeneratorBasedBuilder [[autodoc]] datasets.ArrowBasedBuilder [[autodoc]] datasets.BuilderConfig ## Download ...
datasets/docs/source/package_reference/builder_classes.mdx/0
{ "file_path": "datasets/docs/source/package_reference/builder_classes.mdx", "repo_id": "datasets", "token_count": 240 }
85
# Use with JAX This document is a quick introduction to using `datasets` with JAX, with a particular focus on how to get `jax.Array` objects out of our datasets, and how to use them to train JAX models. <Tip> `jax` and `jaxlib` are required to reproduce to code above, so please make sure you install them as `pip ins...
datasets/docs/source/use_with_jax.mdx/0
{ "file_path": "datasets/docs/source/use_with_jax.mdx", "repo_id": "datasets", "token_count": 2969 }
86
from argparse import ArgumentParser from typing import Optional from datasets.commands import BaseDatasetsCLICommand from datasets.hub import convert_to_parquet def _command_factory(args): return ConvertToParquetCommand( args.dataset_id, args.token, args.revision, args.trust_remot...
datasets/src/datasets/commands/convert_to_parquet.py/0
{ "file_path": "datasets/src/datasets/commands/convert_to_parquet.py", "repo_id": "datasets", "token_count": 652 }
87
# 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/features/features.py/0
{ "file_path": "datasets/src/datasets/features/features.py", "repo_id": "datasets", "token_count": 41338 }
88
import copy import os from functools import partial from itertools import groupby from typing import TYPE_CHECKING, Any, Callable, Iterator, List, Optional, Tuple, TypeVar, Union import numpy as np import pyarrow as pa import pyarrow.compute as pc import pyarrow.types from .utils.logging import get_logger if TYPE_C...
datasets/src/datasets/table.py/0
{ "file_path": "datasets/src/datasets/table.py", "repo_id": "datasets", "token_count": 41738 }
89
# 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": 11710 }
90
# 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/templates/new_dataset_script.py/0
{ "file_path": "datasets/templates/new_dataset_script.py", "repo_id": "datasets", "token_count": 3156 }
91
import contextlib import os import sqlite3 import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def _check_sql_dataset(dataset, expected_f...
datasets/tests/io/test_sql.py/0
{ "file_path": "datasets/tests/io/test_sql.py", "repo_id": "datasets", "token_count": 1628 }
92
import contextlib import copy import itertools import json import os import pickle import re import sys import tempfile from functools import partial from pathlib import Path from unittest import TestCase from unittest.mock import MagicMock, patch import numpy as np import numpy.testing as npt import pandas as pd impo...
datasets/tests/test_arrow_dataset.py/0
{ "file_path": "datasets/tests/test_arrow_dataset.py", "repo_id": "datasets", "token_count": 118239 }
93
import datetime from pathlib import Path from unittest import TestCase import numpy as np import pandas as pd import pyarrow as pa import pytest from datasets import Audio, Features, Image, IterableDataset from datasets.formatting import NumpyFormatter, PandasFormatter, PythonFormatter, query_table from datasets.form...
datasets/tests/test_formatting.py/0
{ "file_path": "datasets/tests/test_formatting.py", "repo_id": "datasets", "token_count": 21450 }
94
import copy import pickle from decimal import Decimal from functools import partial from typing import List, Union from unittest.mock import MagicMock import numpy as np import pyarrow as pa import pytest from datasets.features import Array2D, ClassLabel, Features, Image, LargeList, Sequence, Value from datasets.feat...
datasets/tests/test_table.py/0
{ "file_path": "datasets/tests/test_table.py", "repo_id": "datasets", "token_count": 24240 }
95
<jupyter_start><jupyter_text>Unit 4: Code your first Deep Reinforcement Learning Algorithm with PyTorch: Reinforce. And test its robustness 💪In this notebook, you'll code your first Deep Reinforcement Learning algorithm from scratch: Reinforce (also called Monte Carlo Policy Gradient).Reinforce is a *Policy-based meth...
deep-rl-class/notebooks/unit4/unit4.ipynb/0
{ "file_path": "deep-rl-class/notebooks/unit4/unit4.ipynb", "repo_id": "deep-rl-class", "token_count": 12740 }
96
# The Exploration/Exploitation trade-off [[exp-exp-tradeoff]] Finally, before looking at the different methods to solve Reinforcement Learning problems, we must cover one more very important topic: *the exploration/exploitation trade-off.* - *Exploration* is exploring the environment by trying random actions in order...
deep-rl-class/units/en/unit1/exp-exp-tradeoff.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/exp-exp-tradeoff.mdx", "repo_id": "deep-rl-class", "token_count": 699 }
97
# Monte Carlo vs Temporal Difference Learning [[mc-vs-td]] The last thing we need to discuss before diving into Q-Learning is the two learning strategies. Remember that an RL agent **learns by interacting with its environment.** The idea is that **given the experience and the received reward, the agent will update it...
deep-rl-class/units/en/unit2/mc-vs-td.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/mc-vs-td.mdx", "repo_id": "deep-rl-class", "token_count": 2316 }
98
# Deep Q-Learning [[deep-q-learning]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit4/thumbnail.jpg" alt="Unit 3 thumbnail" width="100%"> In the last unit, we learned our first reinforcement learning algorithm: Q-Learning, **implemented it from scratch**, and...
deep-rl-class/units/en/unit3/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit3/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 437 }
99
# How do Unity ML-Agents work? [[how-mlagents-works]] Before training our agent, we need to understand **what ML-Agents is and how it works**. ## What is Unity ML-Agents? [[what-is-mlagents]] [Unity ML-Agents](https://github.com/Unity-Technologies/ml-agents) is a toolkit for the game engine Unity that **allows us to...
deep-rl-class/units/en/unit5/how-mlagents-works.mdx/0
{ "file_path": "deep-rl-class/units/en/unit5/how-mlagents-works.mdx", "repo_id": "deep-rl-class", "token_count": 1276 }
100
# Introduction [[introduction]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit0/thumbnail.png" alt="Thumbnail"/> Since the beginning of this course, we learned to train agents in a *single-agent system* where our agent was alone in its environment: it was **no...
deep-rl-class/units/en/unit7/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit7/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 574 }
101
# Introduction [[introduction]] In this bonus unit, we'll reinforce what we learned in the first unit by teaching Huggy the Dog to fetch the stick and then [play with him directly in your browser](https://huggingface.co/spaces/ThomasSimonini/Huggy) 🐶 <img src="https://huggingface.co/datasets/huggingface-deep-rl-cour...
deep-rl-class/units/en/unitbonus1/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus1/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 138 }
102
# Brief introduction to RL documentation In this advanced topic, we address the question: **how should we monitor and keep track of powerful reinforcement learning agents that we are training in the real world and interfacing with humans?** As machine learning systems have increasingly impacted modern life, the **cal...
deep-rl-class/units/en/unitbonus3/rl-documentation.mdx/0
{ "file_path": "deep-rl-class/units/en/unitbonus3/rl-documentation.mdx", "repo_id": "deep-rl-class", "token_count": 886 }
103
import argparse import sys sys.path.append(".") from base_classes import ControlNetBenchmark, ControlNetSDXLBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="lllyasviel/sd-controlnet-canny", ...
diffusers/benchmarks/benchmark_controlnet.py/0
{ "file_path": "diffusers/benchmarks/benchmark_controlnet.py", "repo_id": "diffusers", "token_count": 352 }
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/api/loaders/single_file.md/0
{ "file_path": "diffusers/docs/source/en/api/loaders/single_file.md", "repo_id": "diffusers", "token_count": 831 }
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/api/pipelines/stable_diffusion/latent_upscale.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/latent_upscale.md", "repo_id": "diffusers", "token_count": 543 }
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/optimization/habana.md/0
{ "file_path": "diffusers/docs/source/en/optimization/habana.md", "repo_id": "diffusers", "token_count": 1399 }
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/training/distributed_inference.md/0
{ "file_path": "diffusers/docs/source/en/training/distributed_inference.md", "repo_id": "diffusers", "token_count": 1621 }
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/en/tutorials/inference_with_big_models.md/0
{ "file_path": "diffusers/docs/source/en/tutorials/inference_with_big_models.md", "repo_id": "diffusers", "token_count": 1972 }
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/en/using-diffusers/kandinsky.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/kandinsky.md", "repo_id": "diffusers", "token_count": 10810 }
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/en/using-diffusers/svd.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/svd.md", "repo_id": "diffusers", "token_count": 1832 }
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/conceptual/contribution.md/0
{ "file_path": "diffusers/docs/source/ko/conceptual/contribution.md", "repo_id": "diffusers", "token_count": 35978 }
112
<!--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/quicktour.md/0
{ "file_path": "diffusers/docs/source/ko/quicktour.md", "repo_id": "diffusers", "token_count": 11428 }
113
<!--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/conditional_image_generation.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/conditional_image_generation.md", "repo_id": "diffusers", "token_count": 1550 }
114
<!--Copyright 2023 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/ko/using-diffusers/svd.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/svd.md", "repo_id": "diffusers", "token_count": 3466 }
115
# 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/fresco_v2v.py/0
{ "file_path": "diffusers/examples/community/fresco_v2v.py", "repo_id": "diffusers", "token_count": 53403 }
116
## ---------------------------------------------------------- # A SDXL pipeline can take unlimited weighted prompt # # Author: Andrew Zhu # GitHub: https://github.com/xhinker # Medium: https://medium.com/@xhinker ## ----------------------------------------------------------- import inspect import os from typing import...
diffusers/examples/community/lpw_stable_diffusion_xl.py/0
{ "file_path": "diffusers/examples/community/lpw_stable_diffusion_xl.py", "repo_id": "diffusers", "token_count": 48001 }
117
# 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/pipeline_sdxl_style_aligned.py/0
{ "file_path": "diffusers/examples/community/pipeline_sdxl_style_aligned.py", "repo_id": "diffusers", "token_count": 42028 }
118
# Copyright 2024 UC Berkeley 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 # # Unless ...
diffusers/examples/community/scheduling_ufogen.py/0
{ "file_path": "diffusers/examples/community/scheduling_ufogen.py", "repo_id": "diffusers", "token_count": 10811 }
119
# DreamBooth training example [DreamBooth](https://arxiv.org/abs/2208.12242) is a method to personalize text2image models like stable diffusion given just a few(3~5) images of a subject. The `train_dreambooth.py` script shows how to implement the training procedure and adapt it for stable diffusion. ## Running local...
diffusers/examples/dreambooth/README.md/0
{ "file_path": "diffusers/examples/dreambooth/README.md", "repo_id": "diffusers", "token_count": 9826 }
120
#!/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/dreambooth/train_dreambooth.py/0
{ "file_path": "diffusers/examples/dreambooth/train_dreambooth.py", "repo_id": "diffusers", "token_count": 25383 }
121
#!/usr/bin/env python # coding=utf-8 # Copyright 2024 Harutatsu Akiyama and 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....
diffusers/examples/instruct_pix2pix/train_instruct_pix2pix_sdxl.py/0
{ "file_path": "diffusers/examples/instruct_pix2pix/train_instruct_pix2pix_sdxl.py", "repo_id": "diffusers", "token_count": 23515 }
122
#!/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/consistency_training/train_cm_ct_unconditional.py/0
{ "file_path": "diffusers/examples/research_projects/consistency_training/train_cm_ct_unconditional.py", "repo_id": "diffusers", "token_count": 26288 }
123
# GLIGEN: Open-Set Grounded Text-to-Image Generation These scripts contain the code to prepare the grounding data and train the GLIGEN model on COCO dataset. ### Install the requirements ```bash conda create -n diffusers python==3.10 conda activate diffusers pip install -r requirements.txt ``` And initialize an [🤗...
diffusers/examples/research_projects/gligen/README.md/0
{ "file_path": "diffusers/examples/research_projects/gligen/README.md", "repo_id": "diffusers", "token_count": 1748 }
124
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNet2DConditionModel def parse_args(): parser = argparse.ArgumentParser() ...
diffusers/examples/research_projects/intel_opts/textual_inversion_dfq/text2images.py/0
{ "file_path": "diffusers/examples/research_projects/intel_opts/textual_inversion_dfq/text2images.py", "repo_id": "diffusers", "token_count": 1518 }
125
import argparse import logging import math import os import random from pathlib import Path import jax import jax.numpy as jnp import numpy as np import optax import PIL import torch import torch.utils.checkpoint import transformers from flax import jax_utils from flax.training import train_state from flax.training.co...
diffusers/examples/research_projects/multi_token_textual_inversion/textual_inversion_flax.py/0
{ "file_path": "diffusers/examples/research_projects/multi_token_textual_inversion/textual_inversion_flax.py", "repo_id": "diffusers", "token_count": 10599 }
126
import inspect from typing import Callable, List, Optional, Union import torch from PIL import Image from retriever import Retriever, normalize_images, preprocess_images from transformers import CLIPImageProcessor, CLIPModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPip...
diffusers/examples/research_projects/rdm/pipeline_rdm.py/0
{ "file_path": "diffusers/examples/research_projects/rdm/pipeline_rdm.py", "repo_id": "diffusers", "token_count": 7202 }
127
<jupyter_start><jupyter_text>Running Stable Diffusion 3 (SD3) DreamBooth LoRA training under 16GB GPU VRAM Install Dependencies<jupyter_code>!pip install -q -U git+https://github.com/huggingface/diffusers !pip install -q -U \ transformers \ accelerate \ wandb \ bitsandbytes \ peft<jupyter_output><e...
diffusers/examples/research_projects/sd3_lora_colab/sd3_dreambooth_lora_16gb.ipynb/0
{ "file_path": "diffusers/examples/research_projects/sd3_lora_colab/sd3_dreambooth_lora_16gb.ipynb", "repo_id": "diffusers", "token_count": 1077 }
128
import argparse import json import torch from diffusers import AutoencoderKL, DDPMPipeline, DDPMScheduler, UNet2DModel, VQModel def shave_segments(path, n_shave_prefix_segments=1): """ Removes segments. Positive values shave the first segments, negative shave the last segments. """ if n_shave_prefix...
diffusers/scripts/convert_ddpm_original_checkpoint_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_ddpm_original_checkpoint_to_diffusers.py", "repo_id": "diffusers", "token_count": 8490 }
129
# 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": 2130 }
130
# Run this script to convert the Stable Cascade model weights to a diffusers pipeline. import argparse import json import os from contextlib import nullcontext import torch from safetensors.torch import load_file from transformers import ( AutoTokenizer, T5EncoderModel, ) from diffusers import ( Autoencod...
diffusers/scripts/convert_stable_audio.py/0
{ "file_path": "diffusers/scripts/convert_stable_audio.py", "repo_id": "diffusers", "token_count": 4812 }
131
import random import torch from huggingface_hub import HfApi from diffusers import UNet2DModel api = HfApi() results = {} # fmt: off results["google_ddpm_cifar10_32"] = torch.tensor([ -0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467, 1.2342, -2.2485, 0.4636, 0.8076, -0.7991, 0.3969, 0.849...
diffusers/scripts/generate_logits.py/0
{ "file_path": "diffusers/scripts/generate_logits.py", "repo_id": "diffusers", "token_count": 3530 }
132
from typing import TYPE_CHECKING from ..utils import DIFFUSERS_SLOW_IMPORT, _LazyModule, deprecate from ..utils.import_utils import is_peft_available, is_torch_available, is_transformers_available def text_encoder_lora_state_dict(text_encoder): deprecate( "text_encoder_load_state_dict in `models`", ...
diffusers/src/diffusers/loaders/__init__.py/0
{ "file_path": "diffusers/src/diffusers/loaders/__init__.py", "repo_id": "diffusers", "token_count": 1789 }
133
# 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...
diffusers/src/diffusers/models/adapter.py/0
{ "file_path": "diffusers/src/diffusers/models/adapter.py", "repo_id": "diffusers", "token_count": 10101 }
134
# Copyright 2024 Black Forest Labs, The HuggingFace Team and The InstantX 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/LIC...
diffusers/src/diffusers/models/controlnet_flux.py/0
{ "file_path": "diffusers/src/diffusers/models/controlnet_flux.py", "repo_id": "diffusers", "token_count": 10426 }
135
# Copyright 2024 The HuggingFace Team. All rights reserved. # `TemporalConvLayer` Copyright 2024 Alibaba DAMO-VILAB, The ModelScope 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. #...
diffusers/src/diffusers/models/resnet.py/0
{ "file_path": "diffusers/src/diffusers/models/resnet.py", "repo_id": "diffusers", "token_count": 14442 }
136