text stringlengths 7 1.24M | id stringlengths 14 166 | metadata dict | __index_level_0__ int64 0 519 |
|---|---|---|---|
# coding=utf-8
# Copyright 2024 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | diffusers/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_k_diffusion.py/0 | {
"file_path": "diffusers/tests/pipelines/stable_diffusion_xl/test_stable_diffusion_xl_k_diffusion.py",
"repo_id": "diffusers",
"token_count": 2166
} | 161 |
# coding=utf-8
# Copyright 2024 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | diffusers/tests/pipelines/text_to_video_synthesis/test_text_to_video_zero_sdxl.py/0 | {
"file_path": "diffusers/tests/pipelines/text_to_video_synthesis/test_text_to_video_zero_sdxl.py",
"repo_id": "diffusers",
"token_count": 7435
} | 162 |
import torch
from diffusers import DDPMScheduler
from .test_schedulers import SchedulerCommonTest
class DDPMSchedulerTest(SchedulerCommonTest):
scheduler_classes = (DDPMScheduler,)
def get_scheduler_config(self, **kwargs):
config = {
"num_train_timesteps": 1000,
"beta_start"... | diffusers/tests/schedulers/test_scheduler_ddpm.py/0 | {
"file_path": "diffusers/tests/schedulers/test_scheduler_ddpm.py",
"repo_id": "diffusers",
"token_count": 3860
} | 163 |
import tempfile
from typing import Dict, List, Tuple
import torch
from diffusers import LCMScheduler
from diffusers.utils.testing_utils import torch_device
from .test_schedulers import SchedulerCommonTest
class LCMSchedulerTest(SchedulerCommonTest):
scheduler_classes = (LCMScheduler,)
forward_default_kwarg... | diffusers/tests/schedulers/test_scheduler_lcm.py/0 | {
"file_path": "diffusers/tests/schedulers/test_scheduler_lcm.py",
"repo_id": "diffusers",
"token_count": 5668
} | 164 |
import gc
import tempfile
import unittest
import torch
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline
from diffusers.utils import load_image
from diffusers.utils.testing_utils import (
enable_full_determinism,
numpy_cosine_similarity_distance,
require_torch_gpu,
slow,
tor... | diffusers/tests/single_file/test_stable_diffusion_controlnet_img2img_single_file.py/0 | {
"file_path": "diffusers/tests/single_file/test_stable_diffusion_controlnet_img2img_single_file.py",
"repo_id": "diffusers",
"token_count": 3508
} | 165 |
# coding=utf-8
# Copyright 2024 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | diffusers/utils/check_inits.py/0 | {
"file_path": "diffusers/utils/check_inits.py",
"repo_id": "diffusers",
"token_count": 5410
} | 166 |
# coding=utf-8
# Copyright 2024 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | diffusers/utils/update_metadata.py/0 | {
"file_path": "diffusers/utils/update_metadata.py",
"repo_id": "diffusers",
"token_count": 1709
} | 167 |
FROM nvidia/cuda:12.2.2-devel-ubuntu22.04
# Configure image
ARG PYTHON_VERSION=3.10
ARG DEBIAN_FRONTEND=noninteractive
# Install apt dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake \
git git-lfs openssh-client \
nano vim less util-linux tree \
htop... | lerobot/docker/lerobot-gpu-dev/Dockerfile/0 | {
"file_path": "lerobot/docker/lerobot-gpu-dev/Dockerfile",
"repo_id": "lerobot",
"token_count": 983
} | 168 |
#!/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/common/datasets/lerobot_dataset.py/0 | {
"file_path": "lerobot/lerobot/common/datasets/lerobot_dataset.py",
"repo_id": "lerobot",
"token_count": 6675
} | 169 |
#!/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/common/datasets/push_dataset_to_hub/aloha_hdf5_format.py/0 | {
"file_path": "lerobot/lerobot/common/datasets/push_dataset_to_hub/aloha_hdf5_format.py",
"repo_id": "lerobot",
"token_count": 3851
} | 170 |
#!/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/common/envs/factory.py/0 | {
"file_path": "lerobot/lerobot/common/envs/factory.py",
"repo_id": "lerobot",
"token_count": 744
} | 171 |
"""
This file contains utilities for recording frames from cameras. For more info look at `OpenCVCamera` docstring.
"""
import argparse
import concurrent.futures
import math
import platform
import shutil
import threading
import time
from dataclasses import dataclass, replace
from pathlib import Path
from threading imp... | lerobot/lerobot/common/robot_devices/cameras/opencv.py/0 | {
"file_path": "lerobot/lerobot/common/robot_devices/cameras/opencv.py",
"repo_id": "lerobot",
"token_count": 6654
} | 172 |
# @package _global_
fps: 10
env:
name: pusht
task: PushT-v0
image_size: 96
state_dim: 2
action_dim: 2
fps: ${fps}
episode_length: 300
gym:
obs_type: pixels_agent_pos
render_mode: rgb_array
visualization_width: 384
visualization_height: 384
| lerobot/lerobot/configs/env/pusht.yaml/0 | {
"file_path": "lerobot/lerobot/configs/env/pusht.yaml",
"repo_id": "lerobot",
"token_count": 112
} | 173 |
#!/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_dataset_to_hub.py/0 | {
"file_path": "lerobot/lerobot/scripts/push_dataset_to_hub.py",
"repo_id": "lerobot",
"token_count": 5879
} | 174 |
version https://git-lfs.github.com/spec/v1
oid sha256:095c30bfe3c5da168c85aceef905e74e2142866332282965aa6812f6e6e48448
size 4344
| lerobot/tests/data/lerobot/aloha_mobile_chair/meta_data/stats.safetensors/0 | {
"file_path": "lerobot/tests/data/lerobot/aloha_mobile_chair/meta_data/stats.safetensors",
"repo_id": "lerobot",
"token_count": 63
} | 175 |
version https://git-lfs.github.com/spec/v1
oid sha256:c0b18566cbf59e399ea40f1630df12ffbbb9f73bbc733d1d4eba62d675b1fda5
size 247
| lerobot/tests/data/lerobot/aloha_sim_insertion_human/train/state.json/0 | {
"file_path": "lerobot/tests/data/lerobot/aloha_sim_insertion_human/train/state.json",
"repo_id": "lerobot",
"token_count": 66
} | 176 |
version https://git-lfs.github.com/spec/v1
oid sha256:1441f982dcda008d470b3df1283431584e05838b69a374e5afc45483132baa41
size 683048
| lerobot/tests/data/lerobot/aloha_static_coffee_new/train/data-00000-of-00001.arrow/0 | {
"file_path": "lerobot/tests/data/lerobot/aloha_static_coffee_new/train/data-00000-of-00001.arrow",
"repo_id": "lerobot",
"token_count": 63
} | 177 |
version https://git-lfs.github.com/spec/v1
oid sha256:af0c9dfe9d1e8caa0f9b85ea64895ac7898d6a39414b00b6ced19955e8eceef6
size 982
| lerobot/tests/data/lerobot/pusht_image/train/dataset_info.json/0 | {
"file_path": "lerobot/tests/data/lerobot/pusht_image/train/dataset_info.json",
"repo_id": "lerobot",
"token_count": 69
} | 178 |
version https://git-lfs.github.com/spec/v1
oid sha256:a219f973d6535f40737265fd15d81944aabf8eb7527384d28c507926bfa89f25
size 912
| lerobot/tests/data/lerobot/xarm_lift_medium_replay/train/dataset_info.json/0 | {
"file_path": "lerobot/tests/data/lerobot/xarm_lift_medium_replay/train/dataset_info.json",
"repo_id": "lerobot",
"token_count": 64
} | 179 |
version https://git-lfs.github.com/spec/v1
oid sha256:1c5814b892ceeb0869ec2f1821ab2c5040cbc0f1351a89f5369c67bd137cfe48
size 105064
| lerobot/tests/data/lerobot/xarm_push_medium_replay_image/train/data-00000-of-00001.arrow/0 | {
"file_path": "lerobot/tests/data/lerobot/xarm_push_medium_replay_image/train/data-00000-of-00001.arrow",
"repo_id": "lerobot",
"token_count": 66
} | 180 |
version https://git-lfs.github.com/spec/v1
oid sha256:24150994c6959631dc081b43e4001a8664e13b194ac194a32100f7d3fd2c0d0f
size 85353
| lerobot/tests/data/save_dataset_to_safetensors/lerobot/xarm_lift_medium/frame_1.safetensors/0 | {
"file_path": "lerobot/tests/data/save_dataset_to_safetensors/lerobot/xarm_lift_medium/frame_1.safetensors",
"repo_id": "lerobot",
"token_count": 65
} | 181 |
version https://git-lfs.github.com/spec/v1
oid sha256:c9007dd51c748db4ecd6d75e70bdcabf8c312454ac97bf6710895a12e7288557
size 31672
| lerobot/tests/data/save_policy_to_safetensors/dora_aloha_real_act_real/grad_stats.safetensors/0 | {
"file_path": "lerobot/tests/data/save_policy_to_safetensors/dora_aloha_real_act_real/grad_stats.safetensors",
"repo_id": "lerobot",
"token_count": 62
} | 182 |
"""
This file contains generic tests to ensure that nothing breaks if we modify the push_dataset_to_hub API.
Also, this file contains backward compatibility tests. Because they are slow and require to download the raw datasets,
we skip them for now in our CI.
Example to run backward compatiblity tests locally:
```
DAT... | lerobot/tests/test_push_dataset_to_hub.py/0 | {
"file_path": "lerobot/tests/test_push_dataset_to_hub.py",
"repo_id": "lerobot",
"token_count": 6388
} | 183 |
import os
import re
import shutil
from dataclasses import field
from pathlib import Path
from typing import Dict, List
import torch
from datasets import concatenate_datasets, load_from_disk
from wandb import Audio
from datasets import load_from_disk, concatenate_datasets
def list_field(default=None, metadata=None):
... | parler-tts/training/utils.py/0 | {
"file_path": "parler-tts/training/utils.py",
"repo_id": "parler-tts",
"token_count": 3174
} | 184 |
# Builds GPU docker image of PyTorch
# Uses multi-staged approach to reduce size
# Stage 1
# Use base conda image to reduce time
FROM continuumio/miniconda3:latest AS compile-image
# Specify py version
ENV PYTHON_VERSION=3.8
# Install apt libs - copied from https://github.com/huggingface/accelerate/blob/main/docker/acc... | peft/docker/peft-cpu/Dockerfile/0 | {
"file_path": "peft/docker/peft-cpu/Dockerfile",
"repo_id": "peft",
"token_count": 649
} | 185 |
<!--Copyright 2023 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | peft/docs/source/developer_guides/contributing.md/0 | {
"file_path": "peft/docs/source/developer_guides/contributing.md",
"repo_id": "peft",
"token_count": 1620
} | 186 |
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
} | 187 |
<jupyter_start><jupyter_text>Fine-tune large models using 🤗 `peft` adapters, `transformers` & `bitsandbytes`In this tutorial we will cover how we can fine-tune large language models using the very recent `peft` library and `bitsandbytes` for loading large models in 8-bit.The fine-tuning method will rely on a recent me... | peft/examples/int8_training/Finetune_opt_bnb_peft.ipynb/0 | {
"file_path": "peft/examples/int8_training/Finetune_opt_bnb_peft.ipynb",
"repo_id": "peft",
"token_count": 2755
} | 188 |
<jupyter_start><jupyter_code>!pip install -q git+https://github.com/huggingface/transformers.git
!pip install -q git+https://github.com/huggingface/peft.git
!pip install -q git+https://github.com/huggingface/accelerate.git@main
!pip install huggingface_hub
!pip install bitsandbytes
!pip install SentencePiece
import os
... | peft/examples/multi_adapter_examples/PEFT_Multi_LoRA_Inference.ipynb/0 | {
"file_path": "peft/examples/multi_adapter_examples/PEFT_Multi_LoRA_Inference.ipynb",
"repo_id": "peft",
"token_count": 1344
} | 189 |
import argparse
import json
import os
from datetime import date
from pathlib import Path
from tabulate import tabulate
MAX_LEN_MESSAGE = 2900 # slack endpoint has a limit of 3001 characters
parser = argparse.ArgumentParser()
parser.add_argument(
"--slack_channel_name",
default="peft-ci-daily",
)
def main... | peft/scripts/log_reports.py/0 | {
"file_path": "peft/scripts/log_reports.py",
"repo_id": "peft",
"token_count": 2521
} | 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/adalora/__init__.py/0 | {
"file_path": "peft/src/peft/tuners/adalora/__init__.py",
"repo_id": "peft",
"token_count": 429
} | 191 |
# 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/boft/layer.py/0 | {
"file_path": "peft/src/peft/tuners/boft/layer.py",
"repo_id": "peft",
"token_count": 19628
} | 192 |
# 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/ln_tuning/config.py/0 | {
"file_path": "peft/src/peft/tuners/ln_tuning/config.py",
"repo_id": "peft",
"token_count": 950
} | 193 |
# 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/dora.py/0 | {
"file_path": "peft/src/peft/tuners/lora/dora.py",
"repo_id": "peft",
"token_count": 3356
} | 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/src/peft/tuners/oft/model.py/0 | {
"file_path": "peft/src/peft/tuners/oft/model.py",
"repo_id": "peft",
"token_count": 1600
} | 195 |
# 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/save_and_load.py/0 | {
"file_path": "peft/src/peft/utils/save_and_load.py",
"repo_id": "peft",
"token_count": 10762
} | 196 |
# 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_initialization.py/0 | {
"file_path": "peft/tests/test_initialization.py",
"repo_id": "peft",
"token_count": 25439
} | 197 |
#!/bin/bash
NUM_PROC=$1
shift
torchrun --nproc_per_node=$NUM_PROC train.py "$@"
| pytorch-image-models/distributed_train.sh/0 | {
"file_path": "pytorch-image-models/distributed_train.sh",
"repo_id": "pytorch-image-models",
"token_count": 37
} | 198 |
# Deep Layer Aggregation
Extending “shallow” skip connections, **Dense Layer Aggregation (DLA)** incorporates more depth and sharing. The authors introduce two structures for deep layer aggregation (DLA): iterative deep aggregation (IDA) and hierarchical deep aggregation (HDA). These structures are expressed through ... | pytorch-image-models/hfdocs/source/models/dla.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/dla.mdx",
"repo_id": "pytorch-image-models",
"token_count": 6758
} | 199 |
# Inception ResNet v2
**Inception-ResNet-v2** is a convolutional neural architecture that builds on the Inception family of architectures but incorporates [residual connections](https://paperswithcode.com/method/residual-connection) (replacing the filter concatenation stage of the Inception architecture).
## How do I... | pytorch-image-models/hfdocs/source/models/inception-resnet-v2.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/inception-resnet-v2.mdx",
"repo_id": "pytorch-image-models",
"token_count": 1682
} | 200 |
# Res2NeXt
**Res2NeXt** is an image model that employs a variation on [ResNeXt](https://paperswithcode.com/method/resnext) bottleneck residual blocks. The motivation is to be able to represent features at multiple scales. This is achieved through a novel building block for CNNs that constructs hierarchical residual-li... | pytorch-image-models/hfdocs/source/models/res2next.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/res2next.mdx",
"repo_id": "pytorch-image-models",
"token_count": 1711
} | 201 |
# (Tensorflow) EfficientNet Lite
**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/tf-efficientnet-lite.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/tf-efficientnet-lite.mdx",
"repo_id": "pytorch-image-models",
"token_count": 3373
} | 202 |
#!/usr/bin/env python3
"""PyTorch Inference Script
An example inference script that outputs top-k class ids for images in a folder into a csv.
Hacked together by / Copyright 2020 Ross Wightman (https://github.com/rwightman)
"""
import argparse
import json
import logging
import os
import time
from contextlib import su... | pytorch-image-models/inference.py/0 | {
"file_path": "pytorch-image-models/inference.py",
"repo_id": "pytorch-image-models",
"token_count": 6815
} | 203 |
import math
import torch
from torch.utils.data import Sampler
import torch.distributed as dist
class OrderedDistributedSampler(Sampler):
"""Sampler that restricts data loading to a subset of the dataset.
It is especially useful in conjunction with
:class:`torch.nn.parallel.DistributedDataParallel`. In suc... | pytorch-image-models/timm/data/distributed_sampler.py/0 | {
"file_path": "pytorch-image-models/timm/data/distributed_sampler.py",
"repo_id": "pytorch-image-models",
"token_count": 2276
} | 204 |
""" Dataset reader for webdataset
Hacked together by / Copyright 2022 Ross Wightman
"""
import io
import json
import logging
import math
import os
import random
import sys
from dataclasses import dataclass
from functools import partial
from itertools import islice
from typing import Any, Callable, Dict, List, Optional... | pytorch-image-models/timm/data/readers/reader_wds.py/0 | {
"file_path": "pytorch-image-models/timm/data/readers/reader_wds.py",
"repo_id": "pytorch-image-models",
"token_count": 7878
} | 205 |
""" Classifier head and layer factory
Hacked together by / Copyright 2020 Ross Wightman
"""
from collections import OrderedDict
from functools import partial
from typing import Optional, Union, Callable
import torch
import torch.nn as nn
from torch.nn import functional as F
from .adaptive_avgmax_pool import SelectAd... | pytorch-image-models/timm/layers/classifier.py/0 | {
"file_path": "pytorch-image-models/timm/layers/classifier.py",
"repo_id": "pytorch-image-models",
"token_count": 5047
} | 206 |
""" Gather-Excite Attention Block
Paper: `Gather-Excite: Exploiting Feature Context in CNNs` - https://arxiv.org/abs/1810.12348
Official code here, but it's only partial impl in Caffe: https://github.com/hujie-frank/GENet
I've tried to support all of the extent both w/ and w/o params. I don't believe I've seen anoth... | pytorch-image-models/timm/layers/gather_excite.py/0 | {
"file_path": "pytorch-image-models/timm/layers/gather_excite.py",
"repo_id": "pytorch-image-models",
"token_count": 1956
} | 207 |
""" Bilinear-Attention-Transform and Non-Local Attention
Paper: `Non-Local Neural Networks With Grouped Bilinear Attentional Transforms`
- https://openaccess.thecvf.com/content_CVPR_2020/html/Chi_Non-Local_Neural_Networks_With_Grouped_Bilinear_Attentional_Transforms_CVPR_2020_paper.html
Adapted from original code:... | pytorch-image-models/timm/layers/non_local_attn.py/0 | {
"file_path": "pytorch-image-models/timm/layers/non_local_attn.py",
"repo_id": "pytorch-image-models",
"token_count": 3028
} | 208 |
""" Convolution with Weight Standardization (StdConv and ScaledStdConv)
StdConv:
@article{weightstandardization,
author = {Siyuan Qiao and Huiyu Wang and Chenxi Liu and Wei Shen and Alan Yuille},
title = {Weight Standardization},
journal = {arXiv preprint arXiv:1903.10520},
year = {2019},
}
Code:... | pytorch-image-models/timm/layers/std_conv.py/0 | {
"file_path": "pytorch-image-models/timm/layers/std_conv.py",
"repo_id": "pytorch-image-models",
"token_count": 2483
} | 209 |
""" PyTorch FX Based Feature Extraction Helpers
Using https://pytorch.org/vision/stable/feature_extraction.html
"""
from typing import Callable, Dict, List, Optional, Union, Tuple, Type
import torch
from torch import nn
from ._features import _get_feature_info, _get_return_layers
try:
# NOTE we wrap torchvision ... | pytorch-image-models/timm/models/_features_fx.py/0 | {
"file_path": "pytorch-image-models/timm/models/_features_fx.py",
"repo_id": "pytorch-image-models",
"token_count": 2402
} | 210 |
"""
CoaT architecture.
Paper: Co-Scale Conv-Attentional Image Transformers - https://arxiv.org/abs/2104.06399
Official CoaT code at: https://github.com/mlpc-ucsd/CoaT
Modified from timm/models/vision_transformer.py
"""
from typing import List, Optional, Tuple, Union
import torch
import torch.nn as nn
import torch.... | pytorch-image-models/timm/models/coat.py/0 | {
"file_path": "pytorch-image-models/timm/models/coat.py",
"repo_id": "pytorch-image-models",
"token_count": 15701
} | 211 |
""" EfficientViT (by MSRA)
Paper: `EfficientViT: Memory Efficient Vision Transformer with Cascaded Group Attention`
- https://arxiv.org/abs/2305.07027
Adapted from official impl at https://github.com/microsoft/Cream/tree/main/EfficientViT
"""
__all__ = ['EfficientVitMsra']
import itertools
from collections impor... | pytorch-image-models/timm/models/efficientvit_msra.py/0 | {
"file_path": "pytorch-image-models/timm/models/efficientvit_msra.py",
"repo_id": "pytorch-image-models",
"token_count": 11894
} | 212 |
"""
InceptionNeXt paper: https://arxiv.org/abs/2303.16900
Original implementation & weights from: https://github.com/sail-sg/inceptionnext
"""
from functools import partial
from typing import Optional
import torch
import torch.nn as nn
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.layer... | pytorch-image-models/timm/models/inception_next.py/0 | {
"file_path": "pytorch-image-models/timm/models/inception_next.py",
"repo_id": "pytorch-image-models",
"token_count": 7422
} | 213 |
""" 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
} | 214 |
""" 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
} | 215 |
""" 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": 7935
} | 216 |
import math
import torch
from torch.optim.optimizer import Optimizer
class Nadam(Optimizer):
"""Implements Nadam algorithm (a variant of Adam based on Nesterov momentum).
It has been proposed in `Incorporating Nesterov Momentum into Adam`__.
Arguments:
params (iterable): iterable of parameters ... | pytorch-image-models/timm/optim/nadam.py/0 | {
"file_path": "pytorch-image-models/timm/optim/nadam.py",
"repo_id": "pytorch-image-models",
"token_count": 1921
} | 217 |
""" TanH Scheduler
TanH schedule with warmup, cycle/restarts, noise.
Hacked together by / Copyright 2021 Ross Wightman
"""
import logging
import math
import numpy as np
import torch
from typing import List
from .scheduler import Scheduler
_logger = logging.getLogger(__name__)
class TanhLRScheduler(Scheduler):
... | pytorch-image-models/timm/scheduler/tanh_lr.py/0 | {
"file_path": "pytorch-image-models/timm/scheduler/tanh_lr.py",
"repo_id": "pytorch-image-models",
"token_count": 1972
} | 218 |
import random
import numpy as np
import torch
def random_seed(seed=42, rank=0):
torch.manual_seed(seed + rank)
np.random.seed(seed + rank)
random.seed(seed + rank)
| pytorch-image-models/timm/utils/random.py/0 | {
"file_path": "pytorch-image-models/timm/utils/random.py",
"repo_id": "pytorch-image-models",
"token_count": 68
} | 219 |
<div align="center">
<a href="https://www.youtube.com/watch?v=jlMAX2Oaht0">
<img width=560 width=315 alt="Making TGI deployment optimal" src="https://huggingface.co/datasets/Narsil/tgi_assets/resolve/main/thumbnail.png">
</a>
# Text Generation Inference
<a href="https://github.com/huggingface/text-generation-infer... | text-generation-inference/README.md/0 | {
"file_path": "text-generation-inference/README.md",
"repo_id": "text-generation-inference",
"token_count": 3849
} | 220 |
use thiserror::Error;
use text_generation_router::server;
#[derive(Debug, Error)]
pub enum TensorRtLlmBackendError {
#[error("Tokenizer error: {0}")]
Tokenizer(String),
#[error("Argument validation error: {0}")]
ArgumentValidation(String),
#[error("WebServer error: {0}")]
WebServer(#[from] ser... | text-generation-inference/backends/trtllm/src/errors.rs/0 | {
"file_path": "text-generation-inference/backends/trtllm/src/errors.rs",
"repo_id": "text-generation-inference",
"token_count": 171
} | 221 |
use crate::block_allocator::{Allocator, BlockAllocation};
use slotmap::{DefaultKey, SlotMap};
use std::{
collections::{BTreeSet, HashMap},
sync::Arc,
};
pub struct RadixAllocator {
allocation_id: u64,
allocations: HashMap<u64, RadixAllocation>,
cache_blocks: RadixTrie,
/// Blocks that are im... | text-generation-inference/backends/v3/src/radix.rs/0 | {
"file_path": "text-generation-inference/backends/v3/src/radix.rs",
"repo_id": "text-generation-inference",
"token_count": 14068
} | 222 |
import pytest
from text_generation import Client, AsyncClient
from text_generation.errors import NotFoundError, ValidationError
from text_generation.types import FinishReason, InputToken
def test_generate(llama_7b_url, hf_headers):
client = Client(llama_7b_url, hf_headers)
response = client.generate("test", ... | text-generation-inference/clients/python/tests/test_client.py/0 | {
"file_path": "text-generation-inference/clients/python/tests/test_client.py",
"repo_id": "text-generation-inference",
"token_count": 2110
} | 223 |
# Monitoring TGI server with Prometheus and Grafana dashboard
TGI server deployment can easily be monitored through a Grafana dashboard, consuming a Prometheus data collection. Example of inspectable metrics are statistics on the effective batch sizes used by TGI, prefill/decode latencies, number of generated tokens, ... | text-generation-inference/docs/source/basic_tutorials/monitoring.md/0 | {
"file_path": "text-generation-inference/docs/source/basic_tutorials/monitoring.md",
"repo_id": "text-generation-inference",
"token_count": 1376
} | 224 |
# Tensor Parallelism
Tensor parallelism is a technique used to fit a large model in multiple GPUs. For example, when multiplying the input tensors with the first weight tensor, the matrix multiplication is equivalent to splitting the weight tensor column-wise, multiplying each column with the input separately, and the... | text-generation-inference/docs/source/conceptual/tensor_parallelism.md/0 | {
"file_path": "text-generation-inference/docs/source/conceptual/tensor_parallelism.md",
"repo_id": "text-generation-inference",
"token_count": 272
} | 225 |
import asyncio
import contextlib
import json
import math
import os
import random
import shutil
import subprocess
import sys
import tempfile
import time
from typing import Dict, List, Optional
import docker
import pytest
from aiohttp import ClientConnectorError, ClientOSError, ServerDisconnectedError
from docker.errors... | text-generation-inference/integration-tests/conftest.py/0 | {
"file_path": "text-generation-inference/integration-tests/conftest.py",
"repo_id": "text-generation-inference",
"token_count": 9413
} | 226 |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [
{
"id": 2323,
"logprob": null,
"text": "Test"
},
{
"id": 1715,
"logprob": -11.34375,
"text": " request"
}
],
"seed":... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_gptq/test_flash_llama_gptq_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_gptq/test_flash_llama_gptq_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 981
} | 227 |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 60,
"prefill": [
{
"id": 610,
"logprob": null,
"text": "def"
},
{
"id": 1489,
"logprob": -5.265625,
"text": " print"
},
{
"id":... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_starcoder2/test_flash_starcoder2_default_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_starcoder2/test_flash_starcoder2_default_params.json",
"repo_id": "text-generation-inference",
"token_count": 4760
} | 228 |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 13,
"logprob": -0.00756073,
"special": false,
"text": "\n"
},
{
"id": 13,
"logprob": -... | text-generation-inference/integration-tests/models/__snapshots__/test_llava_next/test_flash_llava_next_simple.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_llava_next/test_flash_llava_next_simple.json",
"repo_id": "text-generation-inference",
"token_count": 867
} | 229 |
import pytest
@pytest.fixture(scope="module")
def flash_llama_awq_handle_sharded(launcher):
with launcher(
"abhinavkulkarni/codellama-CodeLlama-7b-Python-hf-w4-g128-awq",
num_shard=2,
quantize="awq",
) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_ll... | text-generation-inference/integration-tests/models/test_flash_awq_sharded.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_awq_sharded.py",
"repo_id": "text-generation-inference",
"token_count": 624
} | 230 |
import pytest
@pytest.fixture(scope="module")
def flash_neox_handle(launcher):
with launcher("stabilityai/stablelm-tuned-alpha-3b", num_shard=1) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_neox(flash_neox_handle):
await flash_neox_handle.health(300)
return flash_neox_... | text-generation-inference/integration-tests/models/test_flash_neox.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_neox.py",
"repo_id": "text-generation-inference",
"token_count": 514
} | 231 |
import pytest
@pytest.fixture(scope="module")
def mpt_sharded_handle(launcher):
with launcher("mosaicml/mpt-7b", num_shard=2) as handle:
yield handle
@pytest.fixture(scope="module")
async def mpt_sharded(mpt_sharded_handle):
await mpt_sharded_handle.health(300)
return mpt_sharded_handle.client
... | text-generation-inference/integration-tests/models/test_mpt.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_mpt.py",
"repo_id": "text-generation-inference",
"token_count": 541
} | 232 |
import { check } from 'k6';
import { scenario } from 'k6/execution';
import http from 'k6/http';
import { Trend, Counter } from 'k6/metrics';
const host = __ENV.HOST;
const model_id = __ENV.MODEL_ID;
const timePerToken = new Trend('time_per_token', true);
const tokens = new Counter('tokens');
const new_tokens = new Co... | text-generation-inference/load_tests/common.js/0 | {
"file_path": "text-generation-inference/load_tests/common.js",
"repo_id": "text-generation-inference",
"token_count": 1530
} | 233 |
flash_att_commit := 3a9bfd076f98746c73362328958dbc68d145fbec
build-flash-attention:
if [ ! -d 'flash-attention' ]; then \
pip install -U packaging ninja --no-cache-dir && \
git clone https://github.com/HazyResearch/flash-attention.git; \
fi
cd flash-attention && git fetch && git checkout $(flash_att_commit) &&... | text-generation-inference/server/Makefile-flash-att/0 | {
"file_path": "text-generation-inference/server/Makefile-flash-att",
"repo_id": "text-generation-inference",
"token_count": 231
} | 234 |
// Adapted from turboderp exllama: https://github.com/turboderp/exllama
#ifndef _q4_matmul_cuh
#define _q4_matmul_cuh
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include <cstdint>
#include <cstdio>
#include <ATen/cuda/CUDAContext.h>
#include "q4_matrix.cuh"
#include "../tuning.h"
void q4_matmul_cuda
(
ExL... | text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matmul.cuh/0 | {
"file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matmul.cuh",
"repo_id": "text-generation-inference",
"token_count": 322
} | 235 |
#include "compat.cuh"
__forceinline__ __device__ half2 dot22_8(half2(&dq)[4], const half* a_ptr, const half2 g_result)
{
half2 result = {};
const half2* a2_ptr = (const half2*)a_ptr;
#pragma unroll
for (int i = 0; i < 4; i++) result = __hfma2(dq[i], *a2_ptr++, result);
return __hadd2(result, g_resu... | text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel_gptq.cuh/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel_gptq.cuh",
"repo_id": "text-generation-inference",
"token_count": 4839
} | 236 |
# Origin: https://github.com/predibase/lorax
# Path: lorax/server/lorax_server/adapters/__init__.py
# License: Apache License Version 2.0, January 2004
from text_generation_server.adapters.weights import (
AdapterBatchData,
AdapterBatchMetadata,
)
__all__ = [
"AdapterBatchData",
"AdapterBatchMe... | text-generation-inference/server/text_generation_server/adapters/__init__.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/adapters/__init__.py",
"repo_id": "text-generation-inference",
"token_count": 125
} | 237 |
# Copied logic from https://github.com/mit-han-lab/llm-awq/blob/f084f40bd996f3cf3a0633c1ad7d9d476c318aaa/awq/quantize/qmodule.py
from typing import Optional
import torch
import torch.nn as nn
import awq_inference_engine # with CUDA kernels
# class ScaledActivation(nn.Module):
# def __init__(self, module, scales... | text-generation-inference/server/text_generation_server/layers/awq/quantize/qmodule.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/awq/quantize/qmodule.py",
"repo_id": "text-generation-inference",
"token_count": 750
} | 238 |
from text_generation_server.layers.marlin.fp8 import GPTQMarlinFP8Linear
from text_generation_server.layers.marlin.gptq import (
GPTQMarlinWeightsLoader,
can_use_gptq_marlin,
repack_gptq_for_marlin,
)
from text_generation_server.layers.marlin.marlin import MarlinWeightsLoader
__all__ = [
"GPTQMarlinFP8... | text-generation-inference/server/text_generation_server/layers/marlin/__init__.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/marlin/__init__.py",
"repo_id": "text-generation-inference",
"token_count": 195
} | 239 |
# coding=utf-8
# Copyright 2024 Cohere 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 GPT-NeoX and OPT used by the M... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_cohere_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_cohere_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 8741
} | 240 |
# coding=utf-8
# Copyright 2024 Starcoder2 AI 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
# t... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_starcoder2_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_starcoder2_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 8804
} | 241 |
def load_text_model(prefix, config, weights, name=None):
if config.model_type == "llama":
from text_generation_server.models.custom_modeling.flash_llama_modeling import (
FlashLlamaForCausalLM,
)
return FlashLlamaForCausalLM(prefix, config, weights)
elif config.model_type ==... | text-generation-inference/server/text_generation_server/models/custom_modeling/vlm.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/vlm.py",
"repo_id": "text-generation-inference",
"token_count": 759
} | 242 |
# Origin: https://github.com/predibase/lorax
# Path: lorax/server/lorax_server/utils/adapter.py
# License: Apache License Version 2.0, January 2004
import warnings
from dataclasses import dataclass
from functools import lru_cache
from typing import TYPE_CHECKING, Set, Tuple, Optional, List
from safetensors.tor... | text-generation-inference/server/text_generation_server/utils/adapter.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/adapter.py",
"repo_id": "text-generation-inference",
"token_count": 4143
} | 243 |
# coding=utf-8
# Copyright 2023 Authors of "A Watermark for Large Language Models"
# available at https://arxiv.org/abs/2301.10226
#
# 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... | text-generation-inference/server/text_generation_server/utils/watermark.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/watermark.py",
"repo_id": "text-generation-inference",
"token_count": 1489
} | 244 |
/* eslint-disable @typescript-eslint/no-explicit-any */
import { bertProcessing, byteLevelProcessing, robertaProcessing, sequenceProcessing, templateProcessing } from '../../'
describe('bertProcessing', () => {
it('instantiates correctly with only two parameters', () => {
const processor = bertProcessing(['sep'... | tokenizers/bindings/node/lib/bindings/post-processors.test.ts/0 | {
"file_path": "tokenizers/bindings/node/lib/bindings/post-processors.test.ts",
"repo_id": "tokenizers",
"token_count": 1022
} | 245 |
# `tokenizers-linux-arm64-gnu`
This is the **aarch64-unknown-linux-gnu** binary for `tokenizers`
| tokenizers/bindings/node/npm/linux-arm64-gnu/README.md/0 | {
"file_path": "tokenizers/bindings/node/npm/linux-arm64-gnu/README.md",
"repo_id": "tokenizers",
"token_count": 35
} | 246 |
use serde::de::Deserializer;
use serde::ser::Serializer;
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
pub fn serialize<S, T>(val: &Option<Arc<RwLock<T>>>, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
T: Serialize,
{
T::serialize(&*(val.clone().unwrap()).read().unwrap(), s)
}
pub f... | tokenizers/bindings/node/src/arc_rwlock_serde.rs/0 | {
"file_path": "tokenizers/bindings/node/src/arc_rwlock_serde.rs",
"repo_id": "tokenizers",
"token_count": 220
} | 247 |
from enum import Enum
from typing import List, Tuple, Union
Offsets = Tuple[int, int]
TextInputSequence = str
"""A :obj:`str` that represents an input sequence """
PreTokenizedInputSequence = Union[List[str], Tuple[str]]
"""A pre-tokenized input sequence. Can be one of:
- A :obj:`List` of :obj:`str`
- A :o... | tokenizers/bindings/python/py_src/tokenizers/__init__.py/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/__init__.py",
"repo_id": "tokenizers",
"token_count": 984
} | 248 |
# Generated content DO NOT EDIT
class PreTokenizer:
"""
Base class for all pre-tokenizers
This class is not supposed to be instantiated directly. Instead, any implementation of a
PreTokenizer will return an instance of this class when instantiated.
"""
def pre_tokenize(self, pretok):
""... | tokenizers/bindings/python/py_src/tokenizers/pre_tokenizers/__init__.pyi/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/pre_tokenizers/__init__.pyi",
"repo_id": "tokenizers",
"token_count": 9665
} | 249 |
use pyo3::exceptions;
use pyo3::prelude::*;
use pyo3::type_object::PyTypeInfo;
use std::fmt::{Display, Formatter, Result as FmtResult};
use tokenizers::tokenizer::Result;
#[derive(Debug)]
pub struct PyError(pub String);
impl PyError {
#[allow(dead_code)]
pub fn from(s: &str) -> Self {
PyError(String::f... | tokenizers/bindings/python/src/error.rs/0 | {
"file_path": "tokenizers/bindings/python/src/error.rs",
"repo_id": "tokenizers",
"token_count": 536
} | 250 |
from tokenizers import Tokenizer, decoders, models, normalizers, pre_tokenizers, processors
from tokenizers.implementations import BaseTokenizer
class TestBaseTokenizer:
def test_get_set_components(self):
toki = Tokenizer(models.BPE())
toki.normalizer = normalizers.NFC()
toki.pre_tokenizer... | tokenizers/bindings/python/tests/implementations/test_base_tokenizer.py/0 | {
"file_path": "tokenizers/bindings/python/tests/implementations/test_base_tokenizer.py",
"repo_id": "tokenizers",
"token_count": 550
} | 251 |
# Normalizers
<tokenizerslangcontent>
<python>
## BertNormalizer
[[autodoc]] tokenizers.normalizers.BertNormalizer
## Lowercase
[[autodoc]] tokenizers.normalizers.Lowercase
## NFC
[[autodoc]] tokenizers.normalizers.NFC
## NFD
[[autodoc]] tokenizers.normalizers.NFD
## NFKC
[[autodoc]] tokenizers.normalizers.NF... | tokenizers/docs/source-doc-builder/api/normalizers.mdx/0 | {
"file_path": "tokenizers/docs/source-doc-builder/api/normalizers.mdx",
"repo_id": "tokenizers",
"token_count": 350
} | 252 |
🤗 Tokenizers is tested on Python 3.5+.
You should install 🤗 Tokenizers in a
`virtual environment <https://docs.python.org/3/library/venv.html>`_. If you're unfamiliar with
Python virtual environments, check out the
`user guide <https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/>`__.
C... | tokenizers/docs/source/installation/python.inc/0 | {
"file_path": "tokenizers/docs/source/installation/python.inc",
"repo_id": "tokenizers",
"token_count": 384
} | 253 |
#[macro_use]
extern crate criterion;
use criterion::Criterion;
use std::collections::HashMap;
use std::fs::read_to_string;
use std::time::{Duration, Instant};
use tokenizers::models::unigram::Unigram;
use tokenizers::models::unigram::UnigramTrainer;
pub fn bench_train(c: &mut Criterion) {
let trainer = UnigramTra... | tokenizers/tokenizers/benches/unigram_benchmark.rs/0 | {
"file_path": "tokenizers/tokenizers/benches/unigram_benchmark.rs",
"repo_id": "tokenizers",
"token_count": 1174
} | 254 |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello wasm-pack!</title>
</head>
<body>
<noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript>
<script src="./bootstrap.js"></script>
</body>
</html>
| tokenizers/tokenizers/examples/unstable_wasm/www/index.html/0 | {
"file_path": "tokenizers/tokenizers/examples/unstable_wasm/www/index.html",
"repo_id": "tokenizers",
"token_count": 110
} | 255 |
use super::{super::OrderedVocabIter, trainer::BpeTrainer, Error, Pair, Word};
use crate::tokenizer::{Model, Result, Token};
use crate::utils::cache::{Cache, DEFAULT_CACHE_CAPACITY};
use crate::utils::iter::ResultShunt;
use serde_json::Value;
use std::borrow::Cow;
use std::{
collections::HashMap,
fs::File,
i... | tokenizers/tokenizers/src/models/bpe/model.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/bpe/model.rs",
"repo_id": "tokenizers",
"token_count": 17495
} | 256 |
use super::WordPiece;
use crate::models::bpe::{BpeTrainer, BpeTrainerBuilder, BPE};
use crate::tokenizer::{AddedToken, Result, Trainer};
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
/// A `WordPieceTrainerBuilder` can be used to create a `WordPieceTrainer` with a custom
/// configuration.
pub st... | tokenizers/tokenizers/src/models/wordpiece/trainer.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/wordpiece/trainer.rs",
"repo_id": "tokenizers",
"token_count": 2499
} | 257 |
use serde::{Deserialize, Serialize};
use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior};
use crate::utils::macro_rules_attribute;
use unicode_categories::UnicodeCategories;
fn is_punc(x: char) -> bool {
char::is_ascii_punctuation(&x) || x.is_punctuation()
}
#[derive(Copy, Cl... | tokenizers/tokenizers/src/pre_tokenizers/punctuation.rs/0 | {
"file_path": "tokenizers/tokenizers/src/pre_tokenizers/punctuation.rs",
"repo_id": "tokenizers",
"token_count": 1102
} | 258 |
use crate::utils::SysRegex;
use crate::{Offsets, Result};
use regex::Regex;
/// Pattern used to split a NormalizedString
pub trait Pattern {
/// Slice the given string in a list of pattern match positions, with
/// a boolean indicating whether this is a match or not.
///
/// This method *must* cover th... | tokenizers/tokenizers/src/tokenizer/pattern.rs/0 | {
"file_path": "tokenizers/tokenizers/src/tokenizer/pattern.rs",
"repo_id": "tokenizers",
"token_count": 3903
} | 259 |
#![cfg(feature = "http")]
use tokenizers::{FromPretrainedParameters, Result, Tokenizer};
#[test]
fn test_from_pretrained() -> Result<()> {
let tokenizer = Tokenizer::from_pretrained("bert-base-cased", None)?;
let encoding = tokenizer.encode("Hey there dear friend!", false)?;
assert_eq!(
encoding.ge... | tokenizers/tokenizers/tests/from_pretrained.rs/0 | {
"file_path": "tokenizers/tokenizers/tests/from_pretrained.rs",
"repo_id": "tokenizers",
"token_count": 683
} | 260 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.