text
stringlengths
7
328k
id
stringlengths
14
166
metadata
dict
__index_level_0__
int64
0
459
# 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/latent_diffusion/test_latent_diffusion.py/0
{ "file_path": "diffusers/tests/pipelines/latent_diffusion/test_latent_diffusion.py", "repo_id": "diffusers", "token_count": 3341 }
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/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py/0
{ "file_path": "diffusers/tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py", "repo_id": "diffusers", "token_count": 31962 }
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/pipelines/stable_diffusion_gligen/test_stable_diffusion_gligen.py/0
{ "file_path": "diffusers/tests/pipelines/stable_diffusion_gligen/test_stable_diffusion_gligen.py", "repo_id": "diffusers", "token_count": 2745 }
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/stable_diffusion_xl/test_stable_diffusion_xl.py/0
{ "file_path": "diffusers/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl.py", "repo_id": "diffusers", "token_count": 22841 }
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/test_pipelines_flax.py/0
{ "file_path": "diffusers/tests/pipelines/test_pipelines_flax.py", "repo_id": "diffusers", "token_count": 4559 }
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/schedulers/test_scheduler_flax.py/0
{ "file_path": "diffusers/tests/schedulers/test_scheduler_flax.py", "repo_id": "diffusers", "token_count": 18869 }
151
# 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_copies.py/0
{ "file_path": "diffusers/utils/check_copies.py", "repo_id": "diffusers", "token_count": 3397 }
152
<jupyter_start><jupyter_text>Diffusion for Audio In this notebook, we're going to take a brief look at generating audio with diffusion models. What you will learn:- How audio is represented in a computer- Methods to convert between raw audio data and spectrograms- How to prepare a dataloader with a custom collate funct...
diffusion-models-class/unit4/02_diffusion_for_audio.ipynb/0
{ "file_path": "diffusion-models-class/unit4/02_diffusion_for_audio.ipynb", "repo_id": "diffusion-models-class", "token_count": 4553 }
153
# Making a Class-Conditioned Diffusion Model <CourseFloatingBanner unit={2} classNames="absolute z-10 right-0 top-0" notebooks={[ {label: "Making a Class-Conditioned Diffusion Model", value: "https://colab.research.google.com/github/huggingface/diffusion-models-class/blob/main/units/en/unit2/class_conditioned_...
diffusion-models-class/units/en/unit2/3.mdx/0
{ "file_path": "diffusion-models-class/units/en/unit2/3.mdx", "repo_id": "diffusion-models-class", "token_count": 2985 }
154
<jupyter_start><jupyter_text>Introduction à 🤗 Diffusers Dans ce *notebook*, vous allez entraîner votre premier modèle de diffusion pour générer des images de mignons papillons 🦋. En cours de route, vous apprendrez les composants de base de la bibliothèque 🤗 *Diffusers*, qui fournira une bonne assise pour les applica...
diffusion-models-class/units/fr/unit1/introduction_to_diffusers.ipynb/0
{ "file_path": "diffusion-models-class/units/fr/unit1/introduction_to_diffusers.ipynb", "repo_id": "diffusion-models-class", "token_count": 11144 }
155
<jupyter_start><jupyter_text>Introduction à Stable DiffusionCe *notebook* va couvrir les bases de l'utilisation de Stable Diffusion pour créer et modifier des images en utilisant les pipelines existants. Nous allons également jeter un bref coup d'œil aux composants clés au sein du pipeline, tout en laissant une explora...
diffusion-models-class/units/fr/unit3/stable_diffusion_introduction.ipynb/0
{ "file_path": "diffusion-models-class/units/fr/unit3/stable_diffusion_introduction.ipynb", "repo_id": "diffusion-models-class", "token_count": 8445 }
156
<jupyter_start><jupyter_text>Derrière le pipeline (TensorFlow) Installez la bibliothèque 🤗 *Transformers* pour exécuter ce *notebook*.<jupyter_code>!pip install transformers[sentencepiece] from transformers import pipeline classifier = pipeline("sentiment-analysis", model="tblard/tf-allocine") classifier( ["J'ai ...
notebooks/course/fr/chapter2/section2_tf.ipynb/0
{ "file_path": "notebooks/course/fr/chapter2/section2_tf.ipynb", "repo_id": "notebooks", "token_count": 473 }
157
<jupyter_start><jupyter_text>Utilisation 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] from transformers import pipeline camembert_fill_mask = pipeline("fill-mask", model="camembert-base") results...
notebooks/course/fr/chapter4/section2_pt.ipynb/0
{ "file_path": "notebooks/course/fr/chapter4/section2_pt.ipynb", "repo_id": "notebooks", "token_count": 259 }
158
<jupyter_start><jupyter_text>Normalisation et prétokenization. Installez les bibliothèques 🤗 *Transformers* et 🤗 *Datasets* pour exécuter ce *notebook*.<jupyter_code>!pip install datasets transformers[sentencepiece] from transformers import AutoTokenizer tokenizer = AutoTokenizer.from_pretrained("camembert-base") p...
notebooks/course/fr/chapter6/section4.ipynb/0
{ "file_path": "notebooks/course/fr/chapter6/section4.ipynb", "repo_id": "notebooks", "token_count": 362 }
159
<jupyter_start><jupyter_text>Réponses aux questions (TensorFlow) Installez les bibliothèques Transformers et Datasets 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 v...
notebooks/course/fr/chapter7/section7_tf.ipynb/0
{ "file_path": "notebooks/course/fr/chapter7/section7_tf.ipynb", "repo_id": "notebooks", "token_count": 6501 }
160
<jupyter_start><jupyter_text>ver since Stable Diffusion took the world by storm, people have been looking for ways to have more control over the results of the generation process. ControlNet provides a minimal interface allowing users to customize the generation process up to a great extent. With [ControlNet](https://h...
notebooks/diffusers/controlnet.ipynb/0
{ "file_path": "notebooks/diffusers/controlnet.ipynb", "repo_id": "notebooks", "token_count": 4606 }
161
<jupyter_start><jupyter_text>🧨 Fast Stable Diffusion in free Colab with JAX / Flax on TPU!🤗 Hugging Face [Diffusers](https://github.com/huggingface/diffusers) supports Flax since version `0.5.1`! This allows for snappy inference on Google TPUs, such as those available in Colab, Kaggle or through Google Cloud Platform...
notebooks/diffusers/stable_diffusion_fast_jax.ipynb/0
{ "file_path": "notebooks/diffusers/stable_diffusion_fast_jax.ipynb", "repo_id": "notebooks", "token_count": 1808 }
162
<jupyter_start><jupyter_text>Before we can browse the rest of the notebook, we need to install the dependencies: this example uses `datasets` and `transformers`. To use TPUs on colab, we need to install `torch_xla` and the last line install `accelerate` from source since we the features we are using are very recent and...
notebooks/examples/accelerate_examples/simple_nlp_example.ipynb/0
{ "file_path": "notebooks/examples/accelerate_examples/simple_nlp_example.ipynb", "repo_id": "notebooks", "token_count": 6454 }
163
<jupyter_start><jupyter_text>Fine-tune Pix2Struct using Hugging Face `transformers` and `datasets` 🤗This tutorial is largely based from the [GiT tutorial](https://colab.research.google.com/drive/1HLxgrG7xZJ9FvXckNG61J72FkyrbqKAA?usp=sharing) on how to fine-tune GiT on a custom image captioning dataset. Here we will us...
notebooks/examples/image_captioning_pix2struct.ipynb/0
{ "file_path": "notebooks/examples/image_captioning_pix2struct.ipynb", "repo_id": "notebooks", "token_count": 3848 }
164
<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 transformers datasets huggingface_hub<jupyter_output><empty_output><jupyter_text>If you're opening this notebook ...
notebooks/examples/language_modeling_from_scratch-tf.ipynb/0
{ "file_path": "notebooks/examples/language_modeling_from_scratch-tf.ipynb", "repo_id": "notebooks", "token_count": 7396 }
165
<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<jupyter_output><empty_output><jupyter_text>If you're opening this notebook locally, make su...
notebooks/examples/question_answering.ipynb/0
{ "file_path": "notebooks/examples/question_answering.ipynb", "repo_id": "notebooks", "token_count": 15331 }
166
<jupyter_start><jupyter_text>Time Series DatasetsThis notebook shows how to create a time series dataset from some csv file in order to then share it on the [🤗 hub](https://huggingface.co/docs/datasets/index). We will use the GluonTS library to read the csv into the appropriate format. We start by installing the libra...
notebooks/examples/time_series_datasets.ipynb/0
{ "file_path": "notebooks/examples/time_series_datasets.ipynb", "repo_id": "notebooks", "token_count": 975 }
167
<jupyter_start><jupyter_text>Huggingface Sagemaker-sdk - Run a batch transform inference job with 🤗 Transformers 1. [Introduction](Introduction) 2. [Run Batch Transform after training a model](Run-Batch-Transform-after-training-a-model) 3. [Run Batch Transform Inference Job with a fine-tuned model using `jsonl`](Run...
notebooks/sagemaker/12_batch_transform_inference/sagemaker-notebook.ipynb/0
{ "file_path": "notebooks/sagemaker/12_batch_transform_inference/sagemaker-notebook.ipynb", "repo_id": "notebooks", "token_count": 2457 }
168
# accelerate-aws-sagemaker Examples showcasing AWS SageMaker integration of 🤗 Accelerate. Just give the `accelerate config` and do `accelerate launch` 🚀. It's as simple as that! 1. Set up the accelerate config by running `accelerate config --config_file accelerate_config.yaml` and answer the SageMaker questions. 2....
notebooks/sagemaker/22_accelerate_sagemaker_examples/README.md/0
{ "file_path": "notebooks/sagemaker/22_accelerate_sagemaker_examples/README.md", "repo_id": "notebooks", "token_count": 3628 }
169
<jupyter_start><jupyter_text>Stable Diffusion on Amazon SageMakerWelcome to this Amazon SageMaker guide on how to use the [Stable Diffusion](https://huggingface.co/blog/stable_diffusion) to generate image for a given input prompt. We will deploy [CompVis/stable-diffusion-v1-4](https://huggingface.co/CompVis/stable-diff...
notebooks/sagemaker/23_stable_diffusion_inference/sagemaker-notebook.ipynb/0
{ "file_path": "notebooks/sagemaker/23_stable_diffusion_inference/sagemaker-notebook.ipynb", "repo_id": "notebooks", "token_count": 4469 }
170
import os import argparse from transformers import ( AutoModelForCausalLM, AutoTokenizer, set_seed, default_data_collator, BitsAndBytesConfig, Trainer, TrainingArguments, ) from datasets import load_from_disk import torch from peft import PeftConfig, PeftModel def parse_arge(): """Pars...
notebooks/sagemaker/28_train_llms_with_qlora/scripts/run_clm.py/0
{ "file_path": "notebooks/sagemaker/28_train_llms_with_qlora/scripts/run_clm.py", "repo_id": "notebooks", "token_count": 2378 }
171
<!--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/conceptual_guides/ia3.md/0
{ "file_path": "peft/docs/source/conceptual_guides/ia3.md", "repo_id": "peft", "token_count": 1030 }
172
<!--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/ia3.md/0
{ "file_path": "peft/docs/source/task_guides/ia3.md", "repo_id": "peft", "token_count": 3197 }
173
<jupyter_start><jupyter_code>from transformers import AutoModelForSeq2SeqLM from peft import get_peft_config, get_peft_model, get_peft_model_state_dict, LoraConfig, TaskType import torch from datasets import load_dataset import os os.environ["TOKENIZERS_PARALLELISM"] = "false" from transformers import AutoTokenizer fr...
peft/examples/conditional_generation/peft_lora_seq2seq.ipynb/0
{ "file_path": "peft/examples/conditional_generation/peft_lora_seq2seq.ipynb", "repo_id": "peft", "token_count": 2336 }
174
<jupyter_start><jupyter_text>Fine-tune large models using 🤗 `peft` adapters, `transformers` & `bitsandbytes`In this tutorial we will cover how we can fine-tune large language models using the very recent `peft` library and `bitsandbytes` for loading large models in 8-bit.The fine-tuning method will rely on a recent me...
peft/examples/int8_training/Finetune_opt_bnb_peft.ipynb/0
{ "file_path": "peft/examples/int8_training/Finetune_opt_bnb_peft.ipynb", "repo_id": "peft", "token_count": 2755 }
175
<jupyter_start><jupyter_code>!pip install -q git+https://github.com/huggingface/transformers.git !pip install -q git+https://github.com/huggingface/peft.git !pip install -q git+https://github.com/huggingface/accelerate.git@main !pip install huggingface_hub !pip install bitsandbytes !pip install SentencePiece import os ...
peft/examples/multi_adapter_examples/PEFT_Multi_LoRA_Inference.ipynb/0
{ "file_path": "peft/examples/multi_adapter_examples/PEFT_Multi_LoRA_Inference.ipynb", "repo_id": "peft", "token_count": 1344 }
176
# Supervised Fine-tuning (SFT) with PEFT In this example, we'll see how to use [PEFT](https://github.com/huggingface/peft) to perform SFT using PEFT on various distributed setups. ## Single GPU SFT with QLoRA QLoRA uses 4-bit quantization of the base model to drastically reduce the GPU memory consumed by the base mode...
peft/examples/sft/README.md/0
{ "file_path": "peft/examples/sft/README.md", "repo_id": "peft", "token_count": 807 }
177
import argparse import json import logging import os from collections import Counter from dataclasses import dataclass from operator import attrgetter from typing import Dict, List, Optional, Union import safetensors import torch import torch.nn as nn from diffusers import UNet2DConditionModel from transformers import...
peft/examples/stable_diffusion/convert_sd_adapter_to_peft.py/0
{ "file_path": "peft/examples/stable_diffusion/convert_sd_adapter_to_peft.py", "repo_id": "peft", "token_count": 10390 }
178
# 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/mixed_model.py/0
{ "file_path": "peft/src/peft/mixed_model.py", "repo_id": "peft", "token_count": 6797 }
179
# 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/bnb.py/0
{ "file_path": "peft/src/peft/tuners/ia3/bnb.py", "repo_id": "peft", "token_count": 2193 }
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/lora/config.py/0
{ "file_path": "peft/src/peft/tuners/lora/config.py", "repo_id": "peft", "token_count": 6552 }
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/p_tuning/config.py/0
{ "file_path": "peft/src/peft/tuners/p_tuning/config.py", "repo_id": "peft", "token_count": 732 }
182
# 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/utils/integrations.py/0
{ "file_path": "peft/src/peft/utils/integrations.py", "repo_id": "peft", "token_count": 890 }
183
# 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/tests/test_feature_extraction_models.py/0
{ "file_path": "peft/tests/test_feature_extraction_models.py", "repo_id": "peft", "token_count": 3356 }
184
# Getting Started ## Welcome Welcome to the `timm` documentation, a lean set of docs that covers the basics of `timm`. For a more comprehensive set of docs (currently under development), please visit [timmdocs](http://timm.fast.ai) by [Aman Arora](https://github.com/amaarora). ## Install The library can be install...
pytorch-image-models/docs/index.md/0
{ "file_path": "pytorch-image-models/docs/index.md", "repo_id": "pytorch-image-models", "token_count": 736 }
185
# EfficientNet (Knapsack Pruned) **EfficientNet** is a convolutional neural network architecture and scaling method that uniformly scales all dimensions of depth/width/resolution using a *compound coefficient*. Unlike conventional practice that arbitrary scales these factors, the EfficientNet scaling method uniformly...
pytorch-image-models/docs/models/.templates/models/efficientnet-pruned.md/0
{ "file_path": "pytorch-image-models/docs/models/.templates/models/efficientnet-pruned.md", "repo_id": "pytorch-image-models", "token_count": 1945 }
186
# (Legacy) SE-ResNet **SE ResNet** is a variant of a [ResNet](https://www.paperswithcode.com/method/resnet) 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. {% include 'code_snippet...
pytorch-image-models/docs/models/.templates/models/legacy-se-resnet.md/0
{ "file_path": "pytorch-image-models/docs/models/.templates/models/legacy-se-resnet.md", "repo_id": "pytorch-image-models", "token_count": 2886 }
187
# 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 [residual block...
pytorch-image-models/docs/models/.templates/models/resnet.md/0
{ "file_path": "pytorch-image-models/docs/models/.templates/models/resnet.md", "repo_id": "pytorch-image-models", "token_count": 4271 }
188
# Installation Before you start, you'll need to setup your environment and install the appropriate packages. `timm` is tested on **Python 3+**. ## Virtual Environment You should install `timm` in a [virtual environment](https://docs.python.org/3/library/venv.html) to keep things tidy and avoid dependency conflicts. ...
pytorch-image-models/hfdocs/source/installation.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/installation.mdx", "repo_id": "pytorch-image-models", "token_count": 619 }
189
# FBNet **FBNet** is a type of convolutional neural architectures discovered through [DNAS](https://paperswithcode.com/method/dnas) neural architecture search. It utilises a basic type of image model block inspired by [MobileNetv2](https://paperswithcode.com/method/mobilenetv2) that utilises depthwise convolutions and...
pytorch-image-models/hfdocs/source/models/fbnet.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models/fbnet.mdx", "repo_id": "pytorch-image-models", "token_count": 1705 }
190
# MnasNet **MnasNet** is a type of convolutional neural network optimized for mobile devices that is discovered through mobile neural architecture search, which explicitly incorporates model latency into the main objective so that the search can identify a model that achieves a good trade-off between accuracy and late...
pytorch-image-models/hfdocs/source/models/mnasnet.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models/mnasnet.mdx", "repo_id": "pytorch-image-models", "token_count": 2101 }
191
# SelecSLS **SelecSLS** uses novel selective long and short range skip connections to improve the information flow allowing for a drastically faster network without compromising accuracy. ## How do I use this model on an image? To load a pretrained model: ```py >>> import timm >>> model = timm.create_model('selecsl...
pytorch-image-models/hfdocs/source/models/selecsls.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models/selecsls.mdx", "repo_id": "pytorch-image-models", "token_count": 2420 }
192
# Xception **Xception** is a convolutional neural network architecture that relies solely on [depthwise separable convolution layers](https://paperswithcode.com/method/depthwise-separable-convolution). The weights from this model were ported from [Tensorflow/Models](https://github.com/tensorflow/models). ## How do I...
pytorch-image-models/hfdocs/source/models/xception.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models/xception.mdx", "repo_id": "pytorch-image-models", "token_count": 2674 }
193
from .auto_augment import RandAugment, AutoAugment, rand_augment_ops, auto_augment_policy,\ rand_augment_transform, auto_augment_transform from .config import resolve_data_config, resolve_model_data_config from .constants import * from .dataset import ImageDataset, IterableImageDataset, AugMixDataset from .dataset_...
pytorch-image-models/timm/data/__init__.py/0
{ "file_path": "pytorch-image-models/timm/data/__init__.py", "repo_id": "pytorch-image-models", "token_count": 256 }
194
import os import pickle def load_class_map(map_or_filename, root=''): if isinstance(map_or_filename, dict): assert dict, 'class_map dict must be non-empty' return map_or_filename class_map_path = map_or_filename if not os.path.exists(class_map_path): class_map_path = os.path.join(r...
pytorch-image-models/timm/data/readers/class_map.py/0
{ "file_path": "pytorch-image-models/timm/data/readers/class_map.py", "repo_id": "pytorch-image-models", "token_count": 387 }
195
from .activations import * from .adaptive_avgmax_pool import \ adaptive_avgmax_pool2d, select_adaptive_pool2d, AdaptiveAvgMaxPool2d, SelectAdaptivePool2d from .attention_pool import AttentionPoolLatent from .attention_pool2d import AttentionPool2d, RotAttentionPool2d, RotaryEmbedding from .blur_pool import BlurPool...
pytorch-image-models/timm/layers/__init__.py/0
{ "file_path": "pytorch-image-models/timm/layers/__init__.py", "repo_id": "pytorch-image-models", "token_count": 1381 }
196
""" Attention Factory Hacked together by / Copyright 2021 Ross Wightman """ import torch from functools import partial from .bottleneck_attn import BottleneckAttn from .cbam import CbamModule, LightCbamModule from .eca import EcaModule, CecaModule from .gather_excite import GatherExcite from .global_context import Gl...
pytorch-image-models/timm/layers/create_attn.py/0
{ "file_path": "pytorch-image-models/timm/layers/create_attn.py", "repo_id": "pytorch-image-models", "token_count": 1588 }
197
import torch from torch import nn as nn try: from inplace_abn.functions import inplace_abn, inplace_abn_sync has_iabn = True except ImportError: has_iabn = False def inplace_abn(x, weight, bias, running_mean, running_var, training=True, momentum=0.1, eps=1e-05, activation="leaky_re...
pytorch-image-models/timm/layers/inplace_abn.py/0
{ "file_path": "pytorch-image-models/timm/layers/inplace_abn.py", "repo_id": "pytorch-image-models", "token_count": 1556 }
198
""" Relative position embedding modules and functions Hacked together by / Copyright 2022 Ross Wightman """ import math import os from typing import Optional, Tuple import torch import torch.nn as nn import torch.nn.functional as F from .grid import ndgrid from .interpolate import RegularGridInterpolator from .mlp i...
pytorch-image-models/timm/layers/pos_embed_rel.py/0
{ "file_path": "pytorch-image-models/timm/layers/pos_embed_rel.py", "repo_id": "pytorch-image-models", "token_count": 9303 }
199
""" Cross Entropy w/ smoothing or soft targets Hacked together by / Copyright 2021 Ross Wightman """ import torch import torch.nn as nn import torch.nn.functional as F class LabelSmoothingCrossEntropy(nn.Module): """ NLL loss with label smoothing. """ def __init__(self, smoothing=0.1): super(Lab...
pytorch-image-models/timm/loss/cross_entropy.py/0
{ "file_path": "pytorch-image-models/timm/loss/cross_entropy.py", "repo_id": "pytorch-image-models", "token_count": 470 }
200
"""Pytorch Densenet implementation w/ tweaks This file is a copy of https://github.com/pytorch/vision 'densenet.py' (BSD-3-Clause) with fixed kwargs passthrough and addition of dynamic global avg/max pool. """ import re from collections import OrderedDict import torch import torch.nn as nn import torch.nn.functional a...
pytorch-image-models/timm/models/densenet.py/0
{ "file_path": "pytorch-image-models/timm/models/densenet.py", "repo_id": "pytorch-image-models", "token_count": 7537 }
201
""" An implementation of GhostNet & GhostNetV2 Models as defined in: GhostNet: More Features from Cheap Operations. https://arxiv.org/abs/1911.11907 GhostNetV2: Enhance Cheap Operation with Long-Range Attention. https://proceedings.neurips.cc/paper_files/paper/2022/file/40b60852a4abdaa696b5a1a78da34635-Paper-Conference...
pytorch-image-models/timm/models/ghostnet.py/0
{ "file_path": "pytorch-image-models/timm/models/ghostnet.py", "repo_id": "pytorch-image-models", "token_count": 7430 }
202
""" MobileViT Paper: V1: `MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer` - https://arxiv.org/abs/2110.02178 V2: `Separable Self-attention for Mobile Vision Transformers` - https://arxiv.org/abs/2206.02680 MobileVitBlock and checkpoints adapted from https://github.com/apple/ml-cvnets...
pytorch-image-models/timm/models/mobilevit.py/0
{ "file_path": "pytorch-image-models/timm/models/mobilevit.py", "repo_id": "pytorch-image-models", "token_count": 12812 }
203
"""Pre-Activation ResNet v2 with GroupNorm and Weight Standardization. A PyTorch implementation of ResNetV2 adapted from the Google Big-Transfer (BiT) source code at https://github.com/google-research/big_transfer to match timm interfaces. The BiT weights have been included here as pretrained models from their origina...
pytorch-image-models/timm/models/resnetv2.py/0
{ "file_path": "pytorch-image-models/timm/models/resnetv2.py", "repo_id": "pytorch-image-models", "token_count": 14679 }
204
""" Hybrid Vision Transformer (ViT) in PyTorch A PyTorch implement of the Hybrid Vision Transformers as described in: 'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale' - https://arxiv.org/abs/2010.11929 `How to train your ViT? Data, Augmentation, and Regularization in Vision Transfor...
pytorch-image-models/timm/models/vision_transformer_hybrid.py/0
{ "file_path": "pytorch-image-models/timm/models/vision_transformer_hybrid.py", "repo_id": "pytorch-image-models", "token_count": 8049 }
205
""" PyTorch LARS / LARC Optimizer An implementation of LARS (SGD) + LARC in PyTorch Based on: * PyTorch SGD: https://github.com/pytorch/pytorch/blob/1.7/torch/optim/sgd.py#L100 * NVIDIA APEX LARC: https://github.com/NVIDIA/apex/blob/master/apex/parallel/LARC.py Additional cleanup and modifications to properly su...
pytorch-image-models/timm/optim/lars.py/0
{ "file_path": "pytorch-image-models/timm/optim/lars.py", "repo_id": "pytorch-image-models", "token_count": 2571 }
206
""" Polynomial Scheduler Polynomial LR schedule with warmup, noise. Hacked together by / Copyright 2021 Ross Wightman """ import math import logging import torch from .scheduler import Scheduler _logger = logging.getLogger(__name__) class PolyLRScheduler(Scheduler): """ Polynomial LR Scheduler w/ warmup, no...
pytorch-image-models/timm/scheduler/poly_lr.py/0
{ "file_path": "pytorch-image-models/timm/scheduler/poly_lr.py", "repo_id": "pytorch-image-models", "token_count": 1967 }
207
""" Model / state_dict utils Hacked together by / Copyright 2020 Ross Wightman """ import fnmatch from copy import deepcopy import torch from torchvision.ops.misc import FrozenBatchNorm2d from timm.layers import BatchNormAct2d, SyncBatchNormAct, FrozenBatchNormAct2d,\ freeze_batch_norm_2d, unfreeze_batch_norm_2d...
pytorch-image-models/timm/utils/model.py/0
{ "file_path": "pytorch-image-models/timm/utils/model.py", "repo_id": "pytorch-image-models", "token_count": 4233 }
208
use std::time::{Duration, Instant}; use text_generation_client::{ Batch, CachedBatch, ClientError, NextTokenChooserParameters, Request, ShardedClient, StoppingCriteriaParameters, }; use tokenizers::{Tokenizer, TruncationDirection}; use tokio::sync::{broadcast, mpsc}; const LOREM_IPSUM: &str = "Lorem ipsum dolo...
text-generation-inference/benchmark/src/generation.rs/0
{ "file_path": "text-generation-inference/benchmark/src/generation.rs", "repo_id": "text-generation-inference", "token_count": 3201 }
209
import json import requests from aiohttp import ClientSession, ClientTimeout from pydantic import ValidationError from typing import Dict, Optional, List, AsyncIterator, Iterator, Union from text_generation.types import ( StreamResponse, Response, Request, Parameters, Grammar, ChatRequest, ...
text-generation-inference/clients/python/text_generation/client.py/0
{ "file_path": "text-generation-inference/clients/python/text_generation/client.py", "repo_id": "text-generation-inference", "token_count": 14202 }
210
# Quantization TGI offers GPTQ and bits-and-bytes quantization to quantize large language models. ## Quantization with GPTQ GPTQ is a post-training quantization method to make the model smaller. It quantizes the layers by finding a compressed version of that weight, that will yield a minimum mean squared error like ...
text-generation-inference/docs/source/conceptual/quantization.md/0
{ "file_path": "text-generation-inference/docs/source/conceptual/quantization.md", "repo_id": "text-generation-inference", "token_count": 1109 }
211
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [ { "id": 1, "logprob": null, "text": "<s>" }, { "id": 1724, "logprob": -7.703125, "text": "What" }, { "id": 338...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_awq/test_flash_llama_awq.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_awq/test_flash_llama_awq.json", "repo_id": "text-generation-inference", "token_count": 1236 }
212
{ "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" }, { "id": 2009,...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama/test_flash_llama.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama/test_flash_llama.json", "repo_id": "text-generation-inference", "token_count": 1050 }
213
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [ { "id": 14402, "logprob": null, "text": "Test" }, { "id": 2581, "logprob": -11.6171875, "text": " request" } ], "see...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_phi/test_flash_phi.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_phi/test_flash_phi.json", "repo_id": "text-generation-inference", "token_count": 1003 }
214
[ { "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [ { "id": 589, "logprob": null, "text": "def" }, { "id": 3226, "logprob": -8.5859375, "text": " ge" ...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_starcoder_gptq/test_flash_starcoder_gptq_load.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_starcoder_gptq/test_flash_starcoder_gptq_load.json", "repo_id": "text-generation-inference", "token_count": 7553 }
215
{ "details": { "best_of_sequences": null, "finish_reason": "eos_token", "generated_tokens": 7, "prefill": [ { "id": 0, "logprob": null, "text": "<pad>" } ], "seed": null, "tokens": [ { "id": 3, "logprob": -0.7001953, "specia...
text-generation-inference/integration-tests/models/__snapshots__/test_t5_sharded/test_t5_sharded.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_t5_sharded/test_t5_sharded.json", "repo_id": "text-generation-inference", "token_count": 680 }
216
import pytest @pytest.fixture(scope="module") def flash_medusa_handle(launcher): with launcher( "FasterDecoding/medusa-vicuna-7b-v1.3", num_shard=2, revision="refs/pr/1" ) as handle: yield handle @pytest.fixture(scope="module") async def flash_medusa(flash_medusa_handle): await flash_med...
text-generation-inference/integration-tests/models/test_flash_medusa.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_flash_medusa.py", "repo_id": "text-generation-inference", "token_count": 749 }
217
import pytest @pytest.fixture(scope="module") def neox_sharded_handle(launcher): with launcher( "OpenAssistant/oasst-sft-1-pythia-12b", num_shard=2, use_flash_attention=False ) as handle: yield handle @pytest.fixture(scope="module") async def neox_sharded(neox_sharded_handle): await neox...
text-generation-inference/integration-tests/models/test_neox_sharded.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_neox_sharded.py", "repo_id": "text-generation-inference", "token_count": 507 }
218
[package] name = "text-generation-router" description = "Text Generation Webserver" build = "build.rs" version.workspace = true edition.workspace = true authors.workspace = true homepage.workspace = true [lib] path = "src/lib.rs" [[bin]] name = "text-generation-router" path = "src/main.rs" [dependencies] async-strea...
text-generation-inference/router/Cargo.toml/0
{ "file_path": "text-generation-inference/router/Cargo.toml", "repo_id": "text-generation-inference", "token_count": 796 }
219
/// HTTP Server logic use crate::health::Health; use crate::infer::{InferError, InferResponse, InferStreamResponse}; use crate::validation::ValidationError; use crate::{ BestOfSequence, Details, ErrorResponse, FinishReason, GenerateParameters, GenerateRequest, GenerateResponse, GrammarType, HubModelInfo, HubTok...
text-generation-inference/router/src/server.rs/0
{ "file_path": "text-generation-inference/router/src/server.rs", "repo_id": "text-generation-inference", "token_count": 27571 }
220
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #ifndef _cuda_compat_cuh #define _cuda_compat_cuh // atomicAdd for half types, to support CC < 7.x __device__ __forceinline__ void atomicAdd_half(half* address, half val) { unsigned int * address_as_ui = (unsigned int *) ((char *)address - (...
text-generation-inference/server/exllama_kernels/exllama_kernels/cu_compat.cuh/0
{ "file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cu_compat.cuh", "repo_id": "text-generation-inference", "token_count": 692 }
221
#ifndef _util_h #define _util_h #define DBGS(__x) printf("%s\n", __x) #define DBGI(__x) printf("%s: %i\n", #__x, __x) #define DBGI2(__x, __y) printf("%s, %s: %i, %i\n", #__x, #__y, __x, __y) #define DBGI3(__x, __y, __z) printf("%s, %s, %s: %i, %i, %i\n", #__x, #__y, #__z, __x, __y, __z) #define DBGF(__x) printf("%s: %...
text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cpp/util.h/0
{ "file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cpp/util.h", "repo_id": "text-generation-inference", "token_count": 296 }
222
#ifndef _util_cuh #define _util_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #include <ATen/cuda/CUDAContext.h> #define DIVIDE(x, size) (((x) + (size) - 1) / (size)) #define DBGS(__x) printf("%s\n", __x) #define DBGI(__x) printf("%s: %i\n", #__x, __x) #define DBGI2(__x, _...
text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/util.cuh/0
{ "file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/util.cuh", "repo_id": "text-generation-inference", "token_count": 1115 }
223
import torch from text_generation_server.utils.layers import ( TensorParallelEmbedding, ) class ProcessGroup: def __init__(self, rank: int, world_size: int): self._rank = rank self.world_size = world_size def size(self) -> int: return self.world_size def rank(self) -> int: ...
text-generation-inference/server/tests/utils/test_layers.py/0
{ "file_path": "text-generation-inference/server/tests/utils/test_layers.py", "repo_id": "text-generation-inference", "token_count": 1111 }
224
# coding=utf-8 # Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # to G...
text-generation-inference/server/text_generation_server/models/custom_modeling/flash_mixtral_modeling.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_mixtral_modeling.py", "repo_id": "text-generation-inference", "token_count": 14049 }
225
# coding=utf-8 # Copyright 2022 The Fairseq Authors and 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/...
text-generation-inference/server/text_generation_server/models/custom_modeling/opt_modeling.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/opt_modeling.py", "repo_id": "text-generation-inference", "token_count": 15538 }
226
import torch import torch.distributed from typing import Optional from transformers import ( AutoTokenizer, AutoConfig, ) from text_generation_server.models import CausalLM from text_generation_server.models.custom_modeling.neox_modeling import ( GPTNeoxForCausalLM, ) from text_generation_server.utils imp...
text-generation-inference/server/text_generation_server/models/gpt_neox.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/gpt_neox.py", "repo_id": "text-generation-inference", "token_count": 1269 }
227
from text_generation_server.utils.convert import convert_file, convert_files from text_generation_server.utils.dist import initialize_torch_distributed from text_generation_server.utils.weights import Weights from text_generation_server.utils.peft import download_and_unload_peft from text_generation_server.utils.hub im...
text-generation-inference/server/text_generation_server/utils/__init__.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/utils/__init__.py", "repo_id": "text-generation-inference", "token_count": 417 }
228
import torch # vllm imports from vllm import cache_ops from vllm import attention_ops _PARTITION_SIZE = 512 def reshape_and_cache( key: torch.Tensor, value: torch.Tensor, key_cache: torch.Tensor, value_cache: torch.Tensor, slots: torch.Tensor, ): cache_ops.reshape_and_cache(key, value, key_c...
text-generation-inference/server/text_generation_server/utils/paged_attention.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/utils/paged_attention.py", "repo_id": "text-generation-inference", "token_count": 1485 }
229
nodeLinker: node-modules npmAuditRegistry: 'https://registry.npmjs.org' yarnPath: .yarn/releases/yarn-3.5.1.cjs
tokenizers/bindings/node/.yarnrc.yml/0
{ "file_path": "tokenizers/bindings/node/.yarnrc.yml", "repo_id": "tokenizers", "token_count": 53 }
230
/* eslint-disable @typescript-eslint/no-empty-function */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { BPE, Unigram, WordPiece } from '../../' const MOCKS_DIR = __dirname + '/__mocks__' describe('WordPiece', () => { describe('fromFile', () => { it('throws if called with only one argument', ...
tokenizers/bindings/node/lib/bindings/models.test.ts/0
{ "file_path": "tokenizers/bindings/node/lib/bindings/models.test.ts", "repo_id": "tokenizers", "token_count": 818 }
231
# `tokenizers-linux-arm-gnueabihf` This is the **armv7-unknown-linux-gnueabihf** binary for `tokenizers`
tokenizers/bindings/node/npm/linux-arm-gnueabihf/README.md/0
{ "file_path": "tokenizers/bindings/node/npm/linux-arm-gnueabihf/README.md", "repo_id": "tokenizers", "token_count": 42 }
232
{ "name": "tokenizers", "version": "0.14.0-dev0", "repository": { "type": "git", "url": "git+https://github.com/huggingface/tokenizers.git" }, "bugs": { "url": "https://github.com/huggingface/tokenizers/issues" }, "homepage": "https://github.com/huggingface/tokenizers/tree/master/bindings/node...
tokenizers/bindings/node/package.json/0
{ "file_path": "tokenizers/bindings/node/package.json", "repo_id": "tokenizers", "token_count": 1532 }
233
{ "compilerOptions": { "target": "ES2018", "strict": true, "moduleResolution": "node", "module": "CommonJS", "noUnusedLocals": true, "noUnusedParameters": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true }, "include": ["."], "exclude": ["node_modules"] }
tokenizers/bindings/node/tsconfig.json/0
{ "file_path": "tokenizers/bindings/node/tsconfig.json", "repo_id": "tokenizers", "token_count": 129 }
234
<jupyter_start><jupyter_code>!wget https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt -O /tmp/bert-base-uncased-vocab.txt from tokenizers import BertWordPieceTokenizer from tokenizers.tools import EncodingVisualizer EncodingVisualizer.unk_token_regex.search("aaa[udsnk]aaa") text = """Mathi...
tokenizers/bindings/python/examples/using_the_visualizer.ipynb/0
{ "file_path": "tokenizers/bindings/python/examples/using_the_visualizer.ipynb", "repo_id": "tokenizers", "token_count": 1221 }
235
# Generated content DO NOT EDIT from .. import pre_tokenizers PreTokenizer = pre_tokenizers.PreTokenizer BertPreTokenizer = pre_tokenizers.BertPreTokenizer ByteLevel = pre_tokenizers.ByteLevel CharDelimiterSplit = pre_tokenizers.CharDelimiterSplit Digits = pre_tokenizers.Digits Metaspace = pre_tokenizers.Metaspace Pun...
tokenizers/bindings/python/py_src/tokenizers/pre_tokenizers/__init__.py/0
{ "file_path": "tokenizers/bindings/python/py_src/tokenizers/pre_tokenizers/__init__.py", "repo_id": "tokenizers", "token_count": 177 }
236
use pyo3::exceptions; use pyo3::prelude::*; use pyo3::types::*; use tk::tokenizer::{Offsets, PaddingDirection}; use tk::utils::truncation::TruncationDirection; use tokenizers as tk; use crate::error::{deprecation_warning, PyError}; /// The :class:`~tokenizers.Encoding` represents the output of a :class:`~tokenizers.T...
tokenizers/bindings/python/src/encoding.rs/0
{ "file_path": "tokenizers/bindings/python/src/encoding.rs", "repo_id": "tokenizers", "token_count": 7397 }
237
from tokenizers import Tokenizer, decoders, models, normalizers, pre_tokenizers, processors from tokenizers.implementations import BaseTokenizer class TestBaseTokenizer: def test_get_set_components(self): toki = Tokenizer(models.BPE()) toki.normalizer = normalizers.NFC() toki.pre_tokenizer...
tokenizers/bindings/python/tests/implementations/test_base_tokenizer.py/0
{ "file_path": "tokenizers/bindings/python/tests/implementations/test_base_tokenizer.py", "repo_id": "tokenizers", "token_count": 550 }
238
# Normalizers <tokenizerslangcontent> <python> ## BertNormalizer [[autodoc]] tokenizers.normalizers.BertNormalizer ## Lowercase [[autodoc]] tokenizers.normalizers.Lowercase ## NFC [[autodoc]] tokenizers.normalizers.NFC ## NFD [[autodoc]] tokenizers.normalizers.NFD ## NFKC [[autodoc]] tokenizers.normalizers.NF...
tokenizers/docs/source-doc-builder/api/normalizers.mdx/0
{ "file_path": "tokenizers/docs/source-doc-builder/api/normalizers.mdx", "repo_id": "tokenizers", "token_count": 350 }
239
🤗 Tokenizers is tested on Python 3.5+. You should install 🤗 Tokenizers in a `virtual environment <https://docs.python.org/3/library/venv.html>`_. If you're unfamiliar with Python virtual environments, check out the `user guide <https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/>`__. C...
tokenizers/docs/source/installation/python.inc/0
{ "file_path": "tokenizers/docs/source/installation/python.inc", "repo_id": "tokenizers", "token_count": 384 }
240
use tokenizers::models::wordpiece::WordPiece; use tokenizers::{AddedToken, Tokenizer}; fn main() { let start = std::time::Instant::now(); let mut tokenizer = Tokenizer::new(WordPiece::default()); // Mix special and not special // You can make sure ids are in order, and special status is correct. l...
tokenizers/tokenizers/examples/serialization.rs/0
{ "file_path": "tokenizers/tokenizers/examples/serialization.rs", "repo_id": "tokenizers", "token_count": 300 }
241
#![allow(clippy::map_entry)] use super::{Pair, WithFirstLastIterator, Word, BPE}; use crate::parallelism::*; use crate::tokenizer::{AddedToken, Result, Trainer}; use crate::utils::progress::{ProgressBar, ProgressStyle}; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::collections::{BinaryHeap, Has...
tokenizers/tokenizers/src/models/bpe/trainer.rs/0
{ "file_path": "tokenizers/tokenizers/src/models/bpe/trainer.rs", "repo_id": "tokenizers", "token_count": 15117 }
242
pub mod bert; pub mod precompiled; pub mod prepend; pub mod replace; pub mod strip; pub mod unicode; pub mod utils; pub use crate::normalizers::bert::BertNormalizer; pub use crate::normalizers::precompiled::Precompiled; pub use crate::normalizers::prepend::Prepend; pub use crate::normalizers::replace::Replace; pub use...
tokenizers/tokenizers/src/normalizers/mod.rs/0
{ "file_path": "tokenizers/tokenizers/src/normalizers/mod.rs", "repo_id": "tokenizers", "token_count": 1090 }
243
mod pre_tokenizer; mod scripts; // Re-export the PreTokenizer pub use pre_tokenizer::UnicodeScripts;
tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/mod.rs/0
{ "file_path": "tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/mod.rs", "repo_id": "tokenizers", "token_count": 35 }
244
use std::borrow::Borrow; use std::collections::HashMap; use std::hash::Hash; use std::sync::RwLock; /// The default capacity for a `BPE`'s internal cache. pub static DEFAULT_CACHE_CAPACITY: usize = 10_000; /// Provides a simple multithread cache to speed up BPE tokenization that will try to read values /// concurrent...
tokenizers/tokenizers/src/utils/cache.rs/0
{ "file_path": "tokenizers/tokenizers/src/utils/cache.rs", "repo_id": "tokenizers", "token_count": 1436 }
245