text
stringlengths
7
328k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
459
# coding=utf-8 # Copyright 2022 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 # # Unless r...
transformers/tests/models/timesformer/test_modeling_timesformer.py/0
{ "file_path": "transformers/tests/models/timesformer/test_modeling_timesformer.py", "repo_id": "transformers", "token_count": 5998 }
435
# coding=utf-8 # Copyright 2021 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/models/vilt/test_image_processing_vilt.py/0
{ "file_path": "transformers/tests/models/vilt/test_image_processing_vilt.py", "repo_id": "transformers", "token_count": 2455 }
436
# coding=utf-8 # Copyright 2022 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 # # Unless r...
transformers/tests/models/x_clip/test_modeling_x_clip.py/0
{ "file_path": "transformers/tests/models/x_clip/test_modeling_x_clip.py", "repo_id": "transformers", "token_count": 12644 }
437
# coding=utf-8 # 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 requir...
transformers/tests/models/xlm_roberta/test_modeling_xlm_roberta.py/0
{ "file_path": "transformers/tests/models/xlm_roberta/test_modeling_xlm_roberta.py", "repo_id": "transformers", "token_count": 1283 }
438
# coding=utf-8 # 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 requir...
transformers/tests/optimization/test_optimization.py/0
{ "file_path": "transformers/tests/optimization/test_optimization.py", "repo_id": "transformers", "token_count": 3392 }
439
# 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...
transformers/tests/pipelines/test_pipelines_image_to_text.py/0
{ "file_path": "transformers/tests/pipelines/test_pipelines_image_to_text.py", "repo_id": "transformers", "token_count": 5160 }
440
# 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...
transformers/tests/pipelines/test_pipelines_zero_shot_image_classification.py/0
{ "file_path": "transformers/tests/pipelines/test_pipelines_zero_shot_image_classification.py", "repo_id": "transformers", "token_count": 5307 }
441
# 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...
transformers/tests/repo_utils/test_check_dummies.py/0
{ "file_path": "transformers/tests/repo_utils/test_check_dummies.py", "repo_id": "transformers", "token_count": 1800 }
442
# 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/test_cache_utils.py/0
{ "file_path": "transformers/tests/test_cache_utils.py", "repo_id": "transformers", "token_count": 9511 }
443
# coding=utf-8 # Copyright 2021 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/test_sequence_feature_extraction_common.py/0
{ "file_path": "transformers/tests/test_sequence_feature_extraction_common.py", "repo_id": "transformers", "token_count": 7929 }
444
# 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_text_summarization.py/0
{ "file_path": "transformers/tests/tools/test_text_summarization.py", "repo_id": "transformers", "token_count": 1135 }
445
# 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/utils/test_audio_utils.py/0
{ "file_path": "transformers/tests/utils/test_audio_utils.py", "repo_id": "transformers", "token_count": 18583 }
446
# 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_offline.py/0
{ "file_path": "transformers/tests/utils/test_offline.py", "repo_id": "transformers", "token_count": 2916 }
447
import argparse import json import subprocess def get_runner_status(target_runners, token): offline_runners = [] cmd = ( f'curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer {token}"' " https://api.github.com/repos/huggingface/transformers/actions/runners" ) outpu...
transformers/utils/check_self_hosted_runner.py/0
{ "file_path": "transformers/utils/check_self_hosted_runner.py", "repo_id": "transformers", "token_count": 611 }
448
# 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...
transformers/utils/notification_service_doc_tests.py/0
{ "file_path": "transformers/utils/notification_service_doc_tests.py", "repo_id": "transformers", "token_count": 6457 }
449
# coding=utf-8 # Copyright 2021 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/tests_fetcher.py/0
{ "file_path": "transformers/utils/tests_fetcher.py", "repo_id": "transformers", "token_count": 22466 }
450
import argparse import math import os import shlex import subprocess import uuid from distutils.util import strtobool import requests def parse_args(): # fmt: off parser = argparse.ArgumentParser() parser.add_argument("--command", type=str, default="", help="the command to run") parser.add_ar...
trl/benchmark/benchmark.py/0
{ "file_path": "trl/benchmark/benchmark.py", "repo_id": "trl", "token_count": 2824 }
451
# Examples of using peft with trl to finetune 8-bit models with Low Rank Adaption (LoRA) The notebooks and scripts in this examples show how to use Low Rank Adaptation (LoRA) to fine-tune models in a memory efficient manner. Most of PEFT methods supported in peft library but note that some PEFT methods such as Prompt ...
trl/docs/source/lora_tuning_peft.mdx/0
{ "file_path": "trl/docs/source/lora_tuning_peft.mdx", "repo_id": "trl", "token_count": 2080 }
452
import argparse import os from accelerate import Accelerator from datasets import load_dataset from peft import LoraConfig from tqdm import tqdm from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, logging, set_seed from trl import SFTTrainer from trl.trainer import ConstantLengthDataset ...
trl/examples/research_projects/stack_llama/scripts/supervised_finetuning.py/0
{ "file_path": "trl/examples/research_projects/stack_llama/scripts/supervised_finetuning.py", "repo_id": "trl", "token_count": 2908 }
453
# 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 # # Unless required by appl...
trl/examples/scripts/ppo.py/0
{ "file_path": "trl/examples/scripts/ppo.py", "repo_id": "trl", "token_count": 2729 }
454
import unittest import torch from transformers import AutoTokenizer, GenerationConfig from trl import AutoModelForCausalLMWithValueHead from trl.core import LengthSampler from trl.extras import BestOfNSampler def queries_to_scores(list_of_strings): return [torch.rand(1).item() for _ in list_of_strings] class ...
trl/tests/test_best_of_n_sampler.py/0
{ "file_path": "trl/tests/test_best_of_n_sampler.py", "repo_id": "trl", "token_count": 1507 }
455
# 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_sft_trainer.py/0
{ "file_path": "trl/tests/test_sft_trainer.py", "repo_id": "trl", "token_count": 19255 }
456
# Copyright 2023 DDPO-pytorch authors (Kevin Black), The HuggingFace Team, metric-space. 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/lic...
trl/trl/models/modeling_sd_base.py/0
{ "file_path": "trl/trl/models/modeling_sd_base.py", "repo_id": "trl", "token_count": 11407 }
457
# 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/trl/trainer/reward_trainer.py/0
{ "file_path": "trl/trl/trainer/reward_trainer.py", "repo_id": "trl", "token_count": 5938 }
458
# 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/benchmarks/big_model_inference.py/0
{ "file_path": "accelerate/benchmarks/big_model_inference.py", "repo_id": "accelerate", "token_count": 2241 }
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/concept_guides/big_model_inference.md/0
{ "file_path": "accelerate/docs/source/concept_guides/big_model_inference.md", "repo_id": "accelerate", "token_count": 4832 }
1
<!--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/ipex.md/0
{ "file_path": "accelerate/docs/source/usage_guides/ipex.md", "repo_id": "accelerate", "token_count": 2636 }
2
# Distributed inference examples with PiPPy This repo contains a variety of tutorials for using the [PiPPy](https://github.com/PyTorch/PiPPy) pipeline parallelism library with accelerate. You will find examples covering: 1. How to trace the model using `accelerate.prepare_pippy` 2. How to specify inputs based on what...
accelerate/examples/inference/README.md/0
{ "file_path": "accelerate/examples/inference/README.md", "repo_id": "accelerate", "token_count": 646 }
3
[tool.ruff] line-length = 119 target-version = "py38" [tool.ruff.lint] preview = true ignore-init-module-imports = true extend-select = [ "B009", # static getattr "B010", # static setattr "CPY", # Copyright "E", # PEP8 errors "F", # PEP8 formatting "I", # Import sorting "TID251", # Banned A...
accelerate/pyproject.toml/0
{ "file_path": "accelerate/pyproject.toml", "repo_id": "accelerate", "token_count": 427 }
4
#!/usr/bin/env python # 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 # # Unles...
accelerate/src/accelerate/commands/env.py/0
{ "file_path": "accelerate/src/accelerate/commands/env.py", "repo_id": "accelerate", "token_count": 1140 }
5
# 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...
accelerate/src/accelerate/local_sgd.py/0
{ "file_path": "accelerate/src/accelerate/local_sgd.py", "repo_id": "accelerate", "token_count": 1531 }
6
#!/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/test_utils/scripts/test_distributed_data_loop.py/0
{ "file_path": "accelerate/src/accelerate/test_utils/scripts/test_distributed_data_loop.py", "repo_id": "accelerate", "token_count": 3115 }
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/launch.py/0
{ "file_path": "accelerate/src/accelerate/utils/launch.py", "repo_id": "accelerate", "token_count": 11894 }
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/tests/fsdp/test_fsdp.py/0
{ "file_path": "accelerate/tests/fsdp/test_fsdp.py", "repo_id": "accelerate", "token_count": 7367 }
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_memory_utils.py/0
{ "file_path": "accelerate/tests/test_memory_utils.py", "repo_id": "accelerate", "token_count": 1740 }
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/xla_spawn.py/0
{ "file_path": "accelerate/tests/xla_spawn.py", "repo_id": "accelerate", "token_count": 917 }
11
# Model arguments model_name_or_path: gpt2 model_revision: main torch_dtype: bfloat16 # Data training arguments dataset_mixer: yhavinga/mc4_nl_cleaned: 1.0 dataset_splits: - train dataset_configs: - tiny preprocessing_num_workers: 12 # SFT trainer config bf16: true do_eval: False evaluation_strategy: "no" gradi...
alignment-handbook/recipes/gpt2-nl/cpt/config_full.yaml/0
{ "file_path": "alignment-handbook/recipes/gpt2-nl/cpt/config_full.yaml", "repo_id": "alignment-handbook", "token_count": 370 }
12
# Instructions to Replicate Zephyr 7B Gemma Similar to how we trained Zephyr 7B Beta in our [technical report](https://huggingface.co/papers/2310.16944), training this model proceeds in two steps: 1. Apply SFT to fine-tune Gemma 7B on the Deita 10k dataset ([link](https://huggingface.co/datasets/HuggingFaceH4/deita-...
alignment-handbook/recipes/zephyr-7b-gemma/README.md/0
{ "file_path": "alignment-handbook/recipes/zephyr-7b-gemma/README.md", "repo_id": "alignment-handbook", "token_count": 505 }
13
# Model arguments model_name_or_path: alignment-handbook/zephyr-7b-sft-full # Data training arguments # For definitions, see: src/h4/training/config.py dataset_mixer: HuggingFaceH4/ultrafeedback_binarized: 1.0 dataset_splits: - train_prefs - test_prefs preprocessing_num_workers: 12 # DPOTrainer arguments bf16: true...
alignment-handbook/tests/fixtures/config_dpo_full.yaml/0
{ "file_path": "alignment-handbook/tests/fixtures/config_dpo_full.yaml", "repo_id": "alignment-handbook", "token_count": 329 }
14
.PHONY: clean-ptx clean test clean-ptx: find target -name "*.ptx" -type f -delete echo "" > candle-kernels/src/lib.rs touch candle-kernels/build.rs touch candle-examples/build.rs touch candle-flash-attn/build.rs clean: cargo clean test: cargo test all: test
candle/Makefile/0
{ "file_path": "candle/Makefile", "repo_id": "candle", "token_count": 107 }
15
[package] name = "candle-core" 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 } byteorder =...
candle/candle-core/Cargo.toml/0
{ "file_path": "candle/candle-core/Cargo.toml", "repo_id": "candle", "token_count": 468 }
16
use crate::{op::BackpropOp, op::Op, Error, Result, Tensor}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct ParamsConv1D { pub(crate) b_size: usize, // Maybe we should have a version without l_in as this bit depends on the input and not only on // the weights. pub(crate) l_in: usize, pub(crate) c...
candle/candle-core/src/conv.rs/0
{ "file_path": "candle/candle-core/src/conv.rs", "repo_id": "candle", "token_count": 5807 }
17
use crate::{DType, DeviceLocation, Layout, MetalError, Shape}; #[derive(Debug, Clone)] pub struct MatMulUnexpectedStriding { pub lhs_l: Layout, pub rhs_l: Layout, pub bmnk: (usize, usize, usize, usize), pub msg: &'static str, } /// Main library error type. #[derive(thiserror::Error, Debug)] pub enum E...
candle/candle-core/src/error.rs/0
{ "file_path": "candle/candle-core/src/error.rs", "repo_id": "candle", "token_count": 3254 }
18
use super::{GgmlDType, QStorage}; use crate::backend::BackendStorage; use crate::{DType, MetalDevice, MetalStorage, Result, Shape}; use metal::Buffer; use std::sync::Arc; pub struct QMetalStorage { dtype: GgmlDType, device: MetalDevice, buffer: Arc<Buffer>, } impl QMetalStorage { pub fn zeros(device: ...
candle/candle-core/src/quantized/metal.rs/0
{ "file_path": "candle/candle-core/src/quantized/metal.rs", "repo_id": "candle", "token_count": 4488 }
19
use candle_core::backend::BackendStorage; use candle_core::cpu_backend; use candle_core::test_utils::to_vec1_round; use candle_core::{CpuStorage, CustomOp1, DType, Device, Error, Layout, Result, Shape, Tensor}; fn fwd<T: num_traits::Float>(v: T, alpha: f64) -> T { if v.is_sign_positive() { v } else { ...
candle/candle-core/tests/custom_op_tests.rs/0
{ "file_path": "candle/candle-core/tests/custom_op_tests.rs", "repo_id": "candle", "token_count": 1542 }
20
# candle-starcoder: code generation 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. ## Running some example ```bash cargo run --example bigcode --release -- --prompt "fn fact(n: u64) -...
candle/candle-examples/examples/bigcode/README.md/0
{ "file_path": "candle/candle-examples/examples/bigcode/README.md", "repo_id": "candle", "token_count": 180 }
21
//! EfficientNet implementation. //! //! https://arxiv.org/abs/1905.11946 #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use candle::{DType, IndexOp, D}; use candle_nn::{Module, VarBuilder}; use candle_transformers::models::efficientnet::{EfficientNet,...
candle/candle-examples/examples/efficientnet/main.rs/0
{ "file_path": "candle/candle-examples/examples/efficientnet/main.rs", "repo_id": "candle", "token_count": 1421 }
22
// An implementation of LLaMA https://github.com/facebookresearch/llama // // This is based on nanoGPT in a similar way to: // https://github.com/Lightning-AI/lit-llama/blob/main/lit_llama/model.py // // The tokenizer config can be retrieved from: // https://huggingface.co/hf-internal-testing/llama-tokenizer/raw/main/t...
candle/candle-examples/examples/llama_multiprocess/main.rs/0
{ "file_path": "candle/candle-examples/examples/llama_multiprocess/main.rs", "repo_id": "candle", "token_count": 3470 }
23
// This should reach 91.5% accuracy. #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use rand::prelude::*; use candle::{DType, Result, Tensor, D}; use candle_nn::{loss, ops, Conv2d, Linear, Module, ModuleT, Optimizer, VarB...
candle/candle-examples/examples/mnist-training/main.rs/0
{ "file_path": "candle/candle-examples/examples/mnist-training/main.rs", "repo_id": "candle", "token_count": 4094 }
24
# candle-reinforcement-learning Reinforcement Learning examples for candle. This has been tested with `gymnasium` version `0.29.1`. You can install the Python package with: ```bash pip install "gymnasium[accept-rom-license]" ``` In order to run the examples, use the following commands. Note the additional `--package...
candle/candle-examples/examples/reinforcement-learning/README.md/0
{ "file_path": "candle/candle-examples/examples/reinforcement-learning/README.md", "repo_id": "candle", "token_count": 198 }
25
#[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use anyhow::Result; use clap::{Parser, ValueEnum}; use candle_transformers::models::quantized_rwkv_v5::Model as Q5; use candle_transformers::models::quantized_rwkv_v6::Model as Q6; use candle_transformers:...
candle/candle-examples/examples/rwkv/main.rs/0
{ "file_path": "candle/candle-examples/examples/rwkv/main.rs", "repo_id": "candle", "token_count": 5059 }
26
#[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::t5; use anyhow::{Error as E, Result}; use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::g...
candle/candle-examples/examples/t5/main.rs/0
{ "file_path": "candle/candle-examples/examples/t5/main.rs", "repo_id": "candle", "token_count": 5920 }
27
use candle::{DType, IndexOp, Result, Tensor, D}; use candle_nn::{batch_norm, conv2d, conv2d_no_bias, Conv2d, Conv2dConfig, Module, VarBuilder}; #[derive(Clone, Copy, PartialEq, Debug)] pub struct Multiples { depth: f64, width: f64, ratio: f64, } impl Multiples { pub fn n() -> Self { Self { ...
candle/candle-examples/examples/yolo-v8/model.rs/0
{ "file_path": "candle/candle-examples/examples/yolo-v8/model.rs", "repo_id": "candle", "token_count": 12422 }
28
/****************************************************************************** * Copyright (c) 2023, Tri Dao. ******************************************************************************/ #pragma once #include <cute/algorithm/copy.hpp> #include <cutlass/cutlass.h> #include <cutlass/array.h> #include <cutlass/nu...
candle/candle-flash-attn/kernels/flash_fwd_kernel.h/0
{ "file_path": "candle/candle-flash-attn/kernels/flash_fwd_kernel.h", "repo_id": "candle", "token_count": 16384 }
29
#include "cuda_utils.cuh" #define BINARY_OP_OUT(TYPENAME, OUT_TYPENAME, FN_NAME, FUNC) \ extern "C" __global__ void FN_NAME( \ const size_t numel, \ const size_t num_dims, \ const size_t *dims_and_strides, \ const TYPENAME *lhs, \ const TYPENAME *rhs, \ OUT_TYPENAME *out \ ) { \ const size_...
candle/candle-kernels/src/binary_op_macros.cuh/0
{ "file_path": "candle/candle-kernels/src/binary_op_macros.cuh", "repo_id": "candle", "token_count": 1561 }
30
#include <metal_stdlib> METAL_FUNC uint get_strided_index( uint idx, constant size_t &num_dims, constant size_t *dims, constant size_t *strides ) { uint strided_i = 0; for (uint d = 0; d < num_dims; d++) { uint dim_idx = num_dims - 1 - d; strided_i += (idx % dims[dim_idx]) * str...
candle/candle-metal-kernels/src/cast.metal/0
{ "file_path": "candle/candle-metal-kernels/src/cast.metal", "repo_id": "candle", "token_count": 2045 }
31
# candle-nn
candle/candle-nn/README.md/0
{ "file_path": "candle/candle-nn/README.md", "repo_id": "candle", "token_count": 5 }
32
//! Various optimization algorithms. use candle::{Result, Tensor, Var}; /// The interface optimizers should implement. pub trait Optimizer: Sized { type Config: Sized; fn new(vars: Vec<Var>, config: Self::Config) -> Result<Self>; fn step(&mut self, grads: &candle::backprop::GradStore) -> Result<()>; ...
candle/candle-nn/src/optim.rs/0
{ "file_path": "candle/candle-nn/src/optim.rs", "repo_id": "candle", "token_count": 2798 }
33
use crate::onnx; use crate::onnx::attribute_proto::AttributeType; use crate::onnx::tensor_proto::DataType; use candle::{bail, DType, Device, Result, Tensor}; use std::collections::HashMap; pub type Value = Tensor; pub fn dtype(dt: DataType) -> Option<DType> { match dt { DataType::Uint8 => Some(DType::U8),...
candle/candle-onnx/src/eval.rs/0
{ "file_path": "candle/candle-onnx/src/eval.rs", "repo_id": "candle", "token_count": 20779 }
34
import candle from typing import Dict, Tuple, Any from candle import Tensor, QTensor, utils, nn from candle.nn import Module, ModuleList def masked_fill(on_false: Tensor, mask: Tensor, on_true: Tensor): shape = mask.shape on_true = candle.tensor(on_true).broadcast_as(shape) return mask.where_cond(on_true,...
candle/candle-pyo3/py_src/candle/models/llama.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/models/llama.py", "repo_id": "candle", "token_count": 2981 }
35
use std::collections::HashMap; use crate::utils::wrap_err; use crate::{PyDType, PyTensor}; use candle_onnx::eval::{dtype, get_tensor, simple_eval}; use candle_onnx::onnx::tensor_proto::DataType; use candle_onnx::onnx::tensor_shape_proto::dimension::Value; use candle_onnx::onnx::type_proto::{Tensor as ONNXTensor, Value...
candle/candle-pyo3/src/onnx.rs/0
{ "file_path": "candle/candle-pyo3/src/onnx.rs", "repo_id": "candle", "token_count": 3266 }
36
pub mod generation; pub mod models; pub mod object_detection; pub mod pipelines; pub mod quantized_nn; pub mod quantized_var_builder; pub mod utils;
candle/candle-transformers/src/lib.rs/0
{ "file_path": "candle/candle-transformers/src/lib.rs", "repo_id": "candle", "token_count": 47 }
37
use super::with_tracing::{linear_no_bias as linear, Linear, RmsNorm}; use candle::{DType, Device, IndexOp, Result, Tensor, D}; use candle_nn::{embedding, Embedding, Module, VarBuilder}; use std::collections::HashMap; pub const MAX_SEQ_LEN: usize = 4096; #[derive(Debug, Clone, serde::Deserialize)] pub struct LlamaConf...
candle/candle-transformers/src/models/llama.rs/0
{ "file_path": "candle/candle-transformers/src/models/llama.rs", "repo_id": "candle", "token_count": 7514 }
38
use std::collections::HashMap; use candle::quantized::QTensor; use candle::quantized::{ggml_file, gguf_file}; use candle::{DType, Device, IndexOp, Result, Tensor, D}; use candle_nn::{Embedding, Module}; pub const MAX_SEQ_LEN: usize = 4096; #[derive(Debug, Clone)] struct RmsNorm { inner: candle_nn::LayerNorm, ...
candle/candle-transformers/src/models/quantized_llama.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_llama.rs", "repo_id": "candle", "token_count": 11792 }
39
use candle::{DType, IndexOp, Result, Tensor}; use candle_nn::{layer_norm, LayerNorm, Module, VarBuilder}; #[derive(Debug)] struct PatchEmbed { proj: candle_nn::Conv2d, span: tracing::Span, } impl PatchEmbed { fn new( in_chans: usize, embed_dim: usize, k_size: usize, stride:...
candle/candle-transformers/src/models/segment_anything/image_encoder.rs/0
{ "file_path": "candle/candle-transformers/src/models/segment_anything/image_encoder.rs", "repo_id": "candle", "token_count": 8848 }
40
//! 2D UNet Denoising Models //! //! The 2D Unet models take as input a noisy sample and the current diffusion //! timestep and return a denoised version of the input. use super::embeddings::{TimestepEmbedding, Timesteps}; use super::unet_2d_blocks::*; use crate::models::with_tracing::{conv2d, Conv2d}; use candle::{Res...
candle/candle-transformers/src/models/stable_diffusion/unet_2d.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/unet_2d.rs", "repo_id": "candle", "token_count": 8419 }
41
use candle::{DType, Module, Result, Tensor, D}; use candle_nn::VarBuilder; // https://github.com/huggingface/diffusers/blob/19edca82f1ff194c07317369a92b470dbae97f34/src/diffusers/pipelines/wuerstchen/modeling_wuerstchen_common.py#L22 #[derive(Debug)] pub struct WLayerNorm { eps: f64, } impl WLayerNorm { pub f...
candle/candle-transformers/src/models/wuerstchen/common.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/common.rs", "repo_id": "candle", "token_count": 3219 }
42
//load Candle Bert Module wasm module import init, { Model } from "./build/m.js"; async function fetchArrayBuffer(url) { const cacheName = "bert-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse....
candle/candle-wasm-examples/bert/bertWorker.js/0
{ "file_path": "candle/candle-wasm-examples/bert/bertWorker.js", "repo_id": "candle", "token_count": 779 }
43
cargo build --target wasm32-unknown-unknown --release wasm-bindgen ../../target/wasm32-unknown-unknown/release/m.wasm --out-dir build --target web
candle/candle-wasm-examples/llama2-c/build-lib.sh/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/build-lib.sh", "repo_id": "candle", "token_count": 48 }
44
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::generation::LogitsProcessor; use candle_transformers::models::mixformer::{Config, MixFormerSequentialForCausalLM as MixFormer}; use candle_transformers::models::quantized_mixformer::MixFormerSequentialForCausalLM as QMixFormer; use...
candle/candle-wasm-examples/phi/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/phi/src/bin/m.rs", "repo_id": "candle", "token_count": 2646 }
45
use crate::languages::LANGUAGES; use anyhow::Error as E; use candle::{safetensors::Load, DType, Device, IndexOp, Tensor, D}; use candle_nn::{ops::softmax, VarBuilder}; pub use candle_transformers::models::whisper::{self as m, Config}; use rand::{distributions::Distribution, rngs::StdRng, SeedableRng}; use serde::{Deser...
candle/candle-wasm-examples/whisper/src/worker.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/worker.rs", "repo_id": "candle", "token_count": 8765 }
46
[package] name = "candle-wasm-tests" version.workspace = true edition.workspace = true description = "WASM tests for candle" keywords.workspace = true categories.workspace = true [dependencies] candle = { workspace = true } rand = { workspace = true } getrandom = { version = "0.2", features = ["js"] } [dev-dependenci...
candle/candle-wasm-tests/Cargo.toml/0
{ "file_path": "candle/candle-wasm-tests/Cargo.toml", "repo_id": "candle", "token_count": 122 }
47
ARG INCLUDE_DB=false FROM mongo:latest as mongo FROM node:20-slim as local_db_false FROM node:20-slim as local_db_true RUN apt-get update RUN apt-get install gnupg curl -y COPY --from=mongo /usr/bin/mongo* /usr/bin/ FROM local_db_${INCLUDE_DB} as final ARG INCLUDE_DB=false ENV INCLUDE_DB=${INCLUDE_DB} WORKDIR /ap...
chat-ui/Dockerfile.local/0
{ "file_path": "chat-ui/Dockerfile.local", "repo_id": "chat-ui", "token_count": 278 }
48
export function clickOutside(element: HTMLDialogElement, callbackFunction: () => void) { function onClick(event: MouseEvent) { if (!element.contains(event.target as Node)) { callbackFunction(); } } document.body.addEventListener("click", onClick); return { update(newCallbackFunction: () => void) { cal...
chat-ui/src/lib/actions/clickOutside.ts/0
{ "file_path": "chat-ui/src/lib/actions/clickOutside.ts", "repo_id": "chat-ui", "token_count": 143 }
49
<script lang="ts"> import type { WebSearchUpdate } from "$lib/types/MessageUpdate"; import CarbonError from "~icons/carbon/error-filled"; import EosIconsLoading from "~icons/eos-icons/loading"; import IconInternet from "./icons/IconInternet.svelte"; export let classNames = ""; export let webSearchMessages: WebS...
chat-ui/src/lib/components/OpenWebSearchResults.svelte/0
{ "file_path": "chat-ui/src/lib/components/OpenWebSearchResults.svelte", "repo_id": "chat-ui", "token_count": 1709 }
50
<script lang="ts"> import { marked } from "marked"; import markedKatex from "marked-katex-extension"; import type { Message } from "$lib/types/Message"; import { afterUpdate, createEventDispatcher, tick } from "svelte"; import { deepestChild } from "$lib/utils/deepestChild"; import { page } from "$app/stores"; ...
chat-ui/src/lib/components/chat/ChatMessage.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/ChatMessage.svelte", "repo_id": "chat-ui", "token_count": 6727 }
51
import type { MongoClient, ObjectId } from "mongodb"; import updateSearchAssistant from "./01-update-search-assistants"; export interface Migration { _id: ObjectId; name: string; up: (client: MongoClient) => Promise<boolean>; down?: (client: MongoClient) => Promise<boolean>; runForFreshInstall?: "only" | "never"...
chat-ui/src/lib/migrations/routines/index.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/index.ts", "repo_id": "chat-ui", "token_count": 149 }
52
import type { TextGenerationStreamOutput } from "@huggingface/inference"; import type OpenAI from "openai"; import type { Stream } from "openai/streaming"; /** * Transform a stream of OpenAI.Completions.Completion into a stream of TextGenerationStreamOutput */ export async function* openAICompletionToTextGenerationS...
chat-ui/src/lib/server/endpoints/openai/openAICompletionToTextGenerationStream.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/openai/openAICompletionToTextGenerationStream.ts", "repo_id": "chat-ui", "token_count": 310 }
53
import type { YouWebSearch } from "../../types/WebSearch"; import { WebSearchProvider } from "../../types/WebSearch"; import { SERPAPI_KEY, SERPER_API_KEY, SERPSTACK_API_KEY, USE_LOCAL_WEBSEARCH, SEARXNG_QUERY_URL, YDC_API_KEY, } from "$env/static/private"; import { getJson } from "serpapi"; import type { GoogleP...
chat-ui/src/lib/server/websearch/searchWeb.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/searchWeb.ts", "repo_id": "chat-ui", "token_count": 1441 }
54
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": 219 }
55
/** * Chunk array into arrays of length at most `chunkSize` * * @param chunkSize must be greater than or equal to 1 */ export function chunk<T extends unknown[] | string>(arr: T, chunkSize: number): T[] { if (isNaN(chunkSize) || chunkSize < 1) { throw new RangeError("Invalid chunk size: " + chunkSize); } if (...
chat-ui/src/lib/utils/chunk.ts/0
{ "file_path": "chat-ui/src/lib/utils/chunk.ts", "repo_id": "chat-ui", "token_count": 295 }
56
const PUNCTUATION_REGEX = /\p{P}/gu; function removeDiacritics(s: string, form: "NFD" | "NFKD" = "NFD"): string { return s.normalize(form).replace(/[\u0300-\u036f]/g, ""); } export function generateSearchTokens(value: string): string[] { const fullTitleToken = removeDiacritics(value) .replace(PUNCTUATION_REGEX, "...
chat-ui/src/lib/utils/searchTokens.ts/0
{ "file_path": "chat-ui/src/lib/utils/searchTokens.ts", "repo_id": "chat-ui", "token_count": 426 }
57
import type { Message } from "$lib/types/Message"; export function isMessageId(id: string): id is Message["id"] { return id.split("-").length === 5; }
chat-ui/src/lib/utils/tree/isMessageId.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/isMessageId.ts", "repo_id": "chat-ui", "token_count": 48 }
58
import { base } from "$app/paths"; import { ENABLE_ASSISTANTS } from "$env/static/private"; import { collections } from "$lib/server/database.js"; import type { Assistant } from "$lib/types/Assistant"; import type { User } from "$lib/types/User"; import { generateQueryTokens } from "$lib/utils/searchTokens.js"; import ...
chat-ui/src/routes/assistants/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/assistants/+page.server.ts", "repo_id": "chat-ui", "token_count": 673 }
59
import { dev } from "$app/environment"; import { base } from "$app/paths"; import { COOKIE_NAME } from "$env/static/private"; import { collections } from "$lib/server/database"; import { redirect } from "@sveltejs/kit"; export const actions = { async default({ cookies, locals }) { await collections.sessions.deleteO...
chat-ui/src/routes/logout/+page.server.ts/0
{ "file_path": "chat-ui/src/routes/logout/+page.server.ts", "repo_id": "chat-ui", "token_count": 203 }
60
<script lang="ts"> import { applyAction, enhance } from "$app/forms"; import { invalidateAll } from "$app/navigation"; import Modal from "$lib/components/Modal.svelte"; import { createEventDispatcher } from "svelte"; const dispatch = createEventDispatcher<{ close: void }>(); let reason = ""; </script> <Modal o...
chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/ReportModal.svelte/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/assistants/[assistantId]/ReportModal.svelte", "repo_id": "chat-ui", "token_count": 593 }
61
{ "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "data": { "values": "<DVC_METRIC_DATA>" }, "title": "<DVC_METRIC_TITLE>", "mark": { "type": "line" }, "encoding": { "x": { "field": "<DVC_METRIC_X>", "type": "quantitative", ...
datasets/.dvc/plots/smooth.json/0
{ "file_path": "datasets/.dvc/plots/smooth.json", "repo_id": "datasets", "token_count": 569 }
62
# Process audio data This guide shows specific methods for processing audio datasets. Learn how to: - Resample the sampling rate. - Use [`~Dataset.map`] with audio datasets. For a guide on how to process any type of dataset, take a look at the <a class="underline decoration-sky-400 decoration-2 font-semibold" href="...
datasets/docs/source/audio_process.mdx/0
{ "file_path": "datasets/docs/source/audio_process.mdx", "repo_id": "datasets", "token_count": 1186 }
63
<!--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...
datasets/docs/source/quickstart.mdx/0
{ "file_path": "datasets/docs/source/quickstart.mdx", "repo_id": "datasets", "token_count": 6102 }
64
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
datasets/metrics/accuracy/accuracy.py/0
{ "file_path": "datasets/metrics/accuracy/accuracy.py", "repo_id": "datasets", "token_count": 1611 }
65
# Metric Card for Competition MATH ## Metric description This metric is used to assess performance on the [Mathematics Aptitude Test of Heuristics (MATH) dataset](https://huggingface.co/datasets/competition_math). It first canonicalizes the inputs (e.g., converting `1/2` to `\\frac{1}{2}`) and then computes accurac...
datasets/metrics/competition_math/README.md/0
{ "file_path": "datasets/metrics/competition_math/README.md", "repo_id": "datasets", "token_count": 1135 }
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/google_bleu/google_bleu.py/0
{ "file_path": "datasets/metrics/google_bleu/google_bleu.py", "repo_id": "datasets", "token_count": 4259 }
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/mse/mse.py/0
{ "file_path": "datasets/metrics/mse/mse.py", "repo_id": "datasets", "token_count": 1715 }
68
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
datasets/metrics/sari/sari.py/0
{ "file_path": "datasets/metrics/sari/sari.py", "repo_id": "datasets", "token_count": 4913 }
69
# Metric Card for WER ## Metric description Word error rate (WER) is a common metric of the performance of an automatic speech recognition (ASR) system. The general difficulty of measuring the performance of ASR systems lies in the fact that the recognized word sequence can have a different length from the reference...
datasets/metrics/wer/README.md/0
{ "file_path": "datasets/metrics/wer/README.md", "repo_id": "datasets", "token_count": 1325 }
70
# Copyright 2020 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 # # Unless required by applicable law or a...
datasets/src/datasets/download/mock_download_manager.py/0
{ "file_path": "datasets/src/datasets/download/mock_download_manager.py", "repo_id": "datasets", "token_count": 4438 }
71
# 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/polars_formatter.py/0
{ "file_path": "datasets/src/datasets/formatting/polars_formatter.py", "repo_id": "datasets", "token_count": 1910 }
72
# 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/load.py/0
{ "file_path": "datasets/src/datasets/load.py", "repo_id": "datasets", "token_count": 53030 }
73
import io import json from itertools import islice from typing import Any, Callable, Dict, List import numpy as np import pyarrow as pa import datasets logger = datasets.utils.logging.get_logger(__name__) class WebDataset(datasets.GeneratorBasedBuilder): DEFAULT_WRITER_BATCH_SIZE = 100 IMAGE_EXTENSIONS: L...
datasets/src/datasets/packaged_modules/webdataset/webdataset.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/webdataset/webdataset.py", "repo_id": "datasets", "token_count": 4107 }
74
from importlib import import_module from .logging import get_logger logger = get_logger(__name__) class _PatchedModuleObj: """Set all the modules components as attributes of the _PatchedModuleObj object.""" def __init__(self, module, attrs=None): attrs = attrs or [] if module is not None: ...
datasets/src/datasets/utils/patching.py/0
{ "file_path": "datasets/src/datasets/utils/patching.py", "repo_id": "datasets", "token_count": 2222 }
75