text stringlengths 96 319k | id stringlengths 14 178 | metadata dict |
|---|---|---|
#!/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_tuners_utils.py/0 | {
"file_path": "peft/tests/test_tuners_utils.py",
"repo_id": "peft",
"token_count": 27556
} |
# timm
<img class="float-left !m-0 !border-0 !dark:border-0 !shadow-none !max-w-lg w-[150px]" src="https://huggingface.co/front/thumbnails/docs/timm.png"/>
`timm` is a library containing SOTA computer vision models, layers, utilities, optimizers, schedulers, data-loaders, augmentations, and training/evaluation script... | pytorch-image-models/hfdocs/source/index.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/index.mdx",
"repo_id": "pytorch-image-models",
"token_count": 560
} |
# ESE-VoVNet
**VoVNet** is a convolutional neural network that seeks to make [DenseNet](https://paperswithcode.com/method/densenet) more efficient by concatenating all features only once in the last feature map, which makes input size constant and enables enlarging new output channel.
Read about [one-shot aggregatio... | pytorch-image-models/hfdocs/source/models/ese-vovnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/ese-vovnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 1953
} |
# 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).
## How do I use this model on an image?
To load a pretrained mo... | pytorch-image-models/hfdocs/source/models/mixnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/mixnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2686
} |
# Wide ResNet
**Wide Residual Networks** are a variant on [ResNets](https://paperswithcode.com/method/resnet) where we decrease depth and increase the width of residual networks. This is achieved through the use of [wide residual blocks](https://paperswithcode.com/method/wide-residual-block).
## How do I use this mod... | pytorch-image-models/hfdocs/source/models/wide-resnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/wide-resnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2037
} |
from .auto_augment import RandAugment, AutoAugment, rand_augment_ops, auto_augment_policy,\
rand_augment_transform, auto_augment_transform
from .config import resolve_data_config, resolve_model_data_config
from .constants import *
from .dataset import ImageDataset, IterableImageDataset, AugMixDataset
from .dataset_... | pytorch-image-models/timm/data/__init__.py/0 | {
"file_path": "pytorch-image-models/timm/data/__init__.py",
"repo_id": "pytorch-image-models",
"token_count": 256
} |
""" Random Erasing (Cutout)
Originally inspired by impl at https://github.com/zhunzhong07/Random-Erasing, Apache 2.0
Copyright Zhun Zhong & Liang Zheng
Hacked together by / Copyright 2019, Ross Wightman
"""
import random
import math
import torch
def _get_pixels(per_pixel, rand_color, patch_size, dtype=torch.float3... | pytorch-image-models/timm/data/random_erasing.py/0 | {
"file_path": "pytorch-image-models/timm/data/random_erasing.py",
"repo_id": "pytorch-image-models",
"token_count": 2258
} |
import math
import numbers
import random
import warnings
from typing import List, Sequence, Tuple, Union
import torch
import torchvision.transforms as transforms
import torchvision.transforms.functional as F
try:
from torchvision.transforms.functional import InterpolationMode
has_interpolation_mode = True
exce... | pytorch-image-models/timm/data/transforms.py/0 | {
"file_path": "pytorch-image-models/timm/data/transforms.py",
"repo_id": "pytorch-image-models",
"token_count": 9216
} |
""" Conv2d + BN + Act
Hacked together by / Copyright 2020 Ross Wightman
"""
from typing import Any, Dict, Optional, Type
from torch import nn as nn
from .typing import LayerType, PadType
from .blur_pool import create_aa
from .create_conv2d import create_conv2d
from .create_norm_act import get_norm_act_layer
class ... | pytorch-image-models/timm/layers/conv_bn_act.py/0 | {
"file_path": "pytorch-image-models/timm/layers/conv_bn_act.py",
"repo_id": "pytorch-image-models",
"token_count": 1446
} |
""" Halo Self Attention
Paper: `Scaling Local Self-Attention for Parameter Efficient Visual Backbones`
- https://arxiv.org/abs/2103.12731
@misc{2103.12731,
Author = {Ashish Vaswani and Prajit Ramachandran and Aravind Srinivas and Niki Parmar and Blake Hechtman and
Jonathon Shlens},
Title = {Scaling Local Self... | pytorch-image-models/timm/layers/halo_attn.py/0 | {
"file_path": "pytorch-image-models/timm/layers/halo_attn.py",
"repo_id": "pytorch-image-models",
"token_count": 4601
} |
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
class PatchDropout(nn.Module):
"""
https://arxiv.org/abs/2212.00794 and https://arxiv.org/pdf/2208.07220
"""
return_indices: torch.jit.Final[bool]
def __init__(
self,
prob: float = 0.5,
... | pytorch-image-models/timm/layers/patch_dropout.py/0 | {
"file_path": "pytorch-image-models/timm/layers/patch_dropout.py",
"repo_id": "pytorch-image-models",
"token_count": 858
} |
import torch
import math
import warnings
from torch import nn
from torch.nn.init import _calculate_fan_in_and_fan_out
def _trunc_normal_(tensor, mean, std, a, b):
# Cut & paste from PyTorch official master until it's in a few official releases - RW
# Method based on https://people.sc.fsu.edu/~jburkardt/presen... | pytorch-image-models/timm/layers/weight_init.py/0 | {
"file_path": "pytorch-image-models/timm/layers/weight_init.py",
"repo_id": "pytorch-image-models",
"token_count": 2577
} |
import copy
from collections import deque, defaultdict
from dataclasses import dataclass, field, replace, asdict
from typing import Any, Deque, Dict, Tuple, Optional, Union
__all__ = ['PretrainedCfg', 'filter_pretrained_cfg', 'DefaultCfg']
@dataclass
class PretrainedCfg:
"""
"""
# weight source location... | pytorch-image-models/timm/models/_pretrained.py/0 | {
"file_path": "pytorch-image-models/timm/models/_pretrained.py",
"repo_id": "pytorch-image-models",
"token_count": 1341
} |
""" CrossViT Model
@inproceedings{
chen2021crossvit,
title={{CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image Classification}},
author={Chun-Fu (Richard) Chen and Quanfu Fan and Rameswar Panda},
booktitle={International Conference on Computer Vision (ICCV)},
year={2021}
}
Paper l... | pytorch-image-models/timm/models/crossvit.py/0 | {
"file_path": "pytorch-image-models/timm/models/crossvit.py",
"repo_id": "pytorch-image-models",
"token_count": 12489
} |
# NOTE timm.models.layers is DEPRECATED, please use timm.layers, this is here to reduce breakages in transition
from timm.layers.activations import *
from timm.layers.adaptive_avgmax_pool import \
adaptive_avgmax_pool2d, select_adaptive_pool2d, AdaptiveAvgMaxPool2d, SelectAdaptivePool2d
from timm.layers.attention_p... | pytorch-image-models/timm/models/layers/__init__.py/0 | {
"file_path": "pytorch-image-models/timm/models/layers/__init__.py",
"repo_id": "pytorch-image-models",
"token_count": 1220
} |
"""
RDNet
Copyright (c) 2024-present NAVER Cloud Corp.
Apache-2.0
"""
from functools import partial
from typing import List, Optional, Tuple, Union, Callable
import torch
import torch.nn as nn
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.layers import DropPath, NormMlpClassifierHead, C... | pytorch-image-models/timm/models/rdnet.py/0 | {
"file_path": "pytorch-image-models/timm/models/rdnet.py",
"repo_id": "pytorch-image-models",
"token_count": 9340
} |
""" Swin Transformer V2
A PyTorch impl of : `Swin Transformer V2: Scaling Up Capacity and Resolution`
- https://arxiv.org/pdf/2111.09883
Code adapted from https://github.com/ChristophReich1996/Swin-Transformer-V2, original copyright/license info below
This implementation is experimental and subject to change in ... | pytorch-image-models/timm/models/swin_transformer_v2_cr.py/0 | {
"file_path": "pytorch-image-models/timm/models/swin_transformer_v2_cr.py",
"repo_id": "pytorch-image-models",
"token_count": 21262
} |
""" Cross-Covariance Image Transformer (XCiT) in PyTorch
Paper:
- https://arxiv.org/abs/2106.09681
Same as the official implementation, with some minor adaptations, original copyright below
- https://github.com/facebookresearch/xcit/blob/master/xcit.py
Modifications and additions for timm hacked together by ... | pytorch-image-models/timm/models/xcit.py/0 | {
"file_path": "pytorch-image-models/timm/models/xcit.py",
"repo_id": "pytorch-image-models",
"token_count": 20442
} |
""" PyTorch LARS / LARC Optimizer
An implementation of LARS (SGD) + LARC in PyTorch
Based on:
* PyTorch SGD: https://github.com/pytorch/pytorch/blob/1.7/torch/optim/sgd.py#L100
* NVIDIA APEX LARC: https://github.com/NVIDIA/apex/blob/master/apex/parallel/LARC.py
Additional cleanup and modifications to properly su... | pytorch-image-models/timm/optim/lars.py/0 | {
"file_path": "pytorch-image-models/timm/optim/lars.py",
"repo_id": "pytorch-image-models",
"token_count": 2549
} |
""" MultiStep LR Scheduler
Basic multi step LR schedule with warmup, noise.
"""
import torch
import bisect
from timm.scheduler.scheduler import Scheduler
from typing import List
class MultiStepLRScheduler(Scheduler):
"""
"""
def __init__(
self,
optimizer: torch.optim.Optimizer,
... | pytorch-image-models/timm/scheduler/multistep_lr.py/0 | {
"file_path": "pytorch-image-models/timm/scheduler/multistep_lr.py",
"repo_id": "pytorch-image-models",
"token_count": 1036
} |
""" Logging helpers
Hacked together by / Copyright 2020 Ross Wightman
"""
import logging
import logging.handlers
class FormatterNoInfo(logging.Formatter):
def __init__(self, fmt='%(levelname)s: %(message)s'):
logging.Formatter.__init__(self, fmt)
def format(self, record):
if record.levelno =... | pytorch-image-models/timm/utils/log.py/0 | {
"file_path": "pytorch-image-models/timm/utils/log.py",
"repo_id": "pytorch-image-models",
"token_count": 383
} |
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: check-yaml
| smolagents/.pre-commit-config.yaml/0 | {
"file_path": "smolagents/.pre-commit-config.yaml",
"repo_id": "smolagents",
"token_count": 158
} |
<!--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/guided_tour.md/0 | {
"file_path": "smolagents/docs/source/en/guided_tour.md",
"repo_id": "smolagents",
"token_count": 6209
} |
<!--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/guided_tour.md/0 | {
"file_path": "smolagents/docs/source/hi/guided_tour.md",
"repo_id": "smolagents",
"token_count": 16510
} |
<!--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/index.md/0 | {
"file_path": "smolagents/docs/source/zh/index.md",
"repo_id": "smolagents",
"token_count": 1807
} |
import argparse
import os
import threading
from dotenv import load_dotenv
from huggingface_hub import login
from scripts.text_inspector_tool import TextInspectorTool
from scripts.text_web_browser import (
ArchiveSearchTool,
FinderTool,
FindNextTool,
PageDownTool,
PageUpTool,
SearchInformationTo... | smolagents/examples/open_deep_research/run.py/0 | {
"file_path": "smolagents/examples/open_deep_research/run.py",
"repo_id": "smolagents",
"token_count": 1635
} |
#!/usr/bin/env python
# coding=utf-8
# Copyright 2025 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/L... | smolagents/src/smolagents/_function_type_hints_utils.py/0 | {
"file_path": "smolagents/src/smolagents/_function_type_hints_utils.py",
"repo_id": "smolagents",
"token_count": 5814
} |
import argparse
from io import BytesIO
from time import sleep
import helium
from dotenv import load_dotenv
from PIL import Image
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from smolagents import CodeAgent, DuckDuckGoSearchTool, tool
from ... | smolagents/src/smolagents/vision_web_browser.py/0 | {
"file_path": "smolagents/src/smolagents/vision_web_browser.py",
"repo_id": "smolagents",
"token_count": 2507
} |
# 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_tools.py/0 | {
"file_path": "smolagents/tests/test_tools.py",
"repo_id": "smolagents",
"token_count": 7487
} |
install-server:
cd server && make install
install-server-cpu:
cd server && make install-server
install-router:
cargo install --path backends/v3/
install-launcher:
cargo install --path launcher/
install-benchmark:
cargo install --path benchmark/
install: install-server install-router install-launcher
install... | text-generation-inference/Makefile/0 | {
"file_path": "text-generation-inference/Makefile",
"repo_id": "text-generation-inference",
"token_count": 440
} |
//! A crate to extract and inject a OpenTelemetry context from and to a gRPC request.
//! Inspired by: https://github.com/open-telemetry/opentelemetry-rust gRPC examples
use opentelemetry::global;
use opentelemetry::propagation::Injector;
use tracing_opentelemetry::OpenTelemetrySpanExt;
/// Inject context in the meta... | text-generation-inference/backends/grpc-metadata/src/lib.rs/0 | {
"file_path": "text-generation-inference/backends/grpc-metadata/src/lib.rs",
"repo_id": "text-generation-inference",
"token_count": 543
} |
pub use looper::TensorRtLlmBackendV2;
pub mod errors;
mod looper;
mod utils;
#[cxx::bridge(namespace = "huggingface::tgi::backends::trtllm")]
mod ffi {
#[cxx_name = "finish_reason_t"]
#[derive(Debug, Clone, Copy)]
pub enum FinishReason {
/// The request is not finished.
#[cxx_name = "kNOT_... | text-generation-inference/backends/trtllm/src/lib.rs/0 | {
"file_path": "text-generation-inference/backends/trtllm/src/lib.rs",
"repo_id": "text-generation-inference",
"token_count": 1463
} |
use std::sync::Arc;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rand::Rng;
use text_generation_router_v3::block_allocator::Allocator;
use text_generation_router_v3::radix::RadixAllocator;
fn prefix_cache_benchmark(c: &mut Criterion) {
// let prefixes: Vec<Vec<u32>> = (0..8192)
... | text-generation-inference/backends/v3/benches/prefix_cache.rs/0 | {
"file_path": "text-generation-inference/backends/v3/benches/prefix_cache.rs",
"repo_id": "text-generation-inference",
"token_count": 806
} |
mod app;
mod event;
mod generation;
mod table;
mod utils;
use crate::app::App;
use crate::event::Event;
use ratatui::backend::CrosstermBackend;
use ratatui::crossterm::ExecutableCommand;
use ratatui::Terminal;
use std::io;
use text_generation_client::v3::{GrammarType, NextTokenChooserParameters, ShardedClient};
use to... | text-generation-inference/benchmark/src/lib.rs/0 | {
"file_path": "text-generation-inference/benchmark/src/lib.rs",
"repo_id": "text-generation-inference",
"token_count": 1979
} |
from typing import Dict
# Text Generation Inference Errors
class ValidationError(Exception):
def __init__(self, message: str):
super().__init__(message)
class GenerationError(Exception):
def __init__(self, message: str):
super().__init__(message)
class OverloadedError(Exception):
def _... | text-generation-inference/clients/python/text_generation/errors.py/0 | {
"file_path": "text-generation-inference/clients/python/text_generation/errors.py",
"repo_id": "text-generation-inference",
"token_count": 1080
} |
# Train Medusa
This tutorial will show you how to train a Medusa model on a dataset of your choice. Please check out the [speculation documentation](../conceptual/speculation) for more information on how Medusa works and speculation in general.
## What are the benefits of training a Medusa model?
Training Medusa hea... | text-generation-inference/docs/source/basic_tutorials/train_medusa.md/0 | {
"file_path": "text-generation-inference/docs/source/basic_tutorials/train_medusa.md",
"repo_id": "text-generation-inference",
"token_count": 3478
} |
# Installation from source
<Tip warning={true}>
Installing TGI from source is not the recommended usage. We strongly recommend to use TGI through Docker, check the [Quick Tour](./quicktour), [Installation for Nvidia GPUs](./installation_nvidia) and [Installation for AMD GPUs](./installation_amd) to learn how to use T... | text-generation-inference/docs/source/installation.md/0 | {
"file_path": "text-generation-inference/docs/source/installation.md",
"repo_id": "text-generation-inference",
"token_count": 727
} |
# ruff: noqa: E402
import requests
class SessionTimeoutFix(requests.Session):
def request(self, *args, **kwargs):
timeout = kwargs.pop("timeout", 120)
return super().request(*args, **kwargs, timeout=timeout)
requests.sessions.Session = SessionTimeoutFix
import asyncio
import contextlib
import j... | text-generation-inference/integration-tests/conftest.py/0 | {
"file_path": "text-generation-inference/integration-tests/conftest.py",
"repo_id": "text-generation-inference",
"token_count": 11313
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": 0,
"tokens": [
{
"id": 13,
"logprob": -0.19958496,
"special": false,
"text": "\n"
},
{
"id": 4013,
"logprob": -2... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_awq/test_flash_llama_awq_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_awq/test_flash_llama_awq_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 860
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": 0,
"tokens": [
{
"id": 604,
"logprob": -0.28271484,
"special": false,
"text": " for"
},
{
"id": 573,
"logprob": ... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_gemma_gptq/test_flash_gemma_gptq_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_gemma_gptq/test_flash_gemma_gptq_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 867
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": 0,
"tokens": [
{
"id": 25,
"logprob": -0.88183594,
"special": false,
"text": ":"
},
{
"id": 2209,
"logprob": -2.... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_fp8/test_flash_llama_fp8_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_llama_fp8/test_flash_llama_fp8_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 868
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [],
"seed": 0,
"tokens": [
{
"id": 13,
"logprob": -1.1582031,
"special": false,
"text": "\n"
},
{
"id": 2772,
"logprob": -0.... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_medusa/test_flash_medusa_all_params.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_medusa/test_flash_medusa_all_params.json",
"repo_id": "text-generation-inference",
"token_count": 847
} |
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "The image shows a stylized scene set in what appears to be a diner or restaurant. In the foreground, there is a table with various food items, including a burger with lettuce and tomato... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2_vl/test_flash_qwen2_vl_inpaint.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2_vl/test_flash_qwen2_vl_inpaint.json",
"repo_id": "text-generation-inference",
"token_count": 422
} |
{
"details": {
"finish_reason": "eos_token",
"generated_tokens": 7,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 1,
"logprob": -0.49658203,
"special": true,
"text": "<s>"
},
{
"id": 28705,
"logprob": -0.0016384125,
"spec... | text-generation-inference/integration-tests/models/__snapshots__/test_lora_mistral/test_lora_mistral_with_dbpedia_adapter.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_lora_mistral/test_lora_mistral_with_dbpedia_adapter.json",
"repo_id": "text-generation-inference",
"token_count": 611
} |
import pytest
@pytest.fixture(scope="module")
def flash_gemma2_handle(launcher):
with launcher("google/gemma-2-9b-it", num_shard=2) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_gemma2(flash_gemma2_handle):
await flash_gemma2_handle.health(300)
return flash_gemma2_handl... | text-generation-inference/integration-tests/models/test_flash_gemma2.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_gemma2.py",
"repo_id": "text-generation-inference",
"token_count": 602
} |
import pytest
@pytest.fixture(scope="module")
def flash_mixtral_awq_handle(launcher):
with launcher("casperhansen/mixtral-instruct-awq", num_shard=2) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_mixtral_awq(flash_mixtral_awq_handle):
await flash_mixtral_awq_handle.health(3... | text-generation-inference/integration-tests/models/test_flash_mixtral_awq.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_mixtral_awq.py",
"repo_id": "text-generation-inference",
"token_count": 898
} |
import pytest
import requests
from pydantic import BaseModel
from typing import List
@pytest.fixture(scope="module")
def llama_grammar_handle(launcher):
with launcher(
"TinyLlama/TinyLlama-1.1B-Chat-v1.0",
num_shard=1,
disable_grammar_support=False,
use_flash_attention=False,
... | text-generation-inference/integration-tests/models/test_grammar_response_format_llama.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_grammar_response_format_llama.py",
"repo_id": "text-generation-inference",
"token_count": 1447
} |
import json
import datasets
import tqdm
def main():
dataset = datasets.load_dataset("Open-Orca/OpenOrca", split="train")
# Select only the first 2k conversations that start with a human.
max = min(2000, len(dataset))
conversations = []
for item in tqdm.tqdm(dataset, total=max):
conversatio... | text-generation-inference/load_tests/orca.py/0 | {
"file_path": "text-generation-inference/load_tests/orca.py",
"repo_id": "text-generation-inference",
"token_count": 313
} |
// pub(crate) mod v2;
mod chat_template;
pub mod tool_grammar;
use crate::validation::{ValidGenerateRequest, Validation, ValidationError};
use crate::Tool;
use crate::{
ChatTemplateVersions, FinishReason, GenerateRequest, HubProcessorConfig, HubTokenizerConfig,
Message, PrefillToken, Token,
};
use async_stream... | text-generation-inference/router/src/infer/mod.rs/0 | {
"file_path": "text-generation-inference/router/src/infer/mod.rs",
"repo_id": "text-generation-inference",
"token_count": 8228
} |
exllamav2_commit := v0.1.8
build-exllamav2:
git clone https://github.com/turboderp/exllamav2.git exllamav2 && \
cd exllamav2 && git fetch && git checkout $(exllamav2_commit) && \
git submodule update --init --recursive && \
pip install -r requirements.txt && \
CUDA_ARCH_LIST="8.0;9.0a" NVCC_GENCODE="-gencode=arc... | text-generation-inference/server/Makefile-exllamav2/0 | {
"file_path": "text-generation-inference/server/Makefile-exllamav2",
"repo_id": "text-generation-inference",
"token_count": 302
} |
// Adapted from turboderp exllama: https://github.com/turboderp/exllama
#ifndef _column_remap_cuh
#define _column_remap_cuh
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include <cstdint>
void column_remap_cuda
(
const half* x,
half* x_new,
const int x_height,
const int x_width,
const uint32_... | text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/column_remap.cuh/0 | {
"file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/column_remap.cuh",
"repo_id": "text-generation-inference",
"token_count": 153
} |
#ifndef _q_gemm_cuh
#define _q_gemm_cuh
#include <cuda_runtime.h>
#include <cuda_fp16.h>
#include <cstdint>
#include <cstdio>
#include <ATen/cuda/CUDAContext.h>
#include "q_matrix.cuh"
void gemm_half_q_half_cuda
(
cublasHandle_t cublas_handle,
const half* a,
QMatrix* b,
half* c,
int size_m,
i... | text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm.cuh/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm.cuh",
"repo_id": "text-generation-inference",
"token_count": 294
} |
# test_watermark_logits_processor.py
import os
import numpy as np
import torch
from text_generation_server.utils.watermark import WatermarkLogitsProcessor
GAMMA = os.getenv("WATERMARK_GAMMA", 0.5)
DELTA = os.getenv("WATERMARK_DELTA", 2.0)
def test_seed_rng():
input_ids = [101, 2036, 3731, 102, 2003, 103]
p... | text-generation-inference/server/tests/utils/test_watermark.py/0 | {
"file_path": "text-generation-inference/server/tests/utils/test_watermark.py",
"repo_id": "text-generation-inference",
"token_count": 781
} |
import intel_extension_for_pytorch as ipex
import torch
from text_generation_server.layers.attention.kv_cache import KVCache, KVScales
from text_generation_server.layers.attention import Seqlen
from typing import Optional
from text_generation_server.models.globals import (
ATTENTION,
BLOCK_SIZE,
)
SUPPORTS_WIN... | text-generation-inference/server/text_generation_server/layers/attention/ipex.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/attention/ipex.py",
"repo_id": "text-generation-inference",
"token_count": 1723
} |
from dataclasses import dataclass
from typing import List, Union
import torch
from text_generation_server.utils.weights import Weight, Weights, WeightsLoader
@dataclass
class Exl2Weight(Weight):
"""
Exllama2 exl2 quantized weights.
"""
q_weight: torch.Tensor
q_scale: torch.Tensor
q_invperm: ... | text-generation-inference/server/text_generation_server/layers/exl2.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/exl2.py",
"repo_id": "text-generation-inference",
"token_count": 1050
} |
from dataclasses import dataclass
from typing import List, Optional, Union
import torch
import torch.nn as nn
from text_generation_server.layers.marlin.util import _check_marlin_kernels
from text_generation_server.utils.weights import Weight, Weights, WeightsLoader
try:
import marlin_kernels
except ImportError:
... | text-generation-inference/server/text_generation_server/layers/marlin/marlin.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/marlin/marlin.py",
"repo_id": "text-generation-inference",
"token_count": 6002
} |
# coding=utf-8
# Copyright 2022 HuggingFace Inc. team and BigScience workshop.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless re... | text-generation-inference/server/text_generation_server/models/custom_modeling/bloom_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/bloom_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 16226
} |
# coding=utf-8
# Copyright 2024 Microsoft and the HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_phi_moe_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/flash_phi_moe_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 5177
} |
"""A simple, flexible implementation of a GPT model.
Inspired by https://github.com/karpathy/minGPT/blob/master/mingpt/model.py
"""
import math
import warnings
from typing import List, Optional, Tuple, Union
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import PreTrainedModel, P... | text-generation-inference/server/text_generation_server/models/custom_modeling/mpt_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/mpt_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 23706
} |
from io import BytesIO
from PIL import Image
import torch
import torch.distributed
from opentelemetry import trace
from typing import Iterable
from text_generation_server.models.vlm_causal_lm import (
VlmCausalLMBatch,
image_text_replacement,
)
from text_generation_server.pb.generate_pb2 import Request
tracer... | text-generation-inference/server/text_generation_server/models/pali_gemma.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/pali_gemma.py",
"repo_id": "text-generation-inference",
"token_count": 1345
} |
from functools import lru_cache
import math
import time
import torch
from typing import List, Optional, DefaultDict
from loguru import logger
from typing import Dict
from text_generation_server.pb.generate_pb2 import GrammarType
from outlines.fsm.guide import RegexGuide
from transformers import (
LogitsProcessor... | text-generation-inference/server/text_generation_server/utils/logits_process.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/logits_process.py",
"repo_id": "text-generation-inference",
"token_count": 9944
} |
// import { promisify } from 'util'
import { BPE, Tokenizer, mergeEncodings, slice } from '../../'
describe('slice', () => {
const text = 'My name is John 👋'
const sliceText = slice.bind({}, text)
it('returns the full text when no params', () => {
const sliced = sliceText()
expect(sliced).toEqual(text... | tokenizers/bindings/node/lib/bindings/utils.test.ts/0 | {
"file_path": "tokenizers/bindings/node/lib/bindings/utils.test.ts",
"repo_id": "tokenizers",
"token_count": 1866
} |
{
"name": "tokenizers-linux-arm64-musl",
"version": "0.13.4-rc1",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"main": "tokenizers.linux-arm64-musl.node",
"files": [
"tokenizers.linux-arm64-musl.node"
],
"description": "Tokenizers platform specific bindings",
"keywords": [
"napi-rs",
... | tokenizers/bindings/node/npm/linux-arm64-musl/package.json/0 | {
"file_path": "tokenizers/bindings/node/npm/linux-arm64-musl/package.json",
"repo_id": "tokenizers",
"token_count": 291
} |
#![deny(clippy::all)]
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
mod arc_rwlock_serde;
pub mod decoders;
pub mod encoding;
pub mod models;
pub mod normalizers;
pub mod pre_tokenizers;
pub mod processors;
pub mod tasks;
pub mod tokenizer;
pub mod trainers;
pub mod utils;
| tokenizers/bindings/node/src/lib.rs/0 | {
"file_path": "tokenizers/bindings/node/src/lib.rs",
"repo_id": "tokenizers",
"token_count": 102
} |
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.13.2]
- [#1096] Python 3.11 support
## [0.13.1]
- [#1072]... | tokenizers/bindings/python/CHANGELOG.md/0 | {
"file_path": "tokenizers/bindings/python/CHANGELOG.md",
"repo_id": "tokenizers",
"token_count": 7408
} |
# Generated content DO NOT EDIT
class DecodeStream:
"""
Class needed for streaming decode
"""
def __init__(self, skip_special_tokens):
pass
class Decoder:
"""
Base class for all decoders
This class is not supposed to be instantiated directly. Instead, any implementation of
a D... | tokenizers/bindings/python/py_src/tokenizers/decoders/__init__.pyi/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/decoders/__init__.pyi",
"repo_id": "tokenizers",
"token_count": 3238
} |
use pyo3::exceptions::PyException;
use pyo3::types::*;
use pyo3::{exceptions, prelude::*};
use std::sync::{Arc, RwLock};
use crate::error::ToPyResult;
use crate::utils::{PyNormalizedString, PyNormalizedStringRefMut, PyPattern};
use serde::ser::SerializeStruct;
use serde::{Deserialize, Deserializer, Serialize, Serializ... | tokenizers/bindings/python/src/normalizers.rs/0 | {
"file_path": "tokenizers/bindings/python/src/normalizers.rs",
"repo_id": "tokenizers",
"token_count": 14629
} |
import json
import pickle
import pytest
from tokenizers.decoders import (
CTC,
BPEDecoder,
ByteLevel,
Decoder,
Metaspace,
Sequence,
WordPiece,
ByteFallback,
Replace,
Strip,
Fuse,
)
class TestByteLevel:
def test_instantiate(self):
assert ByteLevel() is not None... | tokenizers/bindings/python/tests/bindings/test_decoders.py/0 | {
"file_path": "tokenizers/bindings/python/tests/bindings/test_decoders.py",
"repo_id": "tokenizers",
"token_count": 3527
} |
# Tokenizer
<tokenizerslangcontent>
<python>
## Tokenizer
[[autodoc]] tokenizers.Tokenizer
- all
- decoder
- model
- normalizer
- padding
- post_processor
- pre_tokenizer
- truncation
</python>
<rust>
The Rust API Reference is available directly on the [Docs.rs](https://docs.rs/tokeniz... | tokenizers/docs/source-doc-builder/api/tokenizer.mdx/0 | {
"file_path": "tokenizers/docs/source-doc-builder/api/tokenizer.mdx",
"repo_id": "tokenizers",
"token_count": 156
} |
.highlight .c1, .highlight .sd{
color: #999
}
.highlight .nn, .highlight .k, .highlight .s1, .highlight .nb, .highlight .bp, .highlight .kc, .highlight .kt {
color: #FB8D68;
}
.highlight .kn, .highlight .nv, .highlight .s2, .highlight .ow, .highlight .kd, .highlight .kr, .highlight .s {
color: #6670FF;
}... | tokenizers/docs/source/_static/css/code-snippets.css/0 | {
"file_path": "tokenizers/docs/source/_static/css/code-snippets.css",
"repo_id": "tokenizers",
"token_count": 166
} |
Quicktour
====================================================================================================
Let's have a quick look at the 🤗 Tokenizers library features. The library provides an
implementation of today's most used tokenizers that is both easy to use and blazing fast.
.. only:: python
It can b... | tokenizers/docs/source/quicktour.rst/0 | {
"file_path": "tokenizers/docs/source/quicktour.rst",
"repo_id": "tokenizers",
"token_count": 8904
} |
{
"name": "create-wasm-app",
"version": "0.1.0",
"description": "create an app to consume rust-generated wasm packages",
"main": "index.js",
"bin": {
"create-wasm-app": ".bin/create-wasm-app.js"
},
"scripts": {
"build": "webpack --config webpack.config.js",
"start": "... | tokenizers/tokenizers/examples/unstable_wasm/www/package.json/0 | {
"file_path": "tokenizers/tokenizers/examples/unstable_wasm/www/package.json",
"repo_id": "tokenizers",
"token_count": 516
} |
use super::Pair;
use rand::{thread_rng, Rng};
use std::cmp::Ordering;
use std::collections::{BinaryHeap, HashMap};
#[derive(Debug, Eq)]
struct Merge {
pos: usize,
rank: u32,
new_id: u32,
}
impl PartialEq for Merge {
fn eq(&self, other: &Self) -> bool {
self.rank == other.rank && self.pos == ot... | tokenizers/tokenizers/src/models/bpe/word.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/bpe/word.rs",
"repo_id": "tokenizers",
"token_count": 6487
} |
pub mod bert;
pub mod byte_level;
pub mod precompiled;
pub mod prepend;
pub mod replace;
pub mod strip;
pub mod unicode;
pub mod utils;
pub use crate::normalizers::bert::BertNormalizer;
pub use crate::normalizers::byte_level::ByteLevel;
pub use crate::normalizers::precompiled::Precompiled;
pub use crate::normalizers::p... | tokenizers/tokenizers/src/normalizers/mod.rs/0 | {
"file_path": "tokenizers/tokenizers/src/normalizers/mod.rs",
"repo_id": "tokenizers",
"token_count": 5898
} |
use std::borrow::Borrow;
use std::collections::HashMap;
use std::hash::Hash;
use std::sync::RwLock;
/// The default capacity for a `BPE`'s internal cache.
pub static DEFAULT_CACHE_CAPACITY: usize = 10_000;
/// The maximum length we should cache in a model
/// Strings that are too long have minimal chances to cache hit... | tokenizers/tokenizers/src/utils/cache.rs/0 | {
"file_path": "tokenizers/tokenizers/src/utils/cache.rs",
"repo_id": "tokenizers",
"token_count": 1570
} |
use tokenizers::{
normalizers,
pre_tokenizers::split::{Split, SplitPattern},
AddedToken, NormalizerWrapper, PreTokenizerWrapper, SplitDelimiterBehavior, Tokenizer,
};
#[test]
fn test_decoding_with_added_bpe() {
let mut tokenizer = Tokenizer::from_file("data/llama-3-tokenizer.json").unwrap();
tokeni... | tokenizers/tokenizers/tests/stream.rs/0 | {
"file_path": "tokenizers/tokenizers/tests/stream.rs",
"repo_id": "tokenizers",
"token_count": 1591
} |
# Server-side Audio Processing in Node.js
A major benefit of writing code for the web is that you can access the multitude of APIs that are available in modern browsers. Unfortunately, when writing server-side code, we are not afforded such luxury, so we have to find another way. In this tutorial, we will design a si... | transformers.js/docs/source/guides/node-audio-processing.md/0 | {
"file_path": "transformers.js/docs/source/guides/node-audio-processing.md",
"repo_id": "transformers.js",
"token_count": 1352
} |
import { useState, useRef, useEffect } from "react";
import Editor from "@monaco-editor/react";
import Progress from './components/Progress';
import './App.css'
const MODELS = [
'Xenova/tiny_starcoder_py',
'Xenova/codegen-350M-mono',
// 'Xenova/starcoderbase-1b',
]
function App() {
// Editor setup
const m... | transformers.js/examples/code-completion/src/App.jsx/0 | {
"file_path": "transformers.js/examples/code-completion/src/App.jsx",
"repo_id": "transformers.js",
"token_count": 3961
} |
import { useEffect, useState, useRef, useCallback } from 'react';
import Progress from './components/Progress';
import ImageInput from './components/ImageInput';
const IS_WEBGPU_AVAILABLE = !!navigator.gpu;
function App() {
// Create a reference to the worker object.
const worker = useRef(null);
// Model loa... | transformers.js/examples/florence2-webgpu/src/App.jsx/0 | {
"file_path": "transformers.js/examples/florence2-webgpu/src/App.jsx",
"repo_id": "transformers.js",
"token_count": 4599
} |
import { pipeline } from "@xenova/transformers";
// Use the Singleton pattern to enable lazy construction of the pipeline.
// NOTE: We wrap the class in a function to prevent code duplication (see below).
const P = () => class PipelineSingleton {
static task = 'text-classification';
static model = 'Xenova/dist... | transformers.js/examples/next-server/src/app/classify/pipeline.js/0 | {
"file_path": "transformers.js/examples/next-server/src/app/classify/pipeline.js",
"repo_id": "transformers.js",
"token_count": 370
} |
import { decode } from 'blurhash'
const SIZE = 32;
export function blurHashToDataURL(hash) {
if (!hash) return undefined
const pixels = decode(hash, SIZE, SIZE)
const canvas = document.createElement("canvas");
canvas.width = SIZE;
canvas.height = SIZE;
const ctx = canvas.getContext("2d");
... | transformers.js/examples/semantic-image-search-client/src/app/utils.js/0 | {
"file_path": "transformers.js/examples/semantic-image-search-client/src/app/utils.js",
"repo_id": "transformers.js",
"token_count": 1001
} |
import { AutoTokenizer, CLIPTextModelWithProjection } from "@xenova/transformers";
import { createClient } from '@supabase/supabase-js'
// Use the Singleton pattern to enable lazy construction of the pipeline.
// NOTE: We wrap the class in a function to prevent code duplication (see below).
const S = () => class Appli... | transformers.js/examples/semantic-image-search/src/app/app.js/0 | {
"file_path": "transformers.js/examples/semantic-image-search/src/app/app.js",
"repo_id": "transformers.js",
"token_count": 678
} |
import './style.css';
import { env, AutoModel, AutoProcessor, RawImage } from '@xenova/transformers';
// Since we will download the model from the Hugging Face Hub, we can skip the local model check
env.allowLocalModels = false;
// Proxy the WASM backend to prevent the UI from freezing
env.backends.onnx.wasm.proxy =... | transformers.js/examples/video-object-detection/main.js/0 | {
"file_path": "transformers.js/examples/video-object-detection/main.js",
"repo_id": "transformers.js",
"token_count": 1945
} |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Transformers.js | WebGPU Benchmark</title>
</head>
<body>
<h1>
<a href="https://github.com/huggingface/transformers.js" target="_blank">🤗 Transformers.js</a> We... | transformers.js/examples/webgpu-embedding-benchmark/index.html/0 | {
"file_path": "transformers.js/examples/webgpu-embedding-benchmark/index.html",
"repo_id": "transformers.js",
"token_count": 1004
} |
export default function ImageIcon(props) {
return (
<svg
{...props}
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
stro... | transformers.js/examples/webgpu-vlm/src/components/icons/ImageIcon.jsx/0 | {
"file_path": "transformers.js/examples/webgpu-vlm/src/components/icons/ImageIcon.jsx",
"repo_id": "transformers.js",
"token_count": 462
} |
import { useEffect, useState, useRef } from 'react';
import { AudioVisualizer } from './components/AudioVisualizer';
import Progress from './components/Progress';
import { LanguageSelector } from './components/LanguageSelector';
const IS_WEBGPU_AVAILABLE = !!navigator.gpu;
const WHISPER_SAMPLING_RATE = 16_000;
const... | transformers.js/examples/webgpu-whisper/src/App.jsx/0 | {
"file_path": "transformers.js/examples/webgpu-whisper/src/App.jsx",
"repo_id": "transformers.js",
"token_count": 4256
} |
function titleCase(str) {
str = str.toLowerCase();
return (str.match(/\w+.?/g) || [])
.map((word) => {
return word.charAt(0).toUpperCase() + word.slice(1);
})
.join("");
}
// List of supported languages:
// https://help.openai.com/en/articles/7031512-whisper-api-faq
// http... | transformers.js/examples/whisper-word-timestamps/src/components/LanguageSelector.jsx/0 | {
"file_path": "transformers.js/examples/whisper-word-timestamps/src/components/LanguageSelector.jsx",
"repo_id": "transformers.js",
"token_count": 1603
} |
import { useState, useRef, useEffect, useCallback } from 'react'
import './App.css'
const PLACEHOLDER_REVIEWS = [
// battery/charging problems
"Disappointed with the battery life! The phone barely lasts half a day with regular use. Considering how much I paid for it, I expected better performance in this departmen... | transformers.js/examples/zero-shot-classification/src/App.jsx/0 | {
"file_path": "transformers.js/examples/zero-shot-classification/src/App.jsx",
"repo_id": "transformers.js",
"token_count": 3044
} |
/**
* @module generation/stopping_criteria
*/
import { Callable } from "../utils/generic.js";
// NOTE:
// Stopping Criteria returns a list of `batch_size` booleans, indicating whether each sequence in the batch should be stopped.
/**
* Abstract base class for all stopping criteria that can be applied during gene... | transformers.js/src/generation/stopping_criteria.js/0 | {
"file_path": "transformers.js/src/generation/stopping_criteria.js",
"repo_id": "transformers.js",
"token_count": 1803
} |
import {
ImageProcessor,
post_process_panoptic_segmentation,
post_process_instance_segmentation,
} from "../../base/image_processors_utils.js";
export class MaskFormerImageProcessor extends ImageProcessor {
/** @type {typeof post_process_panoptic_segmentation} */
post_process_panoptic_segmentatio... | transformers.js/src/models/maskformer/image_processing_maskformer.js/0 | {
"file_path": "transformers.js/src/models/maskformer/image_processing_maskformer.js",
"repo_id": "transformers.js",
"token_count": 229
} |
export * from './florence2/processing_florence2.js';
export * from './grounding_dino/processing_grounding_dino.js';
export * from './idefics3/processing_idefics3.js';
export * from './janus/processing_janus.js';
export * from './jina_clip/processing_jina_clip.js';
export * from './mgp_str/processing_mgp_str.js';
export... | transformers.js/src/models/processors.js/0 | {
"file_path": "transformers.js/src/models/processors.js",
"repo_id": "transformers.js",
"token_count": 336
} |
/**
* @file Helper module for audio processing.
*
* These functions and classes are only used internally,
* meaning an end-user shouldn't need to access anything here.
*
* @module utils/audio
*/
import {
getFile,
} from './hub.js';
import { FFT, max } from './maths.js';
import {
calculateReflectOffs... | transformers.js/src/utils/audio.js/0 | {
"file_path": "transformers.js/src/utils/audio.js",
"repo_id": "transformers.js",
"token_count": 12826
} |
// Helper functions used when initialising the testing environment.
// Import Node typing utilities
import * as types from "node:util/types";
// Import onnxruntime-node's default backend
import { onnxruntimeBackend } from "onnxruntime-node/dist/backend";
import * as ONNX_COMMON from "onnxruntime-common";
/**
* A wo... | transformers.js/tests/init.js/0 | {
"file_path": "transformers.js/tests/init.js",
"repo_id": "transformers.js",
"token_count": 2064
} |
import { CohereTokenizer, CohereModel, CohereForCausalLM } from "../../../src/transformers.js";
import { MAX_MODEL_LOAD_TIME, MAX_TEST_EXECUTION_TIME, MAX_MODEL_DISPOSE_TIME, DEFAULT_MODEL_OPTIONS } from "../../init.js";
export default () => {
describe("CohereModel", () => {
const model_id = "hf-internal-testin... | transformers.js/tests/models/cohere/test_modeling_cohere.js/0 | {
"file_path": "transformers.js/tests/models/cohere/test_modeling_cohere.js",
"repo_id": "transformers.js",
"token_count": 1323
} |
import { NllbTokenizer } from "../../../src/tokenizers.js";
import { BASE_TEST_STRINGS } from "../test_strings.js";
export const TOKENIZER_CLASS = NllbTokenizer;
export const TEST_CONFIG = {
"Xenova/nllb-200-distilled-600M": {
SIMPLE: {
text: BASE_TEST_STRINGS.SIMPLE,
tokens: ["\u2581How", "\u2581are... | transformers.js/tests/models/nllb/test_tokenization_nllb.js/0 | {
"file_path": "transformers.js/tests/models/nllb/test_tokenization_nllb.js",
"repo_id": "transformers.js",
"token_count": 5409
} |
import { AutoProcessor, Qwen2VLProcessor } from "../../../src/transformers.js";
import { load_cached_image } from "../../asset_cache.js";
import { MAX_PROCESSOR_LOAD_TIME, MAX_TEST_EXECUTION_TIME } from "../../init.js";
export default () => {
describe("Qwen2VLProcessor", () => {
const model_id = "hf-internal-te... | transformers.js/tests/models/qwen2_vl/test_processor_qwen2_vl.js/0 | {
"file_path": "transformers.js/tests/models/qwen2_vl/test_processor_qwen2_vl.js",
"repo_id": "transformers.js",
"token_count": 612
} |
import { AutoFeatureExtractor, WhisperFeatureExtractor } from "../../../src/transformers.js";
import { load_cached_audio } from "../../asset_cache.js";
import { MAX_FEATURE_EXTRACTOR_LOAD_TIME, MAX_TEST_EXECUTION_TIME } from "../../init.js";
export default () => {
// WhisperFeatureExtractor
describe("WhisperFeatu... | transformers.js/tests/models/whisper/test_feature_extraction_whisper.js/0 | {
"file_path": "transformers.js/tests/models/whisper/test_feature_extraction_whisper.js",
"repo_id": "transformers.js",
"token_count": 516
} |
import { pipeline, ImageToTextPipeline } from "../../src/transformers.js";
import { MAX_MODEL_LOAD_TIME, MAX_TEST_EXECUTION_TIME, MAX_MODEL_DISPOSE_TIME, DEFAULT_MODEL_OPTIONS } from "../init.js";
import { load_cached_image } from "../asset_cache.js";
const PIPELINE_ID = "image-to-text";
export default () => {
des... | transformers.js/tests/pipelines/test_pipelines_image_to_text.js/0 | {
"file_path": "transformers.js/tests/pipelines/test_pipelines_image_to_text.js",
"repo_id": "transformers.js",
"token_count": 684
} |
FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04
LABEL maintainer="Hugging Face"
ARG DEBIAN_FRONTEND=noninteractive
# Use login shell to read variables from `~/.profile` (to pass dynamic created variables between RUN commands)
SHELL ["sh", "-lc"]
# The following `ARG` are mainly used to specify the versions explicit... | transformers/docker/transformers-all-latest-gpu/Dockerfile/0 | {
"file_path": "transformers/docker/transformers-all-latest-gpu/Dockerfile",
"repo_id": "transformers",
"token_count": 1260
} |
# Translating the Transformers documentation into your language
As part of our mission to democratize machine learning, we aim to make the Transformers library available in many more languages! Follow the steps below to help translate the documentation into your language.
## Open an Issue
1. Navigate to the Issues p... | transformers/docs/TRANSLATING.md/0 | {
"file_path": "transformers/docs/TRANSLATING.md",
"repo_id": "transformers",
"token_count": 745
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.