text
stringlengths
5
631k
id
stringlengths
14
178
metadata
dict
__index_level_0__
int64
0
647
# candle-mnist-training Training a 2 layer MLP on mnist in Candle. ## Running an example ```bash $ cargo run --example mnist-training --features candle-datasets > train-images: [60000, 784] > train-labels: [60000] > test-images: [10000, 784] > test-labels: [10000] > 1 train loss: 2.30265 test acc: 68.08% > 2...
candle/candle-examples/examples/mnist-training/README.md/0
{ "file_path": "candle/candle-examples/examples/mnist-training/README.md", "repo_id": "candle", "token_count": 143 }
38
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::{Error as E, Result}; use candle::{DType, IndexOp, Shape, Tensor, D}; use candle_nn::VarBuilder; use candle_transformers::models::nvembed_v2::model::Model; use clap::Parser; use hf_hub::{api::sy...
candle/candle-examples/examples/nvembed_v2/main.rs/0
{ "file_path": "candle/candle-examples/examples/nvembed_v2/main.rs", "repo_id": "candle", "token_count": 3339 }
39
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::{Error as E, Result}; use clap::{Parser, ValueEnum}; use candle_examples::token_output_stream::TokenOutputStream; use candle_transformers::models::mixformer::{Config, MixFormerSequentialForCaus...
candle/candle-examples/examples/phi/main.rs/0
{ "file_path": "candle/candle-examples/examples/phi/main.rs", "repo_id": "candle", "token_count": 9709 }
40
# candle-qwen: large language model series from Alibaba Cloud Qwen 1.5 is a series of large language models that provide strong performances on English and Chinese. - [Blog post](https://qwenlm.github.io/blog/qwen1.5/) introducing Qwen1.5. - [Model card](https://huggingface.co/Qwen/Qwen1.5-0.5B) on the HuggingFace Hu...
candle/candle-examples/examples/qwen/README.md/0
{ "file_path": "candle/candle-examples/examples/qwen/README.md", "repo_id": "candle", "token_count": 616 }
41
# candle-resnet A candle implementation of inference using a pre-trained [ResNet](https://arxiv.org/abs/1512.03385). This uses a classification head trained on the ImageNet dataset and returns the probabilities for the top-5 classes. ## Running an example ``` $ cargo run --example resnet --release -- --image candle-...
candle/candle-examples/examples/resnet/README.md/0
{ "file_path": "candle/candle-examples/examples/resnet/README.md", "repo_id": "candle", "token_count": 220 }
42
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use clap::Parser; use candle::{DType, Tensor}; #[derive(Clone, Debug, Copy, PartialEq, Eq, clap::ValueEnum)] enum Which { #[value(name = "silero")] Silero, } #[derive(Clone, D...
candle/candle-examples/examples/silero-vad/main.rs/0
{ "file_path": "candle/candle-examples/examples/silero-vad/main.rs", "repo_id": "candle", "token_count": 2894 }
43
# candle-starcoder2 Candle implementation of Star Coder 2 family of code generation model from [StarCoder 2 and The Stack v2: The Next Generation](https://arxiv.org/pdf/2402.19173). ## Running an example ```bash $ cargo run --example starcoder2 -- --prompt "write a recursive fibonacci function in python " > # that ...
candle/candle-examples/examples/starcoder2/README.md/0
{ "file_path": "candle/candle-examples/examples/starcoder2/README.md", "repo_id": "candle", "token_count": 126 }
44
use std::path::PathBuf; use anyhow::Result; use hf_hub::{api::sync::Api, Repo, RepoType}; /// # Errors /// /// Returns an error if the model files cannot be downloaded. /// /// # Panics /// /// Panics if the model files cannot be downloaded. pub fn model_files(model_id: &str) -> Result<((PathBuf, Vec<PathBuf>), PathB...
candle/candle-examples/examples/voxtral/download.rs/0
{ "file_path": "candle/candle-examples/examples/voxtral/download.rs", "repo_id": "candle", "token_count": 1158 }
45
# candle-xlm-roberta This example demonstrates how to use the XLM-RoBERTa model in Candle especially known for their use in reranking. It uses the `fill-mask` task to generate a word for a masked token. And a `reranker` task to rerank a list of documents for a given query. ## Usage Fill Mask: ```bash cargo run --exa...
candle/candle-examples/examples/xlm-roberta/Readme.md/0
{ "file_path": "candle/candle-examples/examples/xlm-roberta/Readme.md", "repo_id": "candle", "token_count": 547 }
46
#include "kernels.h" #include "kernel_helpers.h" #include "flash_fwd_launch_template.h" void run_mha_fwd(Flash_fwd_params &params, cudaStream_t stream) { FP16_SWITCH(!params.is_bf16, [&] { HEADDIM_SWITCH(params.d, [&] { BOOL_SWITCH(params.is_causal, Is_causal, [&] { run_mha_fwd_<elem_ty...
candle/candle-flash-attn/kernels/flash_api.cu/0
{ "file_path": "candle/candle-flash-attn/kernels/flash_api.cu", "repo_id": "candle", "token_count": 1818 }
47
use anyhow::Result; use candle::{DType, Device, IndexOp, Tensor, D}; fn to_vec3_round(t: Tensor, digits: i32) -> Result<Vec<Vec<Vec<f32>>>> { let b = 10f32.powi(digits); let t = t.to_vec3::<f32>()?; let t = t .iter() .map(|t| { t.iter() .map(|t| t.iter().map(|t| ...
candle/candle-flash-attn/tests/flash_attn_tests.rs/0
{ "file_path": "candle/candle-flash-attn/tests/flash_attn_tests.rs", "repo_id": "candle", "token_count": 3779 }
48
#include "cuda_utils.cuh" #include <cmath> #include <stdint.h> #define WARP_SIZE 32 const int BLOCK_SIZE = 1024; // TODO: Maybe add some fast_sum_f16_f32 variant that not only accumulate in f32 // but also expect a f32 output so that this can be used for normalization e.g. // in softmax. // Fast reduce sum kernel, t...
candle/candle-kernels/src/reduce.cu/0
{ "file_path": "candle/candle-kernels/src/reduce.cu", "repo_id": "candle", "token_count": 13341 }
49
// The implementation below comes from MLX. // https://github.com/ml-explore/mlx/blob/0cea88bcc5e98e81a24d92eed8870a6976999f05/mlx/backend/metal/kernels/sort.h // Copyright © 2023-2024 Apple Inc. #define MLX_MTL_CONST static constant constexpr const #define MLX_MTL_LOOP_UNROLL _Pragma("clang loop unroll(full)") #incl...
candle/candle-metal-kernels/src/mlx_sort.metal/0
{ "file_path": "candle/candle-metal-kernels/src/mlx_sort.metal", "repo_id": "candle", "token_count": 12675 }
50
[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": 384 }
51
//! Variable initialization. // This is based on: // https://github.com/pytorch/pytorch/blob/07107919297db3f8ab37f11c12666b6d6d5f692e/torch/nn/init.py# use candle::{DType, Device, Result, Shape, Tensor, Var}; /// Number of features as input or output of a layer. /// In Kaiming initialization, choosing `FanIn` preserve...
candle/candle-nn/src/init.rs/0
{ "file_path": "candle/candle-nn/src/init.rs", "repo_id": "candle", "token_count": 2212 }
52
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{Device, Result, Tensor}; #[test] fn kv_cache() -> Result<()> { let mut cache = candle_nn::kv_cache::Cache::new(0, 16); for _ in [0, 1] { assert_eq!(cache.current_seq_len(), 0);...
candle/candle-nn/tests/kv_cache.rs/0
{ "file_path": "candle/candle-nn/tests/kv_cache.rs", "repo_id": "candle", "token_count": 2618 }
53
[package] name = "candle-pyo3" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true readme = "README.md" [lib] name = "candle" crate-type = ["cdylib"] [dependencies] accelerate-src = { ...
candle/candle-pyo3/Cargo.toml/0
{ "file_path": "candle/candle-pyo3/Cargo.toml", "repo_id": "candle", "token_count": 325 }
54
from candle import Tensor, QTensor, DType from typing import ( Dict, Tuple, Any, Optional, Union, Iterator, Set, overload, Mapping, TypeVar, List, ) from collections import OrderedDict, namedtuple TensorLike = Union[Tensor, QTensor] T = TypeVar("T", bound="Module") class _...
candle/candle-pyo3/py_src/candle/nn/module.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/nn/module.py", "repo_id": "candle", "token_count": 12028 }
55
import candle print(f"mkl: {candle.utils.has_mkl()}") print(f"accelerate: {candle.utils.has_accelerate()}") print(f"num-threads: {candle.utils.get_num_threads()}") print(f"cuda: {candle.utils.cuda_is_available()}") t = candle.Tensor(42.0) print(t) print(t.shape, t.rank, t.device) print(t + t) t = can...
candle/candle-pyo3/test.py/0
{ "file_path": "candle/candle-pyo3/test.py", "repo_id": "candle", "token_count": 340 }
56
//! BigCode implementation in Rust based on the GPT-BigCode model. //! //! [StarCoder/BigCode](https://huggingface.co/bigcode/starcoderbase-1b) is a LLM //! model specialized to code generation. The initial model was trained on 80 //! programming languages. See "StarCoder: A State-of-the-Art LLM for Code", Mukherjee et...
candle/candle-transformers/src/models/bigcode.rs/0
{ "file_path": "candle/candle-transformers/src/models/bigcode.rs", "repo_id": "candle", "token_count": 6580 }
57
use std::collections::HashMap; use candle::{bail, Context, DType, Device, Module, Result, Tensor, D}; use candle_nn::{ conv1d, embedding, layer_norm, Conv1d, Conv1dConfig, Embedding, LayerNorm, VarBuilder, }; use serde::{Deserialize, Deserializer}; pub const DTYPE: DType = DType::F32; // NOTE: HiddenAct and Hidd...
candle/candle-transformers/src/models/debertav2.rs/0
{ "file_path": "candle/candle-transformers/src/models/debertav2.rs", "repo_id": "candle", "token_count": 24495 }
58
use candle::{Device, Result, Tensor}; pub fn get_noise( num_samples: usize, height: usize, width: usize, device: &Device, ) -> Result<Tensor> { let height = height.div_ceil(16) * 2; let width = width.div_ceil(16) * 2; Tensor::randn(0f32, 1., (num_samples, 16, height, width), device) } #[de...
candle/candle-transformers/src/models/flux/sampling.rs/0
{ "file_path": "candle/candle-transformers/src/models/flux/sampling.rs", "repo_id": "candle", "token_count": 2069 }
59
//! Mamba inference implementation. //! //! See ["Mamba: Linear-Time Sequence Modeling with Selective State Spaces"](https://arxiv.org/abs/2312.00752) //! //! Based on reference implementation from the AlbertMamba project //! A fast implementation of mamba for inference only. //! Based on Laurent Mazare's rust implemen...
candle/candle-transformers/src/models/mamba.rs/0
{ "file_path": "candle/candle-transformers/src/models/mamba.rs", "repo_id": "candle", "token_count": 3925 }
60
use candle::{Module, Result, Tensor}; use candle_nn as nn; pub struct Qkv { pub q: Tensor, pub k: Tensor, pub v: Tensor, } pub struct Mlp { fc1: nn::Linear, act: nn::Activation, fc2: nn::Linear, } impl Mlp { pub fn new( in_features: usize, hidden_features: usize, v...
candle/candle-transformers/src/models/mmdit/projections.rs/0
{ "file_path": "candle/candle-transformers/src/models/mmdit/projections.rs", "repo_id": "candle", "token_count": 1917 }
61
//! Parler Model implementation for parler_tts text-to-speech synthesis //! //! Implements a transformer-based decoder architecture for generating audio tokens //! from text using discrete tokens. The model converts text into audio segments //! using multiple codebooks of quantized audio tokens. //! //! The model archi...
candle/candle-transformers/src/models/parler_tts.rs/0
{ "file_path": "candle/candle-transformers/src/models/parler_tts.rs", "repo_id": "candle", "token_count": 8563 }
62
//! Quantized MPT model implementation. //! //! MPT (MPT-7B) is a causal transformer model series optimized for code generation. //! This implementation provides quantization for reduced memory and compute. //! //! Key characteristics: //! - Multi-Query Grouped Attention (MQA) //! - Support for KV-caching //! - Pre-com...
candle/candle-transformers/src/models/quantized_mpt.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_mpt.rs", "repo_id": "candle", "token_count": 3969 }
63
//! # ResNet Implementation //! //! Implementation of ResNet architectures as described in the paper: //! //! ## Reference //! //! [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) //! He et al. (2015) //! //! This paper introduced ResNet, a deep neural network architecture that utilizes ...
candle/candle-transformers/src/models/resnet.rs/0
{ "file_path": "candle/candle-transformers/src/models/resnet.rs", "repo_id": "candle", "token_count": 4023 }
64
use super::schedulers::{betas_for_alpha_bar, BetaSchedule, PredictionType}; use candle::{Result, Tensor}; #[derive(Debug, Clone, PartialEq, Eq)] pub enum DDPMVarianceType { FixedSmall, FixedSmallLog, FixedLarge, FixedLargeLog, Learned, } impl Default for DDPMVarianceType { fn default() -> Self...
candle/candle-transformers/src/models/stable_diffusion/ddpm.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/ddpm.rs", "repo_id": "candle", "token_count": 3666 }
65
//! VGG-16 model implementation. //! //! VGG-16 is a convolutional neural network architecture. It consists of 13 //! convolutional layers followed by 3 fully connected layers. //! //! Key characteristics: //! - Conv layers with 3x3 filters //! - Max pooling after every 2-3 conv layers //! - Three fully connected layer...
candle/candle-transformers/src/models/vgg.rs/0
{ "file_path": "candle/candle-transformers/src/models/vgg.rs", "repo_id": "candle", "token_count": 4390 }
66
use super::common::LayerNormNoWeights; use candle::{Module, Result, Tensor}; use candle_nn::VarBuilder; #[derive(Debug)] pub struct MixingResidualBlock { norm1: LayerNormNoWeights, depthwise_conv: candle_nn::Conv2d, norm2: LayerNormNoWeights, channelwise_lin1: candle_nn::Linear, channelwise_lin2: c...
candle/candle-transformers/src/models/wuerstchen/paella_vq.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/paella_vq.rs", "repo_id": "candle", "token_count": 4078 }
67
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Bert</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> @import u...
candle/candle-wasm-examples/bert/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/bert/lib-example.html", "repo_id": "candle", "token_count": 6066 }
68
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Llama.c Rust/WASM</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> ...
candle/candle-wasm-examples/llama2-c/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/lib-example.html", "repo_id": "candle", "token_count": 6089 }
69
## Running T5 with Candle and WASM Here, we provide two examples of how to run Bert using a Candle-compiled WASM binary and runtime. ### Vanilla JS and WebWorkers To build and test the UI made in Vanilla JS and WebWorkers, first we need to build the WASM library: ```bash sh build-lib.sh ``` This will bundle the li...
candle/candle-wasm-examples/t5/README.md/0
{ "file_path": "candle/candle-wasm-examples/t5/README.md", "repo_id": "candle", "token_count": 282 }
70
// Audio processing code, adapted from whisper.cpp // https://github.com/ggerganov/whisper.cpp use super::worker; pub trait Float: num_traits::Float + num_traits::FloatConst + num_traits::NumAssign {} impl Float for f32 {} impl Float for f64 {} // https://github.com/ggerganov/whisper.cpp/blob/4774d2feb01a772a15de81f...
candle/candle-wasm-examples/whisper/src/audio.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/audio.rs", "repo_id": "candle", "token_count": 3162 }
71
use yew_agent::PublicWorker; fn main() { console_error_panic_hook::set_once(); candle_wasm_example_yolo::Worker::register(); }
candle/candle-wasm-examples/yolo/src/bin/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/bin/worker.rs", "repo_id": "candle", "token_count": 53 }
72
MONGODB_URL=mongodb://localhost:27017/
chat-ui/.env.ci/0
{ "file_path": "chat-ui/.env.ci", "repo_id": "chat-ui", "token_count": 16 }
73
{ "useTabs": true, "trailingComma": "es5", "printWidth": 100, "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] }
chat-ui/.prettierrc/0
{ "file_path": "chat-ui/.prettierrc", "repo_id": "chat-ui", "token_count": 93 }
74
{{- if $.Values.ingress.enabled }} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: {{ toYaml .Values.ingress.annotations | nindent 4 }} labels: {{ include "labels.standard" . | nindent 4 }} name: {{ include "name" . }} namespace: {{ .Release.Namespace }} spec: {{ if $.Values.ingress.clas...
chat-ui/chart/templates/ingress.yaml/0
{ "file_path": "chat-ui/chart/templates/ingress.yaml", "repo_id": "chat-ui", "token_count": 400 }
75
# Google | Feature | Available | | --------------------------- | --------- | | [Tools](../tools) | No | | [Multimodal](../multimodal) | No | Chat UI can connect to the google Vertex API endpoints ([List of supported models](https://cloud.google.com/vertex-ai/generative-ai/d...
chat-ui/docs/source/configuration/models/providers/google.md/0
{ "file_path": "chat-ui/docs/source/configuration/models/providers/google.md", "repo_id": "chat-ui", "token_count": 1138 }
76
# Running Locally You may start an instance locally for non-production use cases. For production use cases, please see the other installation options. ## Configuration The default config for Chat UI is stored in the `.env` file. You will need to override some values to get Chat UI to run locally. Start by creating a...
chat-ui/docs/source/installation/local.md/0
{ "file_path": "chat-ui/docs/source/installation/local.md", "repo_id": "chat-ui", "token_count": 416 }
77
import { config, ready } from "$lib/server/config"; import type { Handle, HandleServerError, ServerInit, HandleFetch } from "@sveltejs/kit"; import { collections } from "$lib/server/database"; import { base } from "$app/paths"; import { authenticateRequest, refreshSessionCookie, requiresUser } from "$lib/server/auth"; ...
chat-ui/src/hooks.server.ts/0
{ "file_path": "chat-ui/src/hooks.server.ts", "repo_id": "chat-ui", "token_count": 3045 }
78
<script lang="ts"> import { base } from "$app/paths"; import { page } from "$app/state"; import LogoHuggingFaceBorderless from "$lib/components/icons/LogoHuggingFaceBorderless.svelte"; import Modal from "$lib/components/Modal.svelte"; import { useSettingsStore } from "$lib/stores/settings"; import { cookiesAreEn...
chat-ui/src/lib/components/LoginModal.svelte/0
{ "file_path": "chat-ui/src/lib/components/LoginModal.svelte", "repo_id": "chat-ui", "token_count": 914 }
79
<script lang="ts"> import Modal from "./Modal.svelte"; import CarbonClose from "~icons/carbon/close"; import CarbonBlockchain from "~icons/carbon/blockchain"; interface Props { preprompt: string; } let { preprompt }: Props = $props(); let isOpen = $state(false); </script> <button type="button" class="mx-...
chat-ui/src/lib/components/SystemPromptModal.svelte/0
{ "file_path": "chat-ui/src/lib/components/SystemPromptModal.svelte", "repo_id": "chat-ui", "token_count": 535 }
80
<script lang="ts"> import type { WebSearchSource } from "$lib/types/WebSearch"; import { processTokens, processTokensSync, type Token } from "$lib/utils/marked"; // import MarkdownWorker from "$lib/workers/markdownWorker?worker"; import CodeBlock from "../CodeBlock.svelte"; import type { IncomingMessage, OutgoingM...
chat-ui/src/lib/components/chat/MarkdownRenderer.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/MarkdownRenderer.svelte", "repo_id": "chat-ui", "token_count": 964 }
81
<script lang="ts"> interface Props { classNames?: string; } let { classNames = "" }: Props = $props(); </script> <svg class={classNames} xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" fill="currentColor" viewBox="0 0 32 32" ><path fill-rule...
chat-ui/src/lib/components/icons/IconScreenshot.svelte/0
{ "file_path": "chat-ui/src/lib/components/icons/IconScreenshot.svelte", "repo_id": "chat-ui", "token_count": 471 }
82
import { ObjectId, type WithId } from "mongodb"; import { collections } from "$lib/server/database"; import type { Migration } from "."; import type { Conversation } from "$lib/types/Conversation"; import type { MessageFile } from "$lib/types/Message"; const updateMessageFiles: Migration = { _id: new ObjectId("5f9f5...
chat-ui/src/lib/migrations/routines/05-update-message-files.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/05-update-message-files.ts", "repo_id": "chat-ui", "token_count": 618 }
83
import { Elysia, t } from "elysia"; import { authPlugin } from "$api/authPlugin"; import { ReviewStatus } from "$lib/types/Review"; import { toolFromConfigs } from "$lib/server/tools"; import { collections } from "$lib/server/database"; import { ObjectId, type Filter } from "mongodb"; import type { CommunityToolDB, Too...
chat-ui/src/lib/server/api/routes/groups/tools.ts/0
{ "file_path": "chat-ui/src/lib/server/api/routes/groups/tools.ts", "repo_id": "chat-ui", "token_count": 3068 }
84
import { z } from "zod"; import type { Endpoint } from "../endpoints"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import { config } from "$lib/server/config"; import { logger } from "$lib/server/logger"; export const endpointCloudflareParametersSchema = z.object({ weight: z.number().int...
chat-ui/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/cloudflare/endpointCloudflare.ts", "repo_id": "chat-ui", "token_count": 1620 }
85
import { config } from "$lib/server/config"; import { buildPrompt } from "$lib/buildPrompt"; import { textGenerationStream } from "@huggingface/inference"; import type { Endpoint, EndpointMessage } from "../endpoints"; import { z } from "zod"; import { createImageProcessorOptionsValidator, makeImageProcessor, type I...
chat-ui/src/lib/server/endpoints/tgi/endpointTgi.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/tgi/endpointTgi.ts", "repo_id": "chat-ui", "token_count": 1022 }
86
import { Address6, Address4 } from "ip-address"; import dns from "node:dns"; import { isIP } from "node:net"; const dnsLookup = (hostname: string): Promise<{ address: string; family: number }> => { return new Promise((resolve, reject) => { dns.lookup(hostname, (err, address, family) => { if (err) return reject(e...
chat-ui/src/lib/server/isURLLocal.ts/0
{ "file_path": "chat-ui/src/lib/server/isURLLocal.ts", "repo_id": "chat-ui", "token_count": 466 }
87
import { MessageUpdateType } from "$lib/types/MessageUpdate"; import { ToolColor, ToolIcon, ToolOutputComponents, type BackendCall, type BaseTool, type ConfigTool, type ToolInput, } from "$lib/types/Tool"; import type { TextGenerationContext } from "../textGeneration/types"; import { z } from "zod"; import JSON...
chat-ui/src/lib/server/tools/index.ts/0
{ "file_path": "chat-ui/src/lib/server/tools/index.ts", "repo_id": "chat-ui", "token_count": 3695 }
88
import type { SerializedHTMLElement } from "./types"; interface DBSCANOptions<T> { dataset: T[]; epsilon?: number; epsilonCompare?: (distance: number, epsilon: number) => boolean; minimumPoints?: number; distanceFunction: (a: T, b: T) => number; } export function spatialParser() { /** * Implementation for dbs...
chat-ui/src/lib/server/websearch/scrape/parser.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/scrape/parser.ts", "repo_id": "chat-ui", "token_count": 6106 }
89
import { base } from "$app/paths"; import { ERROR_MESSAGES, error } from "$lib/stores/errors"; import { share } from "./utils/share"; import { page } from "$app/state"; export async function shareConversation(id: string, title: string) { try { if (id.length === 7) { const shareUrl = `${ page.data.publicConfi...
chat-ui/src/lib/shareConversation.ts/0
{ "file_path": "chat-ui/src/lib/shareConversation.ts", "repo_id": "chat-ui", "token_count": 470 }
90
import type { MessageUpdate } from "./MessageUpdate"; import type { Timestamps } from "./Timestamps"; import type { WebSearch } from "./WebSearch"; import type { v4 } from "uuid"; export type Message = Partial<Timestamps> & { from: "user" | "assistant" | "system"; id: ReturnType<typeof v4>; content: string; update...
chat-ui/src/lib/types/Message.ts/0
{ "file_path": "chat-ui/src/lib/types/Message.ts", "repo_id": "chat-ui", "token_count": 277 }
91
import type { ObjectId } from "mongodb"; import type { Timestamps } from "./Timestamps"; export interface User extends Timestamps { _id: ObjectId; username?: string; name: string; email?: string; avatarUrl: string | undefined; hfUserId: string; isAdmin?: boolean; isEarlyAccess?: boolean; }
chat-ui/src/lib/types/User.ts/0
{ "file_path": "chat-ui/src/lib/types/User.ts", "repo_id": "chat-ui", "token_count": 100 }
92
import { browser } from "$app/environment"; export function isVirtualKeyboard(): boolean { if (!browser) return false; // Check for touch capability if (navigator.maxTouchPoints > 0 && screen.width <= 768) return true; // Check for touch events if ("ontouchstart" in window) return true; // Fallback to user ag...
chat-ui/src/lib/utils/isVirtualKeyboard.ts/0
{ "file_path": "chat-ui/src/lib/utils/isVirtualKeyboard.ts", "repo_id": "chat-ui", "token_count": 144 }
93
export const webSearchToolId = "00000000000000000000000a"; export const fetchUrlToolId = "00000000000000000000000b"; export const imageGenToolId = "000000000000000000000001"; export const documentParserToolId = "000000000000000000000002";
chat-ui/src/lib/utils/toolIds.ts/0
{ "file_path": "chat-ui/src/lib/utils/toolIds.ts", "repo_id": "chat-ui", "token_count": 52 }
94
<script lang="ts"> import { page } from "$app/state"; </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 dark...
chat-ui/src/routes/+error.svelte/0
{ "file_path": "chat-ui/src/routes/+error.svelte", "repo_id": "chat-ui", "token_count": 342 }
95
import { models } from "$lib/server/models"; export async function GET() { const res = models .filter((m) => m.unlisted == false) .map((model) => ({ id: model.id, name: model.name, websiteUrl: model.websiteUrl ?? "https://huggingface.co", modelUrl: model.modelUrl ?? "https://huggingface.co", tokeni...
chat-ui/src/routes/api/models/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/models/+server.ts", "repo_id": "chat-ui", "token_count": 311 }
96
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": 1252 }
97
<script lang="ts"> import { page } from "$app/state"; import { base } from "$app/paths"; import { goto } from "$app/navigation"; import { onMount } from "svelte"; import { usePublicConfig } from "$lib/utils/PublicConfig.svelte"; import ChatWindow from "$lib/components/chat/ChatWindow.svelte"; import { findCurre...
chat-ui/src/routes/models/[...model]/+page.svelte/0
{ "file_path": "chat-ui/src/routes/models/[...model]/+page.svelte", "repo_id": "chat-ui", "token_count": 931 }
98
<script lang="ts"> import type { PageData } from "./$types"; import { page } from "$app/state"; import AssistantSettings from "$lib/components/AssistantSettings.svelte"; interface Props { data: PageData; } let { data }: Props = $props(); let assistant = data.assistants.find((el) => el._id.toString() === pag...
chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/edit/+page.svelte/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/edit/+page.svelte", "repo_id": "chat-ui", "token_count": 135 }
99
import { sveltekit } from "@sveltejs/kit/vite"; import Icons from "unplugin-icons/vite"; import { promises } from "fs"; import { defineConfig } from "vitest/config"; import { resolve } from "path"; import fs from "fs-extra"; import { spawn } from "child_process"; import type { Plugin } from "vite"; // used to load fon...
chat-ui/vite.config.ts/0
{ "file_path": "chat-ui/vite.config.ts", "repo_id": "chat-ui", "token_count": 1683 }
100
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration SPEED_TEST_N_EXAMPLES = 500_000 RESULTS_BASEPATH, RESULTS_FILENAME = os.path.split(__file__) RESULTS_FILE_PATH = os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py...
datasets/benchmarks/benchmark_map_filter.py/0
{ "file_path": "datasets/benchmarks/benchmark_map_filter.py", "repo_id": "datasets", "token_count": 996 }
101
# Build and load Nearly every deep learning workflow begins with loading a dataset, which makes it one of the most important steps. With 🤗 Datasets, there are more than 900 datasets available to help you get started with your NLP task. All you have to do is call: [`load_dataset`] to take your first step. This functio...
datasets/docs/source/about_dataset_load.mdx/0
{ "file_path": "datasets/docs/source/about_dataset_load.mdx", "repo_id": "datasets", "token_count": 2241 }
102
# Overview The how-to guides offer a more comprehensive overview of all the tools 🤗 Datasets offers and how to use them. This will help you tackle messier real-world datasets where you may need to manipulate the dataset structure or content to get it ready for training. The guides assume you are familiar and comfort...
datasets/docs/source/how_to.md/0
{ "file_path": "datasets/docs/source/how_to.md", "repo_id": "datasets", "token_count": 471 }
103
# Main classes ## DatasetInfo [[autodoc]] datasets.DatasetInfo ## Dataset The base class [`Dataset`] implements a Dataset backed by an Apache Arrow table. [[autodoc]] datasets.Dataset - add_column - add_item - from_file - from_buffer - from_pandas - from_dict - from_generator - dat...
datasets/docs/source/package_reference/main_classes.mdx/0
{ "file_path": "datasets/docs/source/package_reference/main_classes.mdx", "repo_id": "datasets", "token_count": 2022 }
104
# Use with Pandas This document is a quick introduction to using `datasets` with Pandas, with a particular focus on how to process datasets using Pandas functions, and how to convert a dataset to Pandas or from Pandas. This is particularly useful as it allows fast operations, since `datasets` uses PyArrow under the h...
datasets/docs/source/use_with_pandas.mdx/0
{ "file_path": "datasets/docs/source/use_with_pandas.mdx", "repo_id": "datasets", "token_count": 1010 }
105
from typing import 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, _interleave_it...
datasets/src/datasets/combine.py/0
{ "file_path": "datasets/src/datasets/combine.py", "repo_id": "datasets", "token_count": 4602 }
106
import numpy as np from torchcodec.decoders import AudioDecoder as _AudioDecoder class AudioDecoder(_AudioDecoder): def __getitem__(self, key: str): if key == "array": y = self.get_all_samples().data.cpu().numpy() return np.mean(y, axis=tuple(range(y.ndim - 1))) if y.ndim > 1 else ...
datasets/src/datasets/features/_torchcodec.py/0
{ "file_path": "datasets/src/datasets/features/_torchcodec.py", "repo_id": "datasets", "token_count": 278 }
107
# 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/torch_formatter.py/0
{ "file_path": "datasets/src/datasets/formatting/torch_formatter.py", "repo_id": "datasets", "token_count": 2151 }
108
# 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/naming.py/0
{ "file_path": "datasets/src/datasets/naming.py", "repo_id": "datasets", "token_count": 1179 }
109
#!/usr/bin/env python # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
datasets/src/datasets/utils/_filelock.py/0
{ "file_path": "datasets/src/datasets/utils/_filelock.py", "repo_id": "datasets", "token_count": 896 }
110
{ "monolingual": "contains a single language", "multilingual": "contains multiple languages", "translation": "contains translated or aligned text", "other": "other type of language distribution" }
datasets/src/datasets/utils/resources/multilingualities.json/0
{ "file_path": "datasets/src/datasets/utils/resources/multilingualities.json", "repo_id": "datasets", "token_count": 55 }
111
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, List, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict _TestCommandArgs = namedtuple( "_TestCommandArgs", [ "dataset", "name", ...
datasets/tests/commands/test_test.py/0
{ "file_path": "datasets/tests/commands/test_test.py", "repo_id": "datasets", "token_count": 1495 }
112
import os import shutil import tarfile import warnings from io import BytesIO import numpy as np import pandas as pd import pyarrow as pa import pytest from datasets import Column, Dataset, Features, Image, List, Value, concatenate_datasets, load_dataset from datasets.features.image import encode_np_array, image_to_b...
datasets/tests/features/test_image.py/0
{ "file_path": "datasets/tests/features/test_image.py", "repo_id": "datasets", "token_count": 11308 }
113
import os import tempfile from pathlib import Path from unittest import TestCase import pyarrow as pa import pytest from datasets.arrow_dataset import Dataset from datasets.arrow_reader import ArrowReader, BaseReader, FileInstructions, ReadInstruction, make_file_instructions from datasets.info import DatasetInfo from...
datasets/tests/test_arrow_reader.py/0
{ "file_path": "datasets/tests/test_arrow_reader.py", "repo_id": "datasets", "token_count": 5688 }
114
from textwrap import dedent from types import SimpleNamespace from unittest.mock import patch from urllib.parse import quote import pytest from huggingface_hub import CommitOperationAdd, CommitOperationDelete import datasets from datasets.config import METADATA_CONFIGS_FIELD from datasets.hub import delete_from_hub f...
datasets/tests/test_hub.py/0
{ "file_path": "datasets/tests/test_hub.py", "repo_id": "datasets", "token_count": 1576 }
115
import unittest from unittest.mock import patch import pytest from pytest import CaptureFixture from datasets.utils import ( are_progress_bars_disabled, disable_progress_bars, enable_progress_bars, tqdm, ) class TestTqdmUtils(unittest.TestCase): @pytest.fixture(autouse=True) def capsys(self,...
datasets/tests/test_tqdm.py/0
{ "file_path": "datasets/tests/test_tqdm.py", "repo_id": "datasets", "token_count": 1804 }
116
# Diffusers Benchmarks Welcome to Diffusers Benchmarks. These benchmarks are use to obtain latency and memory information of the most popular models across different scenarios such as: * Base case i.e., when using `torch.bfloat16` and `torch.nn.functional.scaled_dot_product_attention`. * Base + `torch.compile()` * NF...
diffusers/benchmarks/README.md/0
{ "file_path": "diffusers/benchmarks/README.md", "repo_id": "diffusers", "token_count": 765 }
117
<!--Copyright 2025 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/lora.md/0
{ "file_path": "diffusers/docs/source/en/api/loaders/lora.md", "repo_id": "diffusers", "token_count": 1878 }
118
<!--Copyright 2025 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/autoencoderkl.md/0
{ "file_path": "diffusers/docs/source/en/api/models/autoencoderkl.md", "repo_id": "diffusers", "token_count": 784 }
119
<!--Copyright 2025 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/LICENSE-2.0 Unless required by ap...
diffusers/docs/source/en/api/models/controlnet_flux.md/0
{ "file_path": "diffusers/docs/source/en/api/models/controlnet_flux.md", "repo_id": "diffusers", "token_count": 740 }
120
<!--Copyright 2025 The HuggingFace Team and Tencent Hunyuan 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...
diffusers/docs/source/en/api/pipelines/controlnet_hunyuandit.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/controlnet_hunyuandit.md", "repo_id": "diffusers", "token_count": 712 }
121
<!-- Copyright 2025 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 applic...
diffusers/docs/source/en/api/pipelines/framepack.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/framepack.md", "repo_id": "diffusers", "token_count": 2945 }
122
<!-- Copyright 2023-2025 Marigold Team, ETH Zürich. All rights reserved. Copyright 2024-2025 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.ap...
diffusers/docs/source/en/api/pipelines/marigold.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/marigold.md", "repo_id": "diffusers", "token_count": 4138 }
123
<!--Copyright 2025 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_2.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_2.md", "repo_id": "diffusers", "token_count": 2283 }
124
<!--Copyright 2025 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/quantization.md/0
{ "file_path": "diffusers/docs/source/en/api/quantization.md", "repo_id": "diffusers", "token_count": 385 }
125
<!--Copyright 2025 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/index.md/0
{ "file_path": "diffusers/docs/source/en/index.md", "repo_id": "diffusers", "token_count": 509 }
126
<!--Copyright 2025 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": 595 }
127
<!--Copyright 2025 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/quantization/quanto.md/0
{ "file_path": "diffusers/docs/source/en/quantization/quanto.md", "repo_id": "diffusers", "token_count": 1703 }
128
<!--Copyright 2025 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/overview.md/0
{ "file_path": "diffusers/docs/source/en/training/overview.md", "repo_id": "diffusers", "token_count": 1542 }
129
# Create a server Diffusers' pipelines can be used as an inference engine for a server. It supports concurrent and multithreaded requests to generate images that may be requested by multiple users at the same time. This guide will show you how to use the [`StableDiffusion3Pipeline`] in a server, but feel free to use...
diffusers/docs/source/en/using-diffusers/create_a_server.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/create_a_server.md", "repo_id": "diffusers", "token_count": 1150 }
130
<!--Copyright 2025 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/pag.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/pag.md", "repo_id": "diffusers", "token_count": 5179 }
131
- sections: - local: index title: 🧨 Diffusers - local: quicktour title: クイックツアー - local: stable_diffusion title: 有効で効率の良い拡散モデル - local: installation title: インストール title: はじめに - sections: - local: tutorials/tutorial_overview title: 概要 - local: tutorials/autopipeline title: AutoPipe...
diffusers/docs/source/ja/_toctree.yml/0
{ "file_path": "diffusers/docs/source/ja/_toctree.yml", "repo_id": "diffusers", "token_count": 166 }
132
<!--Copyright 2025 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/coreml.md/0
{ "file_path": "diffusers/docs/source/ko/optimization/coreml.md", "repo_id": "diffusers", "token_count": 8303 }
133
<!--Copyright 2025 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/ko/training/dreambooth.md/0
{ "file_path": "diffusers/docs/source/ko/training/dreambooth.md", "repo_id": "diffusers", "token_count": 11696 }
134
<!--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/kandinsky.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/kandinsky.md", "repo_id": "diffusers", "token_count": 16319 }
135
<!--Copyright 2025 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
diffusers/docs/source/pt/installation.md/0
{ "file_path": "diffusers/docs/source/pt/installation.md", "repo_id": "diffusers", "token_count": 2101 }
136
<!--版权 2025 The HuggingFace Team。保留所有权利。 根据 Apache 许可证 2.0 版("许可证")授权;除非符合许可证,否则不得使用此文件。您可以在 http://www.apache.org/licenses/LICENSE-2.0 获取许可证的副本。 除非适用法律要求或书面同意,根据许可证分发的软件按"原样"分发,无任何明示或暗示的担保或条件。请参阅许可证了解 特定语言下的权限和限制。 --> # LoopSequentialPipelineBlocks [`~modular_pipelines.LoopSequentialPipelineBlocks`] 是一种多块类型,它将其他...
diffusers/docs/source/zh/modular_diffusers/loop_sequential_pipeline_blocks.md/0
{ "file_path": "diffusers/docs/source/zh/modular_diffusers/loop_sequential_pipeline_blocks.md", "repo_id": "diffusers", "token_count": 2174 }
137