text stringlengths 7 328k | id stringlengths 14 166 | metadata dict | __index_level_0__ int64 0 459 |
|---|---|---|---|
# Copyright 2024 Susung Hong and The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | diffusers/src/diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py/0 | {
"file_path": "diffusers/src/diffusers/pipelines/stable_diffusion_sag/pipeline_stable_diffusion_sag.py",
"repo_id": "diffusers",
"token_count": 20000
} | 139 |
# Copyright 2024 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | diffusers/src/diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py/0 | {
"file_path": "diffusers/src/diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py",
"repo_id": "diffusers",
"token_count": 14098
} | 140 |
# Copyright (c) 2023 Dominic Rampas MIT License
# 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/licen... | diffusers/src/diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py/0 | {
"file_path": "diffusers/src/diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py",
"repo_id": "diffusers",
"token_count": 3806
} | 141 |
# Copyright 2024 ParaDiGMS authors and The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | diffusers/src/diffusers/schedulers/scheduling_ddim_parallel.py/0 | {
"file_path": "diffusers/src/diffusers/schedulers/scheduling_ddim_parallel.py",
"repo_id": "diffusers",
"token_count": 13291
} | 142 |
# Copyright 2024 Katherine Crowson, The HuggingFace Team and hlky. 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
#
# ... | diffusers/src/diffusers/schedulers/scheduling_heun_discrete.py/0 | {
"file_path": "diffusers/src/diffusers/schedulers/scheduling_heun_discrete.py",
"repo_id": "diffusers",
"token_count": 9031
} | 143 |
# Copyright 2024 TSAIL Team and The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | diffusers/src/diffusers/schedulers/scheduling_unipc_multistep.py/0 | {
"file_path": "diffusers/src/diffusers/schedulers/scheduling_unipc_multistep.py",
"repo_id": "diffusers",
"token_count": 17388
} | 144 |
# This file is autogenerated by the command `make fix-copies`, do not edit.
from ..utils import DummyObject, requires_backends
class LMSDiscreteScheduler(metaclass=DummyObject):
_backends = ["torch", "scipy"]
def __init__(self, *args, **kwargs):
requires_backends(self, ["torch", "scipy"])
@class... | diffusers/src/diffusers/utils/dummy_torch_and_scipy_objects.py/0 | {
"file_path": "diffusers/src/diffusers/utils/dummy_torch_and_scipy_objects.py",
"repo_id": "diffusers",
"token_count": 220
} | 145 |
# Copyright 2024 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | diffusers/src/diffusers/utils/state_dict_utils.py/0 | {
"file_path": "diffusers/src/diffusers/utils/state_dict_utils.py",
"repo_id": "diffusers",
"token_count": 5702
} | 146 |
# coding=utf-8
# Copyright 2024 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... | diffusers/tests/models/autoencoders/test_models_vq.py/0 | {
"file_path": "diffusers/tests/models/autoencoders/test_models_vq.py",
"repo_id": "diffusers",
"token_count": 1280
} | 147 |
# coding=utf-8
# Copyright 2024 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... | diffusers/tests/models/unets/test_models_unet_stable_cascade.py/0 | {
"file_path": "diffusers/tests/models/unets/test_models_unet_stable_cascade.py",
"repo_id": "diffusers",
"token_count": 3387
} | 148 |
# coding=utf-8
# Copyright 2024 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... | diffusers/tests/pipelines/amused/test_amused_img2img.py/0 | {
"file_path": "diffusers/tests/pipelines/amused/test_amused_img2img.py",
"repo_id": "diffusers",
"token_count": 3982
} | 149 |
# coding=utf-8
# Copyright 2024 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... | diffusers/tests/pipelines/controlnet/test_controlnet_img2img.py/0 | {
"file_path": "diffusers/tests/pipelines/controlnet/test_controlnet_img2img.py",
"repo_id": "diffusers",
"token_count": 8286
} | 150 |
# coding=utf-8
# Copyright 2024 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... | diffusers/tests/pipelines/deepfloyd_if/test_if_inpainting.py/0 | {
"file_path": "diffusers/tests/pipelines/deepfloyd_if/test_if_inpainting.py",
"repo_id": "diffusers",
"token_count": 2035
} | 151 |
# coding=utf-8
# Copyright 2024 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... | diffusers/tests/pipelines/stable_diffusion_gligen_text_image/test_stable_diffusion_gligen_text_image.py/0 | {
"file_path": "diffusers/tests/pipelines/stable_diffusion_gligen_text_image/test_stable_diffusion_gligen_text_image.py",
"repo_id": "diffusers",
"token_count": 3232
} | 152 |
# coding=utf-8
# Copyright 2024 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... | diffusers/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py/0 | {
"file_path": "diffusers/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_img2img.py",
"repo_id": "diffusers",
"token_count": 15327
} | 153 |
import torch
from diffusers import DDIMScheduler
from .test_schedulers import SchedulerCommonTest
class DDIMSchedulerTest(SchedulerCommonTest):
scheduler_classes = (DDIMScheduler,)
forward_default_kwargs = (("eta", 0.0), ("num_inference_steps", 50))
def get_scheduler_config(self, **kwargs):
con... | diffusers/tests/schedulers/test_scheduler_ddim.py/0 | {
"file_path": "diffusers/tests/schedulers/test_scheduler_ddim.py",
"repo_id": "diffusers",
"token_count": 3127
} | 154 |
import tempfile
import torch
from diffusers import IPNDMScheduler
from .test_schedulers import SchedulerCommonTest
class IPNDMSchedulerTest(SchedulerCommonTest):
scheduler_classes = (IPNDMScheduler,)
forward_default_kwargs = (("num_inference_steps", 50),)
def get_scheduler_config(self, **kwargs):
... | diffusers/tests/schedulers/test_scheduler_ipndm.py/0 | {
"file_path": "diffusers/tests/schedulers/test_scheduler_ipndm.py",
"repo_id": "diffusers",
"token_count": 3120
} | 155 |
# coding=utf-8
# Copyright 2024 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... | diffusers/utils/check_dummies.py/0 | {
"file_path": "diffusers/utils/check_dummies.py",
"repo_id": "diffusers",
"token_count": 2591
} | 156 |
<jupyter_start><jupyter_text>Fine-Tuning and GuidanceIn this notebook, we're going to cover two main approaches for adapting existing diffusion models:* With **fine-tuning**, we'll re-train existing models on new data to change the type of output they produce* With **guidance**, we'll take an existing model and steer t... | diffusion-models-class/unit2/01_finetuning_and_guidance.ipynb/0 | {
"file_path": "diffusion-models-class/unit2/01_finetuning_and_guidance.ipynb",
"repo_id": "diffusion-models-class",
"token_count": 11877
} | 157 |
- title: Course introduction
sections:
- local: unit0/1
title: Introduction
- title: 1. Introduction to diffusion models
sections:
- local: unit1/1
title: Overview
- local: unit1/2
title: Implementation with 🤗 Diffusers
- local: unit1/3
title: Implementation from scratch
- title: 2. Fine-... | diffusion-models-class/units/en/_toctree.yml/0 | {
"file_path": "diffusion-models-class/units/en/_toctree.yml",
"repo_id": "diffusion-models-class",
"token_count": 424
} | 158 |
# Diffusion for Audio
<CourseFloatingBanner unit={4}
classNames="absolute z-10 right-0 top-0"
notebooks={[
{label: "Diffusion for Audio", value: "https://colab.research.google.com/github/huggingface/diffusion-models-class/blob/main/units/en/unit4/diffusion_for_audio.ipynb"},
{label: "Diffusion for Audio", ... | diffusion-models-class/units/en/unit4/3.mdx/0 | {
"file_path": "diffusion-models-class/units/en/unit4/3.mdx",
"repo_id": "diffusion-models-class",
"token_count": 4647
} | 159 |
<jupyter_start><jupyter_text>Modèles (TensorFlow) Installez la bibliothèque 🤗 *Transformers* pour exécuter ce *notebook*.<jupyter_code>!pip install transformers[sentencepiece]
from transformers import CamembertConfig, TFCamembertModel
# Construire la configuration
config = CamembertConfig()
# Construire le modèle à ... | notebooks/course/fr/chapter2/section3_tf.ipynb/0 | {
"file_path": "notebooks/course/fr/chapter2/section3_tf.ipynb",
"repo_id": "notebooks",
"token_count": 351
} | 160 |
<jupyter_start><jupyter_text>Partage de modèles pré-entraînés (PyTorch) Installez la bibliothèque 🤗 Transformers pour exécuter ce *notebook*.<jupyter_code>!pip install datasets transformers[sentencepiece]
!apt install git-lfs<jupyter_output><empty_output><jupyter_text>Vous aurez besoin de configurer git, adaptez votre... | notebooks/course/fr/chapter4/section3_pt.ipynb/0 | {
"file_path": "notebooks/course/fr/chapter4/section3_pt.ipynb",
"repo_id": "notebooks",
"token_count": 1050
} | 161 |
<jupyter_start><jupyter_text>WordPiece tokenizationAucun modèle en français utilise WordPiece. Nous utilisons ici CamemBERT utilise SentencePiece. Installez les bibliothèques 🤗 *Transformers* et 🤗 *Datasets* pour exécuter ce *notebook*.<jupyter_code>!pip install datasets transformers[sentencepiece]
corpus = [
"C'... | notebooks/course/fr/chapter6/section6.ipynb/0 | {
"file_path": "notebooks/course/fr/chapter6/section6.ipynb",
"repo_id": "notebooks",
"token_count": 1867
} | 162 |
<jupyter_start><jupyter_text>*Introducing Hugging Face's new library for diffusion models*Diffusion models proved themselves very effective in artificial synthesis, even beating GANs for images. Because of that, they gained traction in the machine learning community and play an important role for systems like [DALL-E 2... | notebooks/diffusers/diffusers_intro.ipynb/0 | {
"file_path": "notebooks/diffusers/diffusers_intro.ipynb",
"repo_id": "notebooks",
"token_count": 6228
} | 163 |
<jupyter_start><jupyter_text>Stable Diffusion Textual Inversion - Concept Library navigation and usageNavigate through the [public library of concepts](https://huggingface.co/sd-concepts-library) and use Stable Diffusion with custom concepts. 🤗 Hugging Face [🧨 Diffusers library](https://github.com/huggingface/diffuse... | notebooks/diffusers/stable_diffusion_textual_inversion_library_navigator.ipynb/0 | {
"file_path": "notebooks/diffusers/stable_diffusion_textual_inversion_library_navigator.ipynb",
"repo_id": "notebooks",
"token_count": 5285
} | 164 |
<jupyter_start><jupyter_text>**Fine-tuning for Audio Classification with 🤗 Transformers** This notebook shows how to fine-tune multi-lingual pretrained speech models for Automatic Speech Recognition. This notebook is built to run on the **Keyword Spotting** subset of the [SUPERB dataset](https://huggingface.co/dataset... | notebooks/examples/audio_classification.ipynb/0 | {
"file_path": "notebooks/examples/audio_classification.ipynb",
"repo_id": "notebooks",
"token_count": 4362
} | 165 |
<jupyter_start><jupyter_text>**Fine-tuning for Image Classification with 🤗 Transformers**This notebook shows how to fine-tune any pretrained Vision model for Image Classification on a custom dataset. The idea is to add a randomly initialized classification head on top of a pre-trained encoder, and fine-tune the model ... | notebooks/examples/image_classification.ipynb/0 | {
"file_path": "notebooks/examples/image_classification.ipynb",
"repo_id": "notebooks",
"token_count": 7435
} | 166 |
<jupyter_start><jupyter_text>Pre-Training a 🤗 Transformers model on TPU with **Flax/JAX**In this notebook, we will see how to pretrain one of the [🤗 Transformers](https://github.com/huggingface/transformers) models on TPU using [**Flax**](https://flax.readthedocs.io/en/latest/index.html). The popular masked language ... | notebooks/examples/masked_language_modeling_flax.ipynb/0 | {
"file_path": "notebooks/examples/masked_language_modeling_flax.ipynb",
"repo_id": "notebooks",
"token_count": 10194
} | 167 |
<jupyter_start><jupyter_text>Segment Anything Model using `transformers` 🤗 library| | | ||---------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------... | notebooks/examples/segment_anything.ipynb/0 | {
"file_path": "notebooks/examples/segment_anything.ipynb",
"repo_id": "notebooks",
"token_count": 5421
} | 168 |
<jupyter_start><jupyter_text>If you're opening this Notebook on colab, you will probably need to install 🤗 Transformers and 🤗 Datasets. Uncomment the following cell and run it.<jupyter_code>#! pip install datasets transformers seqeval<jupyter_output><empty_output><jupyter_text>If you're opening this notebook locally,... | notebooks/examples/token_classification.ipynb/0 | {
"file_path": "notebooks/examples/token_classification.ipynb",
"repo_id": "notebooks",
"token_count": 7204
} | 169 |
import functools
import math
import os # noqa: F401
from random import choice, randint
from time import time
import numpy as np
import torch
import torch.utils.checkpoint as checkpoint
from torch.utils.data import DataLoader, Dataset, RandomSampler, SequentialSampler
from tqdm import tqdm
import faiss # noqa: F401
... | notebooks/longform-qa/lfqa_utils.py/0 | {
"file_path": "notebooks/longform-qa/lfqa_utils.py",
"repo_id": "notebooks",
"token_count": 12846
} | 170 |
<jupyter_start><jupyter_text>Huggingface Sagemaker-sdk - Distributed Training Demo Distributed Question Answering with `transformers` scripts + `Trainer` and `squad` dataset 1. [Introduction](Introduction) 2. [Development Environment and Permissions](Development-Environment-and-Permissions) 1. [Installation](Insta... | notebooks/sagemaker/03_distributed_training_data_parallelism/sagemaker-notebook.ipynb/0 | {
"file_path": "notebooks/sagemaker/03_distributed_training_data_parallelism/sagemaker-notebook.ipynb",
"repo_id": "notebooks",
"token_count": 3514
} | 171 |
accelerate launch --config_file accelerate_config.yaml run_seq2seq_no_trainer.py \
--dataset_name "smangrul/MuDoConv" \
--max_source_length 128 \
--source_prefix "chatbot: " \
--max_target_length 64 \
--val_max_target_length 64 \
--val_min_target_length 20 \
--n_val_batch_generations 5 \
... | notebooks/sagemaker/22_accelerate_sagemaker_examples/src/seq2seq/launch.sh/0 | {
"file_path": "notebooks/sagemaker/22_accelerate_sagemaker_examples/src/seq2seq/launch.sh",
"repo_id": "notebooks",
"token_count": 355
} | 172 |
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
def model_fn(model_dir):
# load model and processor from model_dir
model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto", load_in_8bit=True)
tokenizer = AutoTokenizer.from_pretrained(model_dir)
return model,... | notebooks/sagemaker/24_train_bloom_peft_lora/scripts/inference.py/0 | {
"file_path": "notebooks/sagemaker/24_train_bloom_peft_lora/scripts/inference.py",
"repo_id": "notebooks",
"token_count": 348
} | 173 |
<jupyter_start><jupyter_text>Evaluate LLMs with Hugging Face Lighteval on Amazon SageMakerIn this sagemaker example, we are going to learn how to evaluate LLMs using Hugging Face [lighteval](https://github.com/huggingface/lighteval/tree/main). LightEval is a lightweight LLM evaluation suite that powers [Hugging Face O... | notebooks/sagemaker/30_evaluate_llms_with_lighteval/sagemaker-notebook.ipynb/0 | {
"file_path": "notebooks/sagemaker/30_evaluate_llms_with_lighteval/sagemaker-notebook.ipynb",
"repo_id": "notebooks",
"token_count": 3115
} | 174 |
<!--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... | peft/docs/source/developer_guides/contributing.md/0 | {
"file_path": "peft/docs/source/developer_guides/contributing.md",
"repo_id": "peft",
"token_count": 1620
} | 175 |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | peft/docs/source/task_guides/prompt_based_methods.md/0 | {
"file_path": "peft/docs/source/task_guides/prompt_based_methods.md",
"repo_id": "peft",
"token_count": 4607
} | 176 |
import gc
import os
import sys
import threading
import psutil
import torch
from accelerate import Accelerator
from datasets import load_dataset
from torch.utils.data import DataLoader
from tqdm import tqdm
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from pe... | peft/examples/conditional_generation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py/0 | {
"file_path": "peft/examples/conditional_generation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py",
"repo_id": "peft",
"token_count": 5607
} | 177 |
import argparse
import gc
import json
import logging
import math
import os
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from random import randint
from typing import Any, Dict, List, Union
# datasets imports
import datasets
# metric imports
import evaluate
import numpy as n... | peft/examples/int8_training/peft_adalora_whisper_large_training.py/0 | {
"file_path": "peft/examples/int8_training/peft_adalora_whisper_large_training.py",
"repo_id": "peft",
"token_count": 13114
} | 178 |
compute_environment: LOCAL_MACHINE
debug: false
deepspeed_config:
deepspeed_multinode_launcher: standard
offload_optimizer_device: none
offload_param_device: none
zero3_init... | peft/examples/sft/configs/deepspeed_config_z3_qlora.yaml/0 | {
"file_path": "peft/examples/sft/configs/deepspeed_config_z3_qlora.yaml",
"repo_id": "peft",
"token_count": 331
} | 179 |
<jupyter_start><jupyter_text>IntroductionIn this notebook, we are going to fine-tune the LayoutLM model by Microsoft Research on the [FUNSD](https://guillaumejaume.github.io/FUNSD/) dataset, which is a collection of annotated form documents. The goal of our model is to learn the annotations of a number of labels ("ques... | peft/examples/token_classification/peft_lora_token_cls.ipynb/0 | {
"file_path": "peft/examples/token_classification/peft_lora_token_cls.ipynb",
"repo_id": "peft",
"token_count": 11949
} | 180 |
# Copyright 2023-present 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 law or... | peft/src/peft/tuners/ia3/layer.py/0 | {
"file_path": "peft/src/peft/tuners/ia3/layer.py",
"repo_id": "peft",
"token_count": 6410
} | 181 |
# Copyright 2023-present 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 law or... | peft/src/peft/tuners/lora/layer.py/0 | {
"file_path": "peft/src/peft/tuners/lora/layer.py",
"repo_id": "peft",
"token_count": 22293
} | 182 |
# Copyright 2024-present 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 law or... | peft/src/peft/utils/merge_utils.py/0 | {
"file_path": "peft/src/peft/utils/merge_utils.py",
"repo_id": "peft",
"token_count": 3819
} | 183 |
*This guideline is very much a work-in-progress.*
Contributions to `timm` for code, documentation, tests are more than welcome!
There haven't been any formal guidelines to date so please bear with me, and feel free to add to this guide.
# Coding style
Code linting and auto-format (black) are not currently in place ... | pytorch-image-models/CONTRIBUTING.md/0 | {
"file_path": "pytorch-image-models/CONTRIBUTING.md",
"repo_id": "pytorch-image-models",
"token_count": 1224
} | 184 |
# Model Summaries
The model architectures included come from a wide variety of sources. Sources, including papers, original impl ("reference code") that I rewrote / adapted, and PyTorch impl that I leveraged directly ("code") are listed below.
Most included models have pretrained weights. The weights are either:
1. ... | pytorch-image-models/docs/models.md/0 | {
"file_path": "pytorch-image-models/docs/models.md",
"repo_id": "pytorch-image-models",
"token_count": 4347
} | 185 |
# # Ensemble Adversarial Inception ResNet v2
**Inception-ResNet-v2** is a convolutional neural architecture that builds on the Inception family of architectures but incorporates [residual connections](https://paperswithcode.com/method/residual-connection) (replacing the filter concatenation stage of the Inception arch... | pytorch-image-models/docs/models/.templates/models/ensemble-adversarial.md/0 | {
"file_path": "pytorch-image-models/docs/models/.templates/models/ensemble-adversarial.md",
"repo_id": "pytorch-image-models",
"token_count": 1379
} | 186 |
# (Legacy) SENet
A **SENet** is a convolutional neural network architecture that employs [squeeze-and-excitation blocks](https://paperswithcode.com/method/squeeze-and-excitation-block) to enable the network to perform dynamic channel-wise feature recalibration.
The weights from this model were ported from Gluon.
{% ... | pytorch-image-models/docs/models/.templates/models/legacy-senet.md/0 | {
"file_path": "pytorch-image-models/docs/models/.templates/models/legacy-senet.md",
"repo_id": "pytorch-image-models",
"token_count": 793
} | 187 |
# RexNet
**Rank Expansion Networks** (ReXNets) follow a set of new design principles for designing bottlenecks in image classification models. Authors refine each layer by 1) expanding the input channel size of the convolution layer and 2) replacing the [ReLU6s](https://www.paperswithcode.com/method/relu6).
{% includ... | pytorch-image-models/docs/models/.templates/models/rexnet.md/0 | {
"file_path": "pytorch-image-models/docs/models/.templates/models/rexnet.md",
"repo_id": "pytorch-image-models",
"token_count": 2278
} | 188 |
# (Tensorflow) MobileNet v3
**MobileNetV3** is a convolutional neural network that is designed for mobile phone CPUs. The network design includes the use of a [hard swish activation](https://paperswithcode.com/method/hard-swish) and [squeeze-and-excitation](https://paperswithcode.com/method/squeeze-and-excitation-bloc... | pytorch-image-models/docs/models/.templates/models/tf-mobilenet-v3.md/0 | {
"file_path": "pytorch-image-models/docs/models/.templates/models/tf-mobilenet-v3.md",
"repo_id": "pytorch-image-models",
"token_count": 3951
} | 189 |
# Adversarial Inception v3
**Inception v3** is a convolutional neural network architecture from the Inception family that makes several improvements including using [Label Smoothing](https://paperswithcode.com/method/label-smoothing), Factorized 7 x 7 convolutions, and the use of an [auxiliary classifer](https://paper... | pytorch-image-models/hfdocs/source/models/adversarial-inception-v3.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/adversarial-inception-v3.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2247
} | 190 |
# (Gluon) ResNet
**Residual Networks**, or **ResNets**, learn residual functions with reference to the layer inputs, instead of learning unreferenced functions. Instead of hoping each few stacked layers directly fit a desired underlying mapping, residual nets let these layers fit a residual mapping. They stack [residu... | pytorch-image-models/hfdocs/source/models/gloun-resnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/gloun-resnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 7210
} | 191 |
# SK-ResNet
**SK ResNet** is a variant of a [ResNet](https://www.paperswithcode.com/method/resnet) that employs a [Selective Kernel](https://paperswithcode.com/method/selective-kernel) unit. In general, all the large kernel convolutions in the original bottleneck blocks in ResNet are replaced by the proposed [SK convo... | pytorch-image-models/hfdocs/source/models/skresnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/skresnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2082
} | 192 |
# Data
[[autodoc]] timm.data.create_dataset
[[autodoc]] timm.data.create_loader
[[autodoc]] timm.data.create_transform
[[autodoc]] timm.data.resolve_data_config | pytorch-image-models/hfdocs/source/reference/data.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/reference/data.mdx",
"repo_id": "pytorch-image-models",
"token_count": 67
} | 193 |
from abc import abstractmethod
class Reader:
def __init__(self):
pass
@abstractmethod
def _filename(self, index, basename=False, absolute=False):
pass
def filename(self, index, basename=False, absolute=False):
return self._filename(index, basename=basename, absolute=absolute)... | pytorch-image-models/timm/data/readers/reader.py/0 | {
"file_path": "pytorch-image-models/timm/data/readers/reader.py",
"repo_id": "pytorch-image-models",
"token_count": 171
} | 194 |
""" Activations
A collection of jit-scripted activations fn and modules with a common interface so that they can
easily be swapped. All have an `inplace` arg even if not used.
All jit scripted activations are lacking in-place variations on purpose, scripted kernel fusion does not
currently work across in-place op bou... | pytorch-image-models/timm/layers/activations_jit.py/0 | {
"file_path": "pytorch-image-models/timm/layers/activations_jit.py",
"repo_id": "pytorch-image-models",
"token_count": 1008
} | 195 |
""" Norm Layer Factory
Create norm modules by string (to mirror create_act and creat_norm-act fns)
Copyright 2022 Ross Wightman
"""
import functools
import types
from typing import Type
import torch.nn as nn
from .norm import GroupNorm, GroupNorm1, LayerNorm, LayerNorm2d, RmsNorm
from torchvision.ops.misc import Fr... | pytorch-image-models/timm/layers/create_norm.py/0 | {
"file_path": "pytorch-image-models/timm/layers/create_norm.py",
"repo_id": "pytorch-image-models",
"token_count": 630
} | 196 |
""" Lambda Layer
Paper: `LambdaNetworks: Modeling Long-Range Interactions Without Attention`
- https://arxiv.org/abs/2102.08602
@misc{2102.08602,
Author = {Irwan Bello},
Title = {LambdaNetworks: Modeling Long-Range Interactions Without Attention},
Year = {2021},
}
Status:
This impl is a WIP. Code snippets in the... | pytorch-image-models/timm/layers/lambda_layer.py/0 | {
"file_path": "pytorch-image-models/timm/layers/lambda_layer.py",
"repo_id": "pytorch-image-models",
"token_count": 2611
} | 197 |
""" Selective Kernel Convolution/Attention
Paper: Selective Kernel Networks (https://arxiv.org/abs/1903.06586)
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch
from torch import nn as nn
from .conv_bn_act import ConvNormActAa
from .helpers import make_divisible
from .trace_utils import _assert
de... | pytorch-image-models/timm/layers/selective_kernel.py/0 | {
"file_path": "pytorch-image-models/timm/layers/selective_kernel.py",
"repo_id": "pytorch-image-models",
"token_count": 2318
} | 198 |
from .beit import *
from .byoanet import *
from .byobnet import *
from .cait import *
from .coat import *
from .convit import *
from .convmixer import *
from .convnext import *
from .crossvit import *
from .cspnet import *
from .davit import *
from .deit import *
from .densenet import *
from .dla import *
from .dpn imp... | pytorch-image-models/timm/models/__init__.py/0 | {
"file_path": "pytorch-image-models/timm/models/__init__.py",
"repo_id": "pytorch-image-models",
"token_count": 1077
} | 199 |
""" PyTorch implementation of DualPathNetworks
Based on original MXNet implementation https://github.com/cypw/DPNs with
many ideas from another PyTorch implementation https://github.com/oyam/pytorch-DPNs.
This implementation is compatible with the pretrained weights from cypw's MXNet implementation.
Hacked together b... | pytorch-image-models/timm/models/dpn.py/0 | {
"file_path": "pytorch-image-models/timm/models/dpn.py",
"repo_id": "pytorch-image-models",
"token_count": 6985
} | 200 |
from ._builder import *
from ._helpers import *
from ._manipulate import *
from ._prune import *
import warnings
warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.models", DeprecationWarning)
| pytorch-image-models/timm/models/helpers.py/0 | {
"file_path": "pytorch-image-models/timm/models/helpers.py",
"repo_id": "pytorch-image-models",
"token_count": 64
} | 201 |
""" NasNet-A (Large)
nasnetalarge implementation grabbed from Cadene's pretrained models
https://github.com/Cadene/pretrained-models.pytorch
"""
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.layers import ConvNormAct, create_conv2d, create_pool2d, create_... | pytorch-image-models/timm/models/nasnet.py/0 | {
"file_path": "pytorch-image-models/timm/models/nasnet.py",
"repo_id": "pytorch-image-models",
"token_count": 13247
} | 202 |
"""PyTorch SelecSLS Net example for ImageNet Classification
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/legalcode)
Author: Dushyant Mehta (@mehtadushy)
SelecSLS (core) Network Architecture as proposed in "XNect: Real-time Multi-person 3D
Human Pose Estimation with a Single RGB Camera, Mehta et al."... | pytorch-image-models/timm/models/selecsls.py/0 | {
"file_path": "pytorch-image-models/timm/models/selecsls.py",
"repo_id": "pytorch-image-models",
"token_count": 6442
} | 203 |
""" Vision Transformer (ViT) in PyTorch
A PyTorch implement of Vision Transformers as described in:
'Exploring Plain Vision Transformer Backbones for Object Detection'
- https://arxiv.org/abs/2203.16527
'Segment Anything Model (SAM)'
- https://github.com/facebookresearch/segment-anything/
"""
import logging... | pytorch-image-models/timm/models/vision_transformer_sam.py/0 | {
"file_path": "pytorch-image-models/timm/models/vision_transformer_sam.py",
"repo_id": "pytorch-image-models",
"token_count": 12451
} | 204 |
""" Lookahead Optimizer Wrapper.
Implementation modified from: https://github.com/alphadl/lookahead.pytorch
Paper: `Lookahead Optimizer: k steps forward, 1 step back` - https://arxiv.org/abs/1907.08610
Hacked together by / Copyright 2020 Ross Wightman
"""
from collections import OrderedDict
from typing import Callable... | pytorch-image-models/timm/optim/lookahead.py/0 | {
"file_path": "pytorch-image-models/timm/optim/lookahead.py",
"repo_id": "pytorch-image-models",
"token_count": 1134
} | 205 |
""" Scheduler Factory
Hacked together by / Copyright 2021 Ross Wightman
"""
from typing import List, Optional, Union
from torch.optim import Optimizer
from .cosine_lr import CosineLRScheduler
from .multistep_lr import MultiStepLRScheduler
from .plateau_lr import PlateauLRScheduler
from .poly_lr import PolyLRScheduler... | pytorch-image-models/timm/scheduler/scheduler_factory.py/0 | {
"file_path": "pytorch-image-models/timm/scheduler/scheduler_factory.py",
"repo_id": "pytorch-image-models",
"token_count": 3467
} | 206 |
from typing import Optional, Tuple, List
import torch
def onnx_forward(onnx_file, example_input):
import onnxruntime
sess_options = onnxruntime.SessionOptions()
session = onnxruntime.InferenceSession(onnx_file, sess_options)
input_name = session.get_inputs()[0].name
output = session.run([], {inp... | pytorch-image-models/timm/utils/onnx.py/0 | {
"file_path": "pytorch-image-models/timm/utils/onnx.py",
"repo_id": "pytorch-image-models",
"token_count": 1722
} | 207 |
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: docs/source/basic_tutorials/launcher.md
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
- ... | text-generation-inference/.pre-commit-config.yaml/0 | {
"file_path": "text-generation-inference/.pre-commit-config.yaml",
"repo_id": "text-generation-inference",
"token_count": 226
} | 208 |
/// Text Generation Inference benchmarking tool
///
/// Inspired by the great Oha app: https://github.com/hatoo/oha
/// and: https://github.com/orhun/rust-tui-template
use clap::Parser;
use std::path::Path;
use text_generation_client::ShardedClient;
use tokenizers::{FromPretrainedParameters, Tokenizer};
use tracing_sub... | text-generation-inference/benchmark/src/main.rs/0 | {
"file_path": "text-generation-inference/benchmark/src/main.rs",
"repo_id": "text-generation-inference",
"token_count": 3113
} | 209 |
import os
import requests
from typing import Dict, Optional, List
from huggingface_hub.utils import build_hf_headers
from text_generation import Client, AsyncClient, __version__
from text_generation.types import DeployedModel
from text_generation.errors import NotSupportedError, parse_error
INFERENCE_ENDPOINT = os.e... | text-generation-inference/clients/python/text_generation/inference_api.py/0 | {
"file_path": "text-generation-inference/clients/python/text_generation/inference_api.py",
"repo_id": "text-generation-inference",
"token_count": 2183
} | 210 |
## Speculation
Speculative decoding, assisted generation, Medusa, and others are a few different names for the same idea.
The idea is to generate tokens *before* the large model actually runs, and only *check* if those tokens where valid.
So you are making *more* computations on your LLM, but if you are correct you p... | text-generation-inference/docs/source/conceptual/speculation.md/0 | {
"file_path": "text-generation-inference/docs/source/conceptual/speculation.md",
"repo_id": "text-generation-inference",
"token_count": 671
} | 211 |
[
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [
{
"id": 1,
"logprob": null,
"text": "<s>"
},
{
"id": 4321,
"logprob": -8.6875,
"text": "Test"
... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama/test_flash_llama_load.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama/test_flash_llama_load.json",
"repo_id": "text-generation-inference",
"token_count": 4901
} | 212 |
[
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [
{
"id": 14402,
"logprob": null,
"text": "Test"
},
{
"id": 2581,
"logprob": -11.6171875,
"text": " ... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_phi/test_flash_phi_load.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_phi/test_flash_phi_load.json",
"repo_id": "text-generation-inference",
"token_count": 4672
} | 213 |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [
{
"id": 1,
"logprob": null,
"text": "<s>"
},
{
"id": 4911,
"logprob": -6.9765625,
"text": "User"
},
{
"id": 29... | text-generation-inference/integration-tests/models/__snapshots__/test_idefics/test_idefics.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_idefics/test_idefics.json",
"repo_id": "text-generation-inference",
"token_count": 2062
} | 214 |
{
"choices": [
{
"finish_reason": "length",
"index": 0,
"logprobs": null,
"message": {
"content": "As of today, there is a Update available for the Brooklyn, New York, area. According to the latest forecast, it's warm with high temperatures throughout the day. It's forecasted at 75... | text-generation-inference/integration-tests/models/__snapshots__/test_tools_llama/test_flash_llama_grammar_no_tools.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_tools_llama/test_flash_llama_grammar_no_tools.json",
"repo_id": "text-generation-inference",
"token_count": 355
} | 215 |
import pytest
@pytest.fixture(scope="module")
def flash_neox_handle(launcher):
with launcher("stabilityai/stablelm-tuned-alpha-3b", num_shard=1) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_neox(flash_neox_handle):
await flash_neox_handle.health(300)
return flash_neox_... | text-generation-inference/integration-tests/models/test_flash_neox.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_neox.py",
"repo_id": "text-generation-inference",
"token_count": 498
} | 216 |
import pytest
import json
from text_generation.types import GrammarType
@pytest.fixture(scope="module")
def flash_llama_grammar_tools_handle(launcher):
with launcher(
"TinyLlama/TinyLlama-1.1B-Chat-v1.0", num_shard=2, disable_grammar_support=False
) as handle:
yield handle
@pytest.fixture(s... | text-generation-inference/integration-tests/models/test_tools_llama.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_tools_llama.py",
"repo_id": "text-generation-inference",
"token_count": 3763
} | 217 |
use std::error::Error;
use vergen::EmitBuilder;
fn main() -> Result<(), Box<dyn Error>> {
// Try to get the git sha from the local git repository
if EmitBuilder::builder()
.fail_on_error()
.git_sha(false)
.emit()
.is_err()
{
// Unable to get the git sha
if le... | text-generation-inference/router/build.rs/0 | {
"file_path": "text-generation-inference/router/build.rs",
"repo_id": "text-generation-inference",
"token_count": 324
} | 218 |
[toolchain]
# Released on: 28 December, 2023
# Branched from master on: 10 November, 2023
# https://releases.rs/docs/1.75.0/
channel = "1.75.0"
components = ["rustfmt", "clippy"]
| text-generation-inference/rust-toolchain.toml/0 | {
"file_path": "text-generation-inference/rust-toolchain.toml",
"repo_id": "text-generation-inference",
"token_count": 69
} | 219 |
// Adapted from turboderp exllama: https://github.com/turboderp/exllama
#ifndef _cuda_buffers_cuh
#define _cuda_buffers_cuh
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include <cstdint>
#include <cstdio>
const int CUDA_MAX_DEVICES = 16;
// #ifndef _cuda_buffers_cu
// extern __constant__ half2 q4_table[16][256... | text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_buffers.cuh/0 | {
"file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_buffers.cuh",
"repo_id": "text-generation-inference",
"token_count": 471
} | 220 |
#ifndef _matrix_view_cuh
#define _matrix_view_cuh
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include "quant/qdq_util.cuh"
class MatrixView_half
{
public:
const half* data;
const int height;
const int width;
__device__ __forceinline__ MatrixView_half(const half* data, const int height, const i... | text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/matrix_view.cuh/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/matrix_view.cuh",
"repo_id": "text-generation-inference",
"token_count": 1862
} | 221 |
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import torch
extra_cuda_cflags = ["-lineinfo", "-O3"]
if torch.version.hip:
extra_cuda_cflags += ["-DHIPBLAS_USE_HIP_HALF"]
extra_compile_args = {
"nvcc": extra_cuda_cflags,
}
setup(
name="exllamav2_kernels"... | text-generation-inference/server/exllamav2_kernels/setup.py/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/setup.py",
"repo_id": "text-generation-inference",
"token_count": 363
} | 222 |
# test_watermark_logits_processor.py
import os
import numpy as np
import torch
from text_generation_server.utils.watermark import WatermarkLogitsProcessor
GAMMA = os.getenv("WATERMARK_GAMMA", 0.5)
DELTA = os.getenv("WATERMARK_DELTA", 2.0)
def test_seed_rng():
input_ids = [101, 2036, 3731, 102, 2003, 103]
p... | text-generation-inference/server/tests/utils/test_watermark.py/0 | {
"file_path": "text-generation-inference/server/tests/utils/test_watermark.py",
"repo_id": "text-generation-inference",
"token_count": 781
} | 223 |
import torch
import torch.distributed
from torch import nn
from transformers.activations import ACT2FN
from transformers.configuration_utils import PretrainedConfig
from typing import Optional, List, Tuple
from text_generation_server.utils import paged_attention, flash_attn
from text_generation_server.utils.layers im... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_phi_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_phi_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 6564
} | 224 |
# coding=utf-8
# Copyright 2018 Mesh TensorFlow authors, T5 Authors and 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... | text-generation-inference/server/text_generation_server/models/custom_modeling/t5_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/t5_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 22496
} | 225 |
import torch
import time
from dataclasses import dataclass
from opentelemetry import trace
from transformers import (
AutoProcessor,
AutoTokenizer,
PreTrainedTokenizerBase,
ProcessorMixin,
)
from typing import Optional, Tuple, List, Type, Dict
from text_generation_server.models import Model
from text_... | text-generation-inference/server/text_generation_server/models/idefics_causal_lm.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/idefics_causal_lm.py",
"repo_id": "text-generation-inference",
"token_count": 16378
} | 226 |
# Copied logic from https://github.com/mit-han-lab/llm-awq/blob/f084f40bd996f3cf3a0633c1ad7d9d476c318aaa/awq/quantize/qmodule.py
import math
import torch
import torch.nn as nn
import awq_inference_engine # with CUDA kernels
# class ScaledActivation(nn.Module):
# def __init__(self, module, scales):
# sup... | text-generation-inference/server/text_generation_server/utils/awq/quantize/qmodule.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/awq/quantize/qmodule.py",
"repo_id": "text-generation-inference",
"token_count": 770
} | 227 |
SPECULATE = None
def get_speculate() -> int:
global SPECULATE
return SPECULATE
def set_speculate(speculate: int):
global SPECULATE
SPECULATE = speculate
| text-generation-inference/server/text_generation_server/utils/speculate.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/speculate.py",
"repo_id": "text-generation-inference",
"token_count": 66
} | 228 |
/* eslint-disable @typescript-eslint/no-explicit-any */
import { bertProcessing, byteLevelProcessing, robertaProcessing, sequenceProcessing, templateProcessing } from '../../'
describe('bertProcessing', () => {
it('instantiates correctly with only two parameters', () => {
const processor = bertProcessing(['sep'... | tokenizers/bindings/node/lib/bindings/post-processors.test.ts/0 | {
"file_path": "tokenizers/bindings/node/lib/bindings/post-processors.test.ts",
"repo_id": "tokenizers",
"token_count": 1022
} | 229 |
# `tokenizers-linux-arm64-gnu`
This is the **aarch64-unknown-linux-gnu** binary for `tokenizers`
| tokenizers/bindings/node/npm/linux-arm64-gnu/README.md/0 | {
"file_path": "tokenizers/bindings/node/npm/linux-arm64-gnu/README.md",
"repo_id": "tokenizers",
"token_count": 35
} | 230 |
use serde::de::Deserializer;
use serde::ser::Serializer;
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
pub fn serialize<S, T>(val: &Option<Arc<RwLock<T>>>, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
T: Serialize,
{
T::serialize(&*(val.clone().unwrap()).read().unwrap(), s)
}
pub f... | tokenizers/bindings/node/src/arc_rwlock_serde.rs/0 | {
"file_path": "tokenizers/bindings/node/src/arc_rwlock_serde.rs",
"repo_id": "tokenizers",
"token_count": 220
} | 231 |
# Generated content DO NOT EDIT
class AddedToken:
"""
Represents a token that can be be added to a :class:`~tokenizers.Tokenizer`.
It can have special options that defines the way it should behave.
Args:
content (:obj:`str`): The content of the token
single_word (:obj:`bool`, defaults ... | tokenizers/bindings/python/py_src/tokenizers/__init__.pyi/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/__init__.pyi",
"repo_id": "tokenizers",
"token_count": 16502
} | 232 |
# Generated content DO NOT EDIT
from .. import processors
PostProcessor = processors.PostProcessor
BertProcessing = processors.BertProcessing
ByteLevel = processors.ByteLevel
RobertaProcessing = processors.RobertaProcessing
Sequence = processors.Sequence
TemplateProcessing = processors.TemplateProcessing
| tokenizers/bindings/python/py_src/tokenizers/processors/__init__.py/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/processors/__init__.py",
"repo_id": "tokenizers",
"token_count": 74
} | 233 |
#![warn(clippy::all)]
#![allow(clippy::upper_case_acronyms)]
// Many false positives with pyo3 it seems &str, and &PyAny get flagged
#![allow(clippy::borrow_deref_ref)]
extern crate tokenizers as tk;
mod decoders;
mod encoding;
mod error;
mod models;
mod normalizers;
mod pre_tokenizers;
mod processors;
mod token;
mod... | tokenizers/bindings/python/src/lib.rs/0 | {
"file_path": "tokenizers/bindings/python/src/lib.rs",
"repo_id": "tokenizers",
"token_count": 1086
} | 234 |
from tokenizers import ByteLevelBPETokenizer
from ..utils import data_dir, multiprocessing_with_parallelism, roberta_files
class TestByteLevelBPE:
def test_basic_encode(self, roberta_files):
tokenizer = ByteLevelBPETokenizer.from_file(roberta_files["vocab"], roberta_files["merges"])
output = toke... | tokenizers/bindings/python/tests/implementations/test_byte_level_bpe.py/0 | {
"file_path": "tokenizers/bindings/python/tests/implementations/test_byte_level_bpe.py",
"repo_id": "tokenizers",
"token_count": 1653
} | 235 |
# Pre-tokenizers
<tokenizerslangcontent>
<python>
## BertPreTokenizer
[[autodoc]] tokenizers.pre_tokenizers.BertPreTokenizer
## ByteLevel
[[autodoc]] tokenizers.pre_tokenizers.ByteLevel
## CharDelimiterSplit
[[autodoc]] tokenizers.pre_tokenizers.CharDelimiterSplit
## Digits
[[autodoc]] tokenizers.pre_tokenizers... | tokenizers/docs/source-doc-builder/api/pre-tokenizers.mdx/0 | {
"file_path": "tokenizers/docs/source-doc-builder/api/pre-tokenizers.mdx",
"repo_id": "tokenizers",
"token_count": 371
} | 236 |
The tokenization pipeline
====================================================================================================
When calling :entity:`Tokenizer.encode` or :entity:`Tokenizer.encode_batch`, the input text(s) go
through the following pipeline:
- :ref:`normalization`
- :ref:`pre-tokenization`
- :ref:`mode... | tokenizers/docs/source/pipeline.rst/0 | {
"file_path": "tokenizers/docs/source/pipeline.rst",
"repo_id": "tokenizers",
"token_count": 6323
} | 237 |
[package]
name = "unstable_wasm"
version = "0.1.0"
authors = ["Nicolas Patry"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[features]
default = ["console_error_panic_hook"]
[dependencies]
wasm-bindgen = "0.2.63"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them ... | tokenizers/tokenizers/examples/unstable_wasm/Cargo.toml/0 | {
"file_path": "tokenizers/tokenizers/examples/unstable_wasm/Cargo.toml",
"repo_id": "tokenizers",
"token_count": 364
} | 238 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.