text
stringlengths
96
319k
id
stringlengths
14
178
metadata
dict
# coding=utf-8 # Copyright 2025 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_doc_toc.py/0
{ "file_path": "diffusers/utils/check_doc_toc.py", "repo_id": "diffusers", "token_count": 2177 }
# Copyright 2024 The HuggingFace Team, the AllenNLP library authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
diffusers/utils/stale.py/0
{ "file_path": "diffusers/utils/stale.py", "repo_id": "diffusers", "token_count": 1008 }
This tutorial explains how to use [Stretch 3](https://hello-robot.com/stretch-3-product) with LeRobot. ## Setup Familiarize yourself with Stretch by following its [tutorials](https://docs.hello-robot.com/0.3/getting_started/hello_robot/) (recommended). To use LeRobot on Stretch, 3 options are available: - [tethered ...
lerobot/examples/8_use_stretch.md/0
{ "file_path": "lerobot/examples/8_use_stretch.md", "repo_id": "lerobot", "token_count": 2135 }
#!/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/pusht_zarr_format.py/0
{ "file_path": "lerobot/lerobot/common/datasets/push_dataset_to_hub/pusht_zarr_format.py", "repo_id": "lerobot", "token_count": 4650 }
#!/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/optim/factory.py/0
{ "file_path": "lerobot/lerobot/common/optim/factory.py", "repo_id": "lerobot", "token_count": 883 }
#!/usr/bin/env python # Copyright 2025 Physical Intelligence and The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org...
lerobot/lerobot/common/policies/pi0/modeling_pi0.py/0
{ "file_path": "lerobot/lerobot/common/policies/pi0/modeling_pi0.py", "repo_id": "lerobot", "token_count": 12336 }
import enum import logging import math import time import traceback from copy import deepcopy import numpy as np import tqdm from lerobot.common.robot_devices.motors.configs import DynamixelMotorsBusConfig from lerobot.common.robot_devices.utils import RobotDeviceAlreadyConnectedError, RobotDeviceNotConnectedError fr...
lerobot/lerobot/common/robot_devices/motors/dynamixel.py/0
{ "file_path": "lerobot/lerobot/common/robot_devices/motors/dynamixel.py", "repo_id": "lerobot", "token_count": 15815 }
import datetime as dt import logging from dataclasses import dataclass, field from pathlib import Path from lerobot.common import envs, policies # noqa: F401 from lerobot.common.utils.utils import auto_select_torch_device, is_amp_available, is_torch_device_available from lerobot.configs import parser from lerobot.con...
lerobot/lerobot/configs/eval.py/0
{ "file_path": "lerobot/lerobot/configs/eval.py", "repo_id": "lerobot", "token_count": 1574 }
#!/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/visualize_image_transforms.py/0
{ "file_path": "lerobot/lerobot/scripts/visualize_image_transforms.py", "repo_id": "lerobot", "token_count": 1939 }
#!/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/scripts/save_image_transforms_to_safetensors.py/0
{ "file_path": "lerobot/tests/scripts/save_image_transforms_to_safetensors.py", "repo_id": "lerobot", "token_count": 1043 }
#!/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_sampler.py/0
{ "file_path": "lerobot/tests/test_sampler.py", "repo_id": "lerobot", "token_count": 1429 }
[isort] default_section = FIRSTPARTY ensure_newline_before_comments = True force_grid_wrap = 0 include_trailing_comma = True known_first_party = open_r1 known_third_party = transformers datasets fugashi git h5py matplotlib nltk numpy packaging pandas psutil pytest rou...
open-r1/setup.cfg/0
{ "file_path": "open-r1/setup.cfg", "repo_id": "open-r1", "token_count": 300 }
# coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
open-r1/src/open_r1/utils/upload_details.py/0
{ "file_path": "open-r1/src/open_r1/utils/upload_details.py", "repo_id": "open-r1", "token_count": 615 }
<!--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/package_reference/lora.md/0
{ "file_path": "peft/docs/source/package_reference/lora.md", "repo_id": "peft", "token_count": 627 }
<!--Copyright 2024 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
peft/docs/source/task_guides/lora_based_methods.md/0
{ "file_path": "peft/docs/source/task_guides/lora_based_methods.md", "repo_id": "peft", "token_count": 4895 }
# 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...
peft/examples/boft_controlnet/utils/light_controlnet.py/0
{ "file_path": "peft/examples/boft_controlnet/utils/light_controlnet.py", "repo_id": "peft", "token_count": 4318 }
# 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/examples/bone_finetuning/bone_finetuning.py/0
{ "file_path": "peft/examples/bone_finetuning/bone_finetuning.py", "repo_id": "peft", "token_count": 1490 }
import os import torch from accelerate import Accelerator from datasets import load_dataset from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, default_data_collator, get_linear_schedule_with_warmup from peft import LoraConfig, TaskType, get_pef...
peft/examples/conditional_generation/peft_lora_seq2seq_accelerate_fsdp.py/0
{ "file_path": "peft/examples/conditional_generation/peft_lora_seq2seq_accelerate_fsdp.py", "repo_id": "peft", "token_count": 2543 }
# 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/examples/pissa_finetuning/pissa_finetuning.py/0
{ "file_path": "peft/examples/pissa_finetuning/pissa_finetuning.py", "repo_id": "peft", "token_count": 2492 }
import os from enum import Enum import packaging.version import torch import transformers from datasets import DatasetDict, load_dataset, load_from_disk from datasets.builder import DatasetGenerationError from transformers import ( AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, ) from peft impor...
peft/examples/sft/utils.py/0
{ "file_path": "peft/examples/sft/utils.py", "repo_id": "peft", "token_count": 3623 }
# 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/auto.py/0
{ "file_path": "peft/src/peft/auto.py", "repo_id": "peft", "token_count": 2874 }
# 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/gptq.py/0
{ "file_path": "peft/src/peft/tuners/adalora/gptq.py", "repo_id": "peft", "token_count": 1154 }
# 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/bone/config.py/0
{ "file_path": "peft/src/peft/tuners/bone/config.py", "repo_id": "peft", "token_count": 2283 }
# Copyright 2023-present the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
peft/src/peft/tuners/ia3/config.py/0
{ "file_path": "peft/src/peft/tuners/ia3/config.py", "repo_id": "peft", "token_count": 2119 }
# 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/aqlm.py/0
{ "file_path": "peft/src/peft/tuners/lora/aqlm.py", "repo_id": "peft", "token_count": 1647 }
# 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/mixed/model.py/0
{ "file_path": "peft/src/peft/tuners/mixed/model.py", "repo_id": "peft", "token_count": 6670 }
# 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_hub_features.py/0
{ "file_path": "peft/tests/test_hub_features.py", "repo_id": "peft", "token_count": 1945 }
# 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/tests/test_vera.py/0
{ "file_path": "peft/tests/test_vera.py", "repo_id": "peft", "token_count": 5925 }
# PyTorch Image Models - [What's New](#whats-new) - [Introduction](#introduction) - [Models](#models) - [Features](#features) - [Results](#results) - [Getting Started (Documentation)](#getting-started-documentation) - [Train, Validation, Inference Scripts](#train-validation-inference-scripts) - [Awesome PyTorch Resourc...
pytorch-image-models/README.md/0
{ "file_path": "pytorch-image-models/README.md", "repo_id": "pytorch-image-models", "token_count": 21449 }
# Model Summaries The model architectures included come from a wide variety of sources. Sources, including papers, original impl ("reference code") that I rewrote / adapted, and PyTorch impl that I leveraged directly ("code") are listed below. Most included models have pretrained weights. The weights are either: 1. ...
pytorch-image-models/hfdocs/source/models.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models.mdx", "repo_id": "pytorch-image-models", "token_count": 4501 }
# MobileNet v2 **MobileNetV2** is a convolutional neural network architecture that seeks to perform well on mobile devices. It is based on an [inverted residual structure](https://paperswithcode.com/method/inverted-residual-block) where the residual connections are between the bottleneck layers. The intermediate expa...
pytorch-image-models/hfdocs/source/models/mobilenet-v2.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models/mobilenet-v2.mdx", "repo_id": "pytorch-image-models", "token_count": 3403 }
# Quickstart This quickstart is intended for developers who are ready to dive into the code and see an example of how to integrate `timm` into their model training workflow. First, you'll need to install `timm`. For more information on installation, see [Installation](installation). ```bash pip install timm ``` ## ...
pytorch-image-models/hfdocs/source/quickstart.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/quickstart.mdx", "repo_id": "pytorch-image-models", "token_count": 2581 }
import os import pickle def load_class_map(map_or_filename, root=''): if isinstance(map_or_filename, dict): assert dict, 'class_map dict must be non-empty' return map_or_filename class_map_path = map_or_filename if not os.path.exists(class_map_path): class_map_path = os.path.join(r...
pytorch-image-models/timm/data/readers/class_map.py/0
{ "file_path": "pytorch-image-models/timm/data/readers/class_map.py", "repo_id": "pytorch-image-models", "token_count": 387 }
from .activations import * from .adaptive_avgmax_pool import \ adaptive_avgmax_pool2d, select_adaptive_pool2d, AdaptiveAvgMaxPool2d, SelectAdaptivePool2d from .attention2d import MultiQueryAttention2d, Attention2d, MultiQueryAttentionV2 from .attention_pool import AttentionPoolLatent from .attention_pool2d import A...
pytorch-image-models/timm/layers/__init__.py/0
{ "file_path": "pytorch-image-models/timm/layers/__init__.py", "repo_id": "pytorch-image-models", "token_count": 1500 }
""" Attention Factory Hacked together by / Copyright 2021 Ross Wightman """ import torch from functools import partial from .bottleneck_attn import BottleneckAttn from .cbam import CbamModule, LightCbamModule from .eca import EcaModule, CecaModule from .gather_excite import GatherExcite from .global_context import Gl...
pytorch-image-models/timm/layers/create_attn.py/0
{ "file_path": "pytorch-image-models/timm/layers/create_attn.py", "repo_id": "pytorch-image-models", "token_count": 1588 }
""" Image to Patch Hybird Embedding Layer Hacked together by / Copyright 2020 Ross Wightman """ import logging import math from typing import List, Optional, Tuple, Union import torch from torch import nn as nn import torch.nn.functional as F from .format import Format, nchw_to from .helpers import to_2tuple from .p...
pytorch-image-models/timm/layers/hybrid_embed.py/0
{ "file_path": "pytorch-image-models/timm/layers/hybrid_embed.py", "repo_id": "pytorch-image-models", "token_count": 5059 }
""" AvgPool2d w/ Same Padding Hacked together by / Copyright 2020 Ross Wightman """ import torch import torch.nn as nn import torch.nn.functional as F from typing import List, Tuple, Optional from .helpers import to_2tuple from .padding import pad_same, get_padding_value def avg_pool2d_same(x, kernel_size: List[int...
pytorch-image-models/timm/layers/pool2d_same.py/0
{ "file_path": "pytorch-image-models/timm/layers/pool2d_same.py", "repo_id": "pytorch-image-models", "token_count": 1294 }
import torch import torch.nn as nn class AsymmetricLossMultiLabel(nn.Module): def __init__(self, gamma_neg=4, gamma_pos=1, clip=0.05, eps=1e-8, disable_torch_grad_focal_loss=False): super(AsymmetricLossMultiLabel, self).__init__() self.gamma_neg = gamma_neg self.gamma_pos = gamma_pos ...
pytorch-image-models/timm/loss/asymmetric_loss.py/0
{ "file_path": "pytorch-image-models/timm/loss/asymmetric_loss.py", "repo_id": "pytorch-image-models", "token_count": 1616 }
""" DaViT: Dual Attention Vision Transformers As described in https://arxiv.org/abs/2204.03645 Input size invariant transformer architecture that combines channel and spacial attention in each block. The attention mechanisms used are linear in complexity. DaViT model defs and weights adapted from https://github.com/...
pytorch-image-models/timm/models/davit.py/0
{ "file_path": "pytorch-image-models/timm/models/davit.py", "repo_id": "pytorch-image-models", "token_count": 14224 }
""" MambaOut models for image classification. Some implementations are modified from: timm (https://github.com/rwightman/pytorch-image-models), MetaFormer (https://github.com/sail-sg/metaformer), InceptionNeXt (https://github.com/sail-sg/inceptionnext) """ from collections import OrderedDict from typing import Optional...
pytorch-image-models/timm/models/mambaout.py/0
{ "file_path": "pytorch-image-models/timm/models/mambaout.py", "repo_id": "pytorch-image-models", "token_count": 10626 }
"""RegNet X, Y, Z, and more Paper: `Designing Network Design Spaces` - https://arxiv.org/abs/2003.13678 Original Impl: https://github.com/facebookresearch/pycls/blob/master/pycls/models/regnet.py Paper: `Fast and Accurate Model Scaling` - https://arxiv.org/abs/2103.06877 Original Impl: None Based on original PyTorch...
pytorch-image-models/timm/models/regnet.py/0
{ "file_path": "pytorch-image-models/timm/models/regnet.py", "repo_id": "pytorch-image-models", "token_count": 22592 }
""" Transformer in Transformer (TNT) in PyTorch A PyTorch implement of TNT as described in 'Transformer in Transformer' - https://arxiv.org/abs/2103.00112 The official mindspore code is released and available at https://gitee.com/mindspore/mindspore/tree/master/model_zoo/research/cv/TNT """ import math from typing im...
pytorch-image-models/timm/models/tnt.py/0
{ "file_path": "pytorch-image-models/timm/models/tnt.py", "repo_id": "pytorch-image-models", "token_count": 6783 }
""" Optimizer Factory w/ custom Weight Decay & Layer Decay support Hacked together by / Copyright 2021 Ross Wightman """ import logging from dataclasses import dataclass from functools import partial from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union from fnmatch import fnmatch import impo...
pytorch-image-models/timm/optim/_optim_factory.py/0
{ "file_path": "pytorch-image-models/timm/optim/_optim_factory.py", "repo_id": "pytorch-image-models", "token_count": 18438 }
""" Lookahead Optimizer Wrapper. Implementation modified from: https://github.com/alphadl/lookahead.pytorch Paper: `Lookahead Optimizer: k steps forward, 1 step back` - https://arxiv.org/abs/1907.08610 Hacked together by / Copyright 2020 Ross Wightman """ from collections import OrderedDict from typing import Callable...
pytorch-image-models/timm/optim/lookahead.py/0
{ "file_path": "pytorch-image-models/timm/optim/lookahead.py", "repo_id": "pytorch-image-models", "token_count": 1134 }
""" Misc utils Hacked together by / Copyright 2020 Ross Wightman """ import argparse import ast import re def natural_key(string_): """See http://www.codinghorror.com/blog/archives/001018.html""" return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_.lower())] def add_bool_arg(parser, nam...
pytorch-image-models/timm/utils/misc.py/0
{ "file_path": "pytorch-image-models/timm/utils/misc.py", "repo_id": "pytorch-image-models", "token_count": 451 }
<!--- Copyright 2025 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or ...
smolagents/CONTRIBUTING.md/0
{ "file_path": "smolagents/CONTRIBUTING.md", "repo_id": "smolagents", "token_count": 1156 }
<!--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/reference/agents.md/0
{ "file_path": "smolagents/docs/source/en/reference/agents.md", "repo_id": "smolagents", "token_count": 573 }
<!--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/reference/agents.md/0
{ "file_path": "smolagents/docs/source/hi/reference/agents.md", "repo_id": "smolagents", "token_count": 4332 }
<!--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/reference/tools.md/0
{ "file_path": "smolagents/docs/source/zh/reference/tools.md", "repo_id": "smolagents", "token_count": 704 }
#!/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/agents.py/0
{ "file_path": "smolagents/src/smolagents/agents.py", "repo_id": "smolagents", "token_count": 18519 }
from unittest.mock import patch import pytest from smolagents.agents import MultiStepAgent from smolagents.monitoring import LogLevel original_multi_step_agent_init = MultiStepAgent.__init__ @pytest.fixture(autouse=True) def patch_multi_step_agent_with_suppressed_logging(): with patch.object(MultiStepAgent, "...
smolagents/tests/conftest.py/0
{ "file_path": "smolagents/tests/conftest.py", "repo_id": "smolagents", "token_count": 230 }
# 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_utils.py/0
{ "file_path": "smolagents/tests/test_utils.py", "repo_id": "smolagents", "token_count": 4135 }
[package] name = "text-generation-backends-trtllm" version.workspace = true edition.workspace = true authors.workspace = true homepage.workspace = true [dependencies] async-trait = "0.1" clap = { version = "4.5", features = ["derive"] } cxx = "1.0" hashbrown = "0.15" hf-hub = { workspace = true } text-generation-route...
text-generation-inference/backends/trtllm/Cargo.toml/0
{ "file_path": "text-generation-inference/backends/trtllm/Cargo.toml", "repo_id": "text-generation-inference", "token_count": 275 }
use std::path::{Path, PathBuf}; use clap::Parser; use hf_hub::api::tokio::{Api, ApiBuilder}; use hf_hub::{Cache, Repo, RepoType}; use tracing::info; use text_generation_backends_trtllm::errors::TensorRtLlmBackendError; use text_generation_backends_trtllm::TensorRtLlmBackendV2; use text_generation_router::server::{ ...
text-generation-inference/backends/trtllm/src/main.rs/0
{ "file_path": "text-generation-inference/backends/trtllm/src/main.rs", "repo_id": "text-generation-inference", "token_count": 5530 }
use crate::app::Data; use tabled::settings::Merge; use tabled::{builder::Builder, settings::Style, Table}; #[allow(clippy::too_many_arguments)] pub(crate) fn parameters_table( tokenizer_name: String, sequence_length: u32, decode_length: u32, top_n_tokens: Option<u32>, n_runs: usize, warmups: us...
text-generation-inference/benchmark/src/table.rs/0
{ "file_path": "text-generation-inference/benchmark/src/table.rs", "repo_id": "text-generation-inference", "token_count": 2288 }
from enum import Enum from pydantic import BaseModel, field_validator, ConfigDict from typing import Optional, List, Union, Any from text_generation.errors import ValidationError # enum for grammar type class GrammarType(str, Enum): Json = "json" Regex = "regex" # Grammar type and value class Grammar(BaseM...
text-generation-inference/clients/python/text_generation/types.py/0
{ "file_path": "text-generation-inference/clients/python/text_generation/types.py", "repo_id": "text-generation-inference", "token_count": 5255 }
# Guidance Text Generation Inference (TGI) now supports [JSON and regex grammars](#grammar-and-constraints) and [tools and functions](#tools-and-functions) to help developers guide LLM responses to fit their needs. These feature are available starting from version `1.4.3`. They are accessible via the [`huggingface_hu...
text-generation-inference/docs/source/basic_tutorials/using_guidance.md/0
{ "file_path": "text-generation-inference/docs/source/basic_tutorials/using_guidance.md", "repo_id": "text-generation-inference", "token_count": 6730 }
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": 0, "tokens": [ { "id": 5267, "logprob": -1.1464844, "special": false, "text": "?\n" }, { "id": 33464, "logprob":...
text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8a8_int_dynamic_weight/test_compressed_tensors_w8a8_int_dynamic_weight_all_params.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8a8_int_dynamic_weight/test_compressed_tensors_w8a8_int_dynamic_weight_all_params.json", "repo_id": "text-generation-inference", "token_count": 862 }
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": null, "tokens": [ { "id": 198, "logprob": -0.68603516, "special": false, "text": "\n" }, { "id": 198, "logprob":...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_gpt2/test_flash_gpt2.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_gpt2/test_flash_gpt2.json", "repo_id": "text-generation-inference", "token_count": 866 }
{ "choices": [ { "delta": { "content": "", "role": "assistant", "tool_calls": null }, "finish_reason": "stop", "index": 0, "logprobs": null } ], "created": 1737646031, "id": "", "model": "Qwen/Qwen2-VL-7B-Instruct", "object": "chat.completion.chu...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2_vl/test_flash_qwen2_vl_simple_streaming.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2_vl/test_flash_qwen2_vl_simple_streaming.json", "repo_id": "text-generation-inference", "token_count": 201 }
{ "details": { "best_of_sequences": null, "finish_reason": "eos_token", "generated_tokens": 30, "prefill": [], "seed": null, "tokens": [ { "id": 6377, "logprob": -0.14916992, "special": false, "text": "{\"" }, { "id": 29888, "lo...
text-generation-inference/integration-tests/models/__snapshots__/test_grammar_llama/test_non_flash_llama_grammar_json.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_grammar_llama/test_non_flash_llama_grammar_json.json", "repo_id": "text-generation-inference", "token_count": 2413 }
{ "details": { "finish_reason": "length", "generated_tokens": 40, "prefill": [], "seed": null, "tokens": [ { "id": 13, "logprob": -0.31347656, "special": false, "text": "\n" }, { "id": 13, "logprob": -0.27441406, "special": ...
text-generation-inference/integration-tests/models/__snapshots__/test_lora_mistral/test_lora_mistral_without_customer_support_adapter.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_lora_mistral/test_lora_mistral_without_customer_support_adapter.json", "repo_id": "text-generation-inference", "token_count": 3126 }
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": 0, "tokens": [ { "id": 29899, "logprob": -1.4980469, "special": false, "text": "-" }, { "id": 1454, "logprob": -...
text-generation-inference/integration-tests/models/__snapshots__/test_server_gptq_quantized/test_server_gptq_quantized_all_params.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_server_gptq_quantized/test_server_gptq_quantized_all_params.json", "repo_id": "text-generation-inference", "token_count": 853 }
import pytest @pytest.fixture(scope="module") def bloom_560m_sharded_handle(launcher): with launcher("bigscience/bloom-560m", num_shard=2) as handle: yield handle @pytest.fixture(scope="module") async def bloom_560m_sharded(bloom_560m_sharded_handle): await bloom_560m_sharded_handle.health(240) ...
text-generation-inference/integration-tests/models/test_bloom_560m_sharded.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_bloom_560m_sharded.py", "repo_id": "text-generation-inference", "token_count": 527 }
import pytest @pytest.fixture(scope="module") def flash_gpt2_handle(launcher): with launcher("openai-community/gpt2", num_shard=2) as handle: yield handle @pytest.fixture(scope="module") async def flash_gpt2(flash_gpt2_handle): await flash_gpt2_handle.health(300) return flash_gpt2_handle.client ...
text-generation-inference/integration-tests/models/test_flash_gpt2.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_flash_gpt2.py", "repo_id": "text-generation-inference", "token_count": 476 }
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 }
import pytest @pytest.fixture(scope="module") def flash_idefics2_next_handle(launcher): with launcher( "HuggingFaceM4/idefics2-8b", ) as handle: yield handle @pytest.fixture(scope="module") async def flash_idefics2_next(flash_idefics2_next_handle): await flash_idefics2_next_handle.health...
text-generation-inference/integration-tests/models/test_idefics2.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_idefics2.py", "repo_id": "text-generation-inference", "token_count": 1159 }
[tool.poetry] name = "text-generation-inference-benchmarks" version = "0.1.0" description = "" authors = ["Hugo Larcher <hugo.larcher@huggingface.co>"] readme = "README.md" [tool.poetry.dependencies] python = "^3.11" docker = "^7.1.0" loguru = "^0.7.2" psutil = "^6.0.0" gputil = "^1.4.0" pandas = "^2.2.3" pyarrow = "^...
text-generation-inference/load_tests/pyproject.toml/0
{ "file_path": "text-generation-inference/load_tests/pyproject.toml", "repo_id": "text-generation-inference", "token_count": 195 }
use crate::infer::Infer; use crate::{ default_parameters, server::{generate_internal, ComputeType}, Deserialize, ErrorResponse, GenerateParameters, GenerateRequest, Serialize, ToSchema, }; use axum::extract::{Extension, Path}; use axum::http::{HeaderMap, StatusCode}; use axum::response::IntoResponse; use ax...
text-generation-inference/router/src/kserve.rs/0
{ "file_path": "text-generation-inference/router/src/kserve.rs", "repo_id": "text-generation-inference", "token_count": 3533 }
flash_att_v2_commit_cuda := v2.6.1 flash_att_v2_commit_rocm := 47bd46e0204a95762ae48712fd1a3978827c77fd build-flash-attention-v2-cuda: pip install -U packaging wheel pip install flash-attn==$(flash_att_v2_commit_cuda) install-flash-attention-v2-cuda: build-flash-attention-v2-cuda echo "Flash v2 installed" build-f...
text-generation-inference/server/Makefile-flash-att-v2/0
{ "file_path": "text-generation-inference/server/Makefile-flash-att-v2", "repo_id": "text-generation-inference", "token_count": 397 }
// 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 }
#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 }
import os from typing import Optional import torch from text_generation_server.layers.attention.kv_cache import KVCache, KVScales from text_generation_server.utils.import_utils import SYSTEM from text_generation_server.layers.attention import Seqlen from text_generation_server.utils.log import log_master from text_gene...
text-generation-inference/server/text_generation_server/layers/attention/rocm.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/attention/rocm.py", "repo_id": "text-generation-inference", "token_count": 5501 }
import os from dataclasses import dataclass from typing import List, Optional, Union import torch from loguru import logger from text_generation_server.utils.import_utils import SYSTEM from text_generation_server.utils.log import log_once from text_generation_server.utils.weights import Weight, Weights, WeightsLoader ...
text-generation-inference/server/text_generation_server/layers/gptq/__init__.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/gptq/__init__.py", "repo_id": "text-generation-inference", "token_count": 8349 }
import torch from torch import nn from typing import Tuple, Optional from text_generation_server.utils.speculate import get_speculate from text_generation_server.layers.linear import FastLinear from text_generation_server.layers.tensor_parallel import ( TensorParallelHead, TensorParallelColumnLinear, ) class ...
text-generation-inference/server/text_generation_server/layers/medusa.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/medusa.py", "repo_id": "text-generation-inference", "token_count": 2975 }
# 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": 8924 }
from typing import List, Optional, Tuple import torch import torch.distributed from torch import nn from transformers.configuration_utils import PretrainedConfig from transformers.modeling_utils import PreTrainedModel from text_generation_server.layers import ( SpeculativeHead, TensorParallelColumnLinear, ...
text-generation-inference/server/text_generation_server/models/custom_modeling/flash_rw_modeling.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_rw_modeling.py", "repo_id": "text-generation-inference", "token_count": 11278 }
# coding=utf-8 # Copyright 2022 The Fairseq Authors and The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/...
text-generation-inference/server/text_generation_server/models/custom_modeling/opt_modeling.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/opt_modeling.py", "repo_id": "text-generation-inference", "token_count": 15911 }
import math from typing import List, Optional import torch from opentelemetry import trace from transformers import AutoTokenizer, AutoModelForCausalLM import transformers.modeling_utils from text_generation_server.models.flash_causal_lm import FlashCausalLM from text_generation_server.utils import initialize_torch_d...
text-generation-inference/server/text_generation_server/models/transformers_flash_causal_lm.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/transformers_flash_causal_lm.py", "repo_id": "text-generation-inference", "token_count": 4705 }
# coding=utf-8 # From: https://github.com/huggingface/peft/pull/1364 # Copyright 2024-present the HuggingFace Inc. team. # Modifications by Predibase, 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 th...
text-generation-inference/server/text_generation_server/utils/merges/utils.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/utils/merges/utils.py", "repo_id": "text-generation-inference", "token_count": 1422 }
## How to release # Before the release Simple checklist on how to make releases for `tokenizers`. - Freeze `master` branch. - Run all tests (Check CI has properly run) - If any significant work, check benchmarks: - `cd tokenizers && cargo bench` (needs to be run on latest release tag to measure difference if it's ...
tokenizers/RELEASE.md/0
{ "file_path": "tokenizers/RELEASE.md", "repo_id": "tokenizers", "token_count": 1519 }
/* eslint-disable */ var globRequire = require console.log = (..._args: any[]) => {} describe('quicktourExample', () => { function require(mod: string) { if (mod.startsWith('tokenizers')) { return globRequire('../../') } else { return globRequire(mod) } } it.skip('trains the tokenizer',...
tokenizers/bindings/node/examples/documentation/quicktour.test.ts/0
{ "file_path": "tokenizers/bindings/node/examples/documentation/quicktour.test.ts", "repo_id": "tokenizers", "token_count": 2324 }
{ "name": "tokenizers-linux-x64-gnu", "version": "0.13.4-rc1", "os": [ "linux" ], "cpu": [ "x64" ], "main": "tokenizers.linux-x64-gnu.node", "files": [ "tokenizers.linux-x64-gnu.node" ], "description": "Tokenizers platform specific bindings", "keywords": [ "napi-rs", "NAPI", ...
tokenizers/bindings/node/npm/linux-x64-gnu/package.json/0
{ "file_path": "tokenizers/bindings/node/npm/linux-x64-gnu/package.json", "repo_id": "tokenizers", "token_count": 289 }
use crate::arc_rwlock_serde; use napi::bindgen_prelude::*; use napi_derive::napi; use serde::{Deserialize, Serialize}; use std::sync::{Arc, RwLock}; use tk::normalizers::NormalizerWrapper; use tk::NormalizedString; use tokenizers as tk; /// Normalizer #[derive(Debug, Clone, Serialize, Deserialize)] #[napi] pub struct ...
tokenizers/bindings/node/src/normalizers.rs/0
{ "file_path": "tokenizers/bindings/node/src/normalizers.rs", "repo_id": "tokenizers", "token_count": 1886 }
from typing import Dict, List, Optional, Tuple, Union from tokenizers import AddedToken, EncodeInput, Encoding, InputSequence, Tokenizer from tokenizers.decoders import Decoder from tokenizers.models import Model from tokenizers.normalizers import Normalizer from tokenizers.pre_tokenizers import PreTokenizer from toke...
tokenizers/bindings/python/py_src/tokenizers/implementations/base_tokenizer.py/0
{ "file_path": "tokenizers/bindings/python/py_src/tokenizers/implementations/base_tokenizer.py", "repo_id": "tokenizers", "token_count": 6036 }
import itertools import os import re from string import Template from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple from tokenizers import Encoding, Tokenizer dirname = os.path.dirname(__file__) css_filename = os.path.join(dirname, "visualizer-styles.css") with open(css_filename) as f: css...
tokenizers/bindings/python/py_src/tokenizers/tools/visualizer.py/0
{ "file_path": "tokenizers/bindings/python/py_src/tokenizers/tools/visualizer.py", "repo_id": "tokenizers", "token_count": 6751 }
use std::convert::TryInto; use std::sync::Arc; use std::sync::RwLock; use crate::encoding::PyEncoding; use crate::error::ToPyResult; use pyo3::exceptions; use pyo3::exceptions::PyException; use pyo3::prelude::*; use pyo3::types::*; use serde::ser::SerializeStruct; use serde::Deserializer; use serde::Serializer; use se...
tokenizers/bindings/python/src/processors.rs/0
{ "file_path": "tokenizers/bindings/python/src/processors.rs", "repo_id": "tokenizers", "token_count": 14543 }
import pickle import pytest from tokenizers.models import BPE, Model, WordLevel, WordPiece from ..utils import bert_files, data_dir, roberta_files class TestBPE: def test_instantiate(self, roberta_files): assert isinstance(BPE(), Model) assert isinstance(BPE(), BPE) vocab = {"a": 0, "b"...
tokenizers/bindings/python/tests/bindings/test_models.py/0
{ "file_path": "tokenizers/bindings/python/tests/bindings/test_models.py", "repo_id": "tokenizers", "token_count": 2304 }
# Visualizer <tokenizerslangcontent> <python> ## Annotation [[autodoc]] tokenizers.tools.Annotation ## EncodingVisualizer [[autodoc]] tokenizers.tools.EncodingVisualizer - __call__ </python> <rust> The Rust API Reference is available directly on the [Docs.rs](https://docs.rs/tokenizers/latest/tokenizers/) webs...
tokenizers/docs/source-doc-builder/api/visualizer.mdx/0
{ "file_path": "tokenizers/docs/source-doc-builder/api/visualizer.mdx", "repo_id": "tokenizers", "token_count": 134 }
# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.13.2] - Python only changes ## [0.13.1] - [#1072] Fixing ...
tokenizers/tokenizers/CHANGELOG.md/0
{ "file_path": "tokenizers/tokenizers/CHANGELOG.md", "repo_id": "tokenizers", "token_count": 3387 }
<div align="center"> <h1><code>wasm-pack-template</code></h1> <strong>A template for kick starting a Rust and WebAssembly project using <a href="https://github.com/rustwasm/wasm-pack">wasm-pack</a>.</strong> <p> <a href="https://travis-ci.org/rustwasm/wasm-pack-template"><img src="https://img.shields.io/tr...
tokenizers/tokenizers/examples/unstable_wasm/README.md/0
{ "file_path": "tokenizers/tokenizers/examples/unstable_wasm/README.md", "repo_id": "tokenizers", "token_count": 811 }
use rand::distributions::WeightedIndex; use rand::prelude::*; use std::cell::RefCell; use std::cmp::{min, Ordering}; use std::collections::BinaryHeap; use std::rc::Rc; type NodeRef = Rc<RefCell<Node>>; type HypothesisRef = Rc<RefCell<Hypothesis>>; type Agenda = BinaryHeap<Hypothesis>; struct Hypothesis { node_ref...
tokenizers/tokenizers/src/models/unigram/lattice.rs/0
{ "file_path": "tokenizers/tokenizers/src/models/unigram/lattice.rs", "repo_id": "tokenizers", "token_count": 12682 }
use crate::tokenizer::{NormalizedString, Normalizer, Result}; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "type")] pub struct Prepend { pub prepend: String, } impl Prepend { pub fn new(prepend: String) -> Self { Self { prepend } } } impl Norm...
tokenizers/tokenizers/src/normalizers/prepend.rs/0
{ "file_path": "tokenizers/tokenizers/src/normalizers/prepend.rs", "repo_id": "tokenizers", "token_count": 856 }
// Generated by modified Perl script at https://github.com/google/sentencepiece/blob/master/data/gen_unicode_scripts_code.pl // Unicode scripts : https://gist.github.com/Narsil/07556f26dc84a6baeff4d499e68d3cd2 // Rust adaptation : https://gist.github.com/Narsil/1df9fbbf5296a8d4d62de55dcb2fe700 #[derive(PartialEq, Debu...
tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/scripts.rs/0
{ "file_path": "tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/scripts.rs", "repo_id": "tokenizers", "token_count": 46440 }
use crate::Result; use hf_hub::{api::sync::ApiBuilder, Repo, RepoType}; use std::collections::HashMap; use std::path::PathBuf; /// Defines the additional parameters available for the `from_pretrained` function #[derive(Debug, Clone)] pub struct FromPretrainedParameters { pub revision: String, pub user_agent: H...
tokenizers/tokenizers/src/utils/from_pretrained.rs/0
{ "file_path": "tokenizers/tokenizers/src/utils/from_pretrained.rs", "repo_id": "tokenizers", "token_count": 906 }
#[cfg(not(debug_assertions))] use assert_approx_eq::assert_approx_eq; use std::collections::HashMap; use std::fs::read_to_string; use std::path::Path; #[cfg(not(debug_assertions))] use tokenizers::models::unigram::Lattice; use tokenizers::models::unigram::Unigram; use tokenizers::models::unigram::UnigramTrainer; use to...
tokenizers/tokenizers/tests/unigram.rs/0
{ "file_path": "tokenizers/tokenizers/tests/unigram.rs", "repo_id": "tokenizers", "token_count": 1697 }
# Running models on WebGPU WebGPU is a new web standard for accelerated graphics and compute. The [API](https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API) enables web developers to use the underlying system's GPU to carry out high-performance computations directly in the browser. WebGPU is the successor to [...
transformers.js/docs/source/guides/webgpu.md/0
{ "file_path": "transformers.js/docs/source/guides/webgpu.md", "repo_id": "transformers.js", "token_count": 1452 }
function formatBytes(bytes, decimals = 0) { const sizes = ["Bytes", "KB", "MB", "GB", "TB"]; if (bytes === 0) return "0 Bytes"; const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1000)), 10); const rounded = (bytes / Math.pow(1000, i)).toFixed(decimals); return rounded + " " + sizes[i]; } exp...
transformers.js/examples/code-completion/src/components/Progress.jsx/0
{ "file_path": "transformers.js/examples/code-completion/src/components/Progress.jsx", "repo_id": "transformers.js", "token_count": 278 }
import { env, AutoTokenizer, AutoModelForSequenceClassification } from '@xenova/transformers'; // Skip local model check since we are downloading the model from the Hugging Face Hub. env.allowLocalModels = false; class CrossEncoderSingleton { static model_id = 'mixedbread-ai/mxbai-rerank-xsmall-v1'; static mo...
transformers.js/examples/cross-encoder/src/worker.js/0
{ "file_path": "transformers.js/examples/cross-encoder/src/worker.js", "repo_id": "transformers.js", "token_count": 786 }
// Adapted from https://www.npmjs.com/package/audiobuffer-to-wav export function encodeWAV(samples, sampleRate = 16000) { let offset = 44; const buffer = new ArrayBuffer(offset + samples.length * 4); const view = new DataView(buffer); /* RIFF identifier */ writeString(view, 0, 'RIFF') /* RIFF ...
transformers.js/examples/musicgen-web/src/utils.js/0
{ "file_path": "transformers.js/examples/musicgen-web/src/utils.js", "repo_id": "transformers.js", "token_count": 787 }