text
stringlengths
7
328k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
459
# Copyright 2020 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...
transformers/tests/trainer/test_trainer_distributed.py/0
{ "file_path": "transformers/tests/trainer/test_trainer_distributed.py", "repo_id": "transformers", "token_count": 4112 }
406
# Copyright 2020 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...
transformers/tests/utils/test_hf_argparser.py/0
{ "file_path": "transformers/tests/utils/test_hf_argparser.py", "repo_id": "transformers", "token_count": 6348 }
407
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
transformers/utils/check_copies.py/0
{ "file_path": "transformers/utils/check_copies.py", "repo_id": "transformers", "token_count": 22136 }
408
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging logger = logging.get_logger(__name__) def extract_warnings_from_single_artifact(artifact_path, targets): """Extract warnings from a downl...
transformers/utils/extract_warnings.py/0
{ "file_path": "transformers/utils/extract_warnings.py", "repo_id": "transformers", "token_count": 2110 }
409
from transformers import PretrainedConfig class CustomConfig(PretrainedConfig): model_type = "custom" def __init__(self, attribute=1, **kwargs): self.attribute = attribute super().__init__(**kwargs) class NoSuperInitConfig(PretrainedConfig): model_type = "custom" def __init__(self,...
transformers/utils/test_module/custom_configuration.py/0
{ "file_path": "transformers/utils/test_module/custom_configuration.py", "repo_id": "transformers", "token_count": 136 }
410
import json import os from ghapi.all import GhApi FOLDER_STRING = os.environ.get("FOLDER_STRING", "") folder = f"benchmark/trl/{FOLDER_STRING}" host_url = f"https://huggingface.co/datasets/trl-internal-testing/example-images/resolve/main/images/benchmark/{FOLDER_STRING}" # Create a GitHub API instance github_contex...
trl/benchmark/post_github_comment.py/0
{ "file_path": "trl/benchmark/post_github_comment.py", "repo_id": "trl", "token_count": 358 }
411
# Examples ## Introduction The examples should work in any of the following settings (with the same script): - single GPU - multi GPUS (using PyTorch distributed mode) - multi GPUS (using DeepSpeed ZeRO-Offload stages 1, 2, & 3) - fp16 (mixed-precision), fp32 (normal precision), or bf16 (bfloat16 precisi...
trl/docs/source/example_overview.md/0
{ "file_path": "trl/docs/source/example_overview.md", "repo_id": "trl", "token_count": 1969 }
412
# Text Environments Text environments provide a learning ground for language agents. It allows a language model to use tools to accomplish a task such as using a Python interpreter to answer math questions or using a search index for trivia questions. Having access to tools allows language models to solve tasks that w...
trl/docs/source/text_environments.md/0
{ "file_path": "trl/docs/source/text_environments.md", "repo_id": "trl", "token_count": 2826 }
413
<jupyter_start><jupyter_text>**Best-of-n sampling as an alternative to RLHF**This notebook compares reward-model scores of prompt based responses from 1. a base model (`gpt2-imdb`)2. `RLHF` tuned model based on this base-model 3. the base-model again from which we sample n responses to each prompt, score them and take ...
trl/examples/notebooks/best_of_n.ipynb/0
{ "file_path": "trl/examples/notebooks/best_of_n.ipynb", "repo_id": "trl", "token_count": 1717 }
414
# De-detoxifying language models To run this code, do the following: ```shell ACCELERATE_LOG_LEVEL=info accelerate launch --config_file {CONFIG} examples/research_projects/toxicity/scripts/gpt-j-6b-toxicity.py --log_with wandb ```
trl/examples/research_projects/toxicity/README.md/0
{ "file_path": "trl/examples/research_projects/toxicity/README.md", "repo_id": "trl", "token_count": 79 }
415
# 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 applicabl...
trl/tests/test_environments.py/0
{ "file_path": "trl/tests/test_environments.py", "repo_id": "trl", "token_count": 4813 }
416
# flake8: noqa from typing import TYPE_CHECKING from ..import_utils import _LazyModule _import_structure = { "base_environment": ["TextEnvironment", "TextHistory"], } if TYPE_CHECKING: from .base_environment import TextEnvironment, TextHistory else: import sys sys.modules[__name__] = _LazyModule(__na...
trl/trl/environment/__init__.py/0
{ "file_path": "trl/trl/environment/__init__.py", "repo_id": "trl", "token_count": 131 }
417
# DPO Authors: Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, and Chelsea Finn 2023 # 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. # ...
trl/trl/trainer/dpo_trainer.py/0
{ "file_path": "trl/trl/trainer/dpo_trainer.py", "repo_id": "trl", "token_count": 27951 }
418
# Builds GPU docker image of PyTorch specifically # Uses multi-staged approach to reduce size # Stage 1 # Use base conda image to reduce time FROM continuumio/miniconda3:latest AS compile-image # Specify py version ENV PYTHON_VERSION=3.9 # Install apt libs RUN apt-get update && \ apt-get install -y curl git wget &&...
accelerate/docker/accelerate-gpu/Dockerfile/0
{ "file_path": "accelerate/docker/accelerate-gpu/Dockerfile", "repo_id": "accelerate", "token_count": 539 }
0
<!--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...
accelerate/docs/source/concept_guides/low_precision_training.md/0
{ "file_path": "accelerate/docs/source/concept_guides/low_precision_training.md", "repo_id": "accelerate", "token_count": 1466 }
1
<!--Copyright 2021 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
accelerate/docs/source/package_reference/state.md/0
{ "file_path": "accelerate/docs/source/package_reference/state.md", "repo_id": "accelerate", "token_count": 291 }
2
<!--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 applicable law or agreed...
accelerate/docs/source/usage_guides/model_size_estimator.md/0
{ "file_path": "accelerate/docs/source/usage_guides/model_size_estimator.md", "repo_id": "accelerate", "token_count": 2030 }
3
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/big_modeling.py/0
{ "file_path": "accelerate/src/accelerate/big_modeling.py", "repo_id": "accelerate", "token_count": 11237 }
4
# Copyright 2022 The HuggingFace Team and Brian Chao. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requir...
accelerate/src/accelerate/commands/menu/cursor.py/0
{ "file_path": "accelerate/src/accelerate/commands/menu/cursor.py", "repo_id": "accelerate", "token_count": 763 }
5
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/scheduler.py/0
{ "file_path": "accelerate/src/accelerate/scheduler.py", "repo_id": "accelerate", "token_count": 1577 }
6
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/test_utils/scripts/test_sync.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/test_sync.py", "repo_id": "accelerate", "token_count": 7772 }
7
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/utils/offload.py/0
{ "file_path": "accelerate/src/accelerate/utils/offload.py", "repo_id": "accelerate", "token_count": 3177 }
8
compute_environment: LOCAL_MACHINE deepspeed_config: {} distributed_type: 'NO' fsdp_config: {} machine_rank: 0 main_process_ip: null main_process_port: null main_training_function: main mixed_precision: 'no' num_machines: 1 num_processes: 1 use_cpu: false
accelerate/tests/test_configs/0_11_0.yaml/0
{ "file_path": "accelerate/tests/test_configs/0_11_0.yaml", "repo_id": "accelerate", "token_count": 95 }
9
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/tests/test_offload.py/0
{ "file_path": "accelerate/tests/test_offload.py", "repo_id": "accelerate", "token_count": 1981 }
10
.PHONY: style quality # make sure to test the local checkout in scripts and not the pre-installed one (don't use quotes!) export PYTHONPATH = src check_dirs := src tests scripts style: black --line-length 119 --target-version py310 $(check_dirs) setup.py isort $(check_dirs) setup.py quality: black --check --line...
alignment-handbook/Makefile/0
{ "file_path": "alignment-handbook/Makefile", "repo_id": "alignment-handbook", "token_count": 363 }
11
# Comparing Preference Alignment Algorithms This directory contains various comparisons for three algorithms: DPO, IPO, and KTO. Each algorithm has been run in different hyperparameter configurations to study their performance. Two different models and datasets have been used to compare the performance of each algorith...
alignment-handbook/recipes/pref_align_scan/README.md/0
{ "file_path": "alignment-handbook/recipes/pref_align_scan/README.md", "repo_id": "alignment-handbook", "token_count": 690 }
12
#!/usr/bin/env python # coding=utf-8 # 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/LI...
alignment-handbook/scripts/run_cpt.py/0
{ "file_path": "alignment-handbook/scripts/run_cpt.py", "repo_id": "alignment-handbook", "token_count": 2700 }
13
# coding=utf-8 # 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 requir...
alignment-handbook/tests/test_decontaminate.py/0
{ "file_path": "alignment-handbook/tests/test_decontaminate.py", "repo_id": "alignment-handbook", "token_count": 926 }
14
[book] authors = ["Nicolas Patry"] language = "en" multilingual = false src = "src" title = "Candle Documentation"
candle/candle-book/book.toml/0
{ "file_path": "candle/candle-book/book.toml", "repo_id": "candle", "token_count": 38 }
15
# Advanced Cuda usage
candle/candle-book/src/inference/cuda/README.md/0
{ "file_path": "candle/candle-book/src/inference/cuda/README.md", "repo_id": "candle", "token_count": 6 }
16
use crate::benchmarks::{BenchDevice, BenchDeviceHandler}; use candle_core::{DType, Device, Tensor}; use criterion::{black_box, criterion_group, Criterion, Throughput}; use std::time::Instant; fn run(a: &Tensor) { a.affine(12.34, 56.78).unwrap(); } fn run_affine_benchmark(c: &mut Criterion, device: &Device, dtype:...
candle/candle-core/benches/benchmarks/affine.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/affine.rs", "repo_id": "candle", "token_count": 591 }
17
pub trait VecOps: num_traits::NumAssign + Copy { fn min(self, rhs: Self) -> Self; fn max(self, rhs: Self) -> Self; /// Dot-product of two vectors. /// /// # Safety /// /// The length of `lhs` and `rhs` have to be at least `len`. `res` has to point to a valid /// element. #[inline(al...
candle/candle-core/src/cpu/kernels.rs/0
{ "file_path": "candle/candle-core/src/cpu/kernels.rs", "repo_id": "candle", "token_count": 2328 }
18
use crate::backend::{BackendDevice, BackendStorage}; use crate::conv::{ParamsConv1D, ParamsConv2D, ParamsConvTranspose1D, ParamsConvTranspose2D}; use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT}; use crate::{CpuStorage, DType, Layout, Result, Shape}; use candle_metal_kernels; use candle_metal_kernels::Kernels; use...
candle/candle-core/src/metal_backend.rs/0
{ "file_path": "candle/candle-core/src/metal_backend.rs", "repo_id": "candle", "token_count": 42597 }
19
use crate::Result; pub(super) fn nearest_int(v: f32) -> i32 { v.round() as i32 } /// Validates that the input and output are the right size and returns an iterator which maps each /// input region `xs` to its corresponding output block in `ys`. Each output region is guaranteed /// to be `T::BLCK_SIZE` long. pub(s...
candle/candle-core/src/quantized/utils.rs/0
{ "file_path": "candle/candle-core/src/quantized/utils.rs", "repo_id": "candle", "token_count": 5775 }
20
use anyhow::Result; use candle_core::{Device, IndexOp, Tensor}; #[test] fn integer_index() -> Result<()> { let dev = Device::Cpu; let tensor = Tensor::arange(0u32, 2 * 3, &dev)?.reshape((2, 3))?; let result = tensor.i(1)?; assert_eq!(result.dims(), &[3]); assert_eq!(result.to_vec1::<u32>()?, &[3, ...
candle/candle-core/tests/indexing_tests.rs/0
{ "file_path": "candle/candle-core/tests/indexing_tests.rs", "repo_id": "candle", "token_count": 1994 }
21
use hf_hub::{ api::sync::{Api, ApiRepo}, Repo, RepoType, }; use parquet::file::reader::SerializedFileReader; use std::fs::File; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("ApiError : {0}")] ApiError(#[from] hf_hub::api::sync::ApiError), #[error("IoError : {0}")] IoError(#[from...
candle/candle-datasets/src/hub.rs/0
{ "file_path": "candle/candle-datasets/src/hub.rs", "repo_id": "candle", "token_count": 900 }
22
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::{Error as E, Result}; use clap::Parser; use candle_transformers::models::chatglm::{Config, Model}; use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::gene...
candle/candle-examples/examples/chatglm/main.rs/0
{ "file_path": "candle/candle-examples/examples/chatglm/main.rs", "repo_id": "candle", "token_count": 3423 }
23
#![allow(unused)] use anyhow::{Context, Result}; use std::sync::{Arc, Mutex}; pub const SAMPLE_RATE: usize = 24_000; pub(crate) struct AudioOutputData_ { resampled_data: std::collections::VecDeque<f32>, resampler: rubato::FastFixedIn<f32>, output_buffer: Vec<f32>, input_buffer: Vec<f32>, input_len...
candle/candle-examples/examples/encodec/audio_io.rs/0
{ "file_path": "candle/candle-examples/examples/encodec/audio_io.rs", "repo_id": "candle", "token_count": 4805 }
24
/// This follows the lines of: /// https://github.com/johnma2006/mamba-minimal/blob/master/model.py /// Simple, minimal implementation of Mamba in one file of PyTorch. use candle::{IndexOp, Module, Result, Tensor, D}; use candle_nn::{RmsNorm, VarBuilder}; use candle_transformers::models::with_tracing::{linear, linear_...
candle/candle-examples/examples/mamba-minimal/model.rs/0
{ "file_path": "candle/candle-examples/examples/mamba-minimal/model.rs", "repo_id": "candle", "token_count": 3488 }
25
use candle::{DType, Device, Result, Tensor, D}; use candle_nn::{ embedding, layer_norm, linear_no_bias, Activation, Embedding, LayerNorm, Linear, Module, VarBuilder, }; use candle_transformers::models::{encodec, t5}; // https://github.com/huggingface/transformers/blob/cd4584e3c809bb9e1392ccd3fe38b40daba5519a/s...
candle/candle-examples/examples/musicgen/musicgen_model.rs/0
{ "file_path": "candle/candle-examples/examples/musicgen/musicgen_model.rs", "repo_id": "candle", "token_count": 7592 }
26
#![allow(unused)] //! Wrappers around the Python API of Gymnasium (the new version of OpenAI gym) use candle::{Device, Result, Tensor}; use pyo3::prelude::*; use pyo3::types::PyDict; /// The return value for a step. #[derive(Debug)] pub struct Step<A> { pub state: Tensor, pub action: A, pub reward: f64, ...
candle/candle-examples/examples/reinforcement-learning/gym_env.rs/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/gym_env.rs", "repo_id": "candle", "token_count": 1716 }
27
# candle-segment-anything: Segment-Anything Model This example is based on Meta AI [Segment-Anything Model](https://github.com/facebookresearch/segment-anything). This model provides a robust and fast image segmentation pipeline that can be tweaked via some prompting (requesting some points to be in the target mask, r...
candle/candle-examples/examples/segment-anything/README.md/0
{ "file_path": "candle/candle-examples/examples/segment-anything/README.md", "repo_id": "candle", "token_count": 573 }
28
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Error as E; use clap::{Parser, ValueEnum}; use candle::{DType, Tensor}; use candle_examples::token_output_stream::TokenOutputStream; use candle_nn::VarBuilder; use candle_transformers::models::...
candle/candle-examples/examples/trocr/main.rs/0
{ "file_path": "candle/candle-examples/examples/trocr/main.rs", "repo_id": "candle", "token_count": 2160 }
29
pub const NAMES: [&str; 80] = [ "person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", ...
candle/candle-examples/src/coco_classes.rs/0
{ "file_path": "candle/candle-examples/src/coco_classes.rs", "repo_id": "candle", "token_count": 648 }
30
// Pytorch also has an implementation of Philox RNG: https://github.com/pytorch/pytorch/blob/8ca3c881db3e3510fcb7725389f6a0633c9b992c/torch/csrc/jit/tensorexpr/cuda_random.h #pragma once // Philox CUDA. namespace flash { struct ull2 { unsigned long long x; unsigned long long y; }; inline __device__ uint2 mul...
candle/candle-flash-attn/kernels/philox.cuh/0
{ "file_path": "candle/candle-flash-attn/kernels/philox.cuh", "repo_id": "candle", "token_count": 2511 }
31
#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": 3936 }
32
//! Batch Normalization. //! //! This layer applies Batch Normalization over a mini-batch of inputs as described in [`Batch //! Normalization`]. The input is expected to have at least three dimensions. //! //! Note that this implementation is for inference only, there is no possibility to track the //! running stats. /...
candle/candle-nn/src/batch_norm.rs/0
{ "file_path": "candle/candle-nn/src/batch_norm.rs", "repo_id": "candle", "token_count": 5325 }
33
use candle::{DType, Device, Result, Shape, Tensor, Var}; use std::collections::HashMap; use std::sync::{Arc, Mutex}; /// A `VarMap` is a store that holds named variables. Variables can be retrieved from the stores /// and new variables can be added by providing some initialization config in case they are /// missing. ...
candle/candle-nn/src/var_map.rs/0
{ "file_path": "candle/candle-nn/src/var_map.rs", "repo_id": "candle", "token_count": 1973 }
34
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 }
35
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 }
36
use super::with_tracing::{linear, Embedding, Linear}; use candle::{Result, Tensor}; use candle_nn::{layer_norm, LayerNorm, VarBuilder}; #[derive(Debug, Clone)] pub struct Config { pub vocab_size: usize, pub decoder_vocab_size: Option<usize>, pub max_position_embeddings: usize, pub encoder_layers: usize...
candle/candle-transformers/src/models/marian.rs/0
{ "file_path": "candle/candle-transformers/src/models/marian.rs", "repo_id": "candle", "token_count": 8917 }
37
use crate::quantized_nn::{layer_norm, linear, Linear}; pub use crate::quantized_var_builder::VarBuilder; use candle::{DType, Device, IndexOp, Module, Result, Tensor, D}; use candle_nn::Activation; pub use crate::models::mixformer::Config; const MAX_SEQ_LEN: usize = 4096; #[derive(Debug, Clone)] struct Embedding { ...
candle/candle-transformers/src/models/quantized_mixformer.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_mixformer.rs", "repo_id": "candle", "token_count": 5892 }
38
use candle::{DType, IndexOp, Result, Tensor}; use candle_nn::{Module, VarBuilder}; use super::image_encoder::ImageEncoderViT; use super::mask_decoder::MaskDecoder; use super::prompt_encoder::PromptEncoder; use super::tiny_vit::{tiny_vit_5m, TinyViT}; const PROMPT_EMBED_DIM: usize = 256; pub const IMAGE_SIZE: usize = ...
candle/candle-transformers/src/models/segment_anything/sam.rs/0
{ "file_path": "candle/candle-transformers/src/models/segment_anything/sam.rs", "repo_id": "candle", "token_count": 8444 }
39
use crate::models::with_tracing::{linear, linear_no_bias, Linear}; use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{Activation, LayerNorm, VarBuilder}; use serde::Deserialize; use std::sync::Arc; // https://huggingface.co/stabilityai/stablelm-3b-4e1t/blob/main/configuration_stablelm.py #[derive(...
candle/candle-transformers/src/models/stable_lm.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_lm.rs", "repo_id": "candle", "token_count": 7764 }
40
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 }
41
use candle_transformers::models::bert; use wasm_bindgen::prelude::*; pub use bert::{BertModel, Config, DTYPE}; pub use tokenizers::{PaddingParams, Tokenizer}; #[wasm_bindgen] extern "C" { // Use `js_namespace` here to bind `console.log(..)` instead of just // `log(..)` #[wasm_bindgen(js_namespace = consol...
candle/candle-wasm-examples/bert/src/lib.rs/0
{ "file_path": "candle/candle-wasm-examples/bert/src/lib.rs", "repo_id": "candle", "token_count": 226 }
42
use crate::console_log; use crate::worker::{ModelData, Worker, WorkerInput, WorkerOutput}; use std::str::FromStr; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; use yew::{html, Component, Context, Html}; use yew_agent::{Bridge, Bridged}; async fn fetch_url(url: &str) -> Result<Vec<u8>, JsValue> { ...
candle/candle-wasm-examples/llama2-c/src/app.rs/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/src/app.rs", "repo_id": "candle", "token_count": 5458 }
43
## Running Whisper Examples Here, we provide two examples of how to run Whisper using a Candle-compiled WASM binary and runtimes. ### Pure Rust UI To build and test the UI made in Rust you will need [Trunk](https://trunkrs.dev/#install) From the `candle-wasm-examples/whisper` directory run: Download assets: ```bas...
candle/candle-wasm-examples/whisper/README.md/0
{ "file_path": "candle/candle-wasm-examples/whisper/README.md", "repo_id": "candle", "token_count": 1023 }
44
{ "moz:firefoxOptions": { "prefs": { "media.navigator.streams.fake": true, "media.navigator.permission.disabled": true }, "args": [] }, "goog:chromeOptions": { "args": [ "--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream" ] } }
candle/candle-wasm-tests/webdriver.json/0
{ "file_path": "candle/candle-wasm-tests/webdriver.json", "repo_id": "candle", "token_count": 143 }
45
--- title: chat-ui emoji: 🔥 colorFrom: purple colorTo: purple sdk: docker pinned: false license: apache-2.0 base_path: /chat app_port: 3000 failure_strategy: rollback --- # Chat UI ![Chat UI repository thumbnail](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/chatui-websearch.png) A c...
chat-ui/README.md/0
{ "file_path": "chat-ui/README.md", "repo_id": "chat-ui", "token_count": 9257 }
46
<script lang="ts"> import type { readAndCompressImage } from "browser-image-resizer"; import type { Model } from "$lib/types/Model"; import type { Assistant } from "$lib/types/Assistant"; import { onMount } from "svelte"; import { applyAction, enhance } from "$app/forms"; import { page } from "$app/stores"; imp...
chat-ui/src/lib/components/AssistantSettings.svelte/0
{ "file_path": "chat-ui/src/lib/components/AssistantSettings.svelte", "repo_id": "chat-ui", "token_count": 5719 }
47
<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 }
48
<script lang="ts"> export let classNames = ""; </script> <svg class={classNames} xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32" > <path d="M28,10V28H10V10H28m0-2H10a2,2...
chat-ui/src/lib/components/icons/IconCopy.svelte/0
{ "file_path": "chat-ui/src/lib/components/icons/IconCopy.svelte", "repo_id": "chat-ui", "token_count": 299 }
49
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": 478 }
50
import { smallModel } from "$lib/server/models"; import type { Conversation } from "$lib/types/Conversation"; export async function generateFromDefaultEndpoint({ messages, preprompt, }: { messages: Omit<Conversation["messages"][0], "id">[]; preprompt?: string; }): Promise<string> { const endpoint = await smallMod...
chat-ui/src/lib/server/generateFromDefaultEndpoint.ts/0
{ "file_path": "chat-ui/src/lib/server/generateFromDefaultEndpoint.ts", "repo_id": "chat-ui", "token_count": 289 }
51
import { writable } from "svelte/store"; export const ERROR_MESSAGES = { default: "Oops, something went wrong.", authOnly: "You have to be logged in.", rateLimited: "You are sending too many messages. Try again later.", }; export const error = writable<string | null>(null);
chat-ui/src/lib/stores/errors.ts/0
{ "file_path": "chat-ui/src/lib/stores/errors.ts", "repo_id": "chat-ui", "token_count": 85 }
52
import type { BackendModel } from "$lib/server/models"; export type Model = Pick< BackendModel, | "id" | "name" | "displayName" | "websiteUrl" | "datasetName" | "promptExamples" | "parameters" | "description" | "logoUrl" | "modelUrl" | "datasetUrl" | "preprompt" | "multimodal" | "unlisted" >;
chat-ui/src/lib/types/Model.ts/0
{ "file_path": "chat-ui/src/lib/types/Model.ts", "repo_id": "chat-ui", "token_count": 138 }
53
export function deepestChild(el: HTMLElement): HTMLElement { if (el.lastElementChild && el.lastElementChild.nodeType !== Node.TEXT_NODE) { return deepestChild(el.lastElementChild as HTMLElement); } return el; }
chat-ui/src/lib/utils/deepestChild.ts/0
{ "file_path": "chat-ui/src/lib/utils/deepestChild.ts", "repo_id": "chat-ui", "token_count": 74 }
54
export function sum(nums: number[]): number { return nums.reduce((a, b) => a + b, 0); }
chat-ui/src/lib/utils/sum.ts/0
{ "file_path": "chat-ui/src/lib/utils/sum.ts", "repo_id": "chat-ui", "token_count": 35 }
55
<script lang="ts"> import "../styles/main.css"; import { onDestroy } from "svelte"; import { goto, invalidate } from "$app/navigation"; import { base } from "$app/paths"; import { page } from "$app/stores"; import { browser } from "$app/environment"; import { PUBLIC_APP_DESCRIPTION, PUBLIC_ORIGIN, PUBLIC...
chat-ui/src/routes/+layout.svelte/0
{ "file_path": "chat-ui/src/routes/+layout.svelte", "repo_id": "chat-ui", "token_count": 2668 }
56
<script lang="ts"> import ChatWindow from "$lib/components/chat/ChatWindow.svelte"; import { pendingMessage } from "$lib/stores/pendingMessage"; import { isAborted } from "$lib/stores/isAborted"; import { onMount } from "svelte"; import { page } from "$app/stores"; import { goto, invalidateAll } from "$app/naviga...
chat-ui/src/routes/conversation/[id]/+page.svelte/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/+page.svelte", "repo_id": "chat-ui", "token_count": 5239 }
57
import ModelThumbnail from "./ModelThumbnail.svelte"; import { redirect, type RequestHandler } from "@sveltejs/kit"; import type { SvelteComponent } from "svelte"; import { Resvg } from "@resvg/resvg-js"; import satori from "satori"; import { html } from "satori-html"; import InterRegular from "../../../../../static/...
chat-ui/src/routes/models/[...model]/thumbnail.png/+server.ts/0
{ "file_path": "chat-ui/src/routes/models/[...model]/thumbnail.png/+server.ts", "repo_id": "chat-ui", "token_count": 526 }
58
import { base } from "$app/paths"; import { authCondition, requiresUser } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { fail, type Actions, redirect } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; import { z } from "zod"; import { sha256 } from "$lib/utils/sha256"; i...
chat-ui/src/routes/settings/(nav)/assistants/new/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/new/+page.server.ts", "repo_id": "chat-ui", "token_count": 1538 }
59
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="none"> <path fill="#FFD21E" d="M4 15.55C4 9.72 8.72 5 14.55 5h4.11a9.34 9.34 0 1 1 0 18.68H7.58l-2.89 2.8a.41.41 0 0 1-.69-.3V15.55Z" /> <path fill="#32343D" d="M19.63 12.48c.37.14.52.9.9.7.71-.38.98-1.27.6-1.98a1.46 1.46 0 0 0-1.98-.61 1.4...
chat-ui/static/huggingchat/logo.svg/0
{ "file_path": "chat-ui/static/huggingchat/logo.svg", "repo_id": "chat-ui", "token_count": 523 }
60
# This first_section was backported from nginx loading_datasets: loading share_dataset: share quicktour: quickstart dataset_streaming: stream torch_tensorflow: use_dataset splits: loading#slice-splits processing: process faiss_and_ea: faiss_es features: about_dataset_features using_metrics: how_to_metrics exploring: ac...
datasets/docs/source/_redirects.yml/0
{ "file_path": "datasets/docs/source/_redirects.yml", "repo_id": "datasets", "token_count": 134 }
61
# Create a dataset card Each dataset should have a dataset card to promote responsible usage and inform users of any potential biases within the dataset. This idea was inspired by the Model Cards proposed by [Mitchell, 2018](https://arxiv.org/abs/1810.03993). Dataset cards help users understand a dataset's contents, t...
datasets/docs/source/dataset_card.mdx/0
{ "file_path": "datasets/docs/source/dataset_card.mdx", "repo_id": "datasets", "token_count": 757 }
62
# Load Your data can be stored in various places; they can be on your local machine's disk, in a Github repository, and in in-memory data structures like Python dictionaries and Pandas DataFrames. Wherever a dataset is stored, 🤗 Datasets can help you load it. This guide will show you how to load a dataset from: - T...
datasets/docs/source/loading.mdx/0
{ "file_path": "datasets/docs/source/loading.mdx", "repo_id": "datasets", "token_count": 7158 }
63
# Stream Dataset streaming lets you work with a dataset without downloading it. The data is streamed as you iterate over the dataset. This is especially helpful when: - You don't want to wait for an extremely large dataset to download. - The dataset size exceeds the amount of available disk space on your computer. - ...
datasets/docs/source/stream.mdx/0
{ "file_path": "datasets/docs/source/stream.mdx", "repo_id": "datasets", "token_count": 5324 }
64
# Copyright 2020 The HuggingFace Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
datasets/metrics/bleu/bleu.py/0
{ "file_path": "datasets/metrics/bleu/bleu.py", "repo_id": "datasets", "token_count": 2139 }
65
# Metric Card for CUAD ## Metric description This metric wraps the official scoring script for version 1 of the [Contract Understanding Atticus Dataset (CUAD)](https://huggingface.co/datasets/cuad), which is a corpus of more than 13,000 labels in 510 commercial legal contracts that have been manually labeled to ident...
datasets/metrics/cuad/README.md/0
{ "file_path": "datasets/metrics/cuad/README.md", "repo_id": "datasets", "token_count": 2380 }
66
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
datasets/metrics/mae/mae.py/0
{ "file_path": "datasets/metrics/mae/mae.py", "repo_id": "datasets", "token_count": 1662 }
67
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
datasets/metrics/perplexity/perplexity.py/0
{ "file_path": "datasets/metrics/perplexity/perplexity.py", "repo_id": "datasets", "token_count": 3550 }
68
# Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
datasets/metrics/spearmanr/spearmanr.py/0
{ "file_path": "datasets/metrics/spearmanr/spearmanr.py", "repo_id": "datasets", "token_count": 1942 }
69
# Metric Card for XNLI ## Metric description The XNLI metric allows to evaluate a model's score on the [XNLI dataset](https://huggingface.co/datasets/xnli), which is a subset of a few thousand examples from the [MNLI dataset](https://huggingface.co/datasets/glue/viewer/mnli) that have been translated into a 14 differ...
datasets/metrics/xnli/README.md/0
{ "file_path": "datasets/metrics/xnli/README.md", "repo_id": "datasets", "token_count": 1226 }
70
#!/usr/bin/env python from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestComm...
datasets/src/datasets/commands/datasets_cli.py/0
{ "file_path": "datasets/src/datasets/commands/datasets_cli.py", "repo_id": "datasets", "token_count": 473 }
71
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.download_config import DownloadConfig from ..download.streaming_download_manager import xopen, ...
datasets/src/datasets/features/audio.py/0
{ "file_path": "datasets/src/datasets/features/audio.py", "repo_id": "datasets", "token_count": 5335 }
72
# Copyright 2020 The HuggingFace Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
datasets/src/datasets/inspect.py/0
{ "file_path": "datasets/src/datasets/inspect.py", "repo_id": "datasets", "token_count": 9937 }
73
# 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/splits.py/0
{ "file_path": "datasets/src/datasets/splits.py", "repo_id": "datasets", "token_count": 9598 }
74
import os from apache_beam.io.filesystems import FileSystems from apache_beam.pipeline import Pipeline from .logging import get_logger CHUNK_SIZE = 2 << 20 # 2mb logger = get_logger(__name__) class BeamPipeline(Pipeline): """Wrapper over `apache_beam.pipeline.Pipeline` for convenience""" def is_local(se...
datasets/src/datasets/utils/beam_utils.py/0
{ "file_path": "datasets/src/datasets/utils/beam_utils.py", "repo_id": "datasets", "token_count": 847 }
75
{ "language": [ "found", "crowdsourced", "expert-generated", "machine-generated", "other" ], "annotations": [ "found", "crowdsourced", "expert-generated", "machine-generated", "no-annotation", "other" ] }
datasets/src/datasets/utils/resources/creators.json/0
{ "file_path": "datasets/src/datasets/utils/resources/creators.json", "repo_id": "datasets", "token_count": 119 }
76
## Add Dummy data test **Important** In order to pass the `load_dataset_<dataset_name>` test, dummy data is required for all possible config names. First we distinguish between datasets scripts that - A) have no config class and - B) have a config class For A) the dummy data folder structure, will always look as fol...
datasets/tests/README.md/0
{ "file_path": "datasets/tests/README.md", "repo_id": "datasets", "token_count": 928 }
77
import os import random import tempfile import unittest import numpy as np import pandas as pd import pyarrow as pa import pytest from absl.testing import parameterized import datasets from datasets.arrow_writer import ArrowWriter from datasets.features import Array2D, Array3D, Array4D, Array5D, Value from datasets.f...
datasets/tests/features/test_array_xd.py/0
{ "file_path": "datasets/tests/features/test_array_xd.py", "repo_id": "datasets", "token_count": 9826 }
78
import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def _check_text_dataset(dataset, expected_features): assert isinstance(dataset, Dataset) ...
datasets/tests/io/test_text.py/0
{ "file_path": "datasets/tests/io/test_text.py", "repo_id": "datasets", "token_count": 1833 }
79
import copy import os from pathlib import Path from typing import List from unittest.mock import patch import fsspec import pytest from fsspec.registry import _registry as _fsspec_registry from fsspec.spec import AbstractFileSystem from datasets.data_files import ( DataFilesDict, DataFilesList, DataFilesP...
datasets/tests/test_data_files.py/0
{ "file_path": "datasets/tests/test_data_files.py", "repo_id": "datasets", "token_count": 12329 }
80
import os from pathlib import Path import pytest from datasets.inspect import ( get_dataset_config_info, get_dataset_config_names, get_dataset_default_config_name, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) from datasets.packaged_modules.csv import csv ...
datasets/tests/test_inspect.py/0
{ "file_path": "datasets/tests/test_inspect.py", "repo_id": "datasets", "token_count": 2081 }
81
from copy import deepcopy from unittest.case import TestCase import pytest from datasets.arrow_dataset import Dataset from datasets.features import Audio, ClassLabel, Features, Image, Sequence, Value from datasets.info import DatasetInfo from datasets.tasks import ( AudioClassification, AutomaticSpeechRecogni...
datasets/tests/test_tasks.py/0
{ "file_path": "datasets/tests/test_tasks.py", "repo_id": "datasets", "token_count": 4249 }
82
# The “Deep” in Reinforcement Learning [[deep-rl]] <Tip> What we've talked about so far is Reinforcement Learning. But where does the "Deep" come into play? </Tip> Deep Reinforcement Learning introduces **deep neural networks to solve Reinforcement Learning problems** — hence the name “deep”. For instance, in the ne...
deep-rl-class/units/en/unit1/deep-rl.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/deep-rl.mdx", "repo_id": "deep-rl-class", "token_count": 310 }
83
# Introduction to Q-Learning [[introduction-q-learning]] <img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit3/thumbnail.jpg" alt="Unit 2 thumbnail" width="100%"> In the first unit of this class, we learned about Reinforcement Learning (RL), the RL process, and the ...
deep-rl-class/units/en/unit2/introduction.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/introduction.mdx", "repo_id": "deep-rl-class", "token_count": 466 }
84
# Hands-on [[hands-on]] <CourseFloatingBanner classNames="absolute z-10 right-0 top-0" notebooks={[ {label: "Google Colab", value: "https://colab.research.google.com/github/huggingface/deep-rl-class/blob/main/notebooks/unit3/unit3.ipynb"} ]} askForHelpUrl="http://hf.co/join/discor...
deep-rl-class/units/en/unit3/hands-on.mdx/0
{ "file_path": "deep-rl-class/units/en/unit3/hands-on.mdx", "repo_id": "deep-rl-class", "token_count": 5087 }
85
# Hands-on <CourseFloatingBanner classNames="absolute z-10 right-0 top-0" notebooks={[ {label: "Google Colab", value: "https://colab.research.google.com/github/huggingface/deep-rl-class/blob/main/notebooks/unit5/unit5.ipynb"} ]} askForHelpUrl="http://hf.co/join/discord" /> We learned what ML-Agents is and how ...
deep-rl-class/units/en/unit5/hands-on.mdx/0
{ "file_path": "deep-rl-class/units/en/unit5/hands-on.mdx", "repo_id": "deep-rl-class", "token_count": 5146 }
86