text stringlengths 96 319k | id stringlengths 14 178 | metadata dict |
|---|---|---|
import argparse
import json
import logging
import os
from collections import Counter
from dataclasses import dataclass
from operator import attrgetter
from typing import Dict, List, Optional, Union
import safetensors
import torch
import torch.nn as nn
from diffusers import UNet2DConditionModel
from transformers import... | peft/examples/stable_diffusion/convert_sd_adapter_to_peft.py/0 | {
"file_path": "peft/examples/stable_diffusion/convert_sd_adapter_to_peft.py",
"repo_id": "peft",
"token_count": 10390
} |
# 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/config.py/0 | {
"file_path": "peft/src/peft/config.py",
"repo_id": "peft",
"token_count": 5717
} |
# 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/layer.py/0 | {
"file_path": "peft/src/peft/tuners/adalora/layer.py",
"repo_id": "peft",
"token_count": 7174
} |
# 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/layer.py/0 | {
"file_path": "peft/src/peft/tuners/bone/layer.py",
"repo_id": "peft",
"token_count": 6693
} |
# 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/layer.py/0 | {
"file_path": "peft/src/peft/tuners/ia3/layer.py",
"repo_id": "peft",
"token_count": 6856
} |
# 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/awq.py/0 | {
"file_path": "peft/src/peft/tuners/lora/awq.py",
"repo_id": "peft",
"token_count": 1820
} |
# 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/prefix_tuning/config.py/0 | {
"file_path": "peft/src/peft/tuners/prefix_tuning/config.py",
"repo_id": "peft",
"token_count": 463
} |
# 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/xlora/classifier.py/0 | {
"file_path": "peft/src/peft/tuners/xlora/classifier.py",
"repo_id": "peft",
"token_count": 3252
} |
# 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/conftest.py/0 | {
"file_path": "peft/tests/conftest.py",
"repo_id": "peft",
"token_count": 356
} |
# 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_incremental_pca.py/0 | {
"file_path": "peft/tests/test_incremental_pca.py",
"repo_id": "peft",
"token_count": 2752
} |
# 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_vision_models.py/0 | {
"file_path": "peft/tests/test_vision_models.py",
"repo_id": "peft",
"token_count": 2462
} |
# Adversarial Inception v3
**Inception v3** is a convolutional neural network architecture from the Inception family that makes several improvements including using [Label Smoothing](https://paperswithcode.com/method/label-smoothing), Factorized 7 x 7 convolutions, and the use of an [auxiliary classifier](https://pape... | pytorch-image-models/hfdocs/source/models/adversarial-inception-v3.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/adversarial-inception-v3.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2249
} |
# (Gluon) ResNet
**Residual Networks**, or **ResNets**, learn residual functions with reference to the layer inputs, instead of learning unreferenced functions. Instead of hoping each few stacked layers directly fit a desired underlying mapping, residual nets let these layers fit a residual mapping. They stack [residu... | pytorch-image-models/hfdocs/source/models/gloun-resnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/gloun-resnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 7212
} |
# MobileNet v3
**MobileNetV3** is a convolutional neural network that is designed for mobile phone CPUs. The network design includes the use of a [hard swish activation](https://paperswithcode.com/method/hard-swish) and [squeeze-and-excitation](https://paperswithcode.com/method/squeeze-and-excitation-block) modules in... | pytorch-image-models/hfdocs/source/models/mobilenet-v3.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/mobilenet-v3.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2581
} |
# SK-ResNet
**SK ResNet** is a variant of a [ResNet](https://www.paperswithcode.com/method/resnet) that employs a [Selective Kernel](https://paperswithcode.com/method/selective-kernel) unit. In general, all the large kernel convolutions in the original bottleneck blocks in ResNet are replaced by the proposed [SK convo... | pytorch-image-models/hfdocs/source/models/skresnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/skresnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2084
} |
from copy import deepcopy
__all__ = ['get_img_extensions', 'is_img_extension', 'set_img_extensions', 'add_img_extensions', 'del_img_extensions']
IMG_EXTENSIONS = ('.png', '.jpg', '.jpeg') # singleton, kept public for bwd compat use
_IMG_EXTENSIONS_SET = set(IMG_EXTENSIONS) # set version, private, kept in sync
de... | pytorch-image-models/timm/data/readers/img_extensions.py/0 | {
"file_path": "pytorch-image-models/timm/data/readers/img_extensions.py",
"repo_id": "pytorch-image-models",
"token_count": 582
} |
""" Activations
A collection of activations fn and modules with a common interface so that they can
easily be swapped. All have an `inplace` arg even if not used.
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch
from torch import nn as nn
from torch.nn import functional as F
def swish(x, inplace:... | pytorch-image-models/timm/layers/activations.py/0 | {
"file_path": "pytorch-image-models/timm/layers/activations.py",
"repo_id": "pytorch-image-models",
"token_count": 2008
} |
""" Create Conv2d Factory Method
Hacked together by / Copyright 2020 Ross Wightman
"""
from .mixed_conv2d import MixedConv2d
from .cond_conv2d import CondConv2d
from .conv2d_same import create_conv2d_pad
def create_conv2d(in_channels, out_channels, kernel_size, **kwargs):
""" Select a 2d convolution implementat... | pytorch-image-models/timm/layers/create_conv2d.py/0 | {
"file_path": "pytorch-image-models/timm/layers/create_conv2d.py",
"repo_id": "pytorch-image-models",
"token_count": 652
} |
import torch
from torch import nn as nn
try:
from inplace_abn.functions import inplace_abn, inplace_abn_sync
has_iabn = True
except ImportError:
has_iabn = False
def inplace_abn(x, weight, bias, running_mean, running_var,
training=True, momentum=0.1, eps=1e-05, activation="leaky_re... | pytorch-image-models/timm/layers/inplace_abn.py/0 | {
"file_path": "pytorch-image-models/timm/layers/inplace_abn.py",
"repo_id": "pytorch-image-models",
"token_count": 1556
} |
""" Position Embedding Utilities
Hacked together by / Copyright 2022 Ross Wightman
"""
import logging
import math
from typing import List, Tuple, Optional, Union
import torch
import torch.nn.functional as F
from .helpers import to_2tuple
_logger = logging.getLogger(__name__)
def resample_abs_pos_embed(
po... | pytorch-image-models/timm/layers/pos_embed.py/0 | {
"file_path": "pytorch-image-models/timm/layers/pos_embed.py",
"repo_id": "pytorch-image-models",
"token_count": 1128
} |
""" Binary Cross Entropy w/ a few extras
Hacked together by / Copyright 2021 Ross Wightman
"""
from typing import Optional, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
class BinaryCrossEntropy(nn.Module):
""" BCE with optional one-hot from dense targets, label smoothing, thresholdin... | pytorch-image-models/timm/loss/binary_cross_entropy.py/0 | {
"file_path": "pytorch-image-models/timm/loss/binary_cross_entropy.py",
"repo_id": "pytorch-image-models",
"token_count": 1082
} |
""" DeiT - Data-efficient Image Transformers
DeiT model defs and weights from https://github.com/facebookresearch/deit, original copyright below
paper: `DeiT: Data-efficient Image Transformers` - https://arxiv.org/abs/2012.12877
paper: `DeiT III: Revenge of the ViT` - https://arxiv.org/abs/2204.07118
Modifications ... | pytorch-image-models/timm/models/deit.py/0 | {
"file_path": "pytorch-image-models/timm/models/deit.py",
"repo_id": "pytorch-image-models",
"token_count": 8370
} |
""" Global Context ViT
From scratch implementation of GCViT in the style of timm swin_transformer_v2_cr.py
Global Context Vision Transformers -https://arxiv.org/abs/2206.09959
@article{hatamizadeh2022global,
title={Global Context Vision Transformers},
author={Hatamizadeh, Ali and Yin, Hongxu and Kautz, Jan and M... | pytorch-image-models/timm/models/gcvit.py/0 | {
"file_path": "pytorch-image-models/timm/models/gcvit.py",
"repo_id": "pytorch-image-models",
"token_count": 10814
} |
""" MaxVit and CoAtNet Vision Transformer - CNN Hybrids in PyTorch
This is a from-scratch implementation of both CoAtNet and MaxVit in PyTorch.
99% of the implementation was done from papers, however last minute some adjustments were made
based on the (as yet unfinished?) public code release https://github.com/google... | pytorch-image-models/timm/models/maxxvit.py/0 | {
"file_path": "pytorch-image-models/timm/models/maxxvit.py",
"repo_id": "pytorch-image-models",
"token_count": 43954
} |
"""
An implementation of RepGhostNet Model as defined in:
RepGhost: A Hardware-Efficient Ghost Module via Re-parameterization. https://arxiv.org/abs/2211.06088
Original implementation: https://github.com/ChengpengChen/RepGhost
"""
import copy
from functools import partial
from typing import Optional
import torch
impo... | pytorch-image-models/timm/models/repghost.py/0 | {
"file_path": "pytorch-image-models/timm/models/repghost.py",
"repo_id": "pytorch-image-models",
"token_count": 8221
} |
"""
TResNet: High Performance GPU-Dedicated Architecture
https://arxiv.org/pdf/2003.13630.pdf
Original model: https://github.com/mrT23/TResNet
"""
from collections import OrderedDict
from functools import partial
from typing import Optional
import torch
import torch.nn as nn
from timm.layers import SpaceToDepth, Bl... | pytorch-image-models/timm/models/tresnet.py/0 | {
"file_path": "pytorch-image-models/timm/models/tresnet.py",
"repo_id": "pytorch-image-models",
"token_count": 6188
} |
import logging
from itertools import islice
from typing import Collection, Optional
from torch import nn as nn
from timm.models import group_parameters
_logger = logging.getLogger(__name__)
def param_groups_weight_decay(
model: nn.Module,
weight_decay: float = 1e-5,
no_weight_decay_list: C... | pytorch-image-models/timm/optim/_param_groups.py/0 | {
"file_path": "pytorch-image-models/timm/optim/_param_groups.py",
"repo_id": "pytorch-image-models",
"token_count": 1915
} |
""" PyTorch MADGRAD optimizer
MADGRAD: https://arxiv.org/abs/2101.11075
Code from: https://github.com/facebookresearch/madgrad
"""
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import ma... | pytorch-image-models/timm/optim/madgrad.py/0 | {
"file_path": "pytorch-image-models/timm/optim/madgrad.py",
"repo_id": "pytorch-image-models",
"token_count": 3562
} |
import abc
from abc import ABC
from typing import Any, Dict, List, Optional
import torch
class Scheduler(ABC):
""" Parameter Scheduler Base Class
A scheduler base class that can be used to schedule any optimizer parameter groups.
Unlike the builtin PyTorch schedulers, this is intended to be consistently... | pytorch-image-models/timm/scheduler/scheduler.py/0 | {
"file_path": "pytorch-image-models/timm/scheduler/scheduler.py",
"repo_id": "pytorch-image-models",
"token_count": 2368
} |
""" Model / state_dict utils
Hacked together by / Copyright 2020 Ross Wightman
"""
import fnmatch
from copy import deepcopy
import torch
from torchvision.ops.misc import FrozenBatchNorm2d
from timm.layers import BatchNormAct2d, SyncBatchNormAct, FrozenBatchNormAct2d,\
freeze_batch_norm_2d, unfreeze_batch_norm_2d... | pytorch-image-models/timm/utils/model.py/0 | {
"file_path": "pytorch-image-models/timm/utils/model.py",
"repo_id": "pytorch-image-models",
"token_count": 4328
} |
# Base Python image
FROM python:3.12-slim
# Set working directory
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
zlib1g-dev \
libjpeg-dev \
libpng-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy package files
COPY . /app/
# Install dependencies... | smolagents/Dockerfile/0 | {
"file_path": "smolagents/Dockerfile",
"repo_id": "smolagents",
"token_count": 198
} |
<!--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/models.md/0 | {
"file_path": "smolagents/docs/source/en/reference/models.md",
"repo_id": "smolagents",
"token_count": 1797
} |
<!--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/tools.md/0 | {
"file_path": "smolagents/docs/source/hi/reference/tools.md",
"repo_id": "smolagents",
"token_count": 2277
} |
<!--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/tutorials/building_good_agents.md/0 | {
"file_path": "smolagents/docs/source/zh/tutorials/building_good_agents.md",
"repo_id": "smolagents",
"token_count": 6802
} |
import re
import string
import warnings
def normalize_number_str(number_str: str) -> float:
# we replace these common units and commas to allow
# conversion to float
for char in ["$", "%", ","]:
number_str = number_str.replace(char, "")
try:
return float(number_str)
except ValueErr... | smolagents/examples/open_deep_research/scripts/gaia_scorer.py/0 | {
"file_path": "smolagents/examples/open_deep_research/scripts/gaia_scorer.py",
"repo_id": "smolagents",
"token_count": 1643
} |
#!/usr/bin/env python
# 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/L... | smolagents/src/smolagents/cli.py/0 | {
"file_path": "smolagents/src/smolagents/cli.py",
"repo_id": "smolagents",
"token_count": 1576
} |
# coding=utf-8
# Copyright 2025-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 a... | smolagents/utils/check_tests_in_ci.py/0 | {
"file_path": "smolagents/utils/check_tests_in_ci.py",
"repo_id": "smolagents",
"token_count": 729
} |
# Text Generation Inference - TensorRT-LLM Backend Implementation
## Description
This folder provides the sources of the TensorRT-LLM backend implementation powered by TensorRT-LLM Executor new API
## Simplified Request Sequence
```mermaid
sequenceDiagram
actor User
participant TextGenerationInference.HttpS... | text-generation-inference/backends/trtllm/README.md/0 | {
"file_path": "text-generation-inference/backends/trtllm/README.md",
"repo_id": "text-generation-inference",
"token_count": 1019
} |
///
/// Extract the first line of the provided string reference.
/// If there is no lines in the buffer, it returns a string
/// which content is defined by the content of `fail`
/// # Arguments
///
/// * `s`: The string buffer to extract the first-line from
/// * `fail`: A string content which is returned if no lines ... | text-generation-inference/backends/trtllm/src/utils.rs/0 | {
"file_path": "text-generation-inference/backends/trtllm/src/utils.rs",
"repo_id": "text-generation-inference",
"token_count": 201
} |
use std::sync::Arc;
use tokio::sync::{mpsc, oneshot};
use crate::radix::RadixAllocator;
#[derive(Debug, Clone)]
pub struct BlockAllocation {
pub allocation_id: u64,
pub blocks: Vec<u32>,
pub slots: Vec<u32>,
/// Prefix that was cached and for which the KV does not have to
/// be recomputed.
p... | text-generation-inference/backends/v3/src/block_allocator.rs/0 | {
"file_path": "text-generation-inference/backends/v3/src/block_allocator.rs",
"repo_id": "text-generation-inference",
"token_count": 3008
} |
/// MIT License
//
// Copyright (c) 2020 hatoo
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merg... | text-generation-inference/benchmark/src/utils.rs/0 | {
"file_path": "text-generation-inference/benchmark/src/utils.rs",
"repo_id": "text-generation-inference",
"token_count": 598
} |
# Vision Language Model Inference in TGI
Visual Language Model (VLM) are models that consume both image and text inputs to generate text.
VLM's are trained on a combination of image and text data and can handle a wide range of tasks, such as image captioning, visual question answering, and visual dialog.
> What dist... | text-generation-inference/docs/source/basic_tutorials/visual_language_models.md/0 | {
"file_path": "text-generation-inference/docs/source/basic_tutorials/visual_language_models.md",
"repo_id": "text-generation-inference",
"token_count": 3724
} |
import os
import json
for root, dirs, files in os.walk("."):
for filename in files:
if filename.endswith(".json"):
with open(os.path.join(root, filename), "r") as f:
data = json.load(f)
print(os.path.join(root, filename))
try:
if filenam... | text-generation-inference/integration-tests/models/__snapshots__/test.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test.py",
"repo_id": "text-generation-inference",
"token_count": 388
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 28747,
"logprob": -0.54785156,
"special": false,
"text": ":"
},
{
"id": 3169,
"logprob... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_mistral/test_flash_mistral.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_mistral/test_flash_mistral.json",
"repo_id": "text-generation-inference",
"token_count": 865
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "eos_token",
"generated_tokens": 2,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 54901,
"logprob": -0.84765625,
"special": false,
"text": "beach"
},
{
"id": 1,
"logp... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_pali_gemma/test_flash_pali_gemma.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_pali_gemma/test_flash_pali_gemma.json",
"repo_id": "text-generation-inference",
"token_count": 266
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 1241,
"logprob": -0.9863281,
"special": false,
"text": "():"
},
{
"id": 258,
"logprob"... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_santacoder/test_flash_santacoder.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_santacoder/test_flash_santacoder.json",
"repo_id": "text-generation-inference",
"token_count": 866
} |
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "{ \"unit\": \"fahrenheit\", \"temperature\": [ 72, 79, 88 ] }",
"role": "assistant"
}
}
],
"created": 1732525803,
"id": "",
"model": "TinyLlama/TinyLlama-1.1B-... | text-generation-inference/integration-tests/models/__snapshots__/test_grammar_response_format_llama/test_grammar_response_format_llama_json.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_grammar_response_format_llama/test_grammar_response_format_llama_json.json",
"repo_id": "text-generation-inference",
"token_count": 255
} |
import pytest
@pytest.fixture(scope="module")
def flash_llama_chat_handle(launcher):
with launcher(
"TinyLlama/TinyLlama-1.1B-Chat-v1.0", num_shard=2, disable_grammar_support=False
) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_llama_chat(flash_llama_chat_handle):
... | text-generation-inference/integration-tests/models/test_chat_llama.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_chat_llama.py",
"repo_id": "text-generation-inference",
"token_count": 594
} |
import pytest
import json
from text_generation.types import GrammarType
@pytest.fixture(scope="module")
def flash_llama_grammar_handle(launcher):
with launcher(
"TinyLlama/TinyLlama-1.1B-Chat-v1.0", num_shard=2, disable_grammar_support=False
) as handle:
yield handle
@pytest.fixture(scope="... | text-generation-inference/integration-tests/models/test_flash_grammar_llama.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_grammar_llama.py",
"repo_id": "text-generation-inference",
"token_count": 2366
} |
import pytest
@pytest.fixture(scope="module")
def flash_neox_sharded_handle(launcher):
with launcher("OpenAssistant/oasst-sft-1-pythia-12b", num_shard=2) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_neox_sharded(flash_neox_sharded_handle):
await flash_neox_sharded_handle.h... | text-generation-inference/integration-tests/models/test_flash_neox_sharded.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_neox_sharded.py",
"repo_id": "text-generation-inference",
"token_count": 507
} |
import pytest
@pytest.fixture(scope="module")
def flash_idefics3_next_handle(launcher):
with launcher("HuggingFaceM4/Idefics3-8B-Llama3") as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_idefics3_next(flash_idefics3_next_handle):
await flash_idefics3_next_handle.health(300)
... | text-generation-inference/integration-tests/models/test_idefics3.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_idefics3.py",
"repo_id": "text-generation-inference",
"token_count": 454
} |
{
buildPythonPackage,
poetry-core,
huggingface-hub,
pydantic,
}:
buildPythonPackage {
name = "text-generation";
src = ../clients/python;
pyproject = true;
build-system = [ poetry-core ];
dependencies = [
huggingface-hub
pydantic
];
}
| text-generation-inference/nix/client.nix/0 | {
"file_path": "text-generation-inference/nix/client.nix",
"repo_id": "text-generation-inference",
"token_count": 98
} |
/// Text Generation Inference Webserver
pub mod config;
pub mod infer;
pub mod server;
pub mod validation;
#[cfg(feature = "kserve")]
mod kserve;
pub mod logging;
mod sagemaker;
pub mod usage_stats;
mod vertex;
use crate::infer::tool_grammar::ToolGrammar;
use crate::infer::{Infer, InferError};
use pyo3::prelude::*;
... | text-generation-inference/router/src/lib.rs/0 | {
"file_path": "text-generation-inference/router/src/lib.rs",
"repo_id": "text-generation-inference",
"token_count": 25379
} |
// Adapted from turboderp exllama: https://github.com/turboderp/exllama
#include <ATen/cuda/CUDAContext.h>
#include "q4_matrix.cuh"
#include <vector>
#include "../util.cuh"
#include "../matrix.cuh"
using namespace std;
const int UNSHUF_BLOCKSIZE_X = 64;
const int RECONS_THREADS_X = 64; // Block size and thread... | text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matrix.cu/0 | {
"file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matrix.cu",
"repo_id": "text-generation-inference",
"token_count": 2592
} |
#include "q_matrix.cuh"
#include "matrix_view.cuh"
#include "util.cuh"
#include "quant/qdq_2.cuh"
#include "quant/qdq_3.cuh"
#include "quant/qdq_4.cuh"
#include "quant/qdq_5.cuh"
#include "quant/qdq_6.cuh"
#include "quant/qdq_8.cuh"
#define BLOCK_KN_SIZE 128
#define THREADS_X 32
#define THREADS_Y 32
// Shuffle quan... | text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_matrix.cu/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_matrix.cu",
"repo_id": "text-generation-inference",
"token_count": 10524
} |
# 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
} |
import torch
from typing import List
AWQ_PACK_ORDER = [0, 2, 4, 6, 1, 3, 5, 7]
REVERSE_AWQ_PACK_ORDER = [0, 4, 1, 5, 2, 6, 3, 7]
def pack(imatrix: torch.Tensor, direction: str = "column"):
"""
Packs a 4-bit integer matrix into a packed 32-bit integer matrix.
Args:
imatrix (torch.Tensor): matrix ... | text-generation-inference/server/text_generation_server/layers/awq/conversion_utils.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/awq/conversion_utils.py",
"repo_id": "text-generation-inference",
"token_count": 1384
} |
# https://github.com/fpgaminer/GPTQ-triton
"""
Mostly the same as the autotuner in Triton, but with a few changes like using 40 runs instead of 100.
"""
import builtins
import math
import time
from typing import Dict
import triton
class Autotuner(triton.KernelInterface):
def __init__(
self,
fn,
... | text-generation-inference/server/text_generation_server/layers/gptq/custom_autotune.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/gptq/custom_autotune.py",
"repo_id": "text-generation-inference",
"token_count": 5117
} |
import torch
import math
from torch import nn
from torch.nn import functional as F
from typing import Optional, Tuple
from text_generation_server.layers import TensorParallelEmbedding, FastLinear
from text_generation_server.layers.tensor_parallel import TensorParallelHead
from text_generation_server.utils.speculate imp... | text-generation-inference/server/text_generation_server/layers/mlp.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/mlp.py",
"repo_id": "text-generation-inference",
"token_count": 5007
} |
# coding=utf-8
# Copyright 2022 HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_dbrx_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_dbrx_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 12466
} |
import torch
import torch.distributed
from torch import nn
from transformers.activations import ACT2FN
from typing import Optional, List, Tuple
from text_generation_server.layers.attention import (
paged_attention,
attention,
Seqlen,
)
from text_generation_server.layers import (
TensorParallelRowLinea... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_santacoder_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_santacoder_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 8648
} |
# imlementation of the PhiModel and PhiForCausalLM classes
import torch
import torch.distributed
import math
from torch import nn
from typing import Optional, List, Tuple
from transformers.configuration_utils import PretrainedConfig
from transformers.modeling_outputs import CausalLMOutputWithPast
from text_generatio... | text-generation-inference/server/text_generation_server/models/custom_modeling/phi_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/phi_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 5696
} |
import torch
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List, Optional
from transformers import PreTrainedTokenizerBase
from text_generation_server.pb import generate_pb2
from text_generation_server.pb.generate_pb2 import FinishReason
class Batch(ABC):
@abstractmet... | text-generation-inference/server/text_generation_server/models/types.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/types.py",
"repo_id": "text-generation-inference",
"token_count": 1353
} |
import os
from typing import Union
from loguru import logger
import torch
from transformers import AutoTokenizer
from peft import AutoPeftModelForCausalLM, AutoPeftModelForSeq2SeqLM
def download_and_unload_peft(model_id, revision, trust_remote_code):
torch_dtype = torch.float16
logger.info("Trying to load a... | text-generation-inference/server/text_generation_server/utils/peft.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/peft.py",
"repo_id": "text-generation-inference",
"token_count": 981
} |
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export function bpeDecoder(suffix?: string | undefined | null): Decoder
export function byteFallbackDecoder(): Decoder
export function ctcDecoder(
padToken?: string = '<pad>',
wordDelimiterToken?: string | undefined | null,
cleanup?: bool... | tokenizers/bindings/node/index.d.ts/0 | {
"file_path": "tokenizers/bindings/node/index.d.ts",
"repo_id": "tokenizers",
"token_count": 2753
} |
use crate::arc_rwlock_serde;
use napi::bindgen_prelude::*;
use napi_derive::napi;
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
use tk::pre_tokenizers::PreTokenizerWrapper;
use tk::PreTokenizedString;
use tk::SplitDelimiterBehavior;
use tokenizers as tk;
#[napi(string_enum)]
pub enum JsSplitDelimi... | tokenizers/bindings/node/src/pre_tokenizers.rs/0 | {
"file_path": "tokenizers/bindings/node/src/pre_tokenizers.rs",
"repo_id": "tokenizers",
"token_count": 3152
} |
.PHONY: style check-style test
DATA_DIR = data
dir_guard=@mkdir -p $(@D)
check_dirs := examples py_src/tokenizers tests
# Format source code automatically
style:
python stub.py
ruff check $(check_dirs) --fix
ruff format $(check_dirs)
# Check the source code is formatted correctly
check-style:
python stub.py -... | tokenizers/bindings/python/Makefile/0 | {
"file_path": "tokenizers/bindings/python/Makefile",
"repo_id": "tokenizers",
"token_count": 349
} |
from typing import Dict, Iterator, List, Optional, Union
from tokenizers import AddedToken, Tokenizer, decoders, trainers
from tokenizers.models import WordPiece
from tokenizers.normalizers import BertNormalizer
from tokenizers.pre_tokenizers import BertPreTokenizer
from tokenizers.processors import BertProcessing
fr... | tokenizers/bindings/python/py_src/tokenizers/implementations/bert_wordpiece.py/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/implementations/bert_wordpiece.py",
"repo_id": "tokenizers",
"token_count": 2637
} |
use pyo3::prelude::*;
use tk::Token;
#[pyclass(module = "tokenizers", name = "Token")]
#[derive(Clone)]
pub struct PyToken {
token: Token,
}
impl From<Token> for PyToken {
fn from(token: Token) -> Self {
Self { token }
}
}
impl From<PyToken> for Token {
fn from(token: PyToken) -> Self {
... | tokenizers/bindings/python/src/token.rs/0 | {
"file_path": "tokenizers/bindings/python/src/token.rs",
"repo_id": "tokenizers",
"token_count": 439
} |
import pickle
import pytest
from tokenizers import NormalizedString
from tokenizers.normalizers import (
BertNormalizer,
Lowercase,
Normalizer,
Precompiled,
Sequence,
Strip,
Prepend,
Replace,
)
class TestBertNormalizer:
def test_instantiate(self):
assert isinstance(BertNo... | tokenizers/bindings/python/tests/bindings/test_normalizers.py/0 | {
"file_path": "tokenizers/bindings/python/tests/bindings/test_normalizers.py",
"repo_id": "tokenizers",
"token_count": 3243
} |
import multiprocessing as mp
import os
import pytest
import requests
DATA_PATH = os.path.join("tests", "data")
def download(url, with_filename=None):
filename = with_filename if with_filename is not None else url.rsplit("/")[-1]
filepath = os.path.join(DATA_PATH, filename)
if not os.path.exists(filepa... | tokenizers/bindings/python/tests/utils.py/0 | {
"file_path": "tokenizers/bindings/python/tests/utils.py",
"repo_id": "tokenizers",
"token_count": 1569
} |
[package]
authors = ["Anthony MOI <m.anthony.moi@gmail.com>", "Nicolas Patry <patry.nicolas@protonmail.com>"]
edition = "2018"
name = "tokenizers"
version = "0.21.0-dev.0"
homepage = "https://github.com/huggingface/tokenizers"
repository = "https://github.com/huggingface/tokenizers"
documentation = "https://docs.rs/tok... | tokenizers/tokenizers/Cargo.toml/0 | {
"file_path": "tokenizers/tokenizers/Cargo.toml",
"repo_id": "tokenizers",
"token_count": 908
} |
mod utils;
use tokenizers::models::bpe::{Vocab, BPE};
use tokenizers::Tokenizer;
use wasm_bindgen::prelude::*;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[was... | tokenizers/tokenizers/examples/unstable_wasm/src/lib.rs/0 | {
"file_path": "tokenizers/tokenizers/examples/unstable_wasm/src/lib.rs",
"repo_id": "tokenizers",
"token_count": 543
} |
use crate::tokenizer::{Decoder, Result};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Clone, Debug, Serialize)]
/// Allows decoding Original BPE by joining all the tokens and then replacing
/// the suffix used to identify end-of-words by whitespaces
#[serde(tag = "type")]
#[non_exhaustive]
pub struct BP... | tokenizers/tokenizers/src/decoders/bpe.rs/0 | {
"file_path": "tokenizers/tokenizers/src/decoders/bpe.rs",
"repo_id": "tokenizers",
"token_count": 419
} |
//! [Unigram](https://arxiv.org/abs/1804.10959) model.
mod lattice;
mod model;
mod serialization;
mod trainer;
mod trie;
pub use lattice::*;
pub use model::*;
pub use trainer::*;
| tokenizers/tokenizers/src/models/unigram/mod.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/unigram/mod.rs",
"repo_id": "tokenizers",
"token_count": 72
} |
use crate::tokenizer::pattern::Pattern;
use crate::tokenizer::Decoder;
use crate::tokenizer::{NormalizedString, Normalizer, Result};
use crate::utils::SysRegex;
use serde::{Deserialize, Serialize};
/// Represents the different patterns that `Replace` can use
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq... | tokenizers/tokenizers/src/normalizers/replace.rs/0 | {
"file_path": "tokenizers/tokenizers/src/normalizers/replace.rs",
"repo_id": "tokenizers",
"token_count": 2049
} |
use regex::Regex;
use crate::tokenizer::{
pattern::Invert, PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior,
};
use crate::utils::macro_rules_attribute;
#[derive(Clone, Debug, PartialEq, Eq)]
#[macro_rules_attribute(impl_serde_type!)]
pub struct Whitespace;
impl Default for Whitespace {
fn de... | tokenizers/tokenizers/src/pre_tokenizers/whitespace.rs/0 | {
"file_path": "tokenizers/tokenizers/src/pre_tokenizers/whitespace.rs",
"repo_id": "tokenizers",
"token_count": 1660
} |
//! This comes from the Rust libcore and is duplicated here because it is not exported
//! (cf <https://github.com/rust-lang/rust/blob/25091ed9b7739e12466fb2490baa1e8a2815121c/src/libcore/iter/adapters/mod.rs#L2664>)
//! We are now using the version from <https://stackoverflow.com/questions/44544323/how-to-unzip-a-sequ... | tokenizers/tokenizers/src/utils/iter.rs/0 | {
"file_path": "tokenizers/tokenizers/src/utils/iter.rs",
"repo_id": "tokenizers",
"token_count": 1339
} |
import re
README_TEMPLATE = """
<p align="center">
<br/>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/transformersjs-dark.svg" width="500" style="max-width: 100%;">
<source media="(prefers-color-scheme:... | transformers.js/docs/scripts/build_readme.py/0 | {
"file_path": "transformers.js/docs/scripts/build_readme.py",
"repo_id": "transformers.js",
"token_count": 1756
} |
# Transformers.js
<include>
{
"path": "../snippets/0_introduction.snippet"
}
</include>
## Quick tour
<include>
{
"path": "../snippets/1_quick-tour.snippet"
}
</include>
## Contents
The documentation is organized into 4 sections:
1. **GET STARTED** provides a quick tour of the library and installation ins... | transformers.js/docs/source/index.md/0 | {
"file_path": "transformers.js/docs/source/index.md",
"repo_id": "transformers.js",
"token_count": 495
} |
import { useState, useRef, useEffect, useCallback } from 'react'
import './App.css'
const PLACEHOLDER_TEXTS = [
"A panda is a large black-and-white bear native to China.",
"The typical life span of a panda is 20 years in the wild.",
"A panda's diet consists almost entirely of bamboo.",
"Ailuropoda melanoleuca ... | transformers.js/examples/adaptive-retrieval/src/App.jsx/0 | {
"file_path": "transformers.js/examples/adaptive-retrieval/src/App.jsx",
"repo_id": "transformers.js",
"token_count": 2829
} |
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: opti... | transformers.js/examples/code-completion/src/index.css/0 | {
"file_path": "transformers.js/examples/code-completion/src/index.css",
"repo_id": "transformers.js",
"token_count": 514
} |
{
"manifest_version": 3,
"name": "extension",
"description": "Transformers.js | Sample browser extension",
"version": "0.0.1",
"permissions": [
"activeTab",
"scripting",
"contextMenus",
"storage",
"unlimitedStorage"
],
"background": {
"service_worker": "background.js",
"type": ... | transformers.js/examples/extension/public/manifest.json/0 | {
"file_path": "transformers.js/examples/extension/public/manifest.json",
"repo_id": "transformers.js",
"token_count": 421
} |
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer utilities {
.scrollbar-thin::-webkit-scrollbar {
@apply w-2;
}
.scrollbar-thin::-webkit-scrollbar-track {
@apply rounded-full bg-gray-100 dark:bg-gray-700;
}
.scrollbar-thin::-webkit-scrollbar-thumb {
@apply rounded-full bg-gray-... | transformers.js/examples/florence2-webgpu/src/index.css/0 | {
"file_path": "transformers.js/examples/florence2-webgpu/src/index.css",
"repo_id": "transformers.js",
"token_count": 173
} |
import { pipeline } from "@huggingface/transformers";
// Use the Singleton pattern to enable lazy construction of the pipeline.
class PipelineSingleton {
static task = 'text-classification';
static model = 'Xenova/distilbert-base-uncased-finetuned-sst-2-english';
static instance = null;
static async g... | transformers.js/examples/next-client/src/app/worker.js/0 | {
"file_path": "transformers.js/examples/next-client/src/app/worker.js",
"repo_id": "transformers.js",
"token_count": 369
} |
// The full list of languages in FLORES-200 is available here:
// https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200
const LANGUAGES = {
"Acehnese (Arabic script)": "ace_Arab",
"Acehnese (Latin script)": "ace_Latn",
"Afrikaans": "afr_Latn",
"Akan": "aka_Latn",
"... | transformers.js/examples/react-translator/src/components/LanguageSelector.jsx/0 | {
"file_path": "transformers.js/examples/react-translator/src/components/LanguageSelector.jsx",
"repo_id": "transformers.js",
"token_count": 3102
} |
// Reference the elements we will use
const statusLabel = document.getElementById('status');
const fileUpload = document.getElementById('upload');
const imageContainer = document.getElementById('container');
const example = document.getElementById('example');
const maskCanvas = document.getElementById('mask-output');
... | transformers.js/examples/segment-anything-client/index.js/0 | {
"file_path": "transformers.js/examples/segment-anything-client/index.js",
"repo_id": "transformers.js",
"token_count": 3452
} |
export default function Progress({ text, percentage }) {
percentage ??= 0;
return (
<div className="relative text-black bg-white rounded-lg text-left overflow-hidden">
<div className='px-2 w-[1%] h-full bg-blue-500 whitespace-nowrap' style={{ width: `${percentage}%` }}>
{text} ({`${percentage.toF... | transformers.js/examples/text-to-speech-client/src/components/Progress.jsx/0 | {
"file_path": "transformers.js/examples/text-to-speech-client/src/components/Progress.jsx",
"repo_id": "transformers.js",
"token_count": 144
} |
import { useCallback, useEffect, useRef, useState } from 'react'
import { Token } from './components/Token'
import './App.css'
// Define list of tokenizers and their corresponding human-readable names
const TOKENIZER_OPTIONS = Object.freeze({
'Xenova/gpt-4': 'gpt-4 / gpt-3.5-turbo / text-embedding-ada-002',
'Xenov... | transformers.js/examples/tokenizer-playground/src/App.jsx/0 | {
"file_path": "transformers.js/examples/tokenizer-playground/src/App.jsx",
"repo_id": "transformers.js",
"token_count": 3075
} |
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
html,
body {
height: 100%;
}
body {
padding: 16px 32px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
h1 {
text-align: center;
}
#status {
min-height: 16px;
margin: 8px 0;... | transformers.js/examples/webgpu-embedding-benchmark/style.css/0 | {
"file_path": "transformers.js/examples/webgpu-embedding-benchmark/style.css",
"repo_id": "transformers.js",
"token_count": 518
} |
import { useMemo } from "react";
const Chunk = ({ chunk, currentTime, onClick, ...props }) => {
const { text, timestamp } = chunk;
const [start, end] = timestamp;
const bolded = start <= currentTime && currentTime < end;
return (
<span {...props}>
{text.startsWith(' ') ? " " : ""}... | transformers.js/examples/whisper-word-timestamps/src/components/Transcript.jsx/0 | {
"file_path": "transformers.js/examples/whisper-word-timestamps/src/components/Transcript.jsx",
"repo_id": "transformers.js",
"token_count": 1253
} |
import { env, pipeline } from '@xenova/transformers';
// Skip local model check since we are downloading the model from the Hugging Face Hub.
env.allowLocalModels = false;
class MyZeroShotClassificationPipeline {
static task = 'zero-shot-classification';
static model = 'MoritzLaurer/deberta-v3-xsmall-zeroshot... | transformers.js/examples/zero-shot-classification/src/worker.js/0 | {
"file_path": "transformers.js/examples/zero-shot-classification/src/worker.js",
"repo_id": "transformers.js",
"token_count": 584
} |
from optimum.exporters.onnx.model_configs import WhisperOnnxConfig
from optimum.exporters.onnx.base import ConfigBehavior
from typing import Dict
# List of [layer, head] pairs that select the cross-attention heads that are highly correlated to word-level timing.
# Source: https://gist.github.com/hollance/42e32852f242... | transformers.js/scripts/extra/whisper.py/0 | {
"file_path": "transformers.js/scripts/extra/whisper.py",
"repo_id": "transformers.js",
"token_count": 1700
} |
import { Processor } from "../../base/processing_utils.js";
import { AutoImageProcessor } from "../auto/image_processing_auto.js";
import { AutoTokenizer } from "../../tokenizers.js";
export class Florence2Processor extends Processor {
static tokenizer_class = AutoTokenizer
static image_processor_class = AutoI... | transformers.js/src/models/florence2/processing_florence2.js/0 | {
"file_path": "transformers.js/src/models/florence2/processing_florence2.js",
"repo_id": "transformers.js",
"token_count": 2334
} |
import { Processor } from '../../base/processing_utils.js';
import { PyAnnoteFeatureExtractor } from './feature_extraction_pyannote.js';
export class PyAnnoteProcessor extends Processor {
static feature_extractor_class = PyAnnoteFeatureExtractor
/**
* Calls the feature_extractor function with the given a... | transformers.js/src/models/pyannote/processing_pyannote.js/0 | {
"file_path": "transformers.js/src/models/pyannote/processing_pyannote.js",
"repo_id": "transformers.js",
"token_count": 316
} |
import { FeatureExtractor, validate_audio_inputs } from "../../base/feature_extraction_utils.js";
import { Tensor } from "../../utils/tensor.js";
export class Wav2Vec2FeatureExtractor extends FeatureExtractor {
/**
* @param {Float32Array} input_values
* @returns {Float32Array}
*/
_zero_mean_u... | transformers.js/src/models/wav2vec2/feature_extraction_wav2vec2.js/0 | {
"file_path": "transformers.js/src/models/wav2vec2/feature_extraction_wav2vec2.js",
"repo_id": "transformers.js",
"token_count": 700
} |
/**
* @file Custom data structures.
*
* These are only used internally, meaning an end-user shouldn't
* need to access anything here.
*
* @module utils/data-structures
*/
/**
* Efficient Heap-based Implementation of a Priority Queue.
* It uses an array-based binary heap, where the root is at index `0`, an... | transformers.js/src/utils/data-structures.js/0 | {
"file_path": "transformers.js/src/utils/data-structures.js",
"repo_id": "transformers.js",
"token_count": 5931
} |
import { AutoFeatureExtractor, ASTFeatureExtractor } from "../../../src/transformers.js";
import { load_cached_audio } from "../../asset_cache.js";
import { MAX_FEATURE_EXTRACTOR_LOAD_TIME, MAX_TEST_EXECUTION_TIME } from "../../init.js";
export default () => {
// ASTFeatureExtractor
describe("ASTFeatureExtractor"... | transformers.js/tests/models/audio_spectrogram_transformer/test_feature_extraction_audio_spectrogram_transformer.js/0 | {
"file_path": "transformers.js/tests/models/audio_spectrogram_transformer/test_feature_extraction_audio_spectrogram_transformer.js",
"repo_id": "transformers.js",
"token_count": 926
} |
import { GPT2Tokenizer } from "../../../src/tokenizers.js";
import { BASE_TEST_STRINGS, SENTENCEPIECE_TEST_STRINGS } from "../test_strings.js";
export const TOKENIZER_CLASS = GPT2Tokenizer;
export const TEST_CONFIG = {
// - clean_up_tokenization_spaces=true
// - default pretokenization regex
"Xenova/gpt2": {
... | transformers.js/tests/models/gpt2/test_tokenization_gpt2.js/0 | {
"file_path": "transformers.js/tests/models/gpt2/test_tokenization_gpt2.js",
"repo_id": "transformers.js",
"token_count": 12344
} |
import { SamProcessor, SamModel } from "../../../src/transformers.js";
import { load_cached_image } from "../../asset_cache.js";
import { MAX_MODEL_LOAD_TIME, MAX_TEST_EXECUTION_TIME, MAX_MODEL_DISPOSE_TIME, DEFAULT_MODEL_OPTIONS } from "../../init.js";
export default () => {
describe("SamModel", () => {
const ... | transformers.js/tests/models/sam/test_modeling_sam.js/0 | {
"file_path": "transformers.js/tests/models/sam/test_modeling_sam.js",
"repo_id": "transformers.js",
"token_count": 770
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.