text stringlengths 5 409k | id stringlengths 14 178 | metadata dict | __index_level_0__ int64 0 572 |
|---|---|---|---|
<!--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/install.md/0 | {
"file_path": "peft/docs/source/install.md",
"repo_id": "peft",
"token_count": 439
} | 172 |
<!--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/lokr.md/0 | {
"file_path": "peft/docs/source/package_reference/lokr.md",
"repo_id": "peft",
"token_count": 327
} | 173 |
<!--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/ia3.md/0 | {
"file_path": "peft/docs/source/task_guides/ia3.md",
"repo_id": "peft",
"token_count": 3197
} | 174 |
import random
import numpy as np
import torch
import wandb
from datasets import load_dataset
from diffusers import DDIMScheduler
from PIL import Image
from torchvision import transforms
from utils.pipeline_controlnet import LightControlNetPipeline
def image_grid(imgs, rows, cols):
assert len(imgs) == rows * cols... | peft/examples/boft_controlnet/utils/dataset.py/0 | {
"file_path": "peft/examples/boft_controlnet/utils/dataset.py",
"repo_id": "peft",
"token_count": 3160
} | 175 |
import gc
import os
import sys
import threading
import psutil
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, get_linear_schedule_with_warmup, set_seed
from pe... | peft/examples/conditional_generation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py/0 | {
"file_path": "peft/examples/conditional_generation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py",
"repo_id": "peft",
"token_count": 5610
} | 176 |
# 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/examples/ephemeral_gpu_offloading/load_with_dora.py/0 | {
"file_path": "peft/examples/ephemeral_gpu_offloading/load_with_dora.py",
"repo_id": "peft",
"token_count": 1389
} | 177 |
# 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/loftq_finetuning/train_gsm8k_llama.py/0 | {
"file_path": "peft/examples/loftq_finetuning/train_gsm8k_llama.py",
"repo_id": "peft",
"token_count": 14677
} | 178 |
# PiSSA: Principal Singular values and Singular vectors Adaptation
## Introduction ([Paper](https://arxiv.org/abs/2404.02948), [code](https://github.com/GraphPKU/PiSSA))
PiSSA represents a matrix $W\in\mathbb{R}^{m\times n}$ within the model by the product of two trainable matrices $A \in \mathbb{R}^{m\times r}$ and $B... | peft/examples/pissa_finetuning/README.md/0 | {
"file_path": "peft/examples/pissa_finetuning/README.md",
"repo_id": "peft",
"token_count": 2177
} | 179 |
import os
import sys
from dataclasses import dataclass, field
from typing import Optional
from transformers import HfArgumentParser, set_seed
from trl import SFTConfig, SFTTrainer
from utils import create_and_prepare_model, create_datasets
# Define and parse arguments.
@dataclass
class ModelArguments:
"""
Ar... | peft/examples/sft/train.py/0 | {
"file_path": "peft/examples/sft/train.py",
"repo_id": "peft",
"token_count": 2226
} | 180 |
# 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/__init__.py/0 | {
"file_path": "peft/src/peft/__init__.py",
"repo_id": "peft",
"token_count": 2224
} | 181 |
# 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/config.py/0 | {
"file_path": "peft/src/peft/tuners/adalora/config.py",
"repo_id": "peft",
"token_count": 1944
} | 182 |
# 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/bnb.py/0 | {
"file_path": "peft/src/peft/tuners/ia3/bnb.py",
"repo_id": "peft",
"token_count": 2193
} | 183 |
# Copyright 2023-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/src/peft/tuners/lora/__init__.py/0 | {
"file_path": "peft/src/peft/tuners/lora/__init__.py",
"repo_id": "peft",
"token_count": 662
} | 184 |
# Copyright 2023-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/src/peft/tuners/poly/router.py/0 | {
"file_path": "peft/src/peft/tuners/poly/router.py",
"repo_id": "peft",
"token_count": 1101
} | 185 |
# 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/vera/model.py/0 | {
"file_path": "peft/src/peft/tuners/vera/model.py",
"repo_id": "peft",
"token_count": 9226
} | 186 |
# 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_helpers.py/0 | {
"file_path": "peft/tests/test_helpers.py",
"repo_id": "peft",
"token_count": 8287
} | 187 |
# 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_vblora.py/0 | {
"file_path": "peft/tests/test_vblora.py",
"repo_id": "peft",
"token_count": 5019
} | 188 |
# 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": 21801
} | 189 |
# 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
} | 190 |
# 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
} | 191 |
# 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
} | 192 |
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
} | 193 |
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
} | 194 |
""" 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
} | 195 |
""" 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
} | 196 |
""" 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
} | 197 |
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
} | 198 |
""" 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
} | 199 |
"""
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
} | 200 |
"""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
} | 201 |
""" 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
} | 202 |
""" 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
} | 203 |
""" 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
} | 204 |
""" Polynomial Scheduler
Polynomial LR schedule with warmup, noise.
Hacked together by / Copyright 2021 Ross Wightman
"""
import math
import logging
from typing import List
import torch
from .scheduler import Scheduler
_logger = logging.getLogger(__name__)
class PolyLRScheduler(Scheduler):
""" Polynomial LR... | pytorch-image-models/timm/scheduler/poly_lr.py/0 | {
"file_path": "pytorch-image-models/timm/scheduler/poly_lr.py",
"repo_id": "pytorch-image-models",
"token_count": 2007
} | 205 |
""" 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
} | 206 |
# 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
} | 207 |
<!--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.mdx/0 | {
"file_path": "smolagents/docs/source/en/reference/models.mdx",
"repo_id": "smolagents",
"token_count": 1946
} | 208 |
<!--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.mdx/0 | {
"file_path": "smolagents/docs/source/hi/reference/agents.mdx",
"repo_id": "smolagents",
"token_count": 4440
} | 209 |
<!--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 agree... | smolagents/docs/source/zh/reference/models.mdx/0 | {
"file_path": "smolagents/docs/source/zh/reference/models.mdx",
"repo_id": "smolagents",
"token_count": 2885
} | 210 |
import argparse
import os
import threading
from dotenv import load_dotenv
from huggingface_hub import login
from scripts.text_inspector_tool import TextInspectorTool
from scripts.text_web_browser import (
ArchiveSearchTool,
FinderTool,
FindNextTool,
PageDownTool,
PageUpTool,
SearchInformationTo... | smolagents/examples/open_deep_research/run.py/0 | {
"file_path": "smolagents/examples/open_deep_research/run.py",
"repo_id": "smolagents",
"token_count": 1615
} | 211 |
#!/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/_function_type_hints_utils.py/0 | {
"file_path": "smolagents/src/smolagents/_function_type_hints_utils.py",
"repo_id": "smolagents",
"token_count": 5798
} | 212 |
import argparse
from io import BytesIO
from time import sleep
import helium
from dotenv import load_dotenv
from PIL import Image
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from smolagents import CodeAgent, DuckDuckGoSearchTool, tool
from ... | smolagents/src/smolagents/vision_web_browser.py/0 | {
"file_path": "smolagents/src/smolagents/vision_web_browser.py",
"repo_id": "smolagents",
"token_count": 2507
} | 213 |
ARG PLATFORM=xpu
FROM lukemathwalker/cargo-chef:latest-rust-1.84.0 AS chef
WORKDIR /usr/src
ARG CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
FROM chef AS planner
COPY Cargo.lock Cargo.lock
COPY Cargo.toml Cargo.toml
COPY rust-toolchain.toml rust-toolchain.toml
COPY proto proto
COPY benchmark benchmark
COPY router rout... | text-generation-inference/Dockerfile_intel/0 | {
"file_path": "text-generation-inference/Dockerfile_intel",
"repo_id": "text-generation-inference",
"token_count": 4034
} | 214 |
from text_generation_server.generator import NeuronGenerator
def test_info(neuron_model_path):
generator = NeuronGenerator.from_pretrained(neuron_model_path)
info = generator.info
assert info.requires_padding is True
assert info.device_type == "xla"
assert info.window_size == 0
assert info.spe... | text-generation-inference/backends/neuron/tests/server/test_info.py/0 | {
"file_path": "text-generation-inference/backends/neuron/tests/server/test_info.py",
"repo_id": "text-generation-inference",
"token_count": 112
} | 215 |
#!/bin/bash
set -ex
TRT_VER_BASE="10.8.0"
TRT_VER_FULL="${TRT_VER_BASE}.43"
CUDA_VER="12.8"
CUDNN_VER="9.7.0.66-1"
NCCL_VER="2.25.1-1+cuda${CUDA_VER}"
CUBLAS_VER="${CUDA_VER}.3.14-1"
NVRTC_VER="${CUDA_VER}.61-1"
for i in "$@"; do
case $i in
--TRT_VER=?*) TRT_VER="${i#*=}";;
--CUDA_VER=?*) CUDA_VE... | text-generation-inference/backends/trtllm/scripts/install_tensorrt.sh/0 | {
"file_path": "text-generation-inference/backends/trtllm/scripts/install_tensorrt.sh",
"repo_id": "text-generation-inference",
"token_count": 2083
} | 216 |
/// Inspired by https://github.com/hatoo/oha/blob/bb989ea3cd77727e7743e7daa60a19894bb5e901/src/monitor.rs
use crate::generation::{Decode, Message, Prefill};
use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use ratatui::layout::{Alignment, Constraint, Direction, Layout};
use ratatui::style::{Color, Modi... | text-generation-inference/benchmark/src/app.rs/0 | {
"file_path": "text-generation-inference/benchmark/src/app.rs",
"repo_id": "text-generation-inference",
"token_count": 12188
} | 217 |
import pytest
from text_generation.types import Parameters, Request
from text_generation.errors import ValidationError
def test_parameters_validation():
# Test best_of
Parameters(best_of=1)
with pytest.raises(ValidationError):
Parameters(best_of=0)
with pytest.raises(ValidationError):
... | text-generation-inference/clients/python/tests/test_types.py/0 | {
"file_path": "text-generation-inference/clients/python/tests/test_types.py",
"repo_id": "text-generation-inference",
"token_count": 984
} | 218 |
# Serving Private & Gated Models
If the model you wish to serve is behind gated access or the model repository on Hugging Face Hub is private, and you have access to the model, you can provide your Hugging Face Hub access token. You can generate and copy a read token from [Hugging Face Hub tokens page](https://hugging... | text-generation-inference/docs/source/basic_tutorials/gated_model_access.md/0 | {
"file_path": "text-generation-inference/docs/source/basic_tutorials/gated_model_access.md",
"repo_id": "text-generation-inference",
"token_count": 290
} | 219 |
# Safetensors
Safetensors is a model serialization format for deep learning models. It is [faster](https://huggingface.co/docs/safetensors/speed) and safer compared to other serialization formats like pickle (which is used under the hood in many deep learning libraries).
TGI depends on safetensors format mainly to en... | text-generation-inference/docs/source/conceptual/safetensors.md/0 | {
"file_path": "text-generation-inference/docs/source/conceptual/safetensors.md",
"repo_id": "text-generation-inference",
"token_count": 184
} | 220 |
{
"choices": [
{
"finish_reason": "length",
"index": 0,
"logprobs": null,
"message": {
"content": "As of your last question, the weather in Brooklyn, New York, is typically hot and humid throughout the year. The suburbs around New York City are jealously sheltered, and at least in ... | text-generation-inference/integration-tests/models/__snapshots__/test_chat_llama/test_flash_llama_simple.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_chat_llama/test_flash_llama_simple.json",
"repo_id": "text-generation-inference",
"token_count": 364
} | 221 |
{
"details": {
"best_of_sequences": null,
"finish_reason": "stop_sequence",
"generated_tokens": 5,
"prefill": [],
"seed": 0,
"tokens": [
{
"id": 5229,
"logprob": -2.5839844,
"special": false,
"text": " failed"
},
{
"id": 29901,
... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama/test_flash_llama_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama/test_flash_llama_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 487
} | 222 |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": 0,
"tokens": [
{
"id": 5229,
"logprob": -1.2607422,
"special": false,
"text": " failed"
},
{
"id": 29901,
"logpr... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_marlin/test_flash_llama_marlin_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_marlin/test_flash_llama_marlin_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 855
} | 223 |
{
"details": {
"best_of_sequences": null,
"finish_reason": "eos_token",
"generated_tokens": 7,
"prefill": [
{
"id": 0,
"logprob": null,
"text": "<pad>"
}
],
"seed": null,
"tokens": [
{
"id": 3,
"logprob": -0.7001953,
"specia... | text-generation-inference/integration-tests/models/__snapshots__/test_t5_sharded/test_t5_sharded.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_t5_sharded/test_t5_sharded.json",
"repo_id": "text-generation-inference",
"token_count": 680
} | 224 |
import pytest
import requests
import json
from aiohttp import ClientSession
from text_generation.types import Completion, ChatCompletionChunk
@pytest.fixture(scope="module")
def flash_llama_completion_handle(launcher):
with launcher(
"meta-llama/Meta-Llama-3.1-8B-Instruct",
) as handle:
yield... | text-generation-inference/integration-tests/models/test_completion_prompts.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_completion_prompts.py",
"repo_id": "text-generation-inference",
"token_count": 4135
} | 225 |
import pytest
@pytest.fixture(scope="module")
def flash_llama_handle(launcher):
with launcher("huggingface/llama-7b", num_shard=2) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_llama(flash_llama_handle):
await flash_llama_handle.health(300)
return flash_llama_handle.cli... | text-generation-inference/integration-tests/models/test_flash_llama.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_llama.py",
"repo_id": "text-generation-inference",
"token_count": 657
} | 226 |
import pytest
@pytest.fixture(scope="module")
def flash_pali_gemma_handle(launcher):
with launcher(
"google/paligemma-3b-pt-224",
num_shard=1,
revision="float16",
max_input_length=4000,
max_total_tokens=4096,
) as handle:
yield handle
@pytest.fixture(scope="mo... | text-generation-inference/integration-tests/models/test_flash_pali_gemma.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_pali_gemma.py",
"repo_id": "text-generation-inference",
"token_count": 587
} | 227 |
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
} | 228 |
[pytest]
addopts = --snapshot-warn-unused
asyncio_mode = auto
markers =
private: marks tests as requiring an admin hf token (deselect with '-m "not private"')
| text-generation-inference/integration-tests/pytest.ini/0 | {
"file_path": "text-generation-inference/integration-tests/pytest.ini",
"repo_id": "text-generation-inference",
"token_count": 58
} | 229 |
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
[[package]]
name = "certifi"
version = "2024.8.30"
description = "Python package for providing Mozilla's CA Bundle."
optional = false
python-versions = ">=3.6"
files = [
{file = "certifi-2024.8.30-py3-none-any.whl", hash = "... | text-generation-inference/load_tests/poetry.lock/0 | {
"file_path": "text-generation-inference/load_tests/poetry.lock",
"repo_id": "text-generation-inference",
"token_count": 27378
} | 230 |
use crate::infer::InferError;
use crate::{
FunctionDefinition, FunctionRef, FunctionsMap, JsonSchemaTool, Properties, Tool, ToolChoice,
};
use serde_json::{json, Map, Value};
use std::collections::HashMap;
pub(crate) struct ToolGrammar {}
impl ToolGrammar {
// find a tool by name
fn find_tool_by_name(tool... | text-generation-inference/router/src/infer/tool_grammar.rs/0 | {
"file_path": "text-generation-inference/router/src/infer/tool_grammar.rs",
"repo_id": "text-generation-inference",
"token_count": 2640
} | 231 |
flash_att_commit := ceee0de88c037ee6eda5e75c813a8648e4bcb1c9
build-flash-attention:
if [ ! -d 'flash-attention' ]; then \
pip install -U packaging ninja --no-cache-dir && \
git clone https://github.com/Narsil/flash-attention.git; \
fi
cd flash-attention && git fetch && git checkout $(flash_att_commit) && \
MA... | text-generation-inference/server/Makefile-flash-att/0 | {
"file_path": "text-generation-inference/server/Makefile-flash-att",
"repo_id": "text-generation-inference",
"token_count": 236
} | 232 |
#include "q4_matmul.cuh"
#include "column_remap.cuh"
#include <ATen/cuda/CUDAContext.h>
#include "../util.cuh"
#include "../matrix.cuh"
#include "../cu_compat.cuh"
#include "../cuda_buffers.cuh"
#if defined(USE_ROCM)
#include "../hip_compat.cuh"
#endif
const int THREADS_X = 32; // Block size and thread count alo... | text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matmul.cu/0 | {
"file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matmul.cu",
"repo_id": "text-generation-inference",
"token_count": 4211
} | 233 |
#include "compat.cuh"
__forceinline__ __device__ half2 dot22_8(half2(&dq)[4], const half* a_ptr, const half2 g_result, const half qs_h)
{
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 __hfm... | text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel.cuh/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel.cuh",
"repo_id": "text-generation-inference",
"token_count": 11459
} | 234 |
# test_watermark_logits_processor.py
import os
import numpy as np
import torch
from text_generation_server.utils.watermark import WatermarkLogitsProcessor
GAMMA = os.getenv("WATERMARK_GAMMA", 0.5)
DELTA = os.getenv("WATERMARK_DELTA", 2.0)
def test_seed_rng():
input_ids = [101, 2036, 3731, 102, 2003, 103]
p... | text-generation-inference/server/tests/utils/test_watermark.py/0 | {
"file_path": "text-generation-inference/server/tests/utils/test_watermark.py",
"repo_id": "text-generation-inference",
"token_count": 781
} | 235 |
import intel_extension_for_pytorch as ipex
import torch
from text_generation_server.layers.attention.kv_cache import KVCache, KVScales
from text_generation_server.layers.attention import Seqlen
from typing import Optional
from text_generation_server.models.globals import (
ATTENTION,
BLOCK_SIZE,
)
SUPPORTS_WIN... | text-generation-inference/server/text_generation_server/layers/attention/ipex.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/attention/ipex.py",
"repo_id": "text-generation-inference",
"token_count": 1723
} | 236 |
from dataclasses import dataclass
from typing import List, Union
import torch
from text_generation_server.utils.weights import Weight, Weights, WeightsLoader
@dataclass
class Exl2Weight(Weight):
"""
Exllama2 exl2 quantized weights.
"""
q_weight: torch.Tensor
q_scale: torch.Tensor
q_invperm: ... | text-generation-inference/server/text_generation_server/layers/exl2.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/exl2.py",
"repo_id": "text-generation-inference",
"token_count": 1050
} | 237 |
from dataclasses import dataclass
from typing import List, Optional, Union
import torch
import torch.nn as nn
from text_generation_server.layers.marlin.util import _check_marlin_kernels
from text_generation_server.utils.import_utils import SYSTEM
from text_generation_server.utils.kernels import load_kernel
from text_... | text-generation-inference/server/text_generation_server/layers/marlin/marlin.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/marlin/marlin.py",
"repo_id": "text-generation-inference",
"token_count": 6121
} | 238 |
# coding=utf-8
# Copyright 2022 HuggingFace Inc. team and BigScience workshop.
#
# 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 re... | text-generation-inference/server/text_generation_server/models/custom_modeling/bloom_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/bloom_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 16226
} | 239 |
"""A simple, flexible implementation of a GPT model.
Inspired by https://github.com/karpathy/minGPT/blob/master/mingpt/model.py
"""
import math
import warnings
from typing import List, Optional, Tuple, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import PreTrainedModel, P... | text-generation-inference/server/text_generation_server/models/custom_modeling/mpt_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/mpt_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 23706
} | 240 |
import inspect
import torch
from abc import ABC, abstractmethod
from typing import List, Tuple, Optional, TypeVar, Type, Dict
from collections import defaultdict
from transformers import PreTrainedTokenizerBase
from loguru import logger
from text_generation_server.models.globals import (
ATTENTION,
PREFIX_CAC... | text-generation-inference/server/text_generation_server/models/model.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/model.py",
"repo_id": "text-generation-inference",
"token_count": 2809
} | 241 |
import importlib
from loguru import logger
from hf_kernels import load_kernel as hf_load_kernel
from text_generation_server.utils.log import log_once
def load_kernel(*, module: str, repo_id: str):
"""
Load a kernel. First try to load it as the given module (e.g. for
local development), falling back to a... | text-generation-inference/server/text_generation_server/utils/kernels.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/kernels.py",
"repo_id": "text-generation-inference",
"token_count": 222
} | 242 |
import subprocess
import argparse
import ast
import json
import os
TEMPLATE = """
# Supported Models
Text Generation Inference enables serving optimized models. The following sections list which models (VLMs & LLMs) are supported.
SUPPORTED_MODELS
If the above list lacks the model you would like to serve, dependin... | text-generation-inference/update_doc.py/0 | {
"file_path": "text-generation-inference/update_doc.py",
"repo_id": "text-generation-inference",
"token_count": 2987
} | 243 |
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: HuggingFace's Tokenizers
message: >-
Fast State-of-the-Art Tokenizers optimized for Research
and Production.
type: software
authors:
- given-names: Anthony
family-names: Moi
... | tokenizers/CITATION.cff/0 | {
"file_path": "tokenizers/CITATION.cff",
"repo_id": "tokenizers",
"token_count": 293
} | 244 |
<p align="center">
<br>
<img src="https://huggingface.co/landing/assets/tokenizers/tokenizers-logo.png" width="600"/>
<br>
<p>
<p align="center">
<a href="https://badge.fury.io/js/tokenizers">
<img alt="Build" src="https://badge.fury.io/js/tokenizers.svg">
</a>
<a href="https://github.com/huggingface/to... | tokenizers/bindings/node/README.md/0 | {
"file_path": "tokenizers/bindings/node/README.md",
"repo_id": "tokenizers",
"token_count": 651
} | 245 |
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-empty-function */
import { TruncationStrategy, BPE, Encoding, AddedToken, Tokenizer } from '../../'
// jest.mock('../../bindings/tokenizer');
// jest.mock('../../bindings/models', () => ({
// __esModule: true,
// Model... | tokenizers/bindings/node/lib/bindings/tokenizer.test.ts/0 | {
"file_path": "tokenizers/bindings/node/lib/bindings/tokenizer.test.ts",
"repo_id": "tokenizers",
"token_count": 5268
} | 246 |
# `tokenizers-linux-arm64-musl`
This is the **aarch64-unknown-linux-musl** binary for `tokenizers`
| tokenizers/bindings/node/npm/linux-arm64-musl/README.md/0 | {
"file_path": "tokenizers/bindings/node/npm/linux-arm64-musl/README.md",
"repo_id": "tokenizers",
"token_count": 37
} | 247 |
use crate::tokenizer::PaddingOptions;
use napi::bindgen_prelude::*;
use napi_derive::napi;
use tokenizers::utils::truncation::TruncationDirection;
use tokenizers::Encoding;
#[napi(js_name = "Encoding")]
#[derive(Clone, Default)]
pub struct JsEncoding {
pub(crate) encoding: Option<Encoding>,
}
impl From<Encoding> fo... | tokenizers/bindings/node/src/encoding.rs/0 | {
"file_path": "tokenizers/bindings/node/src/encoding.rs",
"repo_id": "tokenizers",
"token_count": 3778
} | 248 |
from .. import decoders
Decoder = decoders.Decoder
ByteLevel = decoders.ByteLevel
Replace = decoders.Replace
WordPiece = decoders.WordPiece
ByteFallback = decoders.ByteFallback
Fuse = decoders.Fuse
Strip = decoders.Strip
Metaspace = decoders.Metaspace
BPEDecoder = decoders.BPEDecoder
CTC = decoders.CTC
Sequence = dec... | tokenizers/bindings/python/py_src/tokenizers/decoders/__init__.py/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/decoders/__init__.py",
"repo_id": "tokenizers",
"token_count": 140
} | 249 |
# Generated content DO NOT EDIT
class PostProcessor:
"""
Base class for all post-processors
This class is not supposed to be instantiated directly. Instead, any implementation of
a PostProcessor will return an instance of this class when instantiated.
"""
def num_special_tokens_to_add(self, is_... | tokenizers/bindings/python/py_src/tokenizers/processors/__init__.pyi/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/processors/__init__.pyi",
"repo_id": "tokenizers",
"token_count": 4779
} | 250 |
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock};
use crate::token::PyToken;
use crate::trainers::PyTrainer;
use pyo3::exceptions;
use pyo3::prelude::*;
use pyo3::types::*;
use serde::{Deserialize, Serialize};
use tk::models::bpe::{BpeBuilder, Merges, Vocab, BPE};
use tk::mod... | tokenizers/bindings/python/src/models.rs/0 | {
"file_path": "tokenizers/bindings/python/src/models.rs",
"repo_id": "tokenizers",
"token_count": 15947
} | 251 |
from tokenizers import ByteLevelBPETokenizer
from ..utils import data_dir, multiprocessing_with_parallelism, roberta_files
class TestByteLevelBPE:
def test_basic_encode(self, roberta_files):
tokenizer = ByteLevelBPETokenizer.from_file(roberta_files["vocab"], roberta_files["merges"])
output = toke... | tokenizers/bindings/python/tests/implementations/test_byte_level_bpe.py/0 | {
"file_path": "tokenizers/bindings/python/tests/implementations/test_byte_level_bpe.py",
"repo_id": "tokenizers",
"token_count": 1653
} | 252 |
# Pre-tokenizers
<tokenizerslangcontent>
<python>
## BertPreTokenizer
[[autodoc]] tokenizers.pre_tokenizers.BertPreTokenizer
## ByteLevel
[[autodoc]] tokenizers.pre_tokenizers.ByteLevel
## CharDelimiterSplit
[[autodoc]] tokenizers.pre_tokenizers.CharDelimiterSplit
## Digits
[[autodoc]] tokenizers.pre_tokenizers... | tokenizers/docs/source-doc-builder/api/pre-tokenizers.mdx/0 | {
"file_path": "tokenizers/docs/source-doc-builder/api/pre-tokenizers.mdx",
"repo_id": "tokenizers",
"token_count": 371
} | 253 |
The tokenization pipeline
====================================================================================================
When calling :entity:`Tokenizer.encode` or :entity:`Tokenizer.encode_batch`, the input text(s) go
through the following pipeline:
- :ref:`normalization`
- :ref:`pre-tokenization`
- :ref:`mode... | tokenizers/docs/source/pipeline.rst/0 | {
"file_path": "tokenizers/docs/source/pipeline.rst",
"repo_id": "tokenizers",
"token_count": 6322
} | 254 |
use tokenizers::models::wordpiece::WordPiece;
use tokenizers::{AddedToken, Tokenizer};
fn main() {
let start = std::time::Instant::now();
let mut tokenizer = Tokenizer::new(WordPiece::default());
// Mix special and not special
// You can make sure ids are in order, and special status is correct.
l... | tokenizers/tokenizers/examples/serialization.rs/0 | {
"file_path": "tokenizers/tokenizers/examples/serialization.rs",
"repo_id": "tokenizers",
"token_count": 299
} | 255 |
{
"name": "create-wasm-app",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "create-wasm-app",
"version": "0.1.0",
"license": "(MIT OR Apache-2.0)",
"dependencies": {
"unstable_wasm": "fi... | tokenizers/tokenizers/examples/unstable_wasm/www/package-lock.json/0 | {
"file_path": "tokenizers/tokenizers/examples/unstable_wasm/www/package-lock.json",
"repo_id": "tokenizers",
"token_count": 190639
} | 256 |
#![allow(clippy::map_entry)]
use super::{Pair, WithFirstLastIterator, Word, BPE};
use crate::parallelism::*;
use crate::tokenizer::{AddedToken, Result, Trainer};
use crate::utils::progress::{ProgressBar, ProgressStyle};
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::collections::{BinaryHeap, Has... | tokenizers/tokenizers/src/models/bpe/trainer.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/bpe/trainer.rs",
"repo_id": "tokenizers",
"token_count": 15462
} | 257 |
use crate::processors::byte_level::bytes_char;
use crate::tokenizer::{NormalizedString, Normalizer, Result};
use crate::utils::macro_rules_attribute;
use std::collections::{HashMap, HashSet};
#[derive(Clone, Debug)]
#[macro_rules_attribute(impl_serde_type!)]
pub struct ByteLevel;
lazy_static! {
static ref BYTES_C... | tokenizers/tokenizers/src/normalizers/byte_level.rs/0 | {
"file_path": "tokenizers/tokenizers/src/normalizers/byte_level.rs",
"repo_id": "tokenizers",
"token_count": 3445
} | 258 |
use crate::utils::SysRegex;
use serde::{Deserialize, Deserializer, Serialize};
use crate::tokenizer::{
pattern::Invert, PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior,
};
/// Represents the different patterns that `Split` can use
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq)]
pub... | tokenizers/tokenizers/src/pre_tokenizers/split.rs/0 | {
"file_path": "tokenizers/tokenizers/src/pre_tokenizers/split.rs",
"repo_id": "tokenizers",
"token_count": 4042
} | 259 |
use std::marker::PhantomData;
use serde::{
self,
de::{Error, MapAccess, Visitor},
ser::SerializeStruct,
Deserialize, Deserializer, Serialize, Serializer,
};
use super::{added_vocabulary::AddedTokenWithId, TokenizerImpl};
use crate::{Decoder, Model, Normalizer, PostProcessor, PreTokenizer, TokenizerBui... | tokenizers/tokenizers/src/tokenizer/serialization.rs/0 | {
"file_path": "tokenizers/tokenizers/src/tokenizer/serialization.rs",
"repo_id": "tokenizers",
"token_count": 3738
} | 260 |
mod common;
use common::*;
use tokenizers::decoders::byte_level::ByteLevel;
use tokenizers::decoders::DecoderWrapper;
use tokenizers::models::bpe::BPE;
use tokenizers::models::wordlevel::WordLevel;
use tokenizers::models::wordpiece::WordPiece;
use tokenizers::models::ModelWrapper;
use tokenizers::normalizers::bert::Be... | tokenizers/tokenizers/tests/serialization.rs/0 | {
"file_path": "tokenizers/tokenizers/tests/serialization.rs",
"repo_id": "tokenizers",
"token_count": 3890
} | 261 |
# Accessing Private/Gated Models
<Tip>
Due to the possibility of leaking access tokens to users of your website or web application, we only support accessing private/gated models from server-side environments (e.g., Node.js) that have access to the process' environment variables.
</Tip>
## Step 1: Generating a Use... | transformers.js/docs/source/guides/private.md/0 | {
"file_path": "transformers.js/docs/source/guides/private.md",
"repo_id": "transformers.js",
"token_count": 711
} | 262 |
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
| transformers.js/examples/cross-encoder/src/main.jsx/0 | {
"file_path": "transformers.js/examples/cross-encoder/src/main.jsx",
"repo_id": "transformers.js",
"token_count": 87
} | 263 |
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
html,
body {
height: 100%;
}
body {
padding: 16px 32px;
}
body,
#container,
#upload-button {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
h1 {
text-align: center;
}
#contain... | transformers.js/examples/depth-anything-client/style.css/0 | {
"file_path": "transformers.js/examples/depth-anything-client/style.css",
"repo_id": "transformers.js",
"token_count": 474
} | 264 |
{
"name": "extension",
"version": "0.0.1",
"description": "Transformers.js | Sample browser extension",
"scripts": {
"build": "webpack",
"dev": "webpack --watch"
},
"type": "module",
"author": "Xenova",
"license": "MIT",
"devDependencies": {
"copy-webpack-plugin": "^11.0.0",
"html-webp... | transformers.js/examples/extension/package.json/0 | {
"file_path": "transformers.js/examples/extension/package.json",
"repo_id": "transformers.js",
"token_count": 197
} | 265 |
import { useState, useRef } from 'react';
const EXAMPLE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/beetle.png';
const ImageInput = ({ onImageChange, ...props }) => {
const [imagePreview, setImagePreview] = useState(null);
const fileInputRef = useRef(null);
const readF... | transformers.js/examples/florence2-webgpu/src/components/ImageInput.jsx/0 | {
"file_path": "transformers.js/examples/florence2-webgpu/src/components/ImageInput.jsx",
"repo_id": "transformers.js",
"token_count": 1106
} | 266 |
import './globals.css'
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}
export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={... | transformers.js/examples/next-client/src/app/layout.js/0 | {
"file_path": "transformers.js/examples/next-client/src/app/layout.js",
"repo_id": "transformers.js",
"token_count": 128
} | 267 |
// Create a custom request handler for the /classify route.
// For more information, see https://nextjs.org/docs/app/building-your-application/routing/router-handlers
import { NextResponse } from 'next/server'
import PipelineSingleton from './pipeline.js';
export async function GET(request) {
const text = request... | transformers.js/examples/next-server/src/app/classify/route.js/0 | {
"file_path": "transformers.js/examples/next-server/src/app/classify/route.js",
"repo_id": "transformers.js",
"token_count": 250
} | 268 |
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.language-container {
display: flex;
gap: 20px;
}
.textbox-container {
display: flex;
justify-content: center;
gap: 20px;
width: 800px;
}
.textbox-container>textarea, .language-selector {
width: 50%;
}
.language-se... | transformers.js/examples/react-translator/src/App.css/0 | {
"file_path": "transformers.js/examples/react-translator/src/App.css",
"repo_id": "transformers.js",
"token_count": 383
} | 269 |
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
html,
body {
height: 100%;
}
body {
padding: 16px 32px;
}
body,
#container,
#upload-button {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
h1, h3 {
text-... | transformers.js/examples/segment-anything-client/index.css/0 | {
"file_path": "transformers.js/examples/segment-anything-client/index.css",
"repo_id": "transformers.js",
"token_count": 766
} | 270 |
import { env, AutoTokenizer, CLIPTextModelWithProjection } from '@xenova/transformers';
import { getCachedFile, getCachedJSON } from './utils.js';
const EMBED_DIM = 512;
// Skip local model check
env.allowLocalModels = false;
class ApplicationSingleton {
static model_id = 'Xenova/clip-vit-base-patch16';
sta... | transformers.js/examples/semantic-image-search-client/src/app/worker.js/0 | {
"file_path": "transformers.js/examples/semantic-image-search-client/src/app/worker.js",
"repo_id": "transformers.js",
"token_count": 1518
} | 271 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.