text
stringlengths
5
409k
id
stringlengths
14
178
metadata
dict
__index_level_0__
int64
0
572
# coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
open-r1/scripts/upload_details.py/0
{ "file_path": "open-r1/scripts/upload_details.py", "repo_id": "open-r1", "token_count": 615 }
178
# Copyright 2025 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...
open-r1/src/open_r1/sft.py/0
{ "file_path": "open-r1/src/open_r1/sft.py", "repo_id": "open-r1", "token_count": 2556 }
179
# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build SOURCEDIR = source BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" ...
peft/docs/Makefile/0
{ "file_path": "peft/docs/Makefile", "repo_id": "peft", "token_count": 237 }
180
<!--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/developer_guides/model_merging.md/0
{ "file_path": "peft/docs/source/developer_guides/model_merging.md", "repo_id": "peft", "token_count": 2547 }
181
PEFT_TYPE="boft" BLOCK_NUM=8 BLOCK_SIZE=0 N_BUTTERFLY_FACTOR=1 ITER_NUM=50000 export RUN_NAME="${PEFT_TYPE}_${BLOCK_NUM}${BLOCK_SIZE}${N_BUTTERFLY_FACTOR}" export MODEL_NAME="stabilityai/stable-diffusion-2-1" # export MODEL_NAME="runwayml/stable-diffusion-v1-5" export DATASET_NAME="oftverse/control-celeba-hq" export...
peft/examples/boft_controlnet/test_controlnet.sh/0
{ "file_path": "peft/examples/boft_controlnet/test_controlnet.sh", "repo_id": "peft", "token_count": 379 }
182
IDX=$1 PROMPT_IDX=$((IDX % 25)) CLASS_IDX=$((IDX % 30)) # Define the UNIQUE_TOKEN, CLASS_TOKENs, and SUBJECT_NAMES UNIQUE_TOKEN="qwe" SUBJECT_NAMES=( "backpack" "backpack_dog" "bear_plushie" "berry_bowl" "can" "candle" "cat" "cat2" "clock" "colorful_sneaker" "dog" "dog2" "dog3" "dog5" "dog6" "dog7" "d...
peft/examples/boft_dreambooth/train_dreambooth.sh/0
{ "file_path": "peft/examples/boft_dreambooth/train_dreambooth.sh", "repo_id": "peft", "token_count": 3412 }
183
<jupyter_start><jupyter_code>from datasets import load_dataset from transformers import set_seed, AutoModelForSeq2SeqLM, AutoTokenizer from peft import get_peft_model, MultitaskPromptTuningConfig, TaskType, MultitaskPromptTuningInit set_seed(42) model_name = "google/flan-t5-base" peft_config = MultitaskPromptTuningC...
peft/examples/conditional_generation/multitask_prompt_tuning.ipynb/0
{ "file_path": "peft/examples/conditional_generation/multitask_prompt_tuning.ipynb", "repo_id": "peft", "token_count": 3341 }
184
<jupyter_start><jupyter_text>CPT Training and InferenceThis notebook demonstrates the training and evaluation process of Context-Aware Prompt Tuning (CPT) using the Hugging Face Trainer. For more details, refer to the [Paper](https://huggingface.co/papers/2410.17222). Sections Overview:1. **Setup**: Import libraries an...
peft/examples/cpt_finetuning/cpt_train_and_inference.ipynb/0
{ "file_path": "peft/examples/cpt_finetuning/cpt_train_and_inference.ipynb", "repo_id": "peft", "token_count": 6570 }
185
<jupyter_start><jupyter_text>Finetuning Whisper-large-V2 on Colab using PEFT-Lora + BNB INT8 training In this Colab, we present a step-by-step guide on how to fine-tune Whisper for any multilingual ASR dataset using Hugging Face 🤗 Transformers and 🤗 PEFT. Using 🤗 PEFT and `bitsandbytes`, you can train the `whisper-l...
peft/examples/int8_training/peft_bnb_whisper_large_v2_training.ipynb/0
{ "file_path": "peft/examples/int8_training/peft_bnb_whisper_large_v2_training.ipynb", "repo_id": "peft", "token_count": 7713 }
186
<jupyter_start><jupyter_text>Using PEFT with custom models `peft` allows us to fine-tune models efficiently with LoRA. In this short notebook, we will demonstrate how to train a simple multilayer perceptron (MLP) using `peft`. Imports Make sure that you have the latest version of `peft` installed. To ensure that, run ...
peft/examples/multilayer_perceptron/multilayer_perceptron_lora.ipynb/0
{ "file_path": "peft/examples/multilayer_perceptron/multilayer_perceptron_lora.ipynb", "repo_id": "peft", "token_count": 4094 }
187
""" Utility to clean cache files that exceed a specific time in days according to their last access time recorded in the cache. Exit code: - 1 if no candidates are found - 0 if candidates are found Deletion can be enabled by passing `-d` parameter, otherwise it will only list the candidates. """ import sys from date...
peft/scripts/ci_clean_cache.py/0
{ "file_path": "peft/scripts/ci_clean_cache.py", "repo_id": "peft", "token_count": 807 }
188
# 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/loha/model.py/0
{ "file_path": "peft/src/peft/tuners/loha/model.py", "repo_id": "peft", "token_count": 1880 }
189
# 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": 37970 }
190
# 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/model.py/0
{ "file_path": "peft/src/peft/tuners/p_tuning/model.py", "repo_id": "peft", "token_count": 2476 }
191
# 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/tuners/vblora/model.py/0
{ "file_path": "peft/src/peft/tuners/vblora/model.py", "repo_id": "peft", "token_count": 8470 }
192
# 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/loftq_utils.py/0
{ "file_path": "peft/src/peft/utils/loftq_utils.py", "repo_id": "peft", "token_count": 7250 }
193
# 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_decoder_models.py/0
{ "file_path": "peft/tests/test_decoder_models.py", "repo_id": "peft", "token_count": 12220 }
194
# 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_other.py/0
{ "file_path": "peft/tests/test_other.py", "repo_id": "peft", "token_count": 5229 }
195
message: "If you use this software, please cite it as below." title: "PyTorch Image Models" version: "1.2.2" doi: "10.5281/zenodo.4414861" authors: - family-names: Wightman given-names: Ross version: 1.0.11 year: "2019" url: "https://github.com/huggingface/pytorch-image-models" license: "Apache 2.0"
pytorch-image-models/CITATION.cff/0
{ "file_path": "pytorch-image-models/CITATION.cff", "repo_id": "pytorch-image-models", "token_count": 122 }
196
# Changelog ## Jan 19, 2025 * Fix loading of LeViT safetensor weights, remove conversion code which should have been deactivated * Add 'SO150M' ViT weights trained with SBB recipes, decent results, but not optimal shape for ImageNet-12k/1k pretrain/ft * `vit_so150m_patch16_reg4_gap_256.sbb_e250_in12k_ft_in1k` - 86.7...
pytorch-image-models/hfdocs/source/changes.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/changes.mdx", "repo_id": "pytorch-image-models", "token_count": 50077 }
197
# 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/hfdocs/source/models/efficientnet-pruned.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models/efficientnet-pruned.mdx", "repo_id": "pytorch-image-models", "token_count": 2777 }
198
# (Tensorflow) MixNet **MixNet** is a type of convolutional neural network discovered via AutoML that utilises [MixConvs](https://paperswithcode.com/method/mixconv) instead of regular [depthwise convolutions](https://paperswithcode.com/method/depthwise-convolution). The weights from this model were ported from [Tenso...
pytorch-image-models/hfdocs/source/models/tf-mixnet.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models/tf-mixnet.mdx", "repo_id": "pytorch-image-models", "token_count": 2361 }
199
[build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" [project] name = "timm" authors = [ {name = "Ross Wightman", email = "ross@huggingface.co"}, ] description = "PyTorch Image Models" readme = "README.md" requires-python = ">=3.8" keywords = ["pytorch", "image-classification"] license = {text =...
pytorch-image-models/pyproject.toml/0
{ "file_path": "pytorch-image-models/pyproject.toml", "repo_id": "pytorch-image-models", "token_count": 800 }
200
""" Optimzier Tests These tests were adapted from PyTorch' optimizer tests. """ import functools import importlib import os from copy import deepcopy import pytest import torch from torch.nn import Parameter from torch.testing._internal.common_utils import TestCase from timm.optim import create_optimizer_v2, list_o...
pytorch-image-models/tests/test_optim.py/0
{ "file_path": "pytorch-image-models/tests/test_optim.py", "repo_id": "pytorch-image-models", "token_count": 9446 }
201
import csv import os import pkgutil import re from typing import Dict, List, Optional, Union from .dataset_info import DatasetInfo # NOTE no ambiguity wrt to mapping from # classes to ImageNet subset so far, but likely to change _NUM_CLASSES_TO_SUBSET = { 1000: 'imagenet-1k', 11221: 'imagenet-21k-miil', # m...
pytorch-image-models/timm/data/imagenet_info.py/0
{ "file_path": "pytorch-image-models/timm/data/imagenet_info.py", "repo_id": "pytorch-image-models", "token_count": 1732 }
202
from multiprocessing import Value class SharedCount: def __init__(self, epoch: int = 0): self.shared_epoch = Value('i', epoch) @property def value(self): return self.shared_epoch.value @value.setter def value(self, epoch): self.shared_epoch.value = epoch
pytorch-image-models/timm/data/readers/shared_count.py/0
{ "file_path": "pytorch-image-models/timm/data/readers/shared_count.py", "repo_id": "pytorch-image-models", "token_count": 122 }
203
""" PyTorch Conditionally Parameterized Convolution (CondConv) Paper: CondConv: Conditionally Parameterized Convolutions for Efficient Inference (https://arxiv.org/abs/1904.04971) Hacked together by / Copyright 2020 Ross Wightman """ import math from functools import partial import numpy as np import torch from torc...
pytorch-image-models/timm/layers/cond_conv2d.py/0
{ "file_path": "pytorch-image-models/timm/layers/cond_conv2d.py", "repo_id": "pytorch-image-models", "token_count": 2314 }
204
""" Global Context Attention Block Paper: `GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond` - https://arxiv.org/abs/1904.11492 Official code consulted as reference: https://github.com/xvjiarui/GCNet Hacked together by / Copyright 2021 Ross Wightman """ from torch import nn as nn import torc...
pytorch-image-models/timm/layers/global_context.py/0
{ "file_path": "pytorch-image-models/timm/layers/global_context.py", "repo_id": "pytorch-image-models", "token_count": 1169 }
205
""" Normalization layers and wrappers Norm layer definitions that support fast norm and consistent channel arg order (always first arg). Hacked together by / Copyright 2022 Ross Wightman """ import numbers from typing import Tuple import torch import torch.nn as nn import torch.nn.functional as F from .fast_norm im...
pytorch-image-models/timm/layers/norm.py/0
{ "file_path": "pytorch-image-models/timm/layers/norm.py", "repo_id": "pytorch-image-models", "token_count": 4880 }
206
""" Test Time Pooling (Average-Max Pool) Hacked together by / Copyright 2020 Ross Wightman """ import logging from torch import nn import torch.nn.functional as F from .adaptive_avgmax_pool import adaptive_avgmax_pool2d _logger = logging.getLogger(__name__) class TestTimePoolHead(nn.Module): def __init__(sel...
pytorch-image-models/timm/layers/test_time_pool.py/0
{ "file_path": "pytorch-image-models/timm/layers/test_time_pool.py", "repo_id": "pytorch-image-models", "token_count": 881 }
207
""" Model creation / weight loading / state_dict helpers Hacked together by / Copyright 2020 Ross Wightman """ import logging import os from typing import Any, Callable, Dict, Optional, Union import torch try: import safetensors.torch _has_safetensors = True except ImportError: _has_safetensors = False _...
pytorch-image-models/timm/models/_helpers.py/0
{ "file_path": "pytorch-image-models/timm/models/_helpers.py", "repo_id": "pytorch-image-models", "token_count": 2793 }
208
""" ConViT Model @article{d2021convit, title={ConViT: Improving Vision Transformers with Soft Convolutional Inductive Biases}, author={d'Ascoli, St{\'e}phane and Touvron, Hugo and Leavitt, Matthew and Morcos, Ari and Biroli, Giulio and Sagun, Levent}, journal={arXiv preprint arXiv:2103.10697}, year={2021} } P...
pytorch-image-models/timm/models/convit.py/0
{ "file_path": "pytorch-image-models/timm/models/convit.py", "repo_id": "pytorch-image-models", "token_count": 7721 }
209
""" EVA EVA from https://github.com/baaivision/EVA , paper: https://arxiv.org/abs/2211.07636 @article{EVA, title={EVA: Exploring the Limits of Masked Visual Representation Learning at Scale}, author={Fang, Yuxin and Wang, Wen and Xie, Binhui and Sun, Quan and Wu, Ledell and Wang, Xinggang and Huang, Tiejun and ...
pytorch-image-models/timm/models/eva.py/0
{ "file_path": "pytorch-image-models/timm/models/eva.py", "repo_id": "pytorch-image-models", "token_count": 25968 }
210
""" Pytorch Inception-Resnet-V2 implementation Sourced from https://github.com/Cadene/tensorflow-model-zoo.torch (MIT License) which is based upon Google's Tensorflow implementation and pretrained weights (Apache 2.0 License) """ from functools import partial import torch import torch.nn as nn import torch.nn.functiona...
pytorch-image-models/timm/models/inception_resnet_v2.py/0
{ "file_path": "pytorch-image-models/timm/models/inception_resnet_v2.py", "repo_id": "pytorch-image-models", "token_count": 6034 }
211
""" Pooling-based Vision Transformer (PiT) in PyTorch A PyTorch implement of Pooling-based Vision Transformers as described in 'Rethinking Spatial Dimensions of Vision Transformers' - https://arxiv.org/abs/2103.16302 This code was adapted from the original version at https://github.com/naver-ai/pit, original copyrigh...
pytorch-image-models/timm/models/pit.py/0
{ "file_path": "pytorch-image-models/timm/models/pit.py", "repo_id": "pytorch-image-models", "token_count": 7404 }
212
""" Selective Kernel Networks (ResNet base) Paper: Selective Kernel Networks (https://arxiv.org/abs/1903.06586) This was inspired by reading 'Compounding the Performance Improvements...' (https://arxiv.org/abs/2001.06268) and a streamlined impl at https://github.com/clovaai/assembled-cnn but I ended up building somet...
pytorch-image-models/timm/models/sknet.py/0
{ "file_path": "pytorch-image-models/timm/models/sknet.py", "repo_id": "pytorch-image-models", "token_count": 3801 }
213
""" VoVNet (V1 & V2) Papers: * `An Energy and GPU-Computation Efficient Backbone Network` - https://arxiv.org/abs/1904.09730 * `CenterMask : Real-Time Anchor-Free Instance Segmentation` - https://arxiv.org/abs/1911.06667 Looked at https://github.com/youngwanLEE/vovnet-detectron2 & https://github.com/stigma0617/VoVNe...
pytorch-image-models/timm/models/vovnet.py/0
{ "file_path": "pytorch-image-models/timm/models/vovnet.py", "repo_id": "pytorch-image-models", "token_count": 8067 }
214
""" PyTorch Implementation of the Kron (PSGD) optimizer This is a PSGD optimizer using a Kronecker-factored preconditioner. This impl was adapted from https://github.com/evanatyourservice/kron_torch by Evan Walters, licensed CC-BY-4.0. Contributions to above also made by * Lucas Nestler, added to his https://github....
pytorch-image-models/timm/optim/kron.py/0
{ "file_path": "pytorch-image-models/timm/optim/kron.py", "repo_id": "pytorch-image-models", "token_count": 10686 }
215
""" Batch size decay and retry helpers. Copyright 2022 Ross Wightman """ import math def decay_batch_step(batch_size, num_intra_steps=2, no_odd=False): """ power of two batch-size decay with intra steps Decay by stepping between powers of 2: * determine power-of-2 floor of current batch size (base batch...
pytorch-image-models/timm/utils/decay_batch.py/0
{ "file_path": "pytorch-image-models/timm/utils/decay_batch.py", "repo_id": "pytorch-image-models", "token_count": 656 }
216
<!--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...
smolagents/docs/source/en/examples/text_to_sql.mdx/0
{ "file_path": "smolagents/docs/source/en/examples/text_to_sql.mdx", "repo_id": "smolagents", "token_count": 2400 }
217
<!--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...
smolagents/docs/source/hi/examples/multiagents.mdx/0
{ "file_path": "smolagents/docs/source/hi/examples/multiagents.mdx", "repo_id": "smolagents", "token_count": 5840 }
218
<!--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...
smolagents/docs/source/zh/examples/rag.mdx/0
{ "file_path": "smolagents/docs/source/zh/examples/rag.mdx", "repo_id": "smolagents", "token_count": 4008 }
219
from openinference.instrumentation.smolagents import SmolagentsInstrumentor from phoenix.otel import register register() SmolagentsInstrumentor().instrument(skip_dep_check=True) from smolagents import ( CodeAgent, DuckDuckGoSearchTool, HfApiModel, ToolCallingAgent, VisitWebpageTool, ) # Then w...
smolagents/examples/inspect_multiagent_run.py/0
{ "file_path": "smolagents/examples/inspect_multiagent_run.py", "repo_id": "smolagents", "token_count": 260 }
220
# from huggingface_hub import login # login() import datasets from langchain.docstore.document import Document from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain_community.retrievers import BM25Retriever knowledge_base = datasets.load_dataset("m-ric/huggingface_doc", split="train") kno...
smolagents/examples/rag.py/0
{ "file_path": "smolagents/examples/rag.py", "repo_id": "smolagents", "token_count": 805 }
221
system_prompt: |- You are an expert assistant who can solve any task using code blobs. You will be given a task to solve as best you can. To do so, you have been given access to a list of tools: these tools are basically Python functions which you can call with code. To solve the task, you must plan forward to pr...
smolagents/src/smolagents/prompts/code_agent.yaml/0
{ "file_path": "smolagents/src/smolagents/prompts/code_agent.yaml", "repo_id": "smolagents", "token_count": 4632 }
222
import subprocess def test_import_smolagents_without_extras(): # Run the import statement in an isolated virtual environment result = subprocess.run( ["uv", "run", "--isolated", "--no-editable", "-"], input="import smolagents", text=True, capture_output=True ) # Check if the import was success...
smolagents/tests/test_import.py/0
{ "file_path": "smolagents/tests/test_import.py", "repo_id": "smolagents", "token_count": 200 }
223
[workspace] members = [ "benchmark", "backends/v2", "backends/v3", "backends/grpc-metadata", "backends/trtllm", "backends/llamacpp", "launcher", "router" ] default-members = [ "benchmark", "backends/v2", "backends/v3", "backends/grpc-metadata", # "backends/trtllm", ...
text-generation-inference/Cargo.toml/0
{ "file_path": "text-generation-inference/Cargo.toml", "repo_id": "text-generation-inference", "token_count": 512 }
224
use std::fs; fn main() -> Result<(), Box<dyn std::error::Error>> { println!("cargo:rerun-if-changed=../../proto/"); fs::create_dir_all("src/v2/pb").unwrap_or(()); let mut config = prost_build::Config::new(); config.protoc_arg("--experimental_allow_proto3_optional"); tonic_build::configure() ...
text-generation-inference/backends/client/build.rs/0
{ "file_path": "text-generation-inference/backends/client/build.rs", "repo_id": "text-generation-inference", "token_count": 624 }
225
[workspace] members = [ "backends/v2", "backends/grpc-metadata", "launcher", "router" ] default-members = [ "backends/v2", "backends/grpc-metadata", "launcher", "router" ] resolver = "2" [workspace.package] version = "3.0.0" edition = "2021" authors = ["Olivier Dehaene"] homepage = "https://github.com/...
text-generation-inference/backends/neuron/Cargo.toml/0
{ "file_path": "text-generation-inference/backends/neuron/Cargo.toml", "repo_id": "text-generation-inference", "token_count": 416 }
226
use crate::client::{Batch, CachedBatch, ClientError, Generation, Health, ShardedClient}; /// Batching and inference logic use crate::queue::{Entry, Queue}; use async_trait::async_trait; use nohash_hasher::IntMap; use std::sync::Arc; use text_generation_router::infer::{Backend, GeneratedText, InferError, InferStreamResp...
text-generation-inference/backends/v2/src/backend.rs/0
{ "file_path": "text-generation-inference/backends/v2/src/backend.rs", "repo_id": "text-generation-inference", "token_count": 9328 }
227
use clap::{Parser, Subcommand}; use text_generation_router::{server, usage_stats}; use text_generation_router_v3::{connect_backend, V3Error}; use thiserror::Error; /// App Configuration #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] struct Args { #[command(subcommand)] command: Opt...
text-generation-inference/backends/v3/src/main.rs/0
{ "file_path": "text-generation-inference/backends/v3/src/main.rs", "repo_id": "text-generation-inference", "token_count": 3407 }
228
[tool.poetry] name = "text-generation" version = "0.7.0" description = "Hugging Face Text Generation Python Client" license = "Apache-2.0" authors = ["Olivier Dehaene <olivier@huggingface.co>"] maintainers = ["Olivier Dehaene <olivier@huggingface.co>"] readme = "README.md" homepage = "https://github.com/huggingface/tex...
text-generation-inference/clients/python/pyproject.toml/0
{ "file_path": "text-generation-inference/clients/python/pyproject.toml", "repo_id": "text-generation-inference", "token_count": 348 }
229
# Text Generation Inference Architecture This document aims at describing the architecture of Text Generation Inference (TGI), by describing the call flow between the separate components. A high-level architecture diagram can be seen here: ![TGI architecture](https://huggingface.co/datasets/huggingface/documentation...
text-generation-inference/docs/source/architecture.md/0
{ "file_path": "text-generation-inference/docs/source/architecture.md", "repo_id": "text-generation-inference", "token_count": 5207 }
230
# Using TGI with Google TPUs Check out this [guide](https://huggingface.co/docs/optimum-tpu) on how to serve models with TGI on TPUs.
text-generation-inference/docs/source/installation_tpu.md/0
{ "file_path": "text-generation-inference/docs/source/installation_tpu.md", "repo_id": "text-generation-inference", "token_count": 48 }
231
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [ { "id": 17934, "logprob": null, "text": "Pour" }, { "id": 49833, "logprob": -10.5703125, "text": " dég" }, { "...
text-generation-inference/integration-tests/models/__snapshots__/test_bloom_560m/test_bloom_560m.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_bloom_560m/test_bloom_560m.json", "repo_id": "text-generation-inference", "token_count": 1548 }
232
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": null, "tokens": [ { "id": 18682, "logprob": -0.8769531, "special": false, "text": " Deep" }, { "id": 6975, "logp...
text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8an_fp/test_compressed_tensors_w8an.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8an_fp/test_compressed_tensors_w8an.json", "repo_id": "text-generation-inference", "token_count": 869 }
233
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": null, "tokens": [ { "id": 185, "logprob": -1.546875, "special": false, "text": "\n" }, { "id": 549, "logprob": -...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_deepseek_v2/test_flash_deepseek_v2.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_deepseek_v2/test_flash_deepseek_v2.json", "repo_id": "text-generation-inference", "token_count": 858 }
234
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": null, "tokens": [ { "id": 13, "logprob": -2.0566406, "special": false, "text": "\n" }, { "id": 13, "logprob": -1...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_grammar_llama/test_flash_llama_grammar.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_grammar_llama/test_flash_llama_grammar.json", "repo_id": "text-generation-inference", "token_count": 866 }
235
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": 0, "tokens": [ { "id": 28747, "logprob": 0.0, "special": false, "text": ":" }, { "id": 3169, "logprob": -0.13073...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_mistral/test_flash_mistral_all_params.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_mistral/test_flash_mistral_all_params.json", "repo_id": "text-generation-inference", "token_count": 856 }
236
{ "details": { "best_of_sequences": null, "finish_reason": "eos_token", "generated_tokens": 8, "prefill": [], "seed": null, "tokens": [ { "id": 2502, "logprob": -1.7890625, "special": false, "text": "image" }, { "id": 2196, "log...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_pali_gemma/test_flash_pali_gemma_two_images.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_pali_gemma/test_flash_pali_gemma_two_images.json", "repo_id": "text-generation-inference", "token_count": 719 }
237
{ "choices": [ { "finish_reason": "stop", "index": 0, "logprobs": null, "message": { "content": "The image shows a stylized scene set in what appears to be a diner or restaurant. In the foreground, there is a table with various food items, including a burger with lettuce and tomato...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2_vl/test_flash_qwen2_vl_inpaint.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2_vl/test_flash_qwen2_vl_inpaint.json", "repo_id": "text-generation-inference", "token_count": 422 }
238
{ "details": { "finish_reason": "eos_token", "generated_tokens": 7, "prefill": [], "seed": null, "tokens": [ { "id": 1, "logprob": -0.49658203, "special": true, "text": "<s>" }, { "id": 28705, "logprob": -0.0016384125, "spec...
text-generation-inference/integration-tests/models/__snapshots__/test_lora_mistral/test_lora_mistral_with_dbpedia_adapter.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_lora_mistral/test_lora_mistral_with_dbpedia_adapter.json", "repo_id": "text-generation-inference", "token_count": 611 }
239
import pytest @pytest.fixture(scope="module") def flash_gemma_handle(launcher): with launcher("google/gemma-2b", num_shard=1) as handle: yield handle @pytest.fixture(scope="module") async def flash_gemma(flash_gemma_handle): await flash_gemma_handle.health(300) return flash_gemma_handle.client ...
text-generation-inference/integration-tests/models/test_flash_gemma.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_flash_gemma.py", "repo_id": "text-generation-inference", "token_count": 678 }
240
import pytest @pytest.fixture(scope="module") def flash_mixtral_handle(launcher): with launcher("mistralai/Mixtral-8x7B-v0.1", num_shard=8) as handle: yield handle @pytest.fixture(scope="module") async def flash_mixtral(flash_mixtral_handle): await flash_mixtral_handle.health(300) return flash_m...
text-generation-inference/integration-tests/models/test_flash_mixtral.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_flash_mixtral.py", "repo_id": "text-generation-inference", "token_count": 926 }
241
import pytest @pytest.fixture(scope="module") def flash_starcoder_gptq_handle(launcher): with launcher("Narsil/starcoder-gptq", num_shard=2, quantize="gptq") as handle: yield handle @pytest.fixture(scope="module") async def flash_starcoder_gptq(flash_starcoder_gptq_handle): await flash_starcoder_gpt...
text-generation-inference/integration-tests/models/test_flash_starcoder_gptq.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_flash_starcoder_gptq.py", "repo_id": "text-generation-inference", "token_count": 802 }
242
import pytest @pytest.fixture(scope="module") def t5_sharded_handle(launcher): with launcher("google/flan-t5-xxl", num_shard=4) as handle: yield handle @pytest.fixture(scope="module") async def t5_sharded(t5_sharded_handle): await t5_sharded_handle.health(300) return t5_sharded_handle.client @...
text-generation-inference/integration-tests/models/test_t5_sharded.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_t5_sharded.py", "repo_id": "text-generation-inference", "token_count": 443 }
243
import json def main(): with open("./ShareGPT_V3_unfiltered_cleaned_split.json", "r") as f: data = json.load(f) # Select only the first 2k conversations that start with a human. max = 2000 conversations = [] for conversation in data: conv = conversation.get("conversations") ...
text-generation-inference/load_tests/filter.py/0
{ "file_path": "text-generation-inference/load_tests/filter.py", "repo_id": "text-generation-inference", "token_count": 307 }
244
# Router Also named `webserver` throughout the docs. This router is handling most of the logic to handle the "batches" tell when to pass new `prefill` requests and pausing `decode` requests, which ones etc... It uses gRPC to communicate with the shards which can therefore be kept much simpler and focus on having the...
text-generation-inference/router/README.md/0
{ "file_path": "text-generation-inference/router/README.md", "repo_id": "text-generation-inference", "token_count": 1175 }
245
// 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 }
246
#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 }
247
#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 }
248
import pytest from unittest.mock import Mock from text_generation_server.utils.adapter import ( get_attn_weights, get_mlp_weights, parse_lora_adapters, AdapterInfo, ) def test_parse_lora_adapters_empty(): assert parse_lora_adapters(None) == [] assert parse_lora_adapters("") == [] def test_pa...
text-generation-inference/server/tests/utils/test_adapter.py/0
{ "file_path": "text-generation-inference/server/tests/utils/test_adapter.py", "repo_id": "text-generation-inference", "token_count": 4022 }
249
import os from text_generation_server.utils.import_utils import SYSTEM from .common import Seqlen if os.getenv("USE_FLASH_ATTENTION", "").lower() == "false": raise ImportError("`USE_FLASH_ATTENTION` is false.") if SYSTEM == "cuda": from .cuda import ( SUPPORTS_WINDOWING, attention, pa...
text-generation-inference/server/text_generation_server/layers/attention/__init__.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/attention/__init__.py", "repo_id": "text-generation-inference", "token_count": 404 }
250
from typing import List, Optional, Union import torch from compressed_tensors.quantization import QuantizationArgs, QuantizationType from text_generation_server.layers.fp8 import ( Fp8Weight, _load_scalar_or_matrix_scale, requantize_with_max_scale, normalize_e4m3fn_to_native_float8, ) from text_genera...
text-generation-inference/server/text_generation_server/layers/compressed_tensors/w8an_fp.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/compressed_tensors/w8an_fp.py", "repo_id": "text-generation-inference", "token_count": 3370 }
251
import torch from text_generation_server.utils.import_utils import SYSTEM from torch.nn import functional as F import os if SYSTEM == "rocm": ROCM_USE_SKINNY_GEMM = os.getenv("ROCM_USE_SKINNY_GEMM", "True").lower() in ( "true", "1", ) if ROCM_USE_SKINNY_GEMM: try: impor...
text-generation-inference/server/text_generation_server/layers/linear.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/linear.py", "repo_id": "text-generation-inference", "token_count": 1954 }
252
import torch from torch.nn import functional as F from typing import Iterable, List from text_generation_server.layers.linear import get_linear, FastLinear from text_generation_server.utils.import_utils import SYSTEM if SYSTEM == "ipex": import intel_extension_for_pytorch as ipex class LayerConcat(torch.nn.Modul...
text-generation-inference/server/text_generation_server/layers/tensor_parallel.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/tensor_parallel.py", "repo_id": "text-generation-inference", "token_count": 4175 }
253
# 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_mistral_modeling.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_mistral_modeling.py", "repo_id": "text-generation-inference", "token_count": 8969 }
254
# coding=utf-8 # Copyright 2022 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...
text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_processing.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_processing.py", "repo_id": "text-generation-inference", "token_count": 8120 }
255
import torch import os from loguru import logger from typing import Dict, Optional from text_generation_server.utils.log import log_master REQUEST_LOGPROBS = os.getenv("REQUEST_LOGPROBS", "0").lower() in {"1", "true"} ATTENTION = os.environ["ATTENTION"] # default_prefix_caching = "1" if ATTENTION in {"flashinfer", "f...
text-generation-inference/server/text_generation_server/models/globals.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/globals.py", "repo_id": "text-generation-inference", "token_count": 900 }
256
from typing import Iterable from loguru import logger from text_generation_server.pb import generate_pb2 def concat_text_chunks(chunks: Iterable[generate_pb2.InputChunk]) -> str: """ Concatenate text in text chunks. Non-text chunks are dropped. """ text = None for chunk in chunks: chunk_...
text-generation-inference/server/text_generation_server/utils/chunks.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/utils/chunks.py", "repo_id": "text-generation-inference", "token_count": 332 }
257
import re from typing import List, Optional, Tuple, Set, Union import torch from text_generation_server.pb import generate_pb2 from text_generation_server.pb.generate_pb2 import FinishReason, GrammarType from text_generation_server.utils.logits_process import ( FrequencyPenaltyLogitsProcessor, GrammarLogitProc...
text-generation-inference/server/text_generation_server/utils/tokens.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/utils/tokens.py", "repo_id": "text-generation-inference", "token_count": 11317 }
258
import { PaddingDirection, WordPiece, punctuationPreTokenizer, sequencePreTokenizer, whitespacePreTokenizer, Encoding, EncodeOptions, Tokenizer, } from '../../' import { InputSequence } from '../../types' const MOCKS_DIR = __dirname + '/__mocks__' describe('Can modify pretokenizers on the fly', () => ...
tokenizers/bindings/node/lib/bindings/encoding.test.ts/0
{ "file_path": "tokenizers/bindings/node/lib/bindings/encoding.test.ts", "repo_id": "tokenizers", "token_count": 3021 }
259
{ "name": "tokenizers-freebsd-x64", "version": "0.13.4-rc1", "os": [ "freebsd" ], "cpu": [ "x64" ], "main": "tokenizers.freebsd-x64.node", "files": [ "tokenizers.freebsd-x64.node" ], "description": "Tokenizers platform specific bindings", "keywords": [ "napi-rs", "NAPI", "N...
tokenizers/bindings/node/npm/freebsd-x64/package.json/0
{ "file_path": "tokenizers/bindings/node/npm/freebsd-x64/package.json", "repo_id": "tokenizers", "token_count": 272 }
260
{ "name": "tokenizers-win32-x64-msvc", "version": "0.13.4-rc1", "os": [ "win32" ], "cpu": [ "x64" ], "main": "tokenizers.win32-x64-msvc.node", "files": [ "tokenizers.win32-x64-msvc.node" ], "description": "Tokenizers platform specific bindings", "keywords": [ "napi-rs", "NAPI",...
tokenizers/bindings/node/npm/win32-x64-msvc/package.json/0
{ "file_path": "tokenizers/bindings/node/npm/win32-x64-msvc/package.json", "repo_id": "tokenizers", "token_count": 277 }
261
use napi::bindgen_prelude::*; use napi_derive::napi; use tokenizers as tk; use tokenizers::Encoding; use crate::encoding::JsEncoding; #[napi] pub fn slice(s: String, begin_index: Option<i32>, end_index: Option<i32>) -> Result<String> { let len = s.chars().count(); let get_index = |x: i32| -> usize { if x >= ...
tokenizers/bindings/node/src/utils.rs/0
{ "file_path": "tokenizers/bindings/node/src/utils.rs", "repo_id": "tokenizers", "token_count": 503 }
262
import argparse import glob from os.path import join from tokenizers import ByteLevelBPETokenizer parser = argparse.ArgumentParser() parser.add_argument( "--files", default=None, metavar="path", type=str, required=True, help="The files to use as training; accept '**/*.txt' type of patterns \ ...
tokenizers/bindings/python/examples/train_bytelevel_bpe.py/0
{ "file_path": "tokenizers/bindings/python/examples/train_bytelevel_bpe.py", "repo_id": "tokenizers", "token_count": 521 }
263
from .. import normalizers Normalizer = normalizers.Normalizer BertNormalizer = normalizers.BertNormalizer NFD = normalizers.NFD NFKD = normalizers.NFKD NFC = normalizers.NFC NFKC = normalizers.NFKC Sequence = normalizers.Sequence Lowercase = normalizers.Lowercase Prepend = normalizers.Prepend Strip = normalizers.Str...
tokenizers/bindings/python/py_src/tokenizers/normalizers/__init__.py/0
{ "file_path": "tokenizers/bindings/python/py_src/tokenizers/normalizers/__init__.py", "repo_id": "tokenizers", "token_count": 304 }
264
[isort] default_section = FIRSTPARTY ensure_newline_before_comments = True force_grid_wrap = 0 include_trailing_comma = True known_first_party = transformers known_third_party = absl conllu datasets elasticsearch fairseq faiss-cpu fastprogress fire fugashi git h5py matplo...
tokenizers/bindings/python/setup.cfg/0
{ "file_path": "tokenizers/bindings/python/setup.cfg", "repo_id": "tokenizers", "token_count": 386 }
265
use pyo3::exceptions; use pyo3::prelude::*; use tk::utils::SysRegex; /// Instantiate a new Regex with the given pattern #[pyclass(module = "tokenizers", name = "Regex")] pub struct PyRegex { pub inner: SysRegex, pub pattern: String, } #[pymethods] impl PyRegex { #[new] #[pyo3(text_signature = "(self, ...
tokenizers/bindings/python/src/utils/regex.rs/0
{ "file_path": "tokenizers/bindings/python/src/utils/regex.rs", "repo_id": "tokenizers", "token_count": 273 }
266
from tokenizers import Tokenizer from ..utils import data_dir, doc_wiki_tokenizer disable_printing = True original_print = print def print(*args, **kwargs): if not disable_printing: original_print(*args, **kwargs) class TestQuicktour: # This method contains everything we don't want to run @sta...
tokenizers/bindings/python/tests/documentation/test_quicktour.py/0
{ "file_path": "tokenizers/bindings/python/tests/documentation/test_quicktour.py", "repo_id": "tokenizers", "token_count": 3290 }
267
# Encoding <tokenizerslangcontent> <python> ## Encoding [[autodoc]] tokenizers.Encoding - all - attention_mask - ids - n_sequences - offsets - overflowing - sequence_ids - special_tokens_mask - tokens - type_ids - word_ids - words </python> <rust> The Rust API Reference...
tokenizers/docs/source-doc-builder/api/encoding.mdx/0
{ "file_path": "tokenizers/docs/source-doc-builder/api/encoding.mdx", "repo_id": "tokenizers", "token_count": 190 }
268
from docutils import nodes import sphinx from sphinx.locale import _ from conf import rust_version logger = sphinx.util.logging.getLogger(__name__) class RustRef: def __call__(self, name, rawtext, text, lineno, inliner, options={}, content=[]): doctype = name.split("_")[1] parts = text.split(":...
tokenizers/docs/source/_ext/rust_doc.py/0
{ "file_path": "tokenizers/docs/source/_ext/rust_doc.py", "repo_id": "tokenizers", "token_count": 1221 }
269
Tokenizers ==================================================================================================== Fast State-of-the-art tokenizers, optimized for both research and production `🤗 Tokenizers`_ provides an implementation of today's most used tokenizers, with a focus on performance and versatility. These t...
tokenizers/docs/source/index.rst/0
{ "file_path": "tokenizers/docs/source/index.rst", "repo_id": "tokenizers", "token_count": 404 }
270
use std::time::{Duration, Instant}; use criterion::black_box; use tokenizers::{ Decoder, EncodeInput, Model, Normalizer, PostProcessor, PreTokenizer, TokenizerImpl, Trainer, }; pub fn iter_bench_encode<M, N, PT, PP, D>( iters: u64, tokenizer: &TokenizerImpl<M, N, PT, PP, D>, lines: &[EncodeInput], ) ...
tokenizers/tokenizers/benches/common/mod.rs/0
{ "file_path": "tokenizers/tokenizers/benches/common/mod.rs", "repo_id": "tokenizers", "token_count": 964 }
271
use crate::tokenizer::{Decoder, Result}; use serde::{Deserialize, Serialize}; #[derive(Deserialize, Clone, Debug, Serialize)] /// The WordPiece decoder takes care of decoding a list of wordpiece tokens /// back into a readable string. #[serde(tag = "type")] #[non_exhaustive] pub struct WordPiece { /// The prefix ...
tokenizers/tokenizers/src/decoders/wordpiece.rs/0
{ "file_path": "tokenizers/tokenizers/src/decoders/wordpiece.rs", "repo_id": "tokenizers", "token_count": 1275 }
272
use super::WordLevel; use crate::utils::parallelism::*; use crate::{AddedToken, Result, Trainer}; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::collections::HashMap; #[non_exhaustive] #[derive(Debug, Clone, Builder, Serialize, Deserialize)] pub struct WordLevelTrainer { /// The minimum freq...
tokenizers/tokenizers/src/models/wordlevel/trainer.rs/0
{ "file_path": "tokenizers/tokenizers/src/models/wordlevel/trainer.rs", "repo_id": "tokenizers", "token_count": 2735 }
273
use serde::{Deserialize, Serialize}; use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior}; use crate::utils::macro_rules_attribute; #[derive(Clone, Debug, PartialEq, Eq)] /// Pre tokenizes the numbers into single tokens. If individual_digits is set /// to true, then all digits are ...
tokenizers/tokenizers/src/pre_tokenizers/digits.rs/0
{ "file_path": "tokenizers/tokenizers/src/pre_tokenizers/digits.rs", "repo_id": "tokenizers", "token_count": 1667 }
274
use crate::parallelism::*; use crate::tokenizer::{Offsets, Token}; use crate::utils::padding::PaddingDirection; use crate::utils::truncation::TruncationDirection; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::ops::Range; /// Represents the output of a `Tokenizer`. #[derive(Default, Parti...
tokenizers/tokenizers/src/tokenizer/encoding.rs/0
{ "file_path": "tokenizers/tokenizers/src/tokenizer/encoding.rs", "repo_id": "tokenizers", "token_count": 17192 }
275
mod common; use common::*; use tokenizers::tokenizer::AddedToken; #[test] fn add_tokens() { let mut tokenizer = get_empty(); assert_eq!( tokenizer.add_special_tokens(&[ AddedToken::from("<cls>", true), AddedToken::from("<sep>", true) ]), 2 ); assert_eq!...
tokenizers/tokenizers/tests/added_tokens.rs/0
{ "file_path": "tokenizers/tokenizers/tests/added_tokens.rs", "repo_id": "tokenizers", "token_count": 1770 }
276
- local: index title: 🤗 Transformers.js - sections: - local: installation title: Installation - local: pipelines title: The pipeline API - local: custom_usage title: Custom usage title: Get started - sections: - local: tutorials/vanilla-js title: Building a Vanilla JS Application - local:...
transformers.js/docs/source/_toctree.yml/0
{ "file_path": "transformers.js/docs/source/_toctree.yml", "repo_id": "transformers.js", "token_count": 825 }
277