text stringlengths 96 319k | id stringlengths 14 178 | metadata dict |
|---|---|---|
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Any, Type, TypeVar
from huggingface_hub import HfApi
from huggingface_hub.utils import validate_hf_hub_args
T = TypeVar("T", bound="HubMixin")
class HubMixin:
"""
A Mixin containing the functionality to push an object to the... | lerobot/lerobot/common/utils/hub.py/0 | {
"file_path": "lerobot/lerobot/common/utils/hub.py",
"repo_id": "lerobot",
"token_count": 3654
} |
#!/usr/bin/env python
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | lerobot/lerobot/scripts/push_dataset_to_hub.py/0 | {
"file_path": "lerobot/lerobot/scripts/push_dataset_to_hub.py",
"repo_id": "lerobot",
"token_count": 5655
} |
from functools import cache
import numpy as np
CAP_PROP_FPS = 5
CAP_PROP_FRAME_WIDTH = 3
CAP_PROP_FRAME_HEIGHT = 4
COLOR_RGB2BGR = 4
COLOR_BGR2RGB = 4
ROTATE_90_COUNTERCLOCKWISE = 2
ROTATE_90_CLOCKWISE = 0
ROTATE_180 = 1
@cache
def _generate_image(width: int, height: int):
return np.random.randint(0, 256, size... | lerobot/tests/mock_cv2.py/0 | {
"file_path": "lerobot/tests/mock_cv2.py",
"repo_id": "lerobot",
"token_count": 1099
} |
"""
Tests for physical motors and their mocked versions.
If the physical motors are not connected to the computer, or not working,
the test will be skipped.
Example of running a specific test:
```bash
pytest -sx tests/test_motors.py::test_find_port
pytest -sx tests/test_motors.py::test_motors_bus
```
Example of runni... | lerobot/tests/test_motors.py/0 | {
"file_path": "lerobot/tests/test_motors.py",
"repo_id": "lerobot",
"token_count": 1793
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | open-r1/src/open_r1/sft.py/0 | {
"file_path": "open-r1/src/open_r1/sft.py",
"repo_id": "open-r1",
"token_count": 2638
} |
<!---
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 ... | peft/docs/README.md/0 | {
"file_path": "peft/docs/README.md",
"repo_id": "peft",
"token_count": 2889
} |
<!--Copyright 2023 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | peft/docs/source/developer_guides/quantization.md/0 | {
"file_path": "peft/docs/source/developer_guides/quantization.md",
"repo_id": "peft",
"token_count": 3748
} |
#!/usr/bin/env python
# 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 require... | peft/examples/boft_controlnet/train_controlnet.py/0 | {
"file_path": "peft/examples/boft_controlnet/train_controlnet.py",
"repo_id": "peft",
"token_count": 10032
} |
<jupyter_start><jupyter_text>PEFT with DNA Language Models This notebook demonstrates how to utilize parameter-efficient fine-tuning techniques (PEFT) from the PEFT library to fine-tune a DNA Language Model (DNA-LM). The fine-tuned DNA-LM will be applied to solve a task from the nucleotide benchmark dataset. Parameter-... | peft/examples/dna_language_models/dna_lm.ipynb/0 | {
"file_path": "peft/examples/dna_language_models/dna_lm.ipynb",
"repo_id": "peft",
"token_count": 3782
} |
accelerate launch --config_file config.yaml peft_adalora_whisper_large_training.py \
--model_name_or_path "openai/whisper-large-v2" \
--language "Marathi" \
--language_abbr "mr" \
--task "transcribe" \
--dataset_name "mozilla-foundation/common_voice_11_0" \
--push_to_hub \
--preprocessing_nu... | peft/examples/int8_training/run_adalora_whisper_int8.sh/0 | {
"file_path": "peft/examples/int8_training/run_adalora_whisper_int8.sh",
"repo_id": "peft",
"token_count": 509
} |
<jupyter_start><jupyter_text>Dreambooth with OFTThis Notebook assumes that you already ran the train_dreambooth.py script to create your own adapter.<jupyter_code>from diffusers import DiffusionPipeline
from diffusers.utils import check_min_version, get_logger
from peft import PeftModel
# Will error if the minimal ver... | peft/examples/oft_dreambooth/oft_dreambooth_inference.ipynb/0 | {
"file_path": "peft/examples/oft_dreambooth/oft_dreambooth_inference.ipynb",
"repo_id": "peft",
"token_count": 376
} |
# 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/scripts/launch_notebook_mp.py/0 | {
"file_path": "peft/scripts/launch_notebook_mp.py",
"repo_id": "peft",
"token_count": 474
} |
# 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/__init__.py/0 | {
"file_path": "peft/src/peft/tuners/__init__.py",
"repo_id": "peft",
"token_count": 1113
} |
#include <torch/torch.h>
#include <vector>
#include <iostream>
#include <torch/extension.h>
std::vector<at::Tensor> forward_fast_block_diag_cuda(
at::Tensor input);
std::vector<at::Tensor> forward_fast_block_diag(
at::Tensor input
) {
return forward_fast_block_diag_cuda(input);
}
std::vec... | peft/src/peft/tuners/boft/fbd/fbd_cuda.cpp/0 | {
"file_path": "peft/src/peft/tuners/boft/fbd/fbd_cuda.cpp",
"repo_id": "peft",
"token_count": 370
} |
# 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/model.py/0 | {
"file_path": "peft/src/peft/tuners/lora/model.py",
"repo_id": "peft",
"token_count": 20051
} |
# 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/__init__.py/0 | {
"file_path": "peft/src/peft/tuners/vera/__init__.py",
"repo_id": "peft",
"token_count": 419
} |
# 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/utils/merge_utils.py/0 | {
"file_path": "peft/src/peft/utils/merge_utils.py",
"repo_id": "peft",
"token_count": 3819
} |
# Copyright 2023-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/tests/test_encoder_decoder_models.py/0 | {
"file_path": "peft/tests/test_encoder_decoder_models.py",
"repo_id": "peft",
"token_count": 5682
} |
#!/usr/bin/env python3
# coding=utf-8
# 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
#... | peft/tests/test_poly.py/0 | {
"file_path": "peft/tests/test_poly.py",
"repo_id": "peft",
"token_count": 1541
} |
message: "If you use this software, please cite it as below."
title: "PyTorch Image Models"
version: "1.2.2"
doi: "10.5281/zenodo.4414861"
authors:
- family-names: Wightman
given-names: Ross
version: 1.0.11
year: "2019"
url: "https://github.com/huggingface/pytorch-image-models"
license: "Apache 2.0" | pytorch-image-models/CITATION.cff/0 | {
"file_path": "pytorch-image-models/CITATION.cff",
"repo_id": "pytorch-image-models",
"token_count": 122
} |
# EfficientNet (Knapsack Pruned)
**EfficientNet** is a convolutional neural network architecture and scaling method that uniformly scales all dimensions of depth/width/resolution using a *compound coefficient*. Unlike conventional practice that arbitrary scales these factors, the EfficientNet scaling method uniformly ... | pytorch-image-models/hfdocs/source/models/efficientnet-pruned.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/efficientnet-pruned.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2777
} |
# 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 [residual block... | pytorch-image-models/hfdocs/source/models/resnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/resnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 5076
} |
# (Tensorflow) MixNet
**MixNet** is a type of convolutional neural network discovered via AutoML that utilises [MixConvs](https://paperswithcode.com/method/mixconv) instead of regular [depthwise convolutions](https://paperswithcode.com/method/depthwise-convolution).
The weights from this model were ported from [Tenso... | pytorch-image-models/hfdocs/source/models/tf-mixnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/tf-mixnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2361
} |
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
[project]
name = "timm"
authors = [
{name = "Ross Wightman", email = "ross@huggingface.co"},
]
description = "PyTorch Image Models"
readme = "README.md"
requires-python = ">=3.8"
keywords = ["pytorch", "image-classification"]
license = {text =... | pytorch-image-models/pyproject.toml/0 | {
"file_path": "pytorch-image-models/pyproject.toml",
"repo_id": "pytorch-image-models",
"token_count": 800
} |
""" Optimzier Tests
These tests were adapted from PyTorch' optimizer tests.
"""
import functools
import importlib
import os
from copy import deepcopy
import pytest
import torch
from torch.nn import Parameter
from torch.testing._internal.common_utils import TestCase
from timm.optim import create_optimizer_v2, list_o... | pytorch-image-models/tests/test_optim.py/0 | {
"file_path": "pytorch-image-models/tests/test_optim.py",
"repo_id": "pytorch-image-models",
"token_count": 9446
} |
import csv
import os
import pkgutil
import re
from typing import Dict, List, Optional, Union
from .dataset_info import DatasetInfo
# NOTE no ambiguity wrt to mapping from # classes to ImageNet subset so far, but likely to change
_NUM_CLASSES_TO_SUBSET = {
1000: 'imagenet-1k',
11221: 'imagenet-21k-miil', # m... | pytorch-image-models/timm/data/imagenet_info.py/0 | {
"file_path": "pytorch-image-models/timm/data/imagenet_info.py",
"repo_id": "pytorch-image-models",
"token_count": 1732
} |
from multiprocessing import Value
class SharedCount:
def __init__(self, epoch: int = 0):
self.shared_epoch = Value('i', epoch)
@property
def value(self):
return self.shared_epoch.value
@value.setter
def value(self, epoch):
self.shared_epoch.value = epoch
| pytorch-image-models/timm/data/readers/shared_count.py/0 | {
"file_path": "pytorch-image-models/timm/data/readers/shared_count.py",
"repo_id": "pytorch-image-models",
"token_count": 122
} |
""" PyTorch Conditionally Parameterized Convolution (CondConv)
Paper: CondConv: Conditionally Parameterized Convolutions for Efficient Inference
(https://arxiv.org/abs/1904.04971)
Hacked together by / Copyright 2020 Ross Wightman
"""
import math
from functools import partial
import numpy as np
import torch
from torc... | pytorch-image-models/timm/layers/cond_conv2d.py/0 | {
"file_path": "pytorch-image-models/timm/layers/cond_conv2d.py",
"repo_id": "pytorch-image-models",
"token_count": 2314
} |
""" Global Context Attention Block
Paper: `GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond`
- https://arxiv.org/abs/1904.11492
Official code consulted as reference: https://github.com/xvjiarui/GCNet
Hacked together by / Copyright 2021 Ross Wightman
"""
from torch import nn as nn
import torc... | pytorch-image-models/timm/layers/global_context.py/0 | {
"file_path": "pytorch-image-models/timm/layers/global_context.py",
"repo_id": "pytorch-image-models",
"token_count": 1169
} |
""" Normalization layers and wrappers
Norm layer definitions that support fast norm and consistent channel arg order (always first arg).
Hacked together by / Copyright 2022 Ross Wightman
"""
import numbers
from typing import Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from .fast_norm im... | pytorch-image-models/timm/layers/norm.py/0 | {
"file_path": "pytorch-image-models/timm/layers/norm.py",
"repo_id": "pytorch-image-models",
"token_count": 4880
} |
""" Test Time Pooling (Average-Max Pool)
Hacked together by / Copyright 2020 Ross Wightman
"""
import logging
from torch import nn
import torch.nn.functional as F
from .adaptive_avgmax_pool import adaptive_avgmax_pool2d
_logger = logging.getLogger(__name__)
class TestTimePoolHead(nn.Module):
def __init__(sel... | pytorch-image-models/timm/layers/test_time_pool.py/0 | {
"file_path": "pytorch-image-models/timm/layers/test_time_pool.py",
"repo_id": "pytorch-image-models",
"token_count": 881
} |
""" Model creation / weight loading / state_dict helpers
Hacked together by / Copyright 2020 Ross Wightman
"""
import logging
import os
from typing import Any, Callable, Dict, Optional, Union
import torch
try:
import safetensors.torch
_has_safetensors = True
except ImportError:
_has_safetensors = False
_... | pytorch-image-models/timm/models/_helpers.py/0 | {
"file_path": "pytorch-image-models/timm/models/_helpers.py",
"repo_id": "pytorch-image-models",
"token_count": 2793
} |
""" ConViT Model
@article{d2021convit,
title={ConViT: Improving Vision Transformers with Soft Convolutional Inductive Biases},
author={d'Ascoli, St{\'e}phane and Touvron, Hugo and Leavitt, Matthew and Morcos, Ari and Biroli, Giulio and Sagun, Levent},
journal={arXiv preprint arXiv:2103.10697},
year={2021}
}
P... | pytorch-image-models/timm/models/convit.py/0 | {
"file_path": "pytorch-image-models/timm/models/convit.py",
"repo_id": "pytorch-image-models",
"token_count": 7721
} |
""" EVA
EVA from https://github.com/baaivision/EVA , paper: https://arxiv.org/abs/2211.07636
@article{EVA,
title={EVA: Exploring the Limits of Masked Visual Representation Learning at Scale},
author={Fang, Yuxin and Wang, Wen and Xie, Binhui and Sun, Quan and Wu, Ledell and Wang, Xinggang and Huang,
Tiejun and ... | pytorch-image-models/timm/models/eva.py/0 | {
"file_path": "pytorch-image-models/timm/models/eva.py",
"repo_id": "pytorch-image-models",
"token_count": 25968
} |
""" Pytorch Inception-Resnet-V2 implementation
Sourced from https://github.com/Cadene/tensorflow-model-zoo.torch (MIT License) which is
based upon Google's Tensorflow implementation and pretrained weights (Apache 2.0 License)
"""
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functiona... | pytorch-image-models/timm/models/inception_resnet_v2.py/0 | {
"file_path": "pytorch-image-models/timm/models/inception_resnet_v2.py",
"repo_id": "pytorch-image-models",
"token_count": 6034
} |
""" Pooling-based Vision Transformer (PiT) in PyTorch
A PyTorch implement of Pooling-based Vision Transformers as described in
'Rethinking Spatial Dimensions of Vision Transformers' - https://arxiv.org/abs/2103.16302
This code was adapted from the original version at https://github.com/naver-ai/pit, original copyrigh... | pytorch-image-models/timm/models/pit.py/0 | {
"file_path": "pytorch-image-models/timm/models/pit.py",
"repo_id": "pytorch-image-models",
"token_count": 7404
} |
""" Selective Kernel Networks (ResNet base)
Paper: Selective Kernel Networks (https://arxiv.org/abs/1903.06586)
This was inspired by reading 'Compounding the Performance Improvements...' (https://arxiv.org/abs/2001.06268)
and a streamlined impl at https://github.com/clovaai/assembled-cnn but I ended up building somet... | pytorch-image-models/timm/models/sknet.py/0 | {
"file_path": "pytorch-image-models/timm/models/sknet.py",
"repo_id": "pytorch-image-models",
"token_count": 3801
} |
""" VoVNet (V1 & V2)
Papers:
* `An Energy and GPU-Computation Efficient Backbone Network` - https://arxiv.org/abs/1904.09730
* `CenterMask : Real-Time Anchor-Free Instance Segmentation` - https://arxiv.org/abs/1911.06667
Looked at https://github.com/youngwanLEE/vovnet-detectron2 &
https://github.com/stigma0617/VoVNe... | pytorch-image-models/timm/models/vovnet.py/0 | {
"file_path": "pytorch-image-models/timm/models/vovnet.py",
"repo_id": "pytorch-image-models",
"token_count": 8067
} |
""" PyTorch Implementation of the Kron (PSGD) optimizer
This is a PSGD optimizer using a Kronecker-factored preconditioner.
This impl was adapted from https://github.com/evanatyourservice/kron_torch
by Evan Walters, licensed CC-BY-4.0.
Contributions to above also made by
* Lucas Nestler, added to his https://github.... | pytorch-image-models/timm/optim/kron.py/0 | {
"file_path": "pytorch-image-models/timm/optim/kron.py",
"repo_id": "pytorch-image-models",
"token_count": 10686
} |
""" Batch size decay and retry helpers.
Copyright 2022 Ross Wightman
"""
import math
def decay_batch_step(batch_size, num_intra_steps=2, no_odd=False):
""" power of two batch-size decay with intra steps
Decay by stepping between powers of 2:
* determine power-of-2 floor of current batch size (base batch... | pytorch-image-models/timm/utils/decay_batch.py/0 | {
"file_path": "pytorch-image-models/timm/utils/decay_batch.py",
"repo_id": "pytorch-image-models",
"token_count": 656
} |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | smolagents/docs/source/en/examples/rag.md/0 | {
"file_path": "smolagents/docs/source/en/examples/rag.md",
"repo_id": "smolagents",
"token_count": 2207
} |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | smolagents/docs/source/hi/examples/multiagents.md/0 | {
"file_path": "smolagents/docs/source/hi/examples/multiagents.md",
"repo_id": "smolagents",
"token_count": 5840
} |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | smolagents/docs/source/zh/examples/rag.md/0 | {
"file_path": "smolagents/docs/source/zh/examples/rag.md",
"repo_id": "smolagents",
"token_count": 4008
} |
from typing import Optional
import requests
# from smolagents.agents import ToolCallingAgent
from smolagents import CodeAgent, HfApiModel, tool
# Choose which LLM engine to use!
model = HfApiModel()
# model = TransformersModel(model_id="meta-llama/Llama-3.2-2B-Instruct")
# For anthropic: change model_id below to '... | smolagents/examples/multiple_tools.py/0 | {
"file_path": "smolagents/examples/multiple_tools.py",
"repo_id": "smolagents",
"token_count": 3106
} |
from sqlalchemy import (
Column,
Float,
Integer,
MetaData,
String,
Table,
create_engine,
insert,
inspect,
text,
)
engine = create_engine("sqlite:///:memory:")
metadata_obj = MetaData()
# create city SQL table
table_name = "receipts"
receipts = Table(
table_name,
metada... | smolagents/examples/text_to_sql.py/0 | {
"file_path": "smolagents/examples/text_to_sql.py",
"repo_id": "smolagents",
"token_count": 858
} |
import ast
import builtins
import inspect
from typing import Set
from .utils import BASE_BUILTIN_MODULES, get_source
_BUILTIN_NAMES = set(vars(builtins))
class MethodChecker(ast.NodeVisitor):
"""
Checks that a method
- only uses defined names
- contains no local imports (e.g. numpy is ok but local_... | smolagents/src/smolagents/tool_validation.py/0 | {
"file_path": "smolagents/src/smolagents/tool_validation.py",
"repo_id": "smolagents",
"token_count": 3416
} |
# coding=utf-8
# Copyright 2024 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | smolagents/tests/test_models.py/0 | {
"file_path": "smolagents/tests/test_models.py",
"repo_id": "smolagents",
"token_count": 3273
} |
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": 4227
} |
#[allow(clippy::derive_partial_eq_without_eq)]
mod pb;
mod client;
mod sharded_client;
pub use client::Client;
pub use pb::generate::v3::{
input_chunk::Chunk, Batch, CachedBatch, FinishReason, GeneratedText, Generation, GrammarType,
HealthResponse, Image, InfoResponse, Input, InputChunk, NextTokenChooserParam... | text-generation-inference/backends/client/src/v3/mod.rs/0 | {
"file_path": "text-generation-inference/backends/client/src/v3/mod.rs",
"repo_id": "text-generation-inference",
"token_count": 142
} |
#!/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
} |
/// 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
} |
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
} |
# Streaming
## What is Streaming?
Token streaming is the mode in which the server returns the tokens one by one as the model generates them. This enables showing progressive generations to the user rather than waiting for the whole generation. Streaming is an essential aspect of the end-user experience as it reduces... | text-generation-inference/docs/source/conceptual/streaming.md/0 | {
"file_path": "text-generation-inference/docs/source/conceptual/streaming.md",
"repo_id": "text-generation-inference",
"token_count": 1890
} |
# Collection of Usage Statistics
Text Generation Inference collects anonymous usage statistics to help us improve the service. The collected data is used to improve TGI and to understand what causes failures. The data is collected transparently and any sensitive information is omitted.
Usage statistics are collected... | text-generation-inference/docs/source/usage_statistics.md/0 | {
"file_path": "text-generation-inference/docs/source/usage_statistics.md",
"repo_id": "text-generation-inference",
"token_count": 966
} |
[
{
"choices": [
{
"delta": {
"content": "**",
"role": "assistant",
"tool_calls": null
},
"finish_reason": null,
"index": 0,
"logprobs": null
}
],
"created": 1726656043,
"id": "",
"model": "meta-llama/Meta-Llama-3.1-... | text-generation-inference/integration-tests/models/__snapshots__/test_completion_prompts/test_flash_llama_completion_stream_usage.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_completion_prompts/test_flash_llama_completion_stream_usage.json",
"repo_id": "text-generation-inference",
"token_count": 2511
} |
{
"choices": [
{
"finish_reason": "length",
"index": 0,
"logprobs": null,
"message": {
"content": "Both an elephant and a mouse are mammals. However, the differences between elephants and mice are:\n\n1",
"role": "assistant"
}
}
],
"created": 1732541189,
"id... | text-generation-inference/integration-tests/models/__snapshots__/test_continue_final_message/test_llama_completion_single_prompt.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_continue_final_message/test_llama_completion_single_prompt.json",
"repo_id": "text-generation-inference",
"token_count": 258
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 688,
"logprob": -0.546875,
"special": false,
"text": "**"
},
{
"id": 103889,
"logprob"... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_gemma2/test_flash_gemma2.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_gemma2/test_flash_gemma2.json",
"repo_id": "text-generation-inference",
"token_count": 877
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": 0,
"tokens": [
{
"id": 13,
"logprob": -1.9980469,
"special": false,
"text": "."
},
{
"id": 578,
"logprob": -0.15... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_exl2/test_flash_llama_exl2_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_exl2/test_flash_llama_exl2_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 856
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": 0,
"tokens": [
{
"id": 311,
"logprob": -1.4277344,
"special": false,
"text": " to"
},
{
"id": 279,
"logprob": -0... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2/test_flash_qwen2_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2/test_flash_qwen2_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 876
} |
[
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 222,
"logprob": -1.9091797,
"special": false,
"text": "\n"
},
{
... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_starcoder2_lora/test_flash_starcoder2_load.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_starcoder2_lora/test_flash_starcoder2_load.json",
"repo_id": "text-generation-inference",
"token_count": 4084
} |
[
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 13,
"logprob": -0.007621765,
"special": false,
"text": "\n"
},
{
... | text-generation-inference/integration-tests/models/__snapshots__/test_llava_next/test_flash_llava_next_load.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_llava_next/test_flash_llava_next_load.json",
"repo_id": "text-generation-inference",
"token_count": 4048
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 42,
"logprob": -0.86279297,
"special": false,
"text": "I"
},
{
"id": 1353,
"logprob": ... | text-generation-inference/integration-tests/models/__snapshots__/test_neox/test_neox.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_neox/test_neox.json",
"repo_id": "text-generation-inference",
"token_count": 853
} |
import pytest
@pytest.fixture(scope="module")
def flash_deepseek_v2_handle(launcher):
with launcher("deepseek-ai/DeepSeek-V2-Lite", num_shard=2) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_deepseek_v2(flash_deepseek_v2_handle):
await flash_deepseek_v2_handle.health(300)
... | text-generation-inference/integration-tests/models/test_flash_deepseek_v2.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_deepseek_v2.py",
"repo_id": "text-generation-inference",
"token_count": 710
} |
import pytest
@pytest.fixture(scope="module")
def flash_medusa_handle(launcher):
with launcher(
"FasterDecoding/medusa-vicuna-7b-v1.3", num_shard=2, revision="refs/pr/1"
) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_medusa(flash_medusa_handle):
await flash_med... | text-generation-inference/integration-tests/models/test_flash_medusa.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_medusa.py",
"repo_id": "text-generation-inference",
"token_count": 749
} |
import pytest
import requests
@pytest.fixture(scope="module")
def flash_starcoder2_handle(launcher):
with launcher(
"bigcode/starcoder2-3b", lora_adapters=["smangrul/starcoder-3b-hugcoder"]
) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_starcoder2(flash_starcoder2_... | text-generation-inference/integration-tests/models/test_flash_starcoder2_lora.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_starcoder2_lora.py",
"repo_id": "text-generation-inference",
"token_count": 940
} |
import pytest
@pytest.fixture(scope="module")
def flash_smolvlm_next_handle(launcher):
with launcher("HuggingFaceTB/SmolVLM-Instruct") as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_smolvlm_next(flash_smolvlm_next_handle):
await flash_smolvlm_next_handle.health(300)
retu... | text-generation-inference/integration-tests/models/test_smolvlm.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_smolvlm.py",
"repo_id": "text-generation-inference",
"token_count": 435
} |
use std::error::Error;
use vergen::EmitBuilder;
fn main() -> Result<(), Box<dyn Error>> {
// Try to get the git sha from the local git repository
if EmitBuilder::builder()
.fail_on_error()
.git_sha(false)
.emit()
.is_err()
{
// Unable to get the git sha
if le... | text-generation-inference/router/build.rs/0 | {
"file_path": "text-generation-inference/router/build.rs",
"repo_id": "text-generation-inference",
"token_count": 324
} |
include Makefile-flash-att
include Makefile-flash-att-v2
include Makefile-vllm
include Makefile-awq
include Makefile-eetq
include Makefile-selective-scan
include Makefile-lorax-punica
include Makefile-exllamav2
include Makefile-flashinfer
unit-tests:
pip install -U pip uv
uv pip install -e ".[dev]"
pytest -s -vv -m... | text-generation-inference/server/Makefile/0 | {
"file_path": "text-generation-inference/server/Makefile",
"repo_id": "text-generation-inference",
"token_count": 817
} |
// Adapted from turboderp exllama: https://github.com/turboderp/exllama
#define _cuda_buffers_cu
#include "cuda_buffers.cuh"
CudaBuffers* g_buffers[CUDA_MAX_DEVICES] = {NULL};
// __constant__ half2 q4_table[16][256];
// half2 q4_table_host[16][256];
// bool q4_table_init = false;
CudaBuffers::CudaBuffers
(
int _... | text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_buffers.cu/0 | {
"file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_buffers.cu",
"repo_id": "text-generation-inference",
"token_count": 680
} |
#include <torch/extension.h>
#include <c10/cuda/CUDAGuard.h>
#include <ATen/cuda/CUDAContext.h>
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include <cstdint>
#include <cstdio>
#include "config.h"
#include "cuda/q_matrix.cuh"
#include "cuda/q_gemm.cuh"
#include "cpp/util.h"
// Some decluttering macros
#define... | text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/ext.cpp/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/ext.cpp",
"repo_id": "text-generation-inference",
"token_count": 2184
} |
import os
import tempfile
import pytest
import huggingface_hub.constants
import text_generation_server.utils.hub
from text_generation_server.utils.hub import (
weight_hub_files,
download_weights,
weight_files,
EntryNotFoundError,
LocalEntryNotFoundError,
RevisionNotFoundError,
)
@pytest.fix... | text-generation-inference/server/tests/utils/test_hub.py/0 | {
"file_path": "text-generation-inference/server/tests/utils/test_hub.py",
"repo_id": "text-generation-inference",
"token_count": 1250
} |
import torch
from text_generation_server.layers.attention.kv_cache import KVCache, KVScales
from text_generation_server.utils.import_utils import SYSTEM
from text_generation_server.models.globals import (
ATTENTION,
BLOCK_SIZE,
)
from text_generation_server.layers.attention import Seqlen
from typing import Opti... | text-generation-inference/server/text_generation_server/layers/attention/cuda.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/attention/cuda.py",
"repo_id": "text-generation-inference",
"token_count": 5771
} |
from typing import List, Union
import torch
from compressed_tensors.quantization import QuantizationArgs, QuantizationType
from text_generation_server.layers.marlin.marlin import GPTQMarlin24Weight
from text_generation_server.utils.weights import Weights, WeightsLoader
class WNA16Int24Loader(WeightsLoader):
""... | text-generation-inference/server/text_generation_server/layers/compressed_tensors/wna16_int_24.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/compressed_tensors/wna16_int_24.py",
"repo_id": "text-generation-inference",
"token_count": 1629
} |
from text_generation_server.layers.marlin.fp8 import GPTQMarlinFP8Linear
from text_generation_server.layers.marlin.gptq import (
GPTQMarlinWeightsLoader,
can_use_gptq_marlin,
repack_gptq_for_marlin,
)
from text_generation_server.layers.marlin.marlin import MarlinWeightsLoader
__all__ = [
"GPTQMarlinFP8... | text-generation-inference/server/text_generation_server/layers/marlin/__init__.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/marlin/__init__.py",
"repo_id": "text-generation-inference",
"token_count": 195
} |
import torch
import torch.distributed
from typing import Optional, Type
from transformers import (
PreTrainedTokenizerBase,
)
from text_generation_server.models import CausalLM
from text_generation_server.models.causal_lm import CausalLMBatch
from text_generation_server.pb import generate_pb2
class BloomCausal... | text-generation-inference/server/text_generation_server/models/bloom.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/bloom.py",
"repo_id": "text-generation-inference",
"token_count": 543
} |
# coding=utf-8
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
#
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
# and OPT implementations in this library. It has been modified from its
# original forms to accommodate minor architectural differences compared
# to G... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_neox_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_neox_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 6670
} |
# coding=utf-8
# Copyright 2024 the HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | text-generation-inference/server/text_generation_server/models/custom_modeling/llava_next.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/llava_next.py",
"repo_id": "text-generation-inference",
"token_count": 5448
} |
import torch
import triton
import triton.language as tl
from loguru import logger
from typing import List, Optional
from torch.utils._triton import has_triton as has_triton_torch
from text_generation_server.utils.import_utils import (
SYSTEM,
)
from text_generation_server.utils.log import log_master
_HAS_TRITON... | text-generation-inference/server/text_generation_server/models/metadata_kernels.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/metadata_kernels.py",
"repo_id": "text-generation-inference",
"token_count": 4276
} |
import time
import os
from datetime import timedelta
from loguru import logger
from pathlib import Path
from typing import Optional, List
from huggingface_hub import file_download, hf_api, HfApi, hf_hub_download
from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE
from huggingface_hub.utils import (
LocalE... | text-generation-inference/server/text_generation_server/utils/hub.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/hub.py",
"repo_id": "text-generation-inference",
"token_count": 3419
} |
/* eslint-disable @typescript-eslint/no-explicit-any */
import { bertProcessing, byteLevelProcessing, robertaProcessing, sequenceProcessing, templateProcessing } from '../../'
describe('bertProcessing', () => {
it('instantiates correctly with only two parameters', () => {
const processor = bertProcessing(['sep'... | tokenizers/bindings/node/lib/bindings/post-processors.test.ts/0 | {
"file_path": "tokenizers/bindings/node/lib/bindings/post-processors.test.ts",
"repo_id": "tokenizers",
"token_count": 1022
} |
use serde::de::Deserializer;
use serde::ser::Serializer;
use serde::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
pub fn serialize<S, T>(val: &Option<Arc<RwLock<T>>>, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
T: Serialize,
{
T::serialize(&*(val.clone().unwrap()).read().unwrap(), s)
}
pub f... | tokenizers/bindings/node/src/arc_rwlock_serde.rs/0 | {
"file_path": "tokenizers/bindings/node/src/arc_rwlock_serde.rs",
"repo_id": "tokenizers",
"token_count": 220
} |
from enum import Enum
from typing import List, Tuple, Union
Offsets = Tuple[int, int]
TextInputSequence = str
"""A :obj:`str` that represents an input sequence """
PreTokenizedInputSequence = Union[List[str], Tuple[str]]
"""A pre-tokenized input sequence. Can be one of:
- A :obj:`List` of :obj:`str`
- A :o... | tokenizers/bindings/python/py_src/tokenizers/__init__.py/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/__init__.py",
"repo_id": "tokenizers",
"token_count": 984
} |
# Generated content DO NOT EDIT
class PreTokenizer:
"""
Base class for all pre-tokenizers
This class is not supposed to be instantiated directly. Instead, any implementation of a
PreTokenizer will return an instance of this class when instantiated.
"""
def pre_tokenize(self, pretok):
""... | tokenizers/bindings/python/py_src/tokenizers/pre_tokenizers/__init__.pyi/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/pre_tokenizers/__init__.pyi",
"repo_id": "tokenizers",
"token_count": 9661
} |
use pyo3::exceptions;
use pyo3::prelude::*;
use pyo3::type_object::PyTypeInfo;
use std::ffi::CString;
use std::fmt::{Display, Formatter, Result as FmtResult};
use tokenizers::tokenizer::Result;
#[derive(Debug)]
pub struct PyError(pub String);
impl PyError {
#[allow(dead_code)]
pub fn from(s: &str) -> Self {
... | tokenizers/bindings/python/src/error.rs/0 | {
"file_path": "tokenizers/bindings/python/src/error.rs",
"repo_id": "tokenizers",
"token_count": 548
} |
from tokenizers import Tokenizer, decoders, models, normalizers, pre_tokenizers, processors
from tokenizers.implementations import BaseTokenizer
class TestBaseTokenizer:
def test_get_set_components(self):
toki = Tokenizer(models.BPE())
toki.normalizer = normalizers.NFC()
toki.pre_tokenizer... | tokenizers/bindings/python/tests/implementations/test_base_tokenizer.py/0 | {
"file_path": "tokenizers/bindings/python/tests/implementations/test_base_tokenizer.py",
"repo_id": "tokenizers",
"token_count": 550
} |
# Normalizers
<tokenizerslangcontent>
<python>
## BertNormalizer
[[autodoc]] tokenizers.normalizers.BertNormalizer
## Lowercase
[[autodoc]] tokenizers.normalizers.Lowercase
## NFC
[[autodoc]] tokenizers.normalizers.NFC
## NFD
[[autodoc]] tokenizers.normalizers.NFD
## NFKC
[[autodoc]] tokenizers.normalizers.NF... | tokenizers/docs/source-doc-builder/api/normalizers.mdx/0 | {
"file_path": "tokenizers/docs/source-doc-builder/api/normalizers.mdx",
"repo_id": "tokenizers",
"token_count": 350
} |
🤗 Tokenizers is tested on Python 3.5+.
You should install 🤗 Tokenizers in a
`virtual environment <https://docs.python.org/3/library/venv.html>`_. If you're unfamiliar with
Python virtual environments, check out the
`user guide <https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/>`__.
C... | tokenizers/docs/source/installation/python.inc/0 | {
"file_path": "tokenizers/docs/source/installation/python.inc",
"repo_id": "tokenizers",
"token_count": 383
} |
#[macro_use]
extern crate criterion;
use criterion::Criterion;
use std::collections::HashMap;
use std::fs::read_to_string;
use std::time::{Duration, Instant};
use tokenizers::models::unigram::Unigram;
use tokenizers::models::unigram::UnigramTrainer;
pub fn bench_train(c: &mut Criterion) {
let trainer = UnigramTra... | tokenizers/tokenizers/benches/unigram_benchmark.rs/0 | {
"file_path": "tokenizers/tokenizers/benches/unigram_benchmark.rs",
"repo_id": "tokenizers",
"token_count": 1172
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello wasm-pack!</title>
</head>
<body>
<noscript>This page contains webassembly and javascript content, please enable javascript in your browser.</noscript>
<script src="./bootstrap.js"></script>
</body>
</html>
| tokenizers/tokenizers/examples/unstable_wasm/www/index.html/0 | {
"file_path": "tokenizers/tokenizers/examples/unstable_wasm/www/index.html",
"repo_id": "tokenizers",
"token_count": 110
} |
use super::{super::OrderedVocabIter, trainer::BpeTrainer, Error, Pair, Word};
use crate::tokenizer::{Model, Result, Token};
use crate::utils::cache::{Cache, DEFAULT_CACHE_CAPACITY, MAX_LENGTH};
use crate::utils::iter::ResultShunt;
use serde_json::Value;
use std::borrow::Cow;
use std::{
collections::HashMap,
fs:... | tokenizers/tokenizers/src/models/bpe/model.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/bpe/model.rs",
"repo_id": "tokenizers",
"token_count": 17728
} |
use super::WordPiece;
use crate::models::bpe::{BpeTrainer, BpeTrainerBuilder, BPE};
use crate::tokenizer::{AddedToken, Result, Trainer};
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
/// A `WordPieceTrainerBuilder` can be used to create a `WordPieceTrainer` with a custom
/// configuration.
pub st... | tokenizers/tokenizers/src/models/wordpiece/trainer.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/wordpiece/trainer.rs",
"repo_id": "tokenizers",
"token_count": 2499
} |
use serde::{Deserialize, Serialize};
use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior};
use crate::utils::macro_rules_attribute;
use unicode_categories::UnicodeCategories;
fn is_punc(x: char) -> bool {
char::is_ascii_punctuation(&x) || x.is_punctuation()
}
#[derive(Copy, Cl... | tokenizers/tokenizers/src/pre_tokenizers/punctuation.rs/0 | {
"file_path": "tokenizers/tokenizers/src/pre_tokenizers/punctuation.rs",
"repo_id": "tokenizers",
"token_count": 1103
} |
use crate::utils::SysRegex;
use crate::{Offsets, Result};
use regex::Regex;
/// Pattern used to split a NormalizedString
pub trait Pattern {
/// Slice the given string in a list of pattern match positions, with
/// a boolean indicating whether this is a match or not.
///
/// This method *must* cover th... | tokenizers/tokenizers/src/tokenizer/pattern.rs/0 | {
"file_path": "tokenizers/tokenizers/src/tokenizer/pattern.rs",
"repo_id": "tokenizers",
"token_count": 3903
} |
#![cfg(feature = "http")]
use tokenizers::{FromPretrainedParameters, Result, Tokenizer};
#[test]
fn test_from_pretrained() -> Result<()> {
let tokenizer = Tokenizer::from_pretrained("bert-base-cased", None)?;
let encoding = tokenizer.encode("Hey there dear friend!", false)?;
assert_eq!(
encoding.ge... | tokenizers/tokenizers/tests/from_pretrained.rs/0 | {
"file_path": "tokenizers/tokenizers/tests/from_pretrained.rs",
"repo_id": "tokenizers",
"token_count": 683
} |
// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
const { contextBridge, ipcRenderer } = require('electron');
// Here, we use the `contextBridge` API to expose a custom API to the renderer process.
// This API ... | transformers.js/examples/electron/src/preload.js/0 | {
"file_path": "transformers.js/examples/electron/src/preload.js",
"repo_id": "transformers.js",
"token_count": 153
} |
// Adapted from https://github.com/xenova/transformers.js/blob/c367f9d68b809bbbf81049c808bf6d219d761d23/src/utils/hub.js#L330
export async function getCachedFile(url) {
let cache;
try {
cache = await caches.open('semantic-audio-search');
const cachedResponse = await cache.match(url);
if... | transformers.js/examples/semantic-audio-search/utils.js/0 | {
"file_path": "transformers.js/examples/semantic-audio-search/utils.js",
"repo_id": "transformers.js",
"token_count": 502
} |
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb)... | transformers.js/examples/semantic-image-search-client/src/app/globals.css/0 | {
"file_path": "transformers.js/examples/semantic-image-search-client/src/app/globals.css",
"repo_id": "transformers.js",
"token_count": 157
} |
html,
body {
font-family: Arial, Helvetica, sans-serif;
}
.container {
margin: 40px auto;
width: max(50vw, 400px);
display: flex;
flex-direction: column;
align-items: center;
}
.custom-file-upload {
display: flex;
align-items: center;
cursor: pointer;
gap: 10px;
border: 2p... | transformers.js/examples/vanilla-js/style.css/0 | {
"file_path": "transformers.js/examples/vanilla-js/style.css",
"repo_id": "transformers.js",
"token_count": 389
} |
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
html,
body {
height: 100%;
}
body {
padding: 16px 32px;
}
body,
#container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#controls {
display: flex;
padding: 1rem;
gap: 1... | transformers.js/examples/webgpu-clip/style.css/0 | {
"file_path": "transformers.js/examples/webgpu-clip/style.css",
"repo_id": "transformers.js",
"token_count": 510
} |
import './style.css';
import { AutoModel, AutoProcessor, RawImage } from '@xenova/transformers';
async function hasFp16() {
try {
const adapter = await navigator.gpu.requestAdapter()
return adapter.features.has('shader-f16')
} catch (e) {
return false
}
}
// Reference the elements... | transformers.js/examples/webgpu-video-depth-estimation/main.js/0 | {
"file_path": "transformers.js/examples/webgpu-video-depth-estimation/main.js",
"repo_id": "transformers.js",
"token_count": 1857
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.