text
stringlengths
5
424k
id
stringlengths
13
178
metadata
dict
__index_level_0__
int64
0
672
# Copyright 2023-present the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
peft/src/peft/utils/__init__.py/0
{ "file_path": "peft/src/peft/utils/__init__.py", "repo_id": "peft", "token_count": 2266 }
259
# 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_adaption_prompt.py/0
{ "file_path": "peft/tests/test_adaption_prompt.py", "repo_id": "peft", "token_count": 8196 }
260
# Copyright 2024-present the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or...
peft/tests/test_incremental_pca.py/0
{ "file_path": "peft/tests/test_incremental_pca.py", "repo_id": "peft", "token_count": 2775 }
261
# 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_stablediffusion.py/0
{ "file_path": "peft/tests/test_stablediffusion.py", "repo_id": "peft", "token_count": 7695 }
262
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 }
263
# Changelog ## Jan 19, 2025 * Fix loading of LeViT safetensor weights, remove conversion code which should have been deactivated * Add 'SO150M' ViT weights trained with SBB recipes, decent results, but not optimal shape for ImageNet-12k/1k pretrain/ft * `vit_so150m_patch16_reg4_gap_256.sbb_e250_in12k_ft_in1k` - 86.7...
pytorch-image-models/hfdocs/source/changes.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/changes.mdx", "repo_id": "pytorch-image-models", "token_count": 50077 }
264
# 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": 2778 }
265
# 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": 5077 }
266
# (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": 2362 }
267
[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 }
268
""" 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": 9463 }
269
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 }
270
""" A dataset reader that extracts images from folders Folders are scanned recursively to find image files. Labels are based on the folder hierarchy, just leaf folders by default. Hacked together by / Copyright 2020 Ross Wightman """ import os from typing import Dict, List, Optional, Set, Tuple, Union from timm.util...
pytorch-image-models/timm/data/readers/reader_image_folder.py/0
{ "file_path": "pytorch-image-models/timm/data/readers/reader_image_folder.py", "repo_id": "pytorch-image-models", "token_count": 1510 }
271
from typing import List, Optional, Type, Union import torch from torch import nn as nn from torch.nn import functional as F from .config import use_fused_attn from .create_conv2d import create_conv2d from .helpers import to_2tuple from .pool2d_same import create_pool2d class MultiQueryAttentionV2(nn.Module): ""...
pytorch-image-models/timm/layers/attention2d.py/0
{ "file_path": "pytorch-image-models/timm/layers/attention2d.py", "repo_id": "pytorch-image-models", "token_count": 6678 }
272
""" DropBlock, DropPath PyTorch implementations of DropBlock and DropPath (Stochastic Depth) regularization layers. Papers: DropBlock: A regularization method for convolutional networks (https://arxiv.org/abs/1810.12890) Deep Networks with Stochastic Depth (https://arxiv.org/abs/1603.09382) Code: DropBlock impl ins...
pytorch-image-models/timm/layers/drop.py/0
{ "file_path": "pytorch-image-models/timm/layers/drop.py", "repo_id": "pytorch-image-models", "token_count": 3739 }
273
import torch from torch import nn class LayerScale(nn.Module): """ LayerScale on tensors with channels in last-dim. """ def __init__( self, dim: int, init_values: float = 1e-5, inplace: bool = False, ) -> None: super().__init__() self.inp...
pytorch-image-models/timm/layers/layer_scale.py/0
{ "file_path": "pytorch-image-models/timm/layers/layer_scale.py", "repo_id": "pytorch-image-models", "token_count": 482 }
274
""" Sin-cos, fourier, rotary position embedding modules and functions Hacked together by / Copyright 2022 Ross Wightman """ import math from typing import List, Tuple, Optional, Union import torch from torch import nn as nn from ._fx import register_notrace_function from .grid import ndgrid from .trace_utils import ...
pytorch-image-models/timm/layers/pos_embed_sincos.py/0
{ "file_path": "pytorch-image-models/timm/layers/pos_embed_sincos.py", "repo_id": "pytorch-image-models", "token_count": 20095 }
275
import torch import torch.nn as nn import torch.nn.functional as F from .cross_entropy import LabelSmoothingCrossEntropy class JsdCrossEntropy(nn.Module): """ Jensen-Shannon Divergence + Cross-Entropy Loss Based on impl here: https://github.com/google-research/augmix/blob/master/imagenet.py From paper: ...
pytorch-image-models/timm/loss/jsd.py/0
{ "file_path": "pytorch-image-models/timm/loss/jsd.py", "repo_id": "pytorch-image-models", "token_count": 639 }
276
""" Deep Layer Aggregation and DLA w/ Res2Net DLA original adapted from Official Pytorch impl at: https://github.com/ucbdrive/dla DLA Paper: `Deep Layer Aggregation` - https://arxiv.org/abs/1707.06484 Res2Net additions from: https://github.com/gasvn/Res2Net/ Res2Net Paper: `Res2Net: A New Multi-scale Backbone Architec...
pytorch-image-models/timm/models/dla.py/0
{ "file_path": "pytorch-image-models/timm/models/dla.py", "repo_id": "pytorch-image-models", "token_count": 9154 }
277
""" An implementation of GhostNet & GhostNetV2 Models as defined in: GhostNet: More Features from Cheap Operations. https://arxiv.org/abs/1911.11907 GhostNetV2: Enhance Cheap Operation with Long-Range Attention. https://proceedings.neurips.cc/paper_files/paper/2022/file/40b60852a4abdaa696b5a1a78da34635-Paper-Conference...
pytorch-image-models/timm/models/ghostnet.py/0
{ "file_path": "pytorch-image-models/timm/models/ghostnet.py", "repo_id": "pytorch-image-models", "token_count": 17881 }
278
""" Poolformer from MetaFormer is Actually What You Need for Vision https://arxiv.org/abs/2111.11418 IdentityFormer, RandFormer, PoolFormerV2, ConvFormer, and CAFormer from MetaFormer Baselines for Vision https://arxiv.org/abs/2210.13452 All implemented models support feature extraction and variable input resolution....
pytorch-image-models/timm/models/metaformer.py/0
{ "file_path": "pytorch-image-models/timm/models/metaformer.py", "repo_id": "pytorch-image-models", "token_count": 18677 }
279
"""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": 26296 }
280
""" Swin Transformer V2 A PyTorch impl of : `Swin Transformer V2: Scaling Up Capacity and Resolution` - https://arxiv.org/abs/2111.09883 Code/weights from https://github.com/microsoft/Swin-Transformer, original copyright/license info below Modifications and additions for timm hacked together by / Copyright 2022, ...
pytorch-image-models/timm/models/swin_transformer_v2.py/0
{ "file_path": "pytorch-image-models/timm/models/swin_transformer_v2.py", "repo_id": "pytorch-image-models", "token_count": 23221 }
281
"""Pytorch impl of Aligned Xception 41, 65, 71 This is a correct, from scratch impl of Aligned Xception (Deeplab) models compatible with TF weights at https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md Hacked together by / Copyright 2020 Ross Wightman """ from functools import partia...
pytorch-image-models/timm/models/xception_aligned.py/0
{ "file_path": "pytorch-image-models/timm/models/xception_aligned.py", "repo_id": "pytorch-image-models", "token_count": 7780 }
282
""" PyTorch impl of LaProp optimizer Code simplified from https://github.com/Z-T-WANG/LaProp-Optimizer, MIT License Paper: LaProp: Separating Momentum and Adaptivity in Adam, https://arxiv.org/abs/2002.04839 @article{ziyin2020laprop, title={LaProp: a Better Way to Combine Momentum with Adaptive Gradient}, author...
pytorch-image-models/timm/optim/laprop.py/0
{ "file_path": "pytorch-image-models/timm/optim/laprop.py", "repo_id": "pytorch-image-models", "token_count": 2603 }
283
""" Cosine Scheduler Cosine LR schedule with warmup, cycle/restarts, noise, k-decay. Hacked together by / Copyright 2021 Ross Wightman """ import logging import math import numpy as np import torch from typing import List from .scheduler import Scheduler _logger = logging.getLogger(__name__) class CosineLRSchedu...
pytorch-image-models/timm/scheduler/cosine_lr.py/0
{ "file_path": "pytorch-image-models/timm/scheduler/cosine_lr.py", "repo_id": "pytorch-image-models", "token_count": 2070 }
284
""" JIT scripting/tracing utils Hacked together by / Copyright 2020 Ross Wightman """ import os import torch def set_jit_legacy(): """ Set JIT executor to legacy w/ support for op fusion This is hopefully a temporary need in 1.5/1.5.1/1.6 to restore performance due to changes in the JIT executor. These ...
pytorch-image-models/timm/utils/jit.py/0
{ "file_path": "pytorch-image-models/timm/utils/jit.py", "repo_id": "pytorch-image-models", "token_count": 1035 }
285
# Agentic RAG [[open-in-colab]] ## Introduction to Retrieval-Augmented Generation (RAG) Retrieval-Augmented Generation (RAG) combines the power of large language models with external knowledge retrieval to produce more accurate, factual, and contextually relevant responses. At its core, RAG is about "using an LLM to...
smolagents/docs/source/en/examples/rag.md/0
{ "file_path": "smolagents/docs/source/en/examples/rag.md", "repo_id": "smolagents", "token_count": 2523 }
286
- title: Get started sections: - local: index title: 소개 - local: installation title: 설치 옵션 # - local: guided_tour # title: 안내서 - title: 튜토리얼 sections: - local: tutorials/building_good_agents title: 좋은 에이전트 구축하기 # - local: tutorials/inspect_runs # title: 📊 Inspect your agent runs using tel...
smolagents/docs/source/ko/_toctree.yml/0
{ "file_path": "smolagents/docs/source/ko/_toctree.yml", "repo_id": "smolagents", "token_count": 796 }
287
# Agents - 导览 [[open-in-colab]] 在本导览中,您将学习如何构建一个 agent(智能体),如何运行它,以及如何自定义它以使其更好地适应您的使用场景。 > [!TIP] > 译者注:Agent 的业内术语是“智能体”。本译文将保留 agent,不作翻译,以带来更高效的阅读体验。(在中文为主的文章中,It's easier to 注意到英文。Attention Is All You Need!) > [!TIP] > 中文社区发布了关于 smolagents 的介绍和实践讲解视频(来源:[Issue#80](https://github.com/huggingface/smolagents/issu...
smolagents/docs/source/zh/guided_tour.md/0
{ "file_path": "smolagents/docs/source/zh/guided_tour.md", "repo_id": "smolagents", "token_count": 10506 }
288
from openinference.instrumentation.smolagents import SmolagentsInstrumentor from phoenix.otel import register register() SmolagentsInstrumentor().instrument(skip_dep_check=True) from smolagents import ( CodeAgent, InferenceClientModel, ToolCallingAgent, VisitWebpageTool, WebSearchTool, ) # The...
smolagents/examples/inspect_multiagent_run.py/0
{ "file_path": "smolagents/examples/inspect_multiagent_run.py", "repo_id": "smolagents", "token_count": 335 }
289
import base64 import json import mimetypes import os import uuid from io import BytesIO import PIL.Image import requests from dotenv import load_dotenv from huggingface_hub import InferenceClient from smolagents import Tool, tool load_dotenv(override=True) def process_images_and_text(image_path, query, client): ...
smolagents/examples/open_deep_research/scripts/visual_qa.py/0
{ "file_path": "smolagents/examples/open_deep_research/scripts/visual_qa.py", "repo_id": "smolagents", "token_count": 2558 }
290
# 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/src/smolagents/agent_types.py/0
{ "file_path": "smolagents/src/smolagents/agent_types.py", "repo_id": "smolagents", "token_count": 3867 }
291
#!/usr/bin/env python # coding=utf-8 # Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/L...
smolagents/src/smolagents/utils.py/0
{ "file_path": "smolagents/src/smolagents/utils.py", "repo_id": "smolagents", "token_count": 6942 }
292
import json from textwrap import dedent import pytest from mcp import StdioServerParameters from smolagents.mcp_client import MCPClient @pytest.fixture def echo_server_script(): return dedent( ''' from mcp.server.fastmcp import FastMCP mcp = FastMCP("Echo Server") @mcp.tool() ...
smolagents/tests/test_mcp_client.py/0
{ "file_path": "smolagents/tests/test_mcp_client.py", "repo_id": "smolagents", "token_count": 1956 }
293
<!--- 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 ...
text-generation-inference/CONTRIBUTING.md/0
{ "file_path": "text-generation-inference/CONTRIBUTING.md", "repo_id": "text-generation-inference", "token_count": 1396 }
294
{ "__inputs": [ { "name": "DS_PROMETHEUS_EKS API INFERENCE PROD", "label": "Prometheus EKS API Inference Prod", "description": "", "type": "datasource", "pluginId": "prometheus", "pluginName": "Prometheus" } ], "__elements": {}, "__requires": [ { "type": "pa...
text-generation-inference/assets/tgi_grafana.json/0
{ "file_path": "text-generation-inference/assets/tgi_grafana.json", "repo_id": "text-generation-inference", "token_count": 62818 }
295
# Fork that adds only the correct stream to this kernel in order # to make cuda graphs work. awq_commit := bd1dc2d5254345cc76ab71894651fb821275bdd4 awq: rm -rf llm-awq git clone https://github.com/huggingface/llm-awq build-awq: awq cd llm-awq/ && git fetch && git checkout $(awq_commit) cd llm-awq/awq/kernels && p...
text-generation-inference/backends/gaudi/server/Makefile-awq/0
{ "file_path": "text-generation-inference/backends/gaudi/server/Makefile-awq", "repo_id": "text-generation-inference", "token_count": 183 }
296
# Origin: https://github.com/predibase/lorax # Path: lorax/server/lorax_server/adapters/lora.py # License: Apache License Version 2.0, January 2004 from collections import defaultdict from dataclasses import dataclass from typing import Dict, List, Optional, Set, Tuple, Type, Union import torch from peft impor...
text-generation-inference/backends/gaudi/server/text_generation_server/adapters/lora.py/0
{ "file_path": "text-generation-inference/backends/gaudi/server/text_generation_server/adapters/lora.py", "repo_id": "text-generation-inference", "token_count": 8028 }
297
from typing import List, Optional, Union import torch from compressed_tensors.quantization import QuantizationArgs, QuantizationType from text_generation_server.layers.fp8 import ( Fp8Weight, _load_scalar_or_matrix_scale, requantize_with_max_scale, ) from text_generation_server.utils.weights import Weight...
text-generation-inference/backends/gaudi/server/text_generation_server/layers/compressed_tensors/w8an_fp.py/0
{ "file_path": "text-generation-inference/backends/gaudi/server/text_generation_server/layers/compressed_tensors/w8an_fp.py", "repo_id": "text-generation-inference", "token_count": 4701 }
298
from typing import Optional import torch import torch.nn as nn from text_generation_server.utils.weights import UnquantizedWeight, Weights from vllm_hpu_extension.ops import VllmMixtureOfExpertsOp import habana_frameworks.torch as htorch import torch.nn.functional as F import os class UnquantizedSparseMoELayer(nn.M...
text-generation-inference/backends/gaudi/server/text_generation_server/layers/moe/unquantized.py/0
{ "file_path": "text-generation-inference/backends/gaudi/server/text_generation_server/layers/moe/unquantized.py", "repo_id": "text-generation-inference", "token_count": 2816 }
299
# 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/backends/gaudi/server/text_generation_server/models/custom_modeling/flash_gptj_modeling.py/0
{ "file_path": "text-generation-inference/backends/gaudi/server/text_generation_server/models/custom_modeling/flash_gptj_modeling.py", "repo_id": "text-generation-inference", "token_count": 6328 }
300
# coding=utf-8 # Copyright 2024 Starcoder2 AI and the HuggingFace Inc. team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # t...
text-generation-inference/backends/gaudi/server/text_generation_server/models/custom_modeling/flash_starcoder2_modeling.py/0
{ "file_path": "text-generation-inference/backends/gaudi/server/text_generation_server/models/custom_modeling/flash_starcoder2_modeling.py", "repo_id": "text-generation-inference", "token_count": 9861 }
301
# Copyright (C) 2024 Habana Labs, Ltd. an Intel Company. import asyncio import os import torch import time import signal from grpc import aio from loguru import logger from grpc_reflection.v1alpha import reflection from pathlib import Path from typing import List, Optional from text_generation_server.cache import C...
text-generation-inference/backends/gaudi/server/text_generation_server/server.py/0
{ "file_path": "text-generation-inference/backends/gaudi/server/text_generation_server/server.py", "repo_id": "text-generation-inference", "token_count": 5307 }
302
from typing import Optional SUPPORT_CHUNKING: Optional[bool] = None MAX_PREFILL_TOKENS: Optional[int] = None def set_support_chunking(support_chunking: bool): global SUPPORT_CHUNKING SUPPORT_CHUNKING = support_chunking def get_support_chunking() -> bool: global SUPPORT_CHUNKING return SUPPORT_CHUNK...
text-generation-inference/backends/gaudi/server/text_generation_server/utils/prefill_chunking.py/0
{ "file_path": "text-generation-inference/backends/gaudi/server/text_generation_server/utils/prefill_chunking.py", "repo_id": "text-generation-inference", "token_count": 221 }
303
use crate::llamacpp; use async_trait::async_trait; use std::ffi::CString; use std::mem::replace; use std::str::FromStr; use std::sync::{mpsc, Once}; use text_generation_router::infer::{Backend, GeneratedText, InferError, InferStreamResponse}; use text_generation_router::validation::ValidGenerateRequest; use text_gener...
text-generation-inference/backends/llamacpp/src/backend.rs/0
{ "file_path": "text-generation-inference/backends/llamacpp/src/backend.rs", "repo_id": "text-generation-inference", "token_count": 13858 }
304
#!/usr/bin/env python import argparse import logging import os import sys from typing import Any, Dict, List, Optional from optimum.neuron.modeling_decoder import get_available_cores from optimum.neuron.cache import get_hub_cached_entries from optimum.neuron.configuration_utils import NeuronConfig from optimum.neuron...
text-generation-inference/backends/neuron/server/text_generation_server/tgi_env.py/0
{ "file_path": "text-generation-inference/backends/neuron/server/text_generation_server/tgi_env.py", "repo_id": "text-generation-inference", "token_count": 4375 }
305
use async_trait::async_trait; use cxx::UniquePtr; use hashbrown::HashMap; use std::hint; use std::ops::Deref; use std::path::Path; use tokenizers::Tokenizer; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}; use tokio::sync::TryAcquireError; use tokio::task::spawn_blocking; use tokio::time...
text-generation-inference/backends/trtllm/src/looper.rs/0
{ "file_path": "text-generation-inference/backends/trtllm/src/looper.rs", "repo_id": "text-generation-inference", "token_count": 6376 }
306
use std::fs; fn main() -> Result<(), Box<dyn std::error::Error>> { println!("cargo:rerun-if-changed=../../proto/"); fs::create_dir_all("src/client/pb").unwrap_or(()); let mut config = prost_build::Config::new(); config.protoc_arg("--experimental_allow_proto3_optional"); tonic_build::configure() ...
text-generation-inference/backends/v3/build.rs/0
{ "file_path": "text-generation-inference/backends/v3/build.rs", "repo_id": "text-generation-inference", "token_count": 274 }
307
/// Text Generation Inference benchmarking tool /// /// Inspired by the great Oha app: https://github.com/hatoo/oha /// and: https://github.com/orhun/rust-tui-template use clap::Parser; use std::path::Path; use text_generation_client::v3::ShardedClient; use tokenizers::{FromPretrainedParameters, Tokenizer}; use tracing...
text-generation-inference/benchmark/src/main.rs/0
{ "file_path": "text-generation-inference/benchmark/src/main.rs", "repo_id": "text-generation-inference", "token_count": 3164 }
308
import os import requests from typing import Dict, Optional, List from huggingface_hub.utils import build_hf_headers from text_generation import Client, AsyncClient, __version__ from text_generation.types import DeployedModel from text_generation.errors import NotSupportedError, parse_error INFERENCE_ENDPOINT = os.e...
text-generation-inference/clients/python/text_generation/inference_api.py/0
{ "file_path": "text-generation-inference/clients/python/text_generation/inference_api.py", "repo_id": "text-generation-inference", "token_count": 2182 }
309
# Tensor Parallelism Tensor parallelism is a technique used to fit a large model in multiple GPUs. For example, when multiplying the input tensors with the first weight tensor, the matrix multiplication is equivalent to splitting the weight tensor column-wise, multiplying each column with the input separately, and the...
text-generation-inference/docs/source/conceptual/tensor_parallelism.md/0
{ "file_path": "text-generation-inference/docs/source/conceptual/tensor_parallelism.md", "repo_id": "text-generation-inference", "token_count": 272 }
310
{ "nodes": { "cachix": { "inputs": { "devenv": [ "crate2nix" ], "flake-compat": [ "crate2nix" ], "nixpkgs": "nixpkgs", "pre-commit-hooks": [ "crate2nix" ] }, "locked": { "lastModified": 1709700175, ...
text-generation-inference/flake.lock/0
{ "file_path": "text-generation-inference/flake.lock", "repo_id": "text-generation-inference", "token_count": 16562 }
311
{ "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 }
312
{ "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": 0, "tokens": [ { "id": 5380, "logprob": -0.23840332, "special": false, "text": "?\n" }, { "id": 34564, "logprob"...
text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8an_fp/test_compressed_tensors_w8an_all_params.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8an_fp/test_compressed_tensors_w8an_all_params.json", "repo_id": "text-generation-inference", "token_count": 853 }
313
{ "details": { "best_of_sequences": null, "finish_reason": "eos_token", "generated_tokens": 4, "prefill": [], "seed": 0, "tokens": [ { "id": 2143, "logprob": -1.828125, "special": false, "text": " sent" }, { "id": 10081, "logpro...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_deepseek_v2/test_flash_deepseek_v2_all_params.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_deepseek_v2/test_flash_deepseek_v2_all_params.json", "repo_id": "text-generation-inference", "token_count": 424 }
314
{ "choices": [ { "finish_reason": "stop", "index": 0, "logprobs": null, "message": { "content": "That's a fantastic question! However, the image doesn't show a dog. It shows a **Brown Swiss cow** standing on a beach. \n\nBrown Swiss cows are known for their beautiful reddish-brown ...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_gemma3/test_flash_gemma3_image_cow_dog.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_gemma3/test_flash_gemma3_image_cow_dog.json", "repo_id": "text-generation-inference", "token_count": 340 }
315
[ { "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": null, "tokens": [ { "id": 25, "logprob": -2.9785156, "special": false, "text": ":" }, { ...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_exl2/test_flash_llama_exl2_load.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_exl2/test_flash_llama_exl2_load.json", "repo_id": "text-generation-inference", "token_count": 4101 }
316
[ { "choices": [ { "finish_reason": "length", "index": 0, "logprobs": null, "message": { "content": "Jeff Walker's Product Launch Formula is a comprehensive system", "name": null, "role": "assistant", "tool_calls": null }, ...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_prefix/test_flash_llama_load.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_prefix/test_flash_llama_load.json", "repo_id": "text-generation-inference", "token_count": 32395 }
317
[ { "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": null, "tokens": [ { "id": 13, "logprob": -0.6953125, "special": false, "text": "\n" }, { ...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_mixtral_gptq/test_flash_mixtral_gptq_load.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_mixtral_gptq/test_flash_mixtral_gptq_load.json", "repo_id": "text-generation-inference", "token_count": 4066 }
318
[ { "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": null, "tokens": [ { "id": 198, "logprob": -2.9023438, "special": false, "text": "\n" }, { ...
text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2/test_flash_qwen2_load.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2/test_flash_qwen2_load.json", "repo_id": "text-generation-inference", "token_count": 4044 }
319
[ { "details": { "best_of_sequences": null, "finish_reason": "length", "generated_tokens": 10, "prefill": [], "seed": null, "tokens": [ { "id": 330, "logprob": -0.09289551, "special": false, "text": " A" }, { ...
text-generation-inference/integration-tests/models/__snapshots__/test_idefics2/test_flash_idefics2_next_load.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_idefics2/test_flash_idefics2_next_load.json", "repo_id": "text-generation-inference", "token_count": 4039 }
320
{ "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 }
321
import pytest import requests @pytest.fixture(scope="module") def llama_continue_final_message_handle(launcher): with launcher("TinyLlama/TinyLlama-1.1B-Chat-v1.0") as handle: yield handle @pytest.fixture(scope="module") async def llama_continue_final_message(llama_continue_final_message_handle): aw...
text-generation-inference/integration-tests/models/test_continue_final_message.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_continue_final_message.py", "repo_id": "text-generation-inference", "token_count": 1102 }
322
import pytest @pytest.fixture(scope="module") def flash_llama_marlin_handle(launcher): with launcher( "neuralmagic/llama-2-7b-chat-marlin", num_shard=2, quantize="marlin" ) as handle: yield handle @pytest.fixture(scope="module") async def flash_llama_marlin(flash_llama_marlin_handle): aw...
text-generation-inference/integration-tests/models/test_flash_llama_marlin.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_flash_llama_marlin.py", "repo_id": "text-generation-inference", "token_count": 748 }
323
import pytest @pytest.fixture(scope="module") def flash_qwen2_5_vl_handle(launcher): with launcher("Qwen/Qwen2.5-VL-3B-Instruct") as handle: yield handle @pytest.fixture(scope="module") async def flash_qwen2_5(flash_qwen2_5_vl_handle): await flash_qwen2_5_vl_handle.health(300) return flash_qwen2...
text-generation-inference/integration-tests/models/test_flash_qwen2_5_vl.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_flash_qwen2_5_vl.py", "repo_id": "text-generation-inference", "token_count": 2258 }
324
import pytest import asyncio @pytest.fixture(scope="module") def mllama_handle(launcher): with launcher( "unsloth/Llama-3.2-11B-Vision-Instruct", num_shard=2, ) as handle: yield handle @pytest.fixture(scope="module") async def mllama(mllama_handle): await mllama_handle.health(300...
text-generation-inference/integration-tests/models/test_mllama.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_mllama.py", "repo_id": "text-generation-inference", "token_count": 1584 }
325
{ buildPythonPackage, poetry-core, aiohttp, huggingface-hub, pydantic, }: buildPythonPackage { name = "text-generation"; src = ../clients/python; pyproject = true; build-system = [ poetry-core ]; dependencies = [ aiohttp huggingface-hub pydantic ]; }
text-generation-inference/nix/client.nix/0
{ "file_path": "text-generation-inference/nix/client.nix", "repo_id": "text-generation-inference", "token_count": 111 }
326
use crate::infer::Infer; use crate::{ default_parameters, server::{generate_internal, ComputeType}, Deserialize, ErrorResponse, GenerateParameters, GenerateRequest, Serialize, ToSchema, }; use axum::extract::{Extension, Path}; use axum::http::{HeaderMap, StatusCode}; use axum::response::IntoResponse; use ax...
text-generation-inference/router/src/kserve.rs/0
{ "file_path": "text-generation-inference/router/src/kserve.rs", "repo_id": "text-generation-inference", "token_count": 3533 }
327
flash_att_v2_commit_cuda := v2.6.1 flash_att_v2_commit_rocm := 47bd46e0204a95762ae48712fd1a3978827c77fd build-flash-attention-v2-cuda: pip install -U packaging wheel pip install flash-attn==$(flash_att_v2_commit_cuda) install-flash-attention-v2-cuda: build-flash-attention-v2-cuda echo "Flash v2 installed" build-f...
text-generation-inference/server/Makefile-flash-att-v2/0
{ "file_path": "text-generation-inference/server/Makefile-flash-att-v2", "repo_id": "text-generation-inference", "token_count": 397 }
328
// Adapted from turboderp exllama: https://github.com/turboderp/exllama #include <ATen/cuda/CUDAContext.h> #include "q4_matrix.cuh" #include <vector> #include "../util.cuh" #include "../matrix.cuh" using namespace std; const int UNSHUF_BLOCKSIZE_X = 64; const int RECONS_THREADS_X = 64; // Block size and thread...
text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matrix.cu/0
{ "file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matrix.cu", "repo_id": "text-generation-inference", "token_count": 2592 }
329
#include "q_matrix.cuh" #include "matrix_view.cuh" #include "util.cuh" #include "quant/qdq_2.cuh" #include "quant/qdq_3.cuh" #include "quant/qdq_4.cuh" #include "quant/qdq_5.cuh" #include "quant/qdq_6.cuh" #include "quant/qdq_8.cuh" #define BLOCK_KN_SIZE 128 #define THREADS_X 32 #define THREADS_Y 32 // Shuffle quan...
text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_matrix.cu/0
{ "file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_matrix.cu", "repo_id": "text-generation-inference", "token_count": 10524 }
330
import os from typing import Optional import torch from text_generation_server.layers.attention.kv_cache import KVCache, KVScales from text_generation_server.utils.import_utils import SYSTEM from text_generation_server.layers.attention import Seqlen from text_generation_server.utils.log import log_master from text_gene...
text-generation-inference/server/text_generation_server/layers/attention/rocm.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/attention/rocm.py", "repo_id": "text-generation-inference", "token_count": 5552 }
331
import os from dataclasses import dataclass from typing import List, Optional, Union import torch from loguru import logger from text_generation_server.utils.import_utils import SYSTEM from text_generation_server.utils.log import log_once from text_generation_server.utils.weights import ( Weight, Weights, ...
text-generation-inference/server/text_generation_server/layers/gptq/__init__.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/gptq/__init__.py", "repo_id": "text-generation-inference", "token_count": 9078 }
332
import torch from torch import nn from typing import Tuple, Optional from text_generation_server.utils.speculate import get_speculate from text_generation_server.layers.linear import FastLinear from text_generation_server.layers.tensor_parallel import ( TensorParallelHead, TensorParallelColumnLinear, ) class ...
text-generation-inference/server/text_generation_server/layers/medusa.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/layers/medusa.py", "repo_id": "text-generation-inference", "token_count": 2975 }
333
# coding=utf-8 # Copyright 2024 Cohere team. All rights reserved. # # This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX # and OPT implementations in this library. It has been modified from its # original forms to accommodate minor architectural differences compared # to GPT-NeoX and OPT used by the M...
text-generation-inference/server/text_generation_server/models/custom_modeling/flash_cohere_modeling.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_cohere_modeling.py", "repo_id": "text-generation-inference", "token_count": 8966 }
334
import torch import torch.distributed from torch import nn from transformers.activations import ACT2FN from typing import Optional, List, Tuple from text_generation_server.layers.attention import ( paged_attention, attention, Seqlen, ) from text_generation_server.layers import ( TensorParallelMultiAda...
text-generation-inference/server/text_generation_server/models/custom_modeling/flash_qwen2_modeling.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_qwen2_modeling.py", "repo_id": "text-generation-inference", "token_count": 7370 }
335
# 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": 5362 }
336
import torch import torch.distributed from transformers import AutoTokenizer, PreTrainedTokenizerBase from typing import Optional, Union from text_generation_server.models.custom_modeling.mamba_modeling import ( MambaConfig, ) from loguru import logger from text_generation_server.pb import generate_pb2 from text_ge...
text-generation-inference/server/text_generation_server/models/mamba.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/models/mamba.py", "repo_id": "text-generation-inference", "token_count": 15065 }
337
import os import torch from torch.distributed import ProcessGroup from datetime import timedelta from loguru import logger from text_generation_server.utils.import_utils import SYSTEM # Tensor Parallelism settings RANK = int(os.getenv("RANK", "0")) WORLD_SIZE = int(os.getenv("WORLD_SIZE", "1")) # CUDA memory fraction...
text-generation-inference/server/text_generation_server/utils/dist.py/0
{ "file_path": "text-generation-inference/server/text_generation_server/utils/dist.py", "repo_id": "text-generation-inference", "token_count": 1916 }
338
.PHONY: style check-style test DATA_DIR = data dir_guard=@mkdir -p $(@D) # Format source code automatically style: npm run lint # Check the source code is formatted correctly check-style: npm run lint-check TESTS_RESOURCES = $(DATA_DIR)/small.txt $(DATA_DIR)/roberta.json $(DATA_DIR)/tokenizer-wiki.json $(DATA_DI...
tokenizers/bindings/node/Makefile/0
{ "file_path": "tokenizers/bindings/node/Makefile", "repo_id": "tokenizers", "token_count": 406 }
339
import { byteLevelPreTokenizer, metaspacePreTokenizer, punctuationPreTokenizer, sequencePreTokenizer, splitPreTokenizer, whitespaceSplitPreTokenizer, } from '../../' describe('byteLevelPreTokenizer', () => { it('instantiates correctly', () => { const processor = byteLevelPreTokenizer() expect(pro...
tokenizers/bindings/node/lib/bindings/pre-tokenizers.test.ts/0
{ "file_path": "tokenizers/bindings/node/lib/bindings/pre-tokenizers.test.ts", "repo_id": "tokenizers", "token_count": 728 }
340
{ "name": "tokenizers-linux-arm64-gnu", "version": "0.13.4-rc1", "os": [ "linux" ], "cpu": [ "arm64" ], "main": "tokenizers.linux-arm64-gnu.node", "files": [ "tokenizers.linux-arm64-gnu.node" ], "description": "Tokenizers platform specific bindings", "keywords": [ "napi-rs", "N...
tokenizers/bindings/node/npm/linux-arm64-gnu/package.json/0
{ "file_path": "tokenizers/bindings/node/npm/linux-arm64-gnu/package.json", "repo_id": "tokenizers", "token_count": 289 }
341
use crate::arc_rwlock_serde; use serde::{Deserialize, Serialize}; extern crate tokenizers as tk; use napi::bindgen_prelude::*; use napi_derive::napi; use std::sync::{Arc, RwLock}; use tk::decoders::DecoderWrapper; /// Decoder #[derive(Clone, Serialize, Deserialize)] #[napi] pub struct Decoder { #[serde(flatten, wi...
tokenizers/bindings/node/src/decoders.rs/0
{ "file_path": "tokenizers/bindings/node/src/decoders.rs", "repo_id": "tokenizers", "token_count": 2037 }
342
[target.x86_64-apple-darwin] rustflags = [ "-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup", "-C", "link-arg=-mmacosx-version-min=10.11", ] [target.aarch64-apple-darwin] rustflags = [ "-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup", "-C", "link-arg=-mmacosx-version-min=10.11", ]
tokenizers/bindings/python/.cargo/config.toml/0
{ "file_path": "tokenizers/bindings/python/.cargo/config.toml", "repo_id": "tokenizers", "token_count": 146 }
343
# Generated content DO NOT EDIT class AddedToken: """ Represents a token that can be be added to a :class:`~tokenizers.Tokenizer`. It can have special options that defines the way it should behave. Args: content (:obj:`str`): The content of the token single_word (:obj:`bool`, defaults ...
tokenizers/bindings/python/py_src/tokenizers/__init__.pyi/0
{ "file_path": "tokenizers/bindings/python/py_src/tokenizers/__init__.pyi", "repo_id": "tokenizers", "token_count": 19454 }
344
# Generated content DO NOT EDIT from .. import processors PostProcessor = processors.PostProcessor BertProcessing = processors.BertProcessing ByteLevel = processors.ByteLevel RobertaProcessing = processors.RobertaProcessing Sequence = processors.Sequence TemplateProcessing = processors.TemplateProcessing
tokenizers/bindings/python/py_src/tokenizers/processors/__init__.py/0
{ "file_path": "tokenizers/bindings/python/py_src/tokenizers/processors/__init__.py", "repo_id": "tokenizers", "token_count": 74 }
345
#![warn(clippy::all)] #![allow(clippy::upper_case_acronyms)] // Many false positives with pyo3 it seems &str, and &PyAny get flagged #![allow(clippy::borrow_deref_ref)] extern crate tokenizers as tk; use once_cell::sync::Lazy; use std::sync::Arc; use tokio::runtime::Runtime; // We create a global runtime that will b...
tokenizers/bindings/python/src/lib.rs/0
{ "file_path": "tokenizers/bindings/python/src/lib.rs", "repo_id": "tokenizers", "token_count": 1244 }
346
from tokenizers import BertWordPieceTokenizer from ..utils import bert_files, data_dir, multiprocessing_with_parallelism class TestBertWordPieceTokenizer: def test_basic_encode(self, bert_files): tokenizer = BertWordPieceTokenizer.from_file(bert_files["vocab"]) # Encode with special tokens by de...
tokenizers/bindings/python/tests/implementations/test_bert_wordpiece.py/0
{ "file_path": "tokenizers/bindings/python/tests/implementations/test_bert_wordpiece.py", "repo_id": "tokenizers", "token_count": 914 }
347
# Post-processors <tokenizerslangcontent> <python> ## BertProcessing [[autodoc]] tokenizers.processors.BertProcessing ## ByteLevel [[autodoc]] tokenizers.processors.ByteLevel ## RobertaProcessing [[autodoc]] tokenizers.processors.RobertaProcessing ## TemplateProcessing [[autodoc]] tokenizers.processors.Template...
tokenizers/docs/source-doc-builder/api/post-processors.mdx/0
{ "file_path": "tokenizers/docs/source-doc-builder/api/post-processors.mdx", "repo_id": "tokenizers", "token_count": 174 }
348
Crates.io ---------------------------------------------------------------------------------------------------- 🤗 Tokenizers is available on `crates.io <https://crates.io/crates/tokenizers>`__. You just need to add it to your :obj:`Cargo.toml`:: tokenizers = "0.10"
tokenizers/docs/source/installation/rust.inc/0
{ "file_path": "tokenizers/docs/source/installation/rust.inc", "repo_id": "tokenizers", "token_count": 74 }
349
use tokenizers::Tokenizer; fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { let tokenizer = Tokenizer::from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct", None)?; let data = std::fs::read_to_string("data/big.txt")?; let data: Vec<_> = data.lines().collect(); let add_special_tok...
tokenizers/tokenizers/examples/encode_batch.rs/0
{ "file_path": "tokenizers/tokenizers/examples/encode_batch.rs", "repo_id": "tokenizers", "token_count": 165 }
350
import * as wasm from "unstable_wasm"; console.log(wasm.tokenize("ab")); console.log(wasm.tokenize("abc"));
tokenizers/tokenizers/examples/unstable_wasm/www/index.js/0
{ "file_path": "tokenizers/tokenizers/examples/unstable_wasm/www/index.js", "repo_id": "tokenizers", "token_count": 43 }
351
use super::{super::OrderedVocabIter, convert_merges_to_hashmap, BpeBuilder, Pair, BPE}; use ahash::AHashMap; use serde::{ de::{Error, MapAccess, Visitor}, ser::SerializeStruct, Deserialize, Deserializer, Serialize, Serializer, }; impl Serialize for BPE { fn serialize<S>(&self, serializer: S) -> Result<...
tokenizers/tokenizers/src/models/bpe/serialization.rs/0
{ "file_path": "tokenizers/tokenizers/src/models/bpe/serialization.rs", "repo_id": "tokenizers", "token_count": 4848 }
352
use crate::tokenizer::{NormalizedString, Normalizer, Result}; use serde::{Deserialize, Serialize}; use unicode_categories::UnicodeCategories; /// Checks whether a character is whitespace fn is_whitespace(c: char) -> bool { // These are technically control characters but we count them as whitespace match c { ...
tokenizers/tokenizers/src/normalizers/bert.rs/0
{ "file_path": "tokenizers/tokenizers/src/normalizers/bert.rs", "repo_id": "tokenizers", "token_count": 1856 }
353
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 }
354
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": 3902 }
355
#![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 }
356
# Using quantized models (dtypes) Before Transformers.js v3, we used the `quantized` option to specify whether to use a quantized (q8) or full-precision (fp32) variant of the model by setting `quantized` to `true` or `false`, respectively. Now, we've added the ability to select from a much larger list with the `dtype`...
transformers.js/docs/source/guides/dtypes.md/0
{ "file_path": "transformers.js/docs/source/guides/dtypes.md", "repo_id": "transformers.js", "token_count": 1698 }
357
{ "name": "adaptive-retrieval", "version": "0.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "adaptive-retrieval", "version": "0.0.0", "dependencies": { "@xenova/transformers": "^2.15.0", "react": "^18.2.0", "react-dom": "^18.2.0" ...
transformers.js/examples/adaptive-retrieval/package-lock.json/0
{ "file_path": "transformers.js/examples/adaptive-retrieval/package-lock.json", "repo_id": "transformers.js", "token_count": 126980 }
358