text
stringlengths
7
324k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
463
import argparse import logging import sys import time import tensorflow as tf from datasets import load_dataset from packaging.version import parse from transformers import AutoTokenizer, TFAutoModelForSequenceClassification try: import tf_keras as keras except (ModuleNotFoundError, ImportError): import ker...
transformers/tests/sagemaker/scripts/tensorflow/run_tf.py/0
{ "file_path": "transformers/tests/sagemaker/scripts/tensorflow/run_tf.py", "repo_id": "transformers", "token_count": 1577 }
401
# 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/test_modeling_flax_utils.py/0
{ "file_path": "transformers/tests/test_modeling_flax_utils.py", "repo_id": "transformers", "token_count": 6875 }
402
# coding=utf-8 # Copyright 2023 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
transformers/tests/tools/test_image_question_answering.py/0
{ "file_path": "transformers/tests/tools/test_image_question_answering.py", "repo_id": "transformers", "token_count": 768 }
403
# 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_tpu.py/0
{ "file_path": "transformers/tests/trainer/test_trainer_tpu.py", "repo_id": "transformers", "token_count": 1651 }
404
# coding=utf-8 # Copyright 2022 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
transformers/tests/utils/test_image_processing_utils.py/0
{ "file_path": "transformers/tests/utils/test_image_processing_utils.py", "repo_id": "transformers", "token_count": 1072 }
405
# coding=utf-8 # Copyright 2023 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_docstrings.py/0
{ "file_path": "transformers/utils/check_docstrings.py", "repo_id": "transformers", "token_count": 16819 }
406
import argparse import math import traceback import dateutil.parser as date_parser import requests def extract_time_from_single_job(job): """Extract time info from a single job in a GitHub Actions workflow run""" job_info = {} start = job["started_at"] end = job["completed_at"] start_datetime ...
transformers/utils/get_github_job_time.py/0
{ "file_path": "transformers/utils/get_github_job_time.py", "repo_id": "transformers", "token_count": 835 }
407
from transformers import CLIPImageProcessor class CustomImageProcessor(CLIPImageProcessor): pass
transformers/utils/test_module/custom_image_processing.py/0
{ "file_path": "transformers/utils/test_module/custom_image_processing.py", "repo_id": "transformers", "token_count": 29 }
408
# pip install openrlbenchmark==0.2.1a5 # see https://github.com/openrlbenchmark/openrlbenchmark#get-started for documentation BASELINE_PR_TAG=v0.4.7-55-g110e672 BASELINE_PR_NAME=PR-662 python -m openrlbenchmark.rlops_multi_metrics \ --filters '?we=huggingface&wpn=trl&xaxis=_step&ceik=trl_ppo_trainer_config.value.r...
trl/benchmark/plot.sh/0
{ "file_path": "trl/benchmark/plot.sh", "repo_id": "trl", "token_count": 1454 }
409
# 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 }
410
# 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 }
411
<jupyter_start><jupyter_text>Tune GPT2 to generate controlled sentiment reviews> Optimise GPT2 to produce IMDB movie reviews with controlled sentiment using a BERT sentiment classifier for rewards.**WARNING:** We often experienced loss spikes in this examples which caused model training to fail or slow down. There is a...
trl/examples/notebooks/gpt2-sentiment-control.ipynb/0
{ "file_path": "trl/examples/notebooks/gpt2-sentiment-control.ipynb", "repo_id": "trl", "token_count": 4606 }
412
import argparse import csv import evaluate import numpy as np import torch from datasets import load_dataset from tqdm import tqdm from transformers import AutoModelForCausalLM, AutoTokenizer from trl.import_utils import is_npu_available, is_xpu_available toxicity = evaluate.load("ybelkada/toxicity", "DaNLP/da-elec...
trl/examples/research_projects/toxicity/scripts/evaluate-toxicity.py/0
{ "file_path": "trl/examples/research_projects/toxicity/scripts/evaluate-toxicity.py", "repo_id": "trl", "token_count": 2056 }
413
# 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_no_peft.py/0
{ "file_path": "trl/tests/test_no_peft.py", "repo_id": "trl", "token_count": 2576 }
414
# 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...
trl/trl/models/modeling_base.py/0
{ "file_path": "trl/trl/models/modeling_base.py", "repo_id": "trl", "token_count": 13121 }
415
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
trl/trl/trainer/reward_config.py/0
{ "file_path": "trl/trl/trainer/reward_config.py", "repo_id": "trl", "token_count": 461 }
416
<!--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/basic_tutorials/migration.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/migration.md", "repo_id": "accelerate", "token_count": 2930 }
0
<!--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/deepspeed.md/0
{ "file_path": "accelerate/docs/source/usage_guides/deepspeed.md", "repo_id": "accelerate", "token_count": 9823 }
1
# What are these scripts? All scripts in this folder originate from the `nlp_example.py` file, as it is a very simplistic NLP training example using Accelerate with zero extra features. From there, each further script adds in just **one** feature of Accelerate, showing how you can quickly modify your own scripts to i...
accelerate/examples/by_feature/README.md/0
{ "file_path": "accelerate/examples/by_feature/README.md", "repo_id": "accelerate", "token_count": 1218 }
2
{ "fp16": { "enabled": true, "loss_scale": 0, "loss_scale_window": 1000, "initial_scale_power": 16, "hysteresis": 2, "min_loss_scale": 1 }, "optimizer": { "type": "AdamW", "params": { "lr": "auto", "weight_decay": "auto"...
accelerate/examples/deepspeed_config_templates/zero_stage1_config.json/0
{ "file_path": "accelerate/examples/deepspeed_config_templates/zero_stage1_config.json", "repo_id": "accelerate", "token_count": 614 }
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/manim_animations/big_model_inference/stage_1.py/0
{ "file_path": "accelerate/manim_animations/big_model_inference/stage_1.py", "repo_id": "accelerate", "token_count": 1904 }
4
#!/usr/bin/env python # 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 # # Unles...
accelerate/src/accelerate/commands/config/config_args.py/0
{ "file_path": "accelerate/src/accelerate/commands/config/config_args.py", "repo_id": "accelerate", "token_count": 4124 }
5
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
accelerate/src/accelerate/commands/utils.py/0
{ "file_path": "accelerate/src/accelerate/commands/utils.py", "repo_id": "accelerate", "token_count": 1619 }
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/external_deps/test_metrics.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_metrics.py", "repo_id": "accelerate", "token_count": 4704 }
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/dataclasses.py/0
{ "file_path": "accelerate/src/accelerate/utils/dataclasses.py", "repo_id": "accelerate", "token_count": 31951 }
8
# 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/transformer_engine.py/0
{ "file_path": "accelerate/src/accelerate/utils/transformer_engine.py", "repo_id": "accelerate", "token_count": 1481 }
9
# 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 applicabl...
accelerate/tests/test_data_loader.py/0
{ "file_path": "accelerate/tests/test_data_loader.py", "repo_id": "accelerate", "token_count": 8488 }
10
# 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 applicabl...
accelerate/tests/test_scheduler.py/0
{ "file_path": "accelerate/tests/test_scheduler.py", "repo_id": "accelerate", "token_count": 2538 }
11
# Model arguments model_name_or_path: bigcode/starcoder2-15b model_revision: main torch_dtype: bfloat16 use_flash_attention_2: true # Data training arguments chat_template: "{% if not add_generation_prompt is defined %}{% set add_generation_prompt = false %}{% endif %}{% for message in messages %}{{'<|im_start|>' + me...
alignment-handbook/recipes/starchat2-15b/sft/config_v0.1.yaml/0
{ "file_path": "alignment-handbook/recipes/starchat2-15b/sft/config_v0.1.yaml", "repo_id": "alignment-handbook", "token_count": 565 }
12
# coding=utf-8 # 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 requir...
alignment-handbook/src/alignment/configs.py/0
{ "file_path": "alignment-handbook/src/alignment/configs.py", "repo_id": "alignment-handbook", "token_count": 4702 }
13
# Creating a desktop Tauri app
candle/candle-book/src/apps/desktop.md/0
{ "file_path": "candle/candle-book/src/apps/desktop.md", "repo_id": "candle", "token_count": 8 }
14
#[cfg(test)] pub mod simplified; #[cfg(test)] mod tests { use anyhow::Result; use candle::{DType, Device, Tensor}; use parquet::file::reader::SerializedFileReader; // NOTE: Waiting on https://github.com/rust-lang/mdBook/pull/1856 #[rustfmt::skip] #[tokio::test] async fn book_hub_1() { // A...
candle/candle-book/src/lib.rs/0
{ "file_path": "candle/candle-book/src/lib.rs", "repo_id": "candle", "token_count": 2806 }
15
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use candle_core::{Device, Tensor}; fn main() -> Result<()> { let a = Tensor::new(&[[0.0f32, 1.0, 2.0], [3.0, 4.0, 5.0]], &Device::Cpu)?; let b = Tensor::new(&[[88.0f32, 99.0]], ...
candle/candle-core/examples/basics.rs/0
{ "file_path": "candle/candle-core/examples/basics.rs", "repo_id": "candle", "token_count": 287 }
16
use crate::backend::{BackendDevice, BackendStorage}; use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT}; use crate::{CpuStorage, DType, Layout, Result, Shape, WithDType}; pub use candle_kernels as kernels; pub use cudarc; use cudarc::cublas::{Gemm, GemmConfig, StridedBatchedConfig}; use cudarc::driver::{ CudaFun...
candle/candle-core/src/cuda_backend.rs/0
{ "file_path": "candle/candle-core/src/cuda_backend.rs", "repo_id": "candle", "token_count": 45635 }
17
use super::k_quants::{ BlockQ2K, BlockQ3K, BlockQ4K, BlockQ4_0, BlockQ5K, BlockQ6K, BlockQ8K, BlockQ8_0, QK8_0, QK_K, }; use crate::Result; use byteorder::{ByteOrder, LittleEndian}; use half::f16; #[cfg(target_arch = "x86")] use core::arch::x86::*; #[cfg(target_arch = "x86_64")] use core::arch::x86_64::*; #[inlin...
candle/candle-core/src/quantized/avx.rs/0
{ "file_path": "candle/candle-core/src/quantized/avx.rs", "repo_id": "candle", "token_count": 17495 }
18
use crate::Layout; /// An iterator over offset position for items of an N-dimensional arrays stored in a /// flat buffer using some potential strides. #[derive(Debug)] pub struct StridedIndex<'a> { next_storage_index: Option<usize>, multi_index: Vec<usize>, dims: &'a [usize], stride: &'a [usize], } im...
candle/candle-core/src/strided_index.rs/0
{ "file_path": "candle/candle-core/src/strided_index.rs", "repo_id": "candle", "token_count": 1148 }
19
use candle_core::{ bail, quantized::{self, GgmlDType}, test_device, test_utils::to_vec2_round, Device, Module, Result, Tensor, }; use quantized::{k_quants, GgmlType}; use rand::prelude::*; const GGML_TEST_SIZE: usize = 32 * 128; const GGML_MAX_QUANTIZATION_TOTAL_ERROR: f32 = 0.002; const GGML_MAX_...
candle/candle-core/tests/quantized_tests.rs/0
{ "file_path": "candle/candle-core/tests/quantized_tests.rs", "repo_id": "candle", "token_count": 18159 }
20
use candle::Tensor; pub struct Dataset { pub train_images: Tensor, pub train_labels: Tensor, pub test_images: Tensor, pub test_labels: Tensor, pub labels: usize, } pub mod cifar; pub mod mnist;
candle/candle-datasets/src/vision/mod.rs/0
{ "file_path": "candle/candle-datasets/src/vision/mod.rs", "repo_id": "candle", "token_count": 92 }
21
/* * Adapted from * https://github.com/NVIDIA/FasterTransformer/blob/release/v5.3_tag/src/fastertransformer/kernels/reduce_kernel_utils.cuh * Copyright (c) 2023, The vLLM team. * Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); ...
candle/candle-examples/examples/custom-ops/kernels/reduction_utils.cuh/0
{ "file_path": "candle/candle-examples/examples/custom-ops/kernels/reduction_utils.cuh", "repo_id": "candle", "token_count": 529 }
22
# candle-jina-bert Jina-Bert is a general large language model with a context size of 8192, [model card](https://huggingface.co/jinaai/jina-embeddings-v2-base-en). In this example it can be used for two different tasks: - Compute sentence embeddings for a prompt. - Compute similarities between a set of sentences. ##...
candle/candle-examples/examples/jina-bert/README.md/0
{ "file_path": "candle/candle-examples/examples/jina-bert/README.md", "repo_id": "candle", "token_count": 663 }
23
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use clap::Parser; use std::io::Write; use candle_transformers::generation::LogitsProcessor; use candle_transformers::models::encodec; use candle_transformers::models::metavoice::{adapte...
candle/candle-examples/examples/metavoice/main.rs/0
{ "file_path": "candle/candle-examples/examples/metavoice/main.rs", "repo_id": "candle", "token_count": 4560 }
24
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use std::io::Write; use std::path::PathBuf; use candle_transformers::models::quantized_t5 as t5; use anyhow::{Error as E, Result}; use candle::{Device, Tensor}; use candle_transformers::generation::LogitsP...
candle/candle-examples/examples/quantized-t5/main.rs/0
{ "file_path": "candle/candle-examples/examples/quantized-t5/main.rs", "repo_id": "candle", "token_count": 3631 }
25
# 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 tiger.j...
candle/candle-examples/examples/resnet/README.md/0
{ "file_path": "candle/candle-examples/examples/resnet/README.md", "repo_id": "candle", "token_count": 204 }
26
# candle-stable-lm StableLM-3B-4E1T is a 3 billion parameter decoder-only language model pre-trained on 1 trillion tokens of diverse English and code datasets for 4 epochs. See the [HuggingFace Hub Model Card](https://huggingface.co/stabilityai/stablelm-3b-4e1t). Note that this model is gated so you will have to requ...
candle/candle-examples/examples/stable-lm/README.md/0
{ "file_path": "candle/candle-examples/examples/stable-lm/README.md", "repo_id": "candle", "token_count": 526 }
27
# candle-whisper: speech recognition An implementation of [OpenAI Whisper](https://github.com/openai/whisper) using candle. Whisper is a general purpose speech recognition model, it can be used to convert audio files (in the `.wav` format) to text. Supported features include language detection as well as multilingual ...
candle/candle-examples/examples/whisper/README.md/0
{ "file_path": "candle/candle-examples/examples/whisper/README.md", "repo_id": "candle", "token_count": 569 }
28
#include <cmath> #include <cute/tensor.hpp> #include <cutlass/cutlass.h> #include <cutlass/array.h> #include "utils.h" namespace flash { using namespace cute; //////////////////////////////////////////////////////////////////////////////////////////////////// template <bool Is_causal, typename Engine, typename L...
candle/candle-flash-attn/kernels/alibi.h/0
{ "file_path": "candle/candle-flash-attn/kernels/alibi.h", "repo_id": "candle", "token_count": 1367 }
29
# candle-kernels This crate contains CUDA kernels used from candle. Some of these implementations come from the [dfdx crate](https://github.com/coreylowman/dfdx).
candle/candle-kernels/README.md/0
{ "file_path": "candle/candle-kernels/README.md", "repo_id": "candle", "token_count": 45 }
30
[package] name = "candle-metal-kernels" version = "0.4.2" edition = "2021" description = "Metal kernels for Candle" repository = "https://github.com/huggingface/candle" keywords = ["blas", "tensor", "machine-learning"] categories = ["science"] license = "MIT OR Apache-2.0" [dependencies] metal = { version = "0.27.0"...
candle/candle-metal-kernels/Cargo.toml/0
{ "file_path": "candle/candle-metal-kernels/Cargo.toml", "repo_id": "candle", "token_count": 218 }
31
use candle_metal_kernels::{binary, call_binary_contiguous, call_binary_strided, Kernels}; use half::{bf16, f16}; use metal::objc::rc::autoreleasepool; use metal::{Device, MTLResourceOptions}; use rand; use std::any::type_name; use std::time::Instant; fn main() { let device = Device::system_default().unwrap(); ...
candle/candle-metal-kernels/tmp/binary.rs/0
{ "file_path": "candle/candle-metal-kernels/tmp/binary.rs", "repo_id": "candle", "token_count": 3149 }
32
pub mod activation; pub mod batch_norm; pub mod conv; pub mod embedding; pub mod encoding; pub mod func; pub mod group_norm; pub mod init; pub mod layer_norm; pub mod linear; pub mod loss; pub mod ops; pub mod optim; pub mod rnn; pub mod sequential; pub mod var_builder; pub mod var_map; pub use activation::{prelu, Act...
candle/candle-nn/src/lib.rs/0
{ "file_path": "candle/candle-nn/src/lib.rs", "repo_id": "candle", "token_count": 470 }
33
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{test_utils::to_vec2_round, DType, Device, Result, Tensor}; use candle_nn::RNN; /* The following test can be verified against PyTorch using the following snippet. import torch from torch import...
candle/candle-nn/tests/rnn.rs/0
{ "file_path": "candle/candle-nn/tests/rnn.rs", "repo_id": "candle", "token_count": 2010 }
34
# Generated content DO NOT EDIT from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence from os import PathLike from candle.typing import _ArrayLike, Device, Scalar, Index, Shape class bf16(DType): pass @staticmethod def cat(tensors: List[Tensor], dim: int) -> Tensor: """ Concatenat...
candle/candle-pyo3/py_src/candle/__init__.pyi/0
{ "file_path": "candle/candle-pyo3/py_src/candle/__init__.pyi", "repo_id": "candle", "token_count": 5785 }
35
# Generated content DO NOT EDIT from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence from os import PathLike from candle.typing import _ArrayLike, Device, Scalar, Index, Shape from candle import Tensor, DType, QTensor @staticmethod def cuda_is_available() -> bool: """ Returns true if ...
candle/candle-pyo3/py_src/candle/utils/__init__.pyi/0
{ "file_path": "candle/candle-pyo3/py_src/candle/utils/__init__.pyi", "repo_id": "candle", "token_count": 712 }
36
import candle from candle import Tensor, QTensor from candle.utils import load_safetensors, save_gguf, load_gguf, save_safetensors from pathlib import Path TEST_DIR = Path(__file__).parent.parent / "_workdir" TEST_DIR.mkdir(exist_ok=True) def test_can_roundtrip_safetensors(): tensors = { "a": candle.rand...
candle/candle-pyo3/tests/native/test_utils.py/0
{ "file_path": "candle/candle-pyo3/tests/native/test_utils.py", "repo_id": "candle", "token_count": 774 }
37
#![allow(unused)] use candle::{DType, IndexOp, Layout, Module, Result, Shape, Tensor, D}; use candle_nn::{conv1d, Conv1d, Conv1dConfig, ConvTranspose1d, VarBuilder}; // Encodec Model // https://github.com/huggingface/transformers/blob/main/src/transformers/models/encodec/modeling_encodec.py #[derive(Debug, Copy, Clon...
candle/candle-transformers/src/models/encodec.rs/0
{ "file_path": "candle/candle-transformers/src/models/encodec.rs", "repo_id": "candle", "token_count": 12642 }
38
use candle::DType; use serde::Deserialize; pub const DTYPE: DType = DType::F32; #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)] #[serde(rename_all = "lowercase")] pub enum PositionEmbeddingType { Absolute, Alibi, } // https://github.com/huggingface/transformers/blob/main/src/transformers/models/per...
candle/candle-transformers/src/models/persimmon.rs/0
{ "file_path": "candle/candle-transformers/src/models/persimmon.rs", "repo_id": "candle", "token_count": 814 }
39
//! ResNet implementation. //! //! See "Deep Residual Learning for Image Recognition" He et al. 2015 //! <https://arxiv.org/abs/1512.03385> use candle::{Result, D}; use candle_nn::{batch_norm, Conv2d, Func, VarBuilder}; fn conv2d( c_in: usize, c_out: usize, ksize: usize, padding: usize, stride: usi...
candle/candle-transformers/src/models/resnet.rs/0
{ "file_path": "candle/candle-transformers/src/models/resnet.rs", "repo_id": "candle", "token_count": 3959 }
40
//! Ancestral sampling with Euler method steps. //! //! Reference implementation in Rust: //! //! https://github.com/pykeio/diffusers/blob/250b9ad1898af41e76a74c0d8d4292652823338a/src/schedulers/euler_ancestral_discrete.rs //! //! Based on the original [`k-diffusion` implementation by Katherine Crowson][kd]. /// /// [k...
candle/candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/euler_ancestral_discrete.rs", "repo_id": "candle", "token_count": 4176 }
41
use super::Config; use crate::models::with_tracing::{linear, linear_no_bias, Linear}; use candle::{Device, IndexOp, Result, Tensor, D}; use candle_nn::{embedding, Conv1d, Conv1dConfig, Embedding, LayerNorm, Module, VarBuilder}; fn conv1d( in_channels: usize, out_channels: usize, kernel_size: usize, con...
candle/candle-transformers/src/models/whisper/model.rs/0
{ "file_path": "candle/candle-transformers/src/models/whisper/model.rs", "repo_id": "candle", "token_count": 7050 }
42
use candle::{Result, Tensor}; pub fn apply_repeat_penalty(logits: &Tensor, penalty: f32, context: &[u32]) -> Result<Tensor> { let device = logits.device(); let mut logits = logits.to_vec1::<f32>()?; let context: std::collections::HashSet<_> = context.iter().collect(); for (token_id, logit) in logits.it...
candle/candle-transformers/src/utils.rs/0
{ "file_path": "candle/candle-transformers/src/utils.rs", "repo_id": "candle", "token_count": 299 }
43
//load Candle Bert Module wasm module let init, ModelEncoder; async function fetchArrayBuffer(url) { const cacheName = "t5-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse.arrayBuffer(); ret...
candle/candle-wasm-examples/t5/T5ModelEncoderWorker.js/0
{ "file_path": "candle/candle-wasm-examples/t5/T5ModelEncoderWorker.js", "repo_id": "candle", "token_count": 873 }
44
use candle_wasm_example_whisper::worker::{Decoder as D, ModelData}; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct Decoder { decoder: D, } #[wasm_bindgen] impl Decoder { #[wasm_bindgen(constructor)] #[allow(clippy::too_many_arguments)] pub fn new( weights: Vec<u8>, tokenizer:...
candle/candle-wasm-examples/whisper/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/bin/m.rs", "repo_id": "candle", "token_count": 694 }
45
mod app; pub mod coco_classes; pub mod model; pub mod worker; pub use app::App; pub use worker::Worker;
candle/candle-wasm-examples/yolo/src/lib.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/lib.rs", "repo_id": "candle", "token_count": 37 }
46
engine-strict=true
chat-ui/.npmrc/0
{ "file_path": "chat-ui/.npmrc", "repo_id": "chat-ui", "token_count": 7 }
47
import fs from "fs"; const HF_DEPLOYMENT_TOKEN = process.env.HF_DEPLOYMENT_TOKEN; // token used for pushing to hub const SERPER_API_KEY = process.env.SERPER_API_KEY; const OPENID_CONFIG = process.env.OPENID_CONFIG; const MONGODB_URL = process.env.MONGODB_URL; const HF_TOKEN = process.env.HF_TOKEN ?? process.env.HF_AC...
chat-ui/scripts/updateProdEnv.ts/0
{ "file_path": "chat-ui/scripts/updateProdEnv.ts", "repo_id": "chat-ui", "token_count": 628 }
48
<script lang="ts"> import { navigating } from "$app/stores"; import { createEventDispatcher } from "svelte"; import { browser } from "$app/environment"; import { base } from "$app/paths"; import { page } from "$app/stores"; import CarbonClose from "~icons/carbon/close"; import CarbonTextAlignJustify from "~icon...
chat-ui/src/lib/components/MobileNav.svelte/0
{ "file_path": "chat-ui/src/lib/components/MobileNav.svelte", "repo_id": "chat-ui", "token_count": 692 }
49
<script lang="ts"> import CarbonUpload from "~icons/carbon/upload"; export let classNames = ""; export let files: File[]; let filelist: FileList; $: if (filelist) { files = Array.from(filelist); } </script> <button class="btn relative h-8 rounded-lg border bg-white px-3 py-1 text-sm text-gray-500 shadow-sm ...
chat-ui/src/lib/components/UploadBtn.svelte/0
{ "file_path": "chat-ui/src/lib/components/UploadBtn.svelte", "repo_id": "chat-ui", "token_count": 233 }
50
export const PUBLIC_SEP_TOKEN = "</s>";
chat-ui/src/lib/constants/publicSepToken.ts/0
{ "file_path": "chat-ui/src/lib/constants/publicSepToken.ts", "repo_id": "chat-ui", "token_count": 16 }
51
import { HF_ACCESS_TOKEN, HF_TOKEN } from "$env/static/private"; import { buildPrompt } from "$lib/buildPrompt"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import type { Endpoint } from "../endpoints"; import { z } from "zod"; export const endpointLlamacppParametersSchema = z.object({ w...
chat-ui/src/lib/server/endpoints/llamacpp/endpointLlamacpp.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/llamacpp/endpointLlamacpp.ts", "repo_id": "chat-ui", "token_count": 1417 }
52
import { searchWeb } from "$lib/server/websearch/searchWeb"; import type { Message } from "$lib/types/Message"; import type { WebSearch, WebSearchSource } from "$lib/types/WebSearch"; import { generateQuery } from "$lib/server/websearch/generateQuery"; import { parseWeb } from "$lib/server/websearch/parseWeb"; import {...
chat-ui/src/lib/server/websearch/runWebSearch.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/runWebSearch.ts", "repo_id": "chat-ui", "token_count": 1534 }
53
import type { ObjectId } from "mongodb"; import type { Message } from "./Message"; import type { Timestamps } from "./Timestamps"; import type { User } from "./User"; import type { Assistant } from "./Assistant"; export interface Conversation extends Timestamps { _id: ObjectId; sessionId?: string; userId?: User["_...
chat-ui/src/lib/types/Conversation.ts/0
{ "file_path": "chat-ui/src/lib/types/Conversation.ts", "repo_id": "chat-ui", "token_count": 175 }
54
import type { ObjectId } from "mongodb"; import type { Conversation } from "./Conversation"; import type { Timestamps } from "./Timestamps"; export interface WebSearch extends Timestamps { _id?: ObjectId; convId?: Conversation["_id"]; prompt: string; searchQuery: string; results: WebSearchSource[]; context: st...
chat-ui/src/lib/types/WebSearch.ts/0
{ "file_path": "chat-ui/src/lib/types/WebSearch.ts", "repo_id": "chat-ui", "token_count": 306 }
55
type UUID = ReturnType<typeof crypto.randomUUID>; export function randomUUID(): UUID { // Only on old safari / ios if (!("randomUUID" in crypto)) { return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => ( Number(c) ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (Number(c) / 4))...
chat-ui/src/lib/utils/randomUuid.ts/0
{ "file_path": "chat-ui/src/lib/utils/randomUuid.ts", "repo_id": "chat-ui", "token_count": 166 }
56
import { describe, expect, it } from "vitest"; import { isMessageId } from "./isMessageId"; import { v4 } from "uuid"; describe("isMessageId", () => { it("should return true for a valid message id", () => { expect(isMessageId(v4())).toBe(true); }); it("should return false for an invalid message id", () => { exp...
chat-ui/src/lib/utils/tree/isMessageId.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/isMessageId.spec.ts", "repo_id": "chat-ui", "token_count": 170 }
57
<script lang="ts"> export let name: string; export let description: string = ""; export let createdByName: string | undefined; export let avatar: string | undefined; import logo from "../../../../../static/huggingchat/logo.svg?raw"; </script> <div class="flex h-full w-full flex-col items-center justify-center bg...
chat-ui/src/routes/assistant/[assistantId]/thumbnail.png/ChatThumbnail.svelte/0
{ "file_path": "chat-ui/src/routes/assistant/[assistantId]/thumbnail.png/ChatThumbnail.svelte", "repo_id": "chat-ui", "token_count": 545 }
58
import { refreshSessionCookie } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { DEFAULT_SETTINGS } from "$lib/types/Settings"; import { z } from "zod"; import type { UserinfoResponse } from "openid-client"; import { error, type Cookies } from "@s...
chat-ui/src/routes/login/callback/updateUser.ts/0
{ "file_path": "chat-ui/src/routes/login/callback/updateUser.ts", "repo_id": "chat-ui", "token_count": 1318 }
59
import { base } from "$app/paths"; import { redirect } from "@sveltejs/kit"; export async function load({ parent, params }) { const data = await parent(); const assistant = data.settings.assistants.find((id) => id === params.assistantId); if (!assistant) { throw redirect(302, `${base}/assistant/${params.assista...
chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/+page.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/+page.ts", "repo_id": "chat-ui", "token_count": 115 }
60
# Create an audio dataset You can share a dataset with your team or with anyone in the community by creating a dataset repository on the Hugging Face Hub: ```py from datasets import load_dataset dataset = load_dataset("<username>/my_dataset") ``` There are several methods for creating and sharing an audio dataset: ...
datasets/docs/source/audio_dataset.mdx/0
{ "file_path": "datasets/docs/source/audio_dataset.mdx", "repo_id": "datasets", "token_count": 9843 }
61
# Process image data This guide shows specific methods for processing image datasets. Learn how to: - Use [`~Dataset.map`] with image dataset. - Apply data augmentations to a dataset with [`~Dataset.set_transform`]. For a guide on how to process any type of dataset, take a look at the <a class="underline decoration-...
datasets/docs/source/image_process.mdx/0
{ "file_path": "datasets/docs/source/image_process.mdx", "repo_id": "datasets", "token_count": 1031 }
62
# Utilities ## Configure logging 🤗 Datasets strives to be transparent and explicit about how it works, but this can be quite verbose at times. We have included a series of logging methods which allow you to easily adjust the level of verbosity of the entire library. Currently the default verbosity of the library is ...
datasets/docs/source/package_reference/utilities.mdx/0
{ "file_path": "datasets/docs/source/package_reference/utilities.mdx", "repo_id": "datasets", "token_count": 725 }
63
stages: benchmark_array_xd: cmd: python ./benchmarks/benchmark_array_xd.py deps: - ./benchmarks/benchmark_array_xd.py metrics: - ./benchmarks/results/benchmark_array_xd.json: cache: false benchmark_indices_mapping: cmd: python ./benchmarks/benchmark_indices_mapping.py deps: ...
datasets/dvc.yaml/0
{ "file_path": "datasets/dvc.yaml", "repo_id": "datasets", "token_count": 456 }
64
# Metric Card for COMET ## Metric description Crosslingual Optimized Metric for Evaluation of Translation (COMET) is an open-source framework used to train Machine Translation metrics that achieve high levels of correlation with different types of human judgments. ## How to use COMET takes 3 lists of strings as inp...
datasets/metrics/comet/README.md/0
{ "file_path": "datasets/metrics/comet/README.md", "repo_id": "datasets", "token_count": 2148 }
65
# 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/glue/glue.py/0
{ "file_path": "datasets/metrics/glue/glue.py", "repo_id": "datasets", "token_count": 2408 }
66
# Copyright 2020 The HuggingFace Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
datasets/metrics/meteor/meteor.py/0
{ "file_path": "datasets/metrics/meteor/meteor.py", "repo_id": "datasets", "token_count": 1898 }
67
# 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/sacrebleu/sacrebleu.py/0
{ "file_path": "datasets/metrics/sacrebleu/sacrebleu.py", "repo_id": "datasets", "token_count": 3057 }
68
# Metric Card for TER ## Metric Description TER (Translation Edit Rate, also called Translation Error Rate) is a metric to quantify the edit operations that a hypothesis requires to match a reference translation. We use the implementation that is already present in [sacrebleu](https://github.com/mjpost/sacreBLEU#ter),...
datasets/metrics/ter/README.md/0
{ "file_path": "datasets/metrics/ter/README.md", "repo_id": "datasets", "token_count": 2596 }
69
# 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/arrow_reader.py/0
{ "file_path": "datasets/src/datasets/arrow_reader.py", "repo_id": "datasets", "token_count": 11429 }
70
import copy import warnings from dataclasses import InitVar, dataclass, field from pathlib import Path from typing import Any, Dict, Optional, Union from .. import config @dataclass class DownloadConfig: """Configuration for our cached path manager. Attributes: cache_dir (`str` or `Path`, *optional*...
datasets/src/datasets/download/download_config.py/0
{ "file_path": "datasets/src/datasets/download/download_config.py", "repo_id": "datasets", "token_count": 1880 }
71
# Copyright 2021 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/jax_formatter.py/0
{ "file_path": "datasets/src/datasets/formatting/jax_formatter.py", "repo_id": "datasets", "token_count": 2858 }
72
import copy import itertools import sys import warnings from collections import Counter from copy import deepcopy from dataclasses import dataclass from functools import partial from itertools import cycle, islice from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union import numpy as ...
datasets/src/datasets/iterable_dataset.py/0
{ "file_path": "datasets/src/datasets/iterable_dataset.py", "repo_id": "datasets", "token_count": 46471 }
73
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=True) class Summarization(TaskTemplate): # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization task...
datasets/src/datasets/tasks/summarization.py/0
{ "file_path": "datasets/src/datasets/tasks/summarization.py", "repo_id": "datasets", "token_count": 254 }
74
# Copyright 2020 Optuna, Hugging Face # # 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 in ...
datasets/src/datasets/utils/logging.py/0
{ "file_path": "datasets/src/datasets/utils/logging.py", "repo_id": "datasets", "token_count": 1934 }
75
import os from typing import Dict, List, Tuple, TypeVar, Union T = TypeVar("T") ListLike = Union[List[T], Tuple[T, ...]] NestedDataStructureLike = Union[T, List[T], Dict[str, T]] PathLike = Union[str, bytes, os.PathLike]
datasets/src/datasets/utils/typing.py/0
{ "file_path": "datasets/src/datasets/utils/typing.py", "repo_id": "datasets", "token_count": 84 }
76
import json import tarfile import numpy as np import pytest from datasets import Audio, DownloadManager, Features, Image, Value from datasets.packaged_modules.webdataset.webdataset import WebDataset from ..utils import require_pil, require_sndfile @pytest.fixture def image_wds_file(tmp_path, image_file): json_...
datasets/tests/packaged_modules/test_webdataset.py/0
{ "file_path": "datasets/tests/packaged_modules/test_webdataset.py", "repo_id": "datasets", "token_count": 2263 }
77
import json import os import pickle import subprocess from functools import partial from pathlib import Path from tempfile import gettempdir from textwrap import dedent from types import FunctionType from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from multiprocess import...
datasets/tests/test_fingerprint.py/0
{ "file_path": "datasets/tests/test_fingerprint.py", "repo_id": "datasets", "token_count": 6783 }
78
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): example_yaml_structure = yaml.safe_load( """\ name: "" allow_empty: false allow_empty_text: true subsections: - name: "Dataset Card for X" #...
datasets/tests/test_readme_util.py/0
{ "file_path": "datasets/tests/test_readme_util.py", "repo_id": "datasets", "token_count": 6733 }
79
- title: Unit 0. Welcome to the course sections: - local: unit0/introduction title: Welcome to the course 🤗 - local: unit0/setup title: Setup - local: unit0/discord101 title: Discord 101 - title: Unit 1. Introduction to Deep Reinforcement Learning sections: - local: unit1/introduction title...
deep-rl-class/units/en/_toctree.yml/0
{ "file_path": "deep-rl-class/units/en/_toctree.yml", "repo_id": "deep-rl-class", "token_count": 2743 }
80
# Summary [[summary]] That was a lot of information! Let's summarize: - Reinforcement Learning is a computational approach of learning from actions. We build an agent that learns from the environment **by interacting with it through trial and error** and receiving rewards (negative or positive) as feedback. - The go...
deep-rl-class/units/en/unit1/summary.mdx/0
{ "file_path": "deep-rl-class/units/en/unit1/summary.mdx", "repo_id": "deep-rl-class", "token_count": 382 }
81
# Second Quiz [[quiz2]] The best way to learn and [to avoid the illusion of competence](https://www.coursera.org/lecture/learning-how-to-learn/illusions-of-competence-BuFzf) **is to test yourself.** This will help you to find **where you need to reinforce your knowledge**. ### Q1: What is Q-Learning? <Question ch...
deep-rl-class/units/en/unit2/quiz2.mdx/0
{ "file_path": "deep-rl-class/units/en/unit2/quiz2.mdx", "repo_id": "deep-rl-class", "token_count": 1097 }
82
# 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/unit4/unit4.ipynb"} ]} askForHelpUrl="http://hf.co/join/discord" /> Now ...
deep-rl-class/units/en/unit4/hands-on.mdx/0
{ "file_path": "deep-rl-class/units/en/unit4/hands-on.mdx", "repo_id": "deep-rl-class", "token_count": 13495 }
83