text stringlengths 96 319k | id stringlengths 14 178 | metadata dict |
|---|---|---|
#!/usr/bin/env python
# Copyright 2024 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
#
# ... | lerobot/lerobot/scripts/push_pretrained.py/0 | {
"file_path": "lerobot/lerobot/scripts/push_pretrained.py",
"repo_id": "lerobot",
"token_count": 732
} |
"""Mocked classes and functions from dynamixel_sdk to allow for continuous integration
and testing code logic that requires hardware and devices (e.g. robot arms, cameras)
Warning: These mocked versions are minimalist. They do not exactly mock every behaviors
from the original classes and functions (e.g. return types ... | lerobot/tests/mock_dynamixel_sdk.py/0 | {
"file_path": "lerobot/tests/mock_dynamixel_sdk.py",
"repo_id": "lerobot",
"token_count": 1181
} |
#!/usr/bin/env python
# Copyright 2024 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
#
# ... | lerobot/tests/test_online_buffer.py/0 | {
"file_path": "lerobot/tests/test_online_buffer.py",
"repo_id": "lerobot",
"token_count": 4665
} |
compute_environment: LOCAL_MACHINE
debug: false
distributed_type: MULTI_GPU
downcast_bf16: 'no'
gpu_ids: all
machine_rank: 0
main_training_function: main
mixed_precision: bf16
num_machines: 1
num_processes: 8
rdzv_backend: static
same_network: true
tpu_env: []
tpu_use_cluster: false
tpu_use_sudo: false
use_cpu: false
| open-r1/recipes/accelerate_configs/ddp.yaml/0 | {
"file_path": "open-r1/recipes/accelerate_configs/ddp.yaml",
"repo_id": "open-r1",
"token_count": 129
} |
<!--Copyright 2023 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | peft/docs/source/developer_guides/torch_compile.md/0 | {
"file_path": "peft/docs/source/developer_guides/torch_compile.md",
"repo_id": "peft",
"token_count": 1014
} |
PEFT_TYPE="boft"
BLOCK_NUM=8
BLOCK_SIZE=0
N_BUTTERFLY_FACTOR=1
export DATASET_NAME="oftverse/control-celeba-hq"
export PROJECT_NAME="controlnet_${PEFT_TYPE}"
export RUN_NAME="${PEFT_TYPE}_${BLOCK_NUM}${BLOCK_SIZE}${N_BUTTERFLY_FACTOR}"
export CONTROLNET_PATH=""
export MODEL_NAME="stabilityai/stable-diffusion-2-1"
# e... | peft/examples/boft_controlnet/train_controlnet.sh/0 | {
"file_path": "peft/examples/boft_controlnet/train_controlnet.sh",
"repo_id": "peft",
"token_count": 557
} |
import argparse
import os
import warnings
from typing import Optional
from huggingface_hub import HfFolder, whoami
from transformers import PretrainedConfig
def import_model_class_from_model_name_or_path(pretrained_model_name_or_path: str, revision: str):
text_encoder_config = PretrainedConfig.from_pretrained(
... | peft/examples/boft_dreambooth/utils/args_loader.py/0 | {
"file_path": "peft/examples/boft_dreambooth/utils/args_loader.py",
"repo_id": "peft",
"token_count": 5745
} |
<jupyter_start><jupyter_code>from transformers import AutoModelForSeq2SeqLM
import peft
from peft import get_peft_config, get_peft_model, get_peft_model_state_dict, IA3Config, TaskType
import torch
from datasets import load_dataset
import os
os.environ["TOKENIZERS_PARALLELISM"] = "false"
from transformers import AutoT... | peft/examples/conditional_generation/peft_ia3_seq2seq.ipynb/0 | {
"file_path": "peft/examples/conditional_generation/peft_ia3_seq2seq.ipynb",
"repo_id": "peft",
"token_count": 2685
} |
<jupyter_start><jupyter_text>Fine-tuning [Llama-3-8B](https://huggingface.co/meta-llama/Meta-Llama-3-8B) on [timdettmers/openassistant-guanaco](https://huggingface.co/datasets/timdettmers/openassistant-guanaco) Dataset using QDora (quantized Lora w/ use_dora=True) on T4 Free Colab GPU.<jupyter_code># Install the librar... | peft/examples/dora_finetuning/QDoRA_finetuning.ipynb/0 | {
"file_path": "peft/examples/dora_finetuning/QDoRA_finetuning.ipynb",
"repo_id": "peft",
"token_count": 2118
} |
<jupyter_start><jupyter_text>Initializing weights with LoftQ by replacing LoRA weights in-place This notebook shows how to apply [LoftQ](https://arxiv.org/abs/2310.08659) initialization on our QLoRA model.In short, the idea behind LoftQ is the following. When we use QLoRA, i.e. we quantize the base model with bitsandby... | peft/examples/loftq_finetuning/LoftQ_weight_replacement.ipynb/0 | {
"file_path": "peft/examples/loftq_finetuning/LoftQ_weight_replacement.ipynb",
"repo_id": "peft",
"token_count": 2207
} |
import argparse
import gc
import hashlib
import itertools
import logging
import math
import os
import threading
import warnings
from contextlib import nullcontext
from pathlib import Path
import datasets
import diffusers
import numpy as np
import psutil
import torch
import torch.nn.functional as F
import torch.utils.c... | peft/examples/oft_dreambooth/train_dreambooth.py/0 | {
"file_path": "peft/examples/oft_dreambooth/train_dreambooth.py",
"repo_id": "peft",
"token_count": 20006
} |
<jupyter_start><jupyter_text>Using VB-LoRA for sequence classification In this example, we fine-tune Roberta on a sequence classification task using VB-LoRA.This notebook is adapted from `examples/sequence_classification/VeRA.ipynb`. Imports<jupyter_code>import torch
from torch.optim import AdamW
from torch.utils.data... | peft/examples/sequence_classification/VBLoRA.ipynb/0 | {
"file_path": "peft/examples/sequence_classification/VBLoRA.ipynb",
"repo_id": "peft",
"token_count": 2869
} |
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Adapted from https://botorch.org/api/_modules/botorch/utils/torch.html
# TODO: To be removed once (if) https://github.com/pytorch/pytorch... | peft/src/peft/tuners/_buffer_dict.py/0 | {
"file_path": "peft/src/peft/tuners/_buffer_dict.py",
"repo_id": "peft",
"token_count": 2442
} |
// Author: Yao Feng
// Date: 2023/08
// Description: cuda kernel for fast block diag
#include <ATen/ATen.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <vector>
namespace{
template <typename scalar_t>
__global__ void forward_fast_block_diag_cuda_kernel(
const scalar_t* __restrict__ input, //[z, N, b... | peft/src/peft/tuners/boft/fbd/fbd_cuda_kernel.cu/0 | {
"file_path": "peft/src/peft/tuners/boft/fbd/fbd_cuda_kernel.cu",
"repo_id": "peft",
"token_count": 1511
} |
# 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/hra/layer.py/0 | {
"file_path": "peft/src/peft/tuners/hra/layer.py",
"repo_id": "peft",
"token_count": 8755
} |
# 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/lora/torchao.py/0 | {
"file_path": "peft/src/peft/tuners/lora/torchao.py",
"repo_id": "peft",
"token_count": 2496
} |
# 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/poly/config.py/0 | {
"file_path": "peft/src/peft/tuners/poly/config.py",
"repo_id": "peft",
"token_count": 1681
} |
# 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/vera/bnb.py/0 | {
"file_path": "peft/src/peft/tuners/vera/bnb.py",
"repo_id": "peft",
"token_count": 8510
} |
# 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/other.py/0 | {
"file_path": "peft/src/peft/utils/other.py",
"repo_id": "peft",
"token_count": 12804
} |
# 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": 3985
} |
# 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_stablediffusion.py/0 | {
"file_path": "peft/tests/test_stablediffusion.py",
"repo_id": "peft",
"token_count": 6040
} |
# Feature Extraction
All of the models in `timm` have consistent mechanisms for obtaining various types of features from the model for tasks besides classification.
## Penultimate Layer Features (Pre-Classifier Features)
The features from the penultimate model layer can be obtained in several ways without requiring ... | pytorch-image-models/hfdocs/source/feature_extraction.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/feature_extraction.mdx",
"repo_id": "pytorch-image-models",
"token_count": 3391
} |
# EfficientNet
**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 scales network wid... | pytorch-image-models/hfdocs/source/models/efficientnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/efficientnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 4914
} |
# (Legacy) SE-ResNeXt
**SE ResNeXt** is a variant of a [ResNeXt](https://www.paperswithcode.com/method/resnext) 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.
## How do I use this... | pytorch-image-models/hfdocs/source/models/legacy-se-resnext.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/legacy-se-resnext.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2732
} |
# (Tensorflow) MobileNet v3
**MobileNetV3** is a convolutional neural network that is designed for mobile phone CPUs. The network design includes the use of a [hard swish activation](https://paperswithcode.com/method/hard-swish) and [squeeze-and-excitation](https://paperswithcode.com/method/squeeze-and-excitation-bloc... | pytorch-image-models/hfdocs/source/models/tf-mobilenet-v3.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/tf-mobilenet-v3.mdx",
"repo_id": "pytorch-image-models",
"token_count": 4783
} |
from torch.nn.modules.batchnorm import BatchNorm2d
from torchvision.ops.misc import FrozenBatchNorm2d
import timm
import pytest
from timm.utils.model import freeze, unfreeze
from timm.utils.model import ActivationStatsHook
from timm.utils.model import extract_spp_stats
from timm.utils.model import _freeze_unfreeze
fr... | pytorch-image-models/tests/test_utils.py/0 | {
"file_path": "pytorch-image-models/tests/test_utils.py",
"repo_id": "pytorch-image-models",
"token_count": 2521
} |
""" Loader Factory, Fast Collate, CUDA Prefetcher
Prefetcher and Fast Collate inspired by NVIDIA APEX example at
https://github.com/NVIDIA/apex/commit/d5e2bb4bdeedd27b1dfaf5bb2b24d6c000dee9be#diff-cf86c282ff7fba81fad27a559379d5bf
Hacked together by / Copyright 2019, Ross Wightman
"""
import logging
import random
from... | pytorch-image-models/timm/data/loader.py/0 | {
"file_path": "pytorch-image-models/timm/data/loader.py",
"repo_id": "pytorch-image-models",
"token_count": 7038
} |
""" Real labels evaluator for ImageNet
Paper: `Are we done with ImageNet?` - https://arxiv.org/abs/2006.07159
Based on Numpy example at https://github.com/google-research/reassessed-imagenet
Hacked together by / Copyright 2020 Ross Wightman
"""
import os
import json
import numpy as np
import pkgutil
class RealLabels... | pytorch-image-models/timm/data/real_labels.py/0 | {
"file_path": "pytorch-image-models/timm/data/real_labels.py",
"repo_id": "pytorch-image-models",
"token_count": 854
} |
""" Model / Layer Config singleton state
"""
import os
import warnings
from typing import Any, Optional
import torch
__all__ = [
'is_exportable', 'is_scriptable', 'is_no_jit', 'use_fused_attn',
'set_exportable', 'set_scriptable', 'set_no_jit', 'set_layer_config', 'set_fused_attn',
'set_reentrant_ckpt', 'u... | pytorch-image-models/timm/layers/config.py/0 | {
"file_path": "pytorch-image-models/timm/layers/config.py",
"repo_id": "pytorch-image-models",
"token_count": 1974
} |
from typing import Tuple
import torch
def ndgrid(*tensors) -> Tuple[torch.Tensor, ...]:
"""generate N-D grid in dimension order.
The ndgrid function is like meshgrid except that the order of the first two input arguments are switched.
That is, the statement
[X1,X2,X3] = ndgrid(x1,x2,x3)
produc... | pytorch-image-models/timm/layers/grid.py/0 | {
"file_path": "pytorch-image-models/timm/layers/grid.py",
"repo_id": "pytorch-image-models",
"token_count": 565
} |
""" Normalization + Activation Layers
Provides Norm+Act fns for standard PyTorch norm layers such as
* BatchNorm
* GroupNorm
* LayerNorm
This allows swapping with alternative layers that are natively both norm + act such as
* EvoNorm (evo_norm.py)
* FilterResponseNorm (filter_response_norm.py)
* InplaceABN (inplace_a... | pytorch-image-models/timm/layers/norm_act.py/0 | {
"file_path": "pytorch-image-models/timm/layers/norm_act.py",
"repo_id": "pytorch-image-models",
"token_count": 7990
} |
try:
from torch import _assert
except ImportError:
def _assert(condition: bool, message: str):
assert condition, message
def _float_to_int(x: float) -> int:
"""
Symbolic tracing helper to substitute for inbuilt `int`.
Hint: Inbuilt `int` can't accept an argument of type `Proxy`
"""
... | pytorch-image-models/timm/layers/trace_utils.py/0 | {
"file_path": "pytorch-image-models/timm/layers/trace_utils.py",
"repo_id": "pytorch-image-models",
"token_count": 119
} |
import hashlib
import json
import logging
import os
from functools import partial
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Iterable, List, Optional, Tuple, Union
import torch
from torch.hub import HASH_REGEX, download_url_to_file, urlparse
try:
from torch.hub import get_... | pytorch-image-models/timm/models/_hub.py/0 | {
"file_path": "pytorch-image-models/timm/models/_hub.py",
"repo_id": "pytorch-image-models",
"token_count": 7750
} |
""" ConvMixer
"""
from typing import Optional
import torch
import torch.nn as nn
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.layers import SelectAdaptivePool2d
from ._registry import register_model, generate_default_cfgs
from ._builder import build_model_with_cfg
from ._manipulate imp... | pytorch-image-models/timm/models/convmixer.py/0 | {
"file_path": "pytorch-image-models/timm/models/convmixer.py",
"repo_id": "pytorch-image-models",
"token_count": 2255
} |
""" Inception-V3
Originally from torchvision Inception3 model
Licensed BSD-Clause 3 https://github.com/pytorch/vision/blob/master/LICENSE
"""
from functools import partial
from typing import Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.data import IMAGENET_DEFAULT_STD, IMAGEN... | pytorch-image-models/timm/models/inception_v3.py/0 | {
"file_path": "pytorch-image-models/timm/models/inception_v3.py",
"repo_id": "pytorch-image-models",
"token_count": 8642
} |
"""
pnasnet5large implementation grabbed from Cadene's pretrained models
Additional credit to https://github.com/creafz
https://github.com/Cadene/pretrained-models.pytorch/blob/master/pretrainedmodels/models/pnasnet.py
"""
from collections import OrderedDict
from functools import partial
import torch
import torch... | pytorch-image-models/timm/models/pnasnet.py/0 | {
"file_path": "pytorch-image-models/timm/models/pnasnet.py",
"repo_id": "pytorch-image-models",
"token_count": 7672
} |
""" Swin Transformer
A PyTorch impl of : `Swin Transformer: Hierarchical Vision Transformer using Shifted Windows`
- https://arxiv.org/pdf/2103.14030
Code/weights from https://github.com/microsoft/Swin-Transformer, original copyright/license info below
S3 (AutoFormerV2, https://arxiv.org/abs/2111.14725) Swin weig... | pytorch-image-models/timm/models/swin_transformer.py/0 | {
"file_path": "pytorch-image-models/timm/models/swin_transformer.py",
"repo_id": "pytorch-image-models",
"token_count": 21031
} |
"""
Ported to pytorch thanks to [tstandley](https://github.com/tstandley/Xception-PyTorch)
@author: tstandley
Adapted by cadene
Creates an Xception Model as defined in:
Francois Chollet
Xception: Deep Learning with Depthwise Separable Convolutions
https://arxiv.org/pdf/1610.02357.pdf
This weights ported from the Ke... | pytorch-image-models/timm/models/xception.py/0 | {
"file_path": "pytorch-image-models/timm/models/xception.py",
"repo_id": "pytorch-image-models",
"token_count": 3992
} |
""" PyTorch Lamb optimizer w/ behaviour similar to NVIDIA FusedLamb
This optimizer code was adapted from the following (starting with latest)
* https://github.com/HabanaAI/Model-References/blob/2b435114fe8e31f159b1d3063b8280ae37af7423/PyTorch/nlp/bert/pretraining/lamb.py
* https://github.com/NVIDIA/DeepLearningExample... | pytorch-image-models/timm/optim/lamb.py/0 | {
"file_path": "pytorch-image-models/timm/optim/lamb.py",
"repo_id": "pytorch-image-models",
"token_count": 4311
} |
""" Distributed training/validation utils
Hacked together by / Copyright 2020 Ross Wightman
"""
import logging
import os
from typing import Optional
import torch
from torch import distributed as dist
from .model import unwrap_model
_logger = logging.getLogger(__name__)
def reduce_tensor(tensor, n):
rt = tenso... | pytorch-image-models/timm/utils/distributed.py/0 | {
"file_path": "pytorch-image-models/timm/utils/distributed.py",
"repo_id": "pytorch-image-models",
"token_count": 2680
} |
<!--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.md/0 | {
"file_path": "smolagents/docs/source/en/examples/text_to_sql.md",
"repo_id": "smolagents",
"token_count": 2400
} |
<!--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/rag.md/0 | {
"file_path": "smolagents/docs/source/hi/examples/rag.md",
"repo_id": "smolagents",
"token_count": 7786
} |
<!--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/text_to_sql.md/0 | {
"file_path": "smolagents/docs/source/zh/examples/text_to_sql.md",
"repo_id": "smolagents",
"token_count": 3136
} |
<jupyter_start><jupyter_code># !pip install plotly kaleido datasets nbformat -U -q
import os
import datasets
import pandas as pd
from dotenv import load_dotenv
from huggingface_hub import login
load_dotenv(override=True)
login(os.getenv("HF_TOKEN"))
pd.set_option("max_colwidth", None)
OUTPUT_DIR = "output"
eval_ds... | smolagents/examples/open_deep_research/analysis.ipynb/0 | {
"file_path": "smolagents/examples/open_deep_research/analysis.ipynb",
"repo_id": "smolagents",
"token_count": 3691
} |
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "smolagents"
version = "1.9.0.dev0"
description = "🤗 smolagents: a barebones library for agents. Agents write python code to call tools or orchestrate other agents."
authors = [
{ name="Aymeric Roucher", email="aymeric... | smolagents/pyproject.toml/0 | {
"file_path": "smolagents/pyproject.toml",
"repo_id": "smolagents",
"token_count": 995
} |
#!/usr/bin/env python
# coding=utf-8
# Copyright 2024 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/L... | smolagents/src/smolagents/tools.py/0 | {
"file_path": "smolagents/src/smolagents/tools.py",
"repo_id": "smolagents",
"token_count": 18127
} |
# 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... | smolagents/tests/test_monitoring.py/0 | {
"file_path": "smolagents/tests/test_monitoring.py",
"repo_id": "smolagents",
"token_count": 2645
} |
ARG cuda_arch_list="75-real;80-real;86-real;89-real;90-real;100-real;120-real"
ARG cuda_base=12.8.0
ARG build_type=release
ARG ompi_version=4.1.7
ARG sccache_gha_enabled=off
ARG actions_cache_url=""
ARG actions_runtime_token=""
# CUDA dependent dependencies resolver stage
FROM nvidia/cuda:${cuda_base}-cudnn-devel-ubu... | text-generation-inference/Dockerfile_trtllm/0 | {
"file_path": "text-generation-inference/Dockerfile_trtllm",
"repo_id": "text-generation-inference",
"token_count": 2414
} |
/// Multi shard Client
use crate::{v3, Health, ShardInfo};
use crate::{ClientError, Result};
use crate::v3::{Chunk, InfoResponse, Input};
use async_trait::async_trait;
use futures::future::join_all;
use tonic::transport::Uri;
use tracing::instrument;
use v3::client::{DecodeTimings, PrefillTimings};
use v3::{
Batch... | text-generation-inference/backends/client/src/v3/sharded_client.rs/0 | {
"file_path": "text-generation-inference/backends/client/src/v3/sharded_client.rs",
"repo_id": "text-generation-inference",
"token_count": 4351
} |
from argparse import ArgumentParser
AWS_S3_CACHING_VARIABLES = {
"AWS_ACCESS_KEY_ID": "aws_access_key_id",
"AWS_SECRET_ACCESS_KEY": "aws_secret_access_key",
"AWS_SESSION_TOKEN": "aws_session_token",
"SCCACHE_REGION": "s3_region",
"SCCACHE_BUCKET": "s3_bucket_name",
}
ALL_CACHING_STORAGE_VARIABLES ... | text-generation-inference/backends/trtllm/scripts/setup_sccache.py/0 | {
"file_path": "text-generation-inference/backends/trtllm/scripts/setup_sccache.py",
"repo_id": "text-generation-inference",
"token_count": 663
} |
use crate::client::{
Batch, GrammarType, NextTokenChooserParameters, Request, StoppingCriteriaParameters,
};
use nohash_hasher::{BuildNoHashHasher, IntMap};
use std::cmp::min;
use std::collections::VecDeque;
use text_generation_router::infer::InferError;
use text_generation_router::infer::InferStreamResponse;
use t... | text-generation-inference/backends/v2/src/queue.rs/0 | {
"file_path": "text-generation-inference/backends/v2/src/queue.rs",
"repo_id": "text-generation-inference",
"token_count": 11054
} |
/// Inspired by https://github.com/orhun/rust-tui-template/blob/472aa515119d4c94903eac12d9784417281dc7f5/src/event.rs
use ratatui::crossterm::event;
use std::time::{Duration, Instant};
use tokio::sync::{broadcast, mpsc};
/// Events
#[derive(Debug)]
pub(crate) enum Event {
/// Terminal tick.
Tick,
/// Key p... | text-generation-inference/benchmark/src/event.rs/0 | {
"file_path": "text-generation-inference/benchmark/src/event.rs",
"repo_id": "text-generation-inference",
"token_count": 917
} |
# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | text-generation-inference/clients/python/text_generation/__init__.py/0 | {
"file_path": "text-generation-inference/clients/python/text_generation/__init__.py",
"repo_id": "text-generation-inference",
"token_count": 338
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 323,
"logprob": -1.1171875,
"special": false,
"text": " and"
},
{
"id": 1268,
"logprob... | text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8a8_int/test_compressed_tensors_w8a8_int.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8a8_int/test_compressed_tensors_w8a8_int.json",
"repo_id": "text-generation-inference",
"token_count": 873
} |
{
"choices": [
{
"finish_reason": "length",
"index": 0,
"logprobs": null,
"message": {
"content": " the royal mouse? It is a little more slender and only weighs around 1.5 pounds for males and 1.3 pounds",
"role": "assistant"
}
}
],
"created": 1732541190,
"i... | text-generation-inference/integration-tests/models/__snapshots__/test_continue_final_message/test_llama_completion_single_prompt_continue.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_continue_final_message/test_llama_completion_single_prompt_continue.json",
"repo_id": "text-generation-inference",
"token_count": 260
} |
[
{
"choices": [
{
"finish_reason": "length",
"index": 0,
"logprobs": null,
"message": {
"content": "Jeff Walker's Product Launch Formula is a comprehensive system",
"name": null,
"role": "assistant",
"tool_calls": null
},
... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_prefix/test_flash_llama_load.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_prefix/test_flash_llama_load.json",
"repo_id": "text-generation-inference",
"token_count": 32395
} |
{
"details": {
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 100,
"logprob": -0.9824219,
"special": false,
"text": "_"
},
{
"id": 5879,
"logprob": -0.3017578,
"special": ... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_starcoder2_lora/test_flash_starcoder2_with_hugcode_adapter.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_starcoder2_lora/test_flash_starcoder2_with_hugcode_adapter.json",
"repo_id": "text-generation-inference",
"token_count": 852
} |
import pytest
@pytest.fixture(scope="module")
def flash_falcon_handle(launcher):
with launcher("tiiuae/falcon-7b", trust_remote_code=True) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_falcon(flash_falcon_handle):
await flash_falcon_handle.health(300)
return flash_falco... | text-generation-inference/integration-tests/models/test_flash_falcon.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_falcon.py",
"repo_id": "text-generation-inference",
"token_count": 908
} |
import pytest
@pytest.fixture(scope="module")
def flash_mistral_handle(launcher):
with launcher("mistralai/Mistral-7B-Instruct-v0.1") as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_mistral(flash_mistral_handle):
await flash_mistral_handle.health(300)
return flash_mistral... | text-generation-inference/integration-tests/models/test_flash_mistral.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_mistral.py",
"repo_id": "text-generation-inference",
"token_count": 714
} |
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
} |
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
} |
import datasets
import json
dataset = datasets.load_dataset("ccdv/govreport-summarization")
max_new_tokens = 50
conversations = []
for i, item in enumerate(dataset["test"]):
report = item["report"]
messages = [{"from": "human", "value": f"Summarize this report: ```{report}```"}]
conversations.append(... | text-generation-inference/load_tests/long.py/0 | {
"file_path": "text-generation-inference/load_tests/long.py",
"repo_id": "text-generation-inference",
"token_count": 156
} |
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "model_type")]
#[serde(rename_all = "snake_case")]
pub struct LlavaNext {
pub(crate) text_config: TextConfig,
pub(crate) vision_config: VisionConfig,
pub(crate) image_grid_pinpoints: Vec<(usize, usize)>,
}
f... | text-generation-inference/router/src/config.rs/0 | {
"file_path": "text-generation-inference/router/src/config.rs",
"repo_id": "text-generation-inference",
"token_count": 3641
} |
# Fork that adds only the correct stream to this kernel in order
# to make cuda graphs work.
awq_commit := bd1dc2d5254345cc76ab71894651fb821275bdd4
awq:
rm -rf llm-awq
git clone https://github.com/huggingface/llm-awq
build-awq: awq
cd llm-awq/ && git fetch && git checkout $(awq_commit)
cd llm-awq/awq/kernels && p... | text-generation-inference/server/Makefile-awq/0 | {
"file_path": "text-generation-inference/server/Makefile-awq",
"repo_id": "text-generation-inference",
"token_count": 183
} |
// Adapted from turboderp exllama: https://github.com/turboderp/exllama
#ifndef _cuda_buffers_cuh
#define _cuda_buffers_cuh
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include <cstdint>
#include <cstdio>
const int CUDA_MAX_DEVICES = 16;
// #ifndef _cuda_buffers_cu
// extern __constant__ half2 q4_table[16][256... | text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_buffers.cuh/0 | {
"file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_buffers.cuh",
"repo_id": "text-generation-inference",
"token_count": 471
} |
#ifndef _matrix_view_cuh
#define _matrix_view_cuh
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include "quant/qdq_util.cuh"
class MatrixView_half
{
public:
const half* data;
const int height;
const int width;
__device__ __forceinline__ MatrixView_half(const half* data, const int height, const i... | text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/matrix_view.cuh/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/matrix_view.cuh",
"repo_id": "text-generation-inference",
"token_count": 1862
} |
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import torch
extra_cuda_cflags = ["-lineinfo", "-O3"]
extra_cflags = []
if torch.version.hip:
extra_cflags = ["-DLEGACY_HIPBLAS_DIRECT=ON"]
extra_cuda_cflags += ["-DHIPBLAS_USE_HIP_HALF", "-DLEGACY_HIPBLAS_DIRECT=O... | text-generation-inference/server/exllamav2_kernels/setup.py/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/setup.py",
"repo_id": "text-generation-inference",
"token_count": 424
} |
import torch
from text_generation_server.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": 1146
} |
#!/usr/bin/env python
"""
Fused Attention
===============
This is a Triton implementation of the Flash Attention v2 algorithm from Tri Dao
(https://tridao.me/publications/flash2/flash2.pdf)
Credits: OpenAI kernel team, AMD ML Frameworks Triton team
Features supported:
1) Fwd with causal masking
2) Any sequence lengt... | text-generation-inference/server/text_generation_server/layers/attention/flash_attn_triton.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/attention/flash_attn_triton.py",
"repo_id": "text-generation-inference",
"token_count": 14692
} |
from accelerate import init_empty_weights
import torch
@classmethod
def load_conv2d(cls, prefix, weights, in_channels, out_channels, kernel_size, stride):
weight = weights.get_tensor(f"{prefix}.weight")
bias = weights.get_tensor(f"{prefix}.bias")
with init_empty_weights():
conv2d = cls(
... | text-generation-inference/server/text_generation_server/layers/conv.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/conv.py",
"repo_id": "text-generation-inference",
"token_count": 518
} |
from typing import Optional
import torch
import torch.nn as nn
from text_generation_server.layers.fp8 import fp8_quantize
from text_generation_server.layers.marlin.gptq import _check_valid_shape
from text_generation_server.layers.marlin.util import (
_check_marlin_kernels,
permute_scales,
)
try:
import ma... | text-generation-inference/server/text_generation_server/layers/marlin/fp8.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/marlin/fp8.py",
"repo_id": "text-generation-inference",
"token_count": 1806
} |
import torch
import time
import torch.distributed
from dataclasses import dataclass
from opentelemetry import trace
from transformers import (
AutoConfig,
AutoTokenizer,
AutoModelForCausalLM,
PreTrainedTokenizerBase,
)
from typing import Optional, Tuple, List, Type, Dict
from text_generation_server.ut... | text-generation-inference/server/text_generation_server/models/causal_lm.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/causal_lm.py",
"repo_id": "text-generation-inference",
"token_count": 16985
} |
# coding=utf-8
# Copyright 2024 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 requi... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_pali_gemma_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_pali_gemma_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 1969
} |
import torch
import torch.distributed
from mamba_ssm.ops.triton.selective_state_update import selective_state_update
from mamba_ssm.ops.selective_scan_interface import selective_scan_fn
from torch import nn
from typing import Optional, Tuple, Any
from transformers.configuration_utils import PretrainedConfig
import tor... | text-generation-inference/server/text_generation_server/models/custom_modeling/mamba_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/mamba_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 4238
} |
import torch
import numpy as np
from typing import Iterable, Optional, Tuple, List, Dict
from text_generation_server.pb.generate_pb2 import Request
from io import BytesIO
from PIL import Image
from dataclasses import dataclass
from opentelemetry import trace
from transformers import (
PreTrainedTokenizerBase,
)
... | text-generation-inference/server/text_generation_server/models/mllama_causal_lm.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/mllama_causal_lm.py",
"repo_id": "text-generation-inference",
"token_count": 7887
} |
import torch
from loguru import logger
import os
import importlib.util
def is_ipex_available():
return importlib.util.find_spec("intel_extension_for_pytorch") is not None
def get_cuda_free_memory(device, memory_fraction):
total_free_memory, _ = torch.cuda.mem_get_info(device)
total_gpu_memory = torch.... | text-generation-inference/server/text_generation_server/utils/import_utils.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/import_utils.py",
"repo_id": "text-generation-inference",
"token_count": 932
} |
import subprocess
import argparse
import ast
import json
import os
TEMPLATE = """
# Supported Models
Text Generation Inference enables serving optimized models. The following sections list which models (VLMs & LLMs) are supported.
SUPPORTED_MODELS
If the above list lacks the model you would like to serve, dependin... | text-generation-inference/update_doc.py/0 | {
"file_path": "text-generation-inference/update_doc.py",
"repo_id": "text-generation-inference",
"token_count": 2987
} |
.PHONY: style check-style test
DATA_DIR = data
dir_guard=@mkdir -p $(@D)
# Format source code automatically
style:
npm run lint
# Check the source code is formatted correctly
check-style:
npm run lint-check
TESTS_RESOURCES = $(DATA_DIR)/small.txt $(DATA_DIR)/roberta.json $(DATA_DIR)/tokenizer-wiki.json $(DATA_DI... | tokenizers/bindings/node/Makefile/0 | {
"file_path": "tokenizers/bindings/node/Makefile",
"repo_id": "tokenizers",
"token_count": 406
} |
import {
byteLevelPreTokenizer,
metaspacePreTokenizer,
punctuationPreTokenizer,
sequencePreTokenizer,
splitPreTokenizer,
whitespaceSplitPreTokenizer,
} from '../../'
describe('byteLevelPreTokenizer', () => {
it('instantiates correctly', () => {
const processor = byteLevelPreTokenizer()
expect(pro... | tokenizers/bindings/node/lib/bindings/pre-tokenizers.test.ts/0 | {
"file_path": "tokenizers/bindings/node/lib/bindings/pre-tokenizers.test.ts",
"repo_id": "tokenizers",
"token_count": 728
} |
{
"name": "tokenizers-linux-arm64-gnu",
"version": "0.13.4-rc1",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"main": "tokenizers.linux-arm64-gnu.node",
"files": [
"tokenizers.linux-arm64-gnu.node"
],
"description": "Tokenizers platform specific bindings",
"keywords": [
"napi-rs",
"N... | tokenizers/bindings/node/npm/linux-arm64-gnu/package.json/0 | {
"file_path": "tokenizers/bindings/node/npm/linux-arm64-gnu/package.json",
"repo_id": "tokenizers",
"token_count": 289
} |
use crate::arc_rwlock_serde;
use serde::{Deserialize, Serialize};
extern crate tokenizers as tk;
use napi::bindgen_prelude::*;
use napi_derive::napi;
use std::sync::{Arc, RwLock};
use tk::decoders::DecoderWrapper;
/// Decoder
#[derive(Clone, Serialize, Deserialize)]
#[napi]
pub struct Decoder {
#[serde(flatten, wi... | tokenizers/bindings/node/src/decoders.rs/0 | {
"file_path": "tokenizers/bindings/node/src/decoders.rs",
"repo_id": "tokenizers",
"token_count": 2038
} |
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
"-C", "link-arg=-mmacosx-version-min=10.11",
]
[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
"-C", "link-arg=-mmacosx-version-min=10.11",
]
| tokenizers/bindings/python/.cargo/config.toml/0 | {
"file_path": "tokenizers/bindings/python/.cargo/config.toml",
"repo_id": "tokenizers",
"token_count": 146
} |
# Generated content DO NOT EDIT
class AddedToken:
"""
Represents a token that can be be added to a :class:`~tokenizers.Tokenizer`.
It can have special options that defines the way it should behave.
Args:
content (:obj:`str`): The content of the token
single_word (:obj:`bool`, defaults ... | tokenizers/bindings/python/py_src/tokenizers/__init__.pyi/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/__init__.pyi",
"repo_id": "tokenizers",
"token_count": 17247
} |
#![warn(clippy::all)]
#![allow(clippy::upper_case_acronyms)]
// Many false positives with pyo3 it seems &str, and &PyAny get flagged
#![allow(clippy::borrow_deref_ref)]
extern crate tokenizers as tk;
mod decoders;
mod encoding;
mod error;
mod models;
mod normalizers;
mod pre_tokenizers;
mod processors;
mod token;
mod... | tokenizers/bindings/python/src/lib.rs/0 | {
"file_path": "tokenizers/bindings/python/src/lib.rs",
"repo_id": "tokenizers",
"token_count": 1086
} |
from tokenizers import BertWordPieceTokenizer
from ..utils import bert_files, data_dir, multiprocessing_with_parallelism
class TestBertWordPieceTokenizer:
def test_basic_encode(self, bert_files):
tokenizer = BertWordPieceTokenizer.from_file(bert_files["vocab"])
# Encode with special tokens by de... | tokenizers/bindings/python/tests/implementations/test_bert_wordpiece.py/0 | {
"file_path": "tokenizers/bindings/python/tests/implementations/test_bert_wordpiece.py",
"repo_id": "tokenizers",
"token_count": 914
} |
# Post-processors
<tokenizerslangcontent>
<python>
## BertProcessing
[[autodoc]] tokenizers.processors.BertProcessing
## ByteLevel
[[autodoc]] tokenizers.processors.ByteLevel
## RobertaProcessing
[[autodoc]] tokenizers.processors.RobertaProcessing
## TemplateProcessing
[[autodoc]] tokenizers.processors.Template... | tokenizers/docs/source-doc-builder/api/post-processors.mdx/0 | {
"file_path": "tokenizers/docs/source-doc-builder/api/post-processors.mdx",
"repo_id": "tokenizers",
"token_count": 174
} |
use tokenizers::Tokenizer;
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let tokenizer = Tokenizer::from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct", None)?;
let data = std::fs::read_to_string("data/big.txt")?;
let data: Vec<_> = data.lines().collect();
let add_special_tok... | tokenizers/tokenizers/examples/encode_batch.rs/0 | {
"file_path": "tokenizers/tokenizers/examples/encode_batch.rs",
"repo_id": "tokenizers",
"token_count": 165
} |
use super::{super::OrderedVocabIter, convert_merges_to_hashmap, BpeBuilder, Pair, BPE};
use serde::{
de::{Error, MapAccess, Visitor},
ser::SerializeStruct,
Deserialize, Deserializer, Serialize, Serializer,
};
use std::collections::HashMap;
impl Serialize for BPE {
fn serialize<S>(&self, serializer: S) ... | tokenizers/tokenizers/src/models/bpe/serialization.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/bpe/serialization.rs",
"repo_id": "tokenizers",
"token_count": 4848
} |
use crate::tokenizer::{NormalizedString, Normalizer, Result};
use serde::{Deserialize, Serialize};
use unicode_categories::UnicodeCategories;
/// Checks whether a character is whitespace
fn is_whitespace(c: char) -> bool {
// These are technically control characters but we count them as whitespace
match c {
... | tokenizers/tokenizers/src/normalizers/bert.rs/0 | {
"file_path": "tokenizers/tokenizers/src/normalizers/bert.rs",
"repo_id": "tokenizers",
"token_count": 1856
} |
use crate::pre_tokenizers::PreTokenizerWrapper;
use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result};
use crate::utils::macro_rules_attribute;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq)]
#[macro_rules_attribute(impl_serde_type!)]
pub struct Sequence {
pretokenizers: Vec<PreT... | tokenizers/tokenizers/src/pre_tokenizers/sequence.rs/0 | {
"file_path": "tokenizers/tokenizers/src/pre_tokenizers/sequence.rs",
"repo_id": "tokenizers",
"token_count": 1124
} |
use crate::{
normalizer::Range, Encoding, NormalizedString, OffsetReferential, Offsets, Result, Token,
};
use std::collections::HashMap;
/// Various possible types of offsets
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OffsetType {
Byte,
Char,
None,
}
/// Wrapper for a subpart of a `Normaliz... | tokenizers/tokenizers/src/tokenizer/pre_tokenizer.rs/0 | {
"file_path": "tokenizers/tokenizers/src/tokenizer/pre_tokenizer.rs",
"repo_id": "tokenizers",
"token_count": 5310
} |
mod common;
use common::*;
use tokenizers::tokenizer::AddedToken;
macro_rules! check_offsets {
($input: expr, $output:expr, $offset:expr, $result:expr) => {
let offsets = $output.get_offsets()[$offset];
assert_eq!(&$input[offsets.0..offsets.1], $result);
};
}
#[test]
fn byte_level_basic() {
... | tokenizers/tokenizers/tests/offsets.rs/0 | {
"file_path": "tokenizers/tokenizers/tests/offsets.rs",
"repo_id": "tokenizers",
"token_count": 2497
} |
{
"overrides": [
{
"files": ["tests/**/*.js"],
"options": {
"printWidth": 10000000
}
}
]
}
| transformers.js/.prettierrc/0 | {
"file_path": "transformers.js/.prettierrc",
"repo_id": "transformers.js",
"token_count": 108
} |
import './style.css';
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { pipeline, env, RawImage } from '@xenova/transformers';
// Since we will download the model from the Hugging Face Hub, we can skip the local model check
env.allowLocalModels = false;
... | transformers.js/examples/depth-anything-client/main.js/0 | {
"file_path": "transformers.js/examples/depth-anything-client/main.js",
"repo_id": "transformers.js",
"token_count": 1584
} |
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
html,
body {
height: 100%;
}
body {
padding: 16px 32px;
}
body,
#container,
#upload-button {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
h1,
h4 {
text-align: center;
}
h4 {... | transformers.js/examples/remove-background-client/style.css/0 | {
"file_path": "transformers.js/examples/remove-background-client/style.css",
"repo_id": "transformers.js",
"token_count": 422
} |
import { env, AutoTokenizer, ClapTextModelWithProjection } from '@xenova/transformers';
import { getCachedFile } from './utils';
// Skip local model check
env.allowLocalModels = false;
class ApplicationSingleton {
static model_id = 'Xenova/larger_clap_music_and_speech';
static BASE_URL = 'https://huggingface... | transformers.js/examples/semantic-audio-search/worker.js/0 | {
"file_path": "transformers.js/examples/semantic-audio-search/worker.js",
"repo_id": "transformers.js",
"token_count": 1294
} |
import './globals.css'
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
export const metadata = {
title: 'In-browser Semantic Image Search',
description: 'Search for images using text (built w/ Transformers.js)',
}
export default function RootLayout({ children }) {
return (
... | transformers.js/examples/semantic-image-search-client/src/app/layout.js/0 | {
"file_path": "transformers.js/examples/semantic-image-search-client/src/app/layout.js",
"repo_id": "transformers.js",
"token_count": 139
} |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Transformers.js - Text-to-speech demo</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</ht... | transformers.js/examples/text-to-speech-client/index.html/0 | {
"file_path": "transformers.js/examples/text-to-speech-client/index.html",
"repo_id": "transformers.js",
"token_count": 136
} |
{
"name": "webgpu-video-depth-estimation",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"vite": "^5.2.0"
},
"dependencies": {
"@xenova/transformers": "github:xenova/transf... | transformers.js/examples/webgpu-video-depth-estimation/package.json/0 | {
"file_path": "transformers.js/examples/webgpu-video-depth-estimation/package.json",
"repo_id": "transformers.js",
"token_count": 157
} |
export default function BotIcon(props) {
return (
<svg
{...props}
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
stroke... | transformers.js/examples/webgpu-vlm/src/components/icons/BotIcon.jsx/0 | {
"file_path": "transformers.js/examples/webgpu-vlm/src/components/icons/BotIcon.jsx",
"repo_id": "transformers.js",
"token_count": 392
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.