text stringlengths 96 319k | id stringlengths 14 178 | metadata dict |
|---|---|---|
import abc
from dataclasses import dataclass
import draccus
@dataclass
class MotorsBusConfig(draccus.ChoiceRegistry, abc.ABC):
@property
def type(self) -> str:
return self.get_choice_name(self.__class__)
@MotorsBusConfig.register_subclass("dynamixel")
@dataclass
class DynamixelMotorsBusConfig(Motor... | lerobot/lerobot/common/robot_devices/motors/configs.py/0 | {
"file_path": "lerobot/lerobot/common/robot_devices/motors/configs.py",
"repo_id": "lerobot",
"token_count": 220
} |
#!/usr/bin/env python
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | lerobot/lerobot/configs/default.py/0 | {
"file_path": "lerobot/lerobot/configs/default.py",
"repo_id": "lerobot",
"token_count": 929
} |
#!/usr/bin/env python
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | lerobot/lerobot/scripts/visualize_dataset_html.py/0 | {
"file_path": "lerobot/lerobot/scripts/visualize_dataset_html.py",
"repo_id": "lerobot",
"token_count": 7248
} |
#!/usr/bin/env python
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | lerobot/tests/scripts/save_dataset_to_safetensors.py/0 | {
"file_path": "lerobot/tests/scripts/save_dataset_to_safetensors.py",
"repo_id": "lerobot",
"token_count": 1387
} |
"""
Tests for physical robots and their mocked versions.
If the physical robots are not connected to the computer, or not working,
the test will be skipped.
Example of running a specific test:
```bash
pytest -sx tests/test_robots.py::test_robot
```
Example of running test on real robots connected to the computer:
```... | lerobot/tests/test_robots.py/0 | {
"file_path": "lerobot/tests/test_robots.py",
"repo_id": "lerobot",
"token_count": 1872
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | open-r1/scripts/run_benchmarks.py/0 | {
"file_path": "open-r1/scripts/run_benchmarks.py",
"repo_id": "open-r1",
"token_count": 815
} |
#!/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/LI... | open-r1/src/open_r1/utils/hub.py/0 | {
"file_path": "open-r1/src/open_r1/utils/hub.py",
"repo_id": "open-r1",
"token_count": 2180
} |
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->
# Fully Sharded Data Parallel
[Fully sharded data parallel](https://pytorch.org/docs/stable/fsdp.html) (FSDP) is developed for distributed training ... | peft/docs/source/accelerate/fsdp.md/0 | {
"file_path": "peft/docs/source/accelerate/fsdp.md",
"repo_id": "peft",
"token_count": 4780
} |
<!--Copyright 2023 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | peft/docs/source/install.md/0 | {
"file_path": "peft/docs/source/install.md",
"repo_id": "peft",
"token_count": 439
} |
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | peft/docs/source/task_guides/ia3.md/0 | {
"file_path": "peft/docs/source/task_guides/ia3.md",
"repo_id": "peft",
"token_count": 3197
} |
import random
import numpy as np
import torch
import wandb
from datasets import load_dataset
from diffusers import DDIMScheduler
from PIL import Image
from torchvision import transforms
from utils.pipeline_controlnet import LightControlNetPipeline
def image_grid(imgs, rows, cols):
assert len(imgs) == rows * cols... | peft/examples/boft_controlnet/utils/dataset.py/0 | {
"file_path": "peft/examples/boft_controlnet/utils/dataset.py",
"repo_id": "peft",
"token_count": 3160
} |
import gc
import os
import sys
import threading
import psutil
import torch
from accelerate import Accelerator
from datasets import load_dataset
from torch.utils.data import DataLoader
from tqdm import tqdm
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, get_linear_schedule_with_warmup, set_seed
from pe... | peft/examples/conditional_generation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py/0 | {
"file_path": "peft/examples/conditional_generation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py",
"repo_id": "peft",
"token_count": 5610
} |
# Copyright 2024-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/examples/ephemeral_gpu_offloading/load_with_dora.py/0 | {
"file_path": "peft/examples/ephemeral_gpu_offloading/load_with_dora.py",
"repo_id": "peft",
"token_count": 1389
} |
# PiSSA: Principal Singular values and Singular vectors Adaptation
## Introduction ([Paper](https://arxiv.org/abs/2404.02948), [code](https://github.com/GraphPKU/PiSSA))
PiSSA represents a matrix $W\in\mathbb{R}^{m\times n}$ within the model by the product of two trainable matrices $A \in \mathbb{R}^{m\times r}$ and $B... | peft/examples/pissa_finetuning/README.md/0 | {
"file_path": "peft/examples/pissa_finetuning/README.md",
"repo_id": "peft",
"token_count": 2177
} |
import os
import sys
from dataclasses import dataclass, field
from typing import Optional
from transformers import HfArgumentParser, set_seed
from trl import SFTConfig, SFTTrainer
from utils import create_and_prepare_model, create_datasets
# Define and parse arguments.
@dataclass
class ModelArguments:
"""
Ar... | peft/examples/sft/train.py/0 | {
"file_path": "peft/examples/sft/train.py",
"repo_id": "peft",
"token_count": 2226
} |
# Copyright 2023-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/src/peft/__init__.py/0 | {
"file_path": "peft/src/peft/__init__.py",
"repo_id": "peft",
"token_count": 2224
} |
# Copyright 2023-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/src/peft/tuners/adalora/config.py/0 | {
"file_path": "peft/src/peft/tuners/adalora/config.py",
"repo_id": "peft",
"token_count": 1944
} |
# Copyright 2023-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/src/peft/tuners/ia3/bnb.py/0 | {
"file_path": "peft/src/peft/tuners/ia3/bnb.py",
"repo_id": "peft",
"token_count": 2193
} |
# Copyright 2023-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/src/peft/tuners/poly/router.py/0 | {
"file_path": "peft/src/peft/tuners/poly/router.py",
"repo_id": "peft",
"token_count": 1101
} |
# Copyright 2023-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/src/peft/tuners/vera/model.py/0 | {
"file_path": "peft/src/peft/tuners/vera/model.py",
"repo_id": "peft",
"token_count": 9226
} |
# Copyright 2024-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/tests/test_helpers.py/0 | {
"file_path": "peft/tests/test_helpers.py",
"repo_id": "peft",
"token_count": 8287
} |
# Copyright 2024-present the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | peft/tests/test_vblora.py/0 | {
"file_path": "peft/tests/test_vblora.py",
"repo_id": "peft",
"token_count": 5019
} |
# Installation
Before you start, you'll need to setup your environment and install the appropriate packages. `timm` is tested on **Python 3+**.
## Virtual Environment
You should install `timm` in a [virtual environment](https://docs.python.org/3/library/venv.html) to keep things tidy and avoid dependency conflicts.
... | pytorch-image-models/hfdocs/source/installation.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/installation.mdx",
"repo_id": "pytorch-image-models",
"token_count": 623
} |
# MnasNet
**MnasNet** is a type of convolutional neural network optimized for mobile devices that is discovered through mobile neural architecture search, which explicitly incorporates model latency into the main objective so that the search can identify a model that achieves a good trade-off between accuracy and late... | pytorch-image-models/hfdocs/source/models/mnasnet.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/mnasnet.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2103
} |
# SelecSLS
**SelecSLS** uses novel selective long and short range skip connections to improve the information flow allowing for a drastically faster network without compromising accuracy.
## How do I use this model on an image?
To load a pretrained model:
```py
>>> import timm
>>> model = timm.create_model('selecsl... | pytorch-image-models/hfdocs/source/models/selecsls.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/selecsls.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2422
} |
# Xception
**Xception** is a convolutional neural network architecture that relies solely on [depthwise separable convolution layers](https://paperswithcode.com/method/depthwise-separable-convolution).
The weights from this model were ported from [Tensorflow/Models](https://github.com/tensorflow/models).
## How do I... | pytorch-image-models/hfdocs/source/models/xception.mdx/0 | {
"file_path": "pytorch-image-models/hfdocs/source/models/xception.mdx",
"repo_id": "pytorch-image-models",
"token_count": 2676
} |
""" Transforms Factory
Factory methods for building image transforms for use with TIMM (PyTorch Image Models)
Hacked together by / Copyright 2019, Ross Wightman
"""
import math
from typing import Optional, Tuple, Union
import torch
from torchvision import transforms
from timm.data.constants import IMAGENET_DEFAULT_M... | pytorch-image-models/timm/data/transforms_factory.py/0 | {
"file_path": "pytorch-image-models/timm/data/transforms_factory.py",
"repo_id": "pytorch-image-models",
"token_count": 8545
} |
""" Activation Factory
Hacked together by / Copyright 2020 Ross Wightman
"""
from typing import Union, Callable, Type
from .activations import *
from .activations_me import *
from .config import is_exportable, is_scriptable
# PyTorch has an optimized, native 'silu' (aka 'swish') operator as of PyTorch 1.7.
# Also har... | pytorch-image-models/timm/layers/create_act.py/0 | {
"file_path": "pytorch-image-models/timm/layers/create_act.py",
"repo_id": "pytorch-image-models",
"token_count": 1969
} |
""" Layer/Module Helpers
Hacked together by / Copyright 2020 Ross Wightman
"""
from itertools import repeat
import collections.abc
# From PyTorch internals
def _ntuple(n):
def parse(x):
if isinstance(x, collections.abc.Iterable) and not isinstance(x, str):
return tuple(x)
return tuple... | pytorch-image-models/timm/layers/helpers.py/0 | {
"file_path": "pytorch-image-models/timm/layers/helpers.py",
"repo_id": "pytorch-image-models",
"token_count": 462
} |
""" Image to Patch Embedding using Conv2d
A convolution based approach to patchifying a 2D image w/ embedding projection.
Based on code in:
* https://github.com/google-research/vision_transformer
* https://github.com/google-research/big_vision/tree/main/big_vision
Hacked together by / Copyright 2020 Ross Wightma... | pytorch-image-models/timm/layers/patch_embed.py/0 | {
"file_path": "pytorch-image-models/timm/layers/patch_embed.py",
"repo_id": "pytorch-image-models",
"token_count": 5614
} |
import os
import pkgutil
from copy import deepcopy
from torch import nn as nn
from timm.layers import Conv2dSame, BatchNormAct2d, Linear
__all__ = ['extract_layer', 'set_layer', 'adapt_model_from_string', 'adapt_model_from_file']
def extract_layer(model, layer):
layer = layer.split('.')
module = model
... | pytorch-image-models/timm/models/_prune.py/0 | {
"file_path": "pytorch-image-models/timm/models/_prune.py",
"repo_id": "pytorch-image-models",
"token_count": 2096
} |
"""PyTorch CspNet
A PyTorch implementation of Cross Stage Partial Networks including:
* CSPResNet50
* CSPResNeXt50
* CSPDarkNet53
* and DarkNet53 for good measure
Based on paper `CSPNet: A New Backbone that can Enhance Learning Capability of CNN` - https://arxiv.org/abs/1911.11929
Reference impl via darknet cfg file... | pytorch-image-models/timm/models/cspnet.py/0 | {
"file_path": "pytorch-image-models/timm/models/cspnet.py",
"repo_id": "pytorch-image-models",
"token_count": 20103
} |
""" FocalNet
As described in `Focal Modulation Networks` - https://arxiv.org/abs/2203.11926
Significant modifications and refactoring from the original impl at https://github.com/microsoft/FocalNet
This impl is/has:
* fully convolutional, NCHW tensor layout throughout, seemed to have minimal performance impact but m... | pytorch-image-models/timm/models/focalnet.py/0 | {
"file_path": "pytorch-image-models/timm/models/focalnet.py",
"repo_id": "pytorch-image-models",
"token_count": 11648
} |
""" LeViT
Paper: `LeViT: a Vision Transformer in ConvNet's Clothing for Faster Inference`
- https://arxiv.org/abs/2104.01136
@article{graham2021levit,
title={LeViT: a Vision Transformer in ConvNet's Clothing for Faster Inference},
author={Benjamin Graham and Alaaeldin El-Nouby and Hugo Touvron and Pierre Stoc... | pytorch-image-models/timm/models/levit.py/0 | {
"file_path": "pytorch-image-models/timm/models/levit.py",
"repo_id": "pytorch-image-models",
"token_count": 17159
} |
""" TinyViT
Paper: `TinyViT: Fast Pretraining Distillation for Small Vision Transformers`
- https://arxiv.org/abs/2207.10666
Adapted from official impl at https://github.com/microsoft/Cream/tree/main/TinyViT
"""
__all__ = ['TinyVit']
import itertools
from functools import partial
from typing import Dict, Option... | pytorch-image-models/timm/models/tiny_vit.py/0 | {
"file_path": "pytorch-image-models/timm/models/tiny_vit.py",
"repo_id": "pytorch-image-models",
"token_count": 12466
} |
from .adabelief import AdaBelief
from .adafactor import Adafactor
from .adafactor_bv import AdafactorBigVision
from .adahessian import Adahessian
from .adamp import AdamP
from .adamw import AdamWLegacy
from .adan import Adan
from .adopt import Adopt
from .lamb import Lamb
from .laprop import LaProp
from .lars import La... | pytorch-image-models/timm/optim/__init__.py/0 | {
"file_path": "pytorch-image-models/timm/optim/__init__.py",
"repo_id": "pytorch-image-models",
"token_count": 385
} |
""" Lion Optimizer
Paper: `Symbolic Discovery of Optimization Algorithms` - https://arxiv.org/abs/2302.06675
Original Impl: https://github.com/google/automl/tree/master/lion
"""
# Copyright 2023 Google Research. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use t... | pytorch-image-models/timm/optim/lion.py/0 | {
"file_path": "pytorch-image-models/timm/optim/lion.py",
"repo_id": "pytorch-image-models",
"token_count": 3736
} |
""" Plateau Scheduler
Adapts PyTorch plateau scheduler and allows application of noise, warmup.
Hacked together by / Copyright 2020 Ross Wightman
"""
import torch
from typing import List
from .scheduler import Scheduler
class PlateauLRScheduler(Scheduler):
"""Decay the LR by a factor every time the validation ... | pytorch-image-models/timm/scheduler/plateau_lr.py/0 | {
"file_path": "pytorch-image-models/timm/scheduler/plateau_lr.py",
"repo_id": "pytorch-image-models",
"token_count": 1807
} |
""" Eval metrics and related
Hacked together by / Copyright 2020 Ross Wightman
"""
class AverageMeter:
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0
... | pytorch-image-models/timm/utils/metrics.py/0 | {
"file_path": "pytorch-image-models/timm/utils/metrics.py",
"repo_id": "pytorch-image-models",
"token_count": 374
} |
<!--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/index.md/0 | {
"file_path": "smolagents/docs/source/en/index.md",
"repo_id": "smolagents",
"token_count": 1250
} |
<!--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/index.md/0 | {
"file_path": "smolagents/docs/source/hi/index.md",
"repo_id": "smolagents",
"token_count": 2912
} |
<!--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/reference/agents.md/0 | {
"file_path": "smolagents/docs/source/zh/reference/agents.md",
"repo_id": "smolagents",
"token_count": 1598
} |
import argparse
import json
import os
import threading
from concurrent.futures import ThreadPoolExecutor, as_completed
from datetime import datetime
from pathlib import Path
from typing import List
import datasets
import pandas as pd
from dotenv import load_dotenv
from huggingface_hub import login
from scripts.reformu... | smolagents/examples/open_deep_research/run_gaia.py/0 | {
"file_path": "smolagents/examples/open_deep_research/run_gaia.py",
"repo_id": "smolagents",
"token_count": 3998
} |
# 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": 3712
} |
<div align="center">
<a href="https://www.youtube.com/watch?v=jlMAX2Oaht0">
<img width=560 alt="Making TGI deployment optimal" src="https://huggingface.co/datasets/Narsil/tgi_assets/resolve/main/thumbnail.png">
</a>
# Text Generation Inference
<a href="https://github.com/huggingface/text-generation-inference">
<... | text-generation-inference/README.md/0 | {
"file_path": "text-generation-inference/README.md",
"repo_id": "text-generation-inference",
"token_count": 4564
} |
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
} |
/// 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
} |
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
} |
# Using TGI CLI
You can use TGI command-line interface (CLI) to download weights, serve and quantize models, or get information on serving parameters. To install the CLI, please refer to [the installation section](../installation#install-cli).
`text-generation-server` lets you download the model with `download-weight... | text-generation-inference/docs/source/basic_tutorials/using_cli.md/0 | {
"file_path": "text-generation-inference/docs/source/basic_tutorials/using_cli.md",
"repo_id": "text-generation-inference",
"token_count": 323
} |
{
"details": {
"best_of_sequences": null,
"finish_reason": "eos_token",
"generated_tokens": 76,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 18183,
"logprob": -1.5195312,
"special": false,
"text": " Deep"
},
{
"id": 6832,
"l... | text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8a8_int_dynamic_weight/test_compressed_tensors_w8a8_int_dynamic_weight.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_compressed_tensors_w8a8_int_dynamic_weight/test_compressed_tensors_w8a8_int_dynamic_weight.json",
"repo_id": "text-generation-inference",
"token_count": 5893
} |
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "The image depicts an anthropomorphic rabbit, wearing a spacesuit, standing in a barren, rocky landscape that resembles the surface of another planet, possibly Mars. The rabbit has a red... | text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2_vl/test_flash_qwen2_vl_simple.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_flash_qwen2_vl/test_flash_qwen2_vl_simple.json",
"repo_id": "text-generation-inference",
"token_count": 353
} |
{
"details": {
"finish_reason": "length",
"generated_tokens": 40,
"prefill": [],
"seed": null,
"tokens": [
{
"id": 13,
"logprob": -1.0488281,
"special": false,
"text": "\n"
},
{
"id": 13,
"logprob": -1.0800781,
"special": fa... | text-generation-inference/integration-tests/models/__snapshots__/test_lora_mistral/test_lora_mistral_without_adapter.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_lora_mistral/test_lora_mistral_without_adapter.json",
"repo_id": "text-generation-inference",
"token_count": 3130
} |
import pytest
@pytest.fixture(scope="module")
def bloom_560_handle(launcher):
with launcher("bigscience/bloom-560m", num_shard=1) as handle:
yield handle
@pytest.fixture(scope="module")
async def bloom_560(bloom_560_handle):
await bloom_560_handle.health(240)
return bloom_560_handle.client
@py... | text-generation-inference/integration-tests/models/test_bloom_560m.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_bloom_560m.py",
"repo_id": "text-generation-inference",
"token_count": 783
} |
import pytest
@pytest.fixture(scope="module")
def flash_gemma_gptq_handle(launcher):
with launcher("TechxGenus/gemma-2b-GPTQ", num_shard=1, quantize="gptq") as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_gemma_gptq(flash_gemma_gptq_handle):
await flash_gemma_gptq_handle.heal... | text-generation-inference/integration-tests/models/test_flash_gemma_gptq.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_gemma_gptq.py",
"repo_id": "text-generation-inference",
"token_count": 804
} |
import pytest
@pytest.fixture(scope="module")
def flash_mixtral_gptq_handle(launcher):
with launcher(
"TheBloke/Mixtral-8x7B-Instruct-v0.1-GPTQ",
revision="gptq-4bit-128g-actorder_True",
num_shard=2,
) as handle:
yield handle
@pytest.fixture(scope="module")
async def flash_mi... | text-generation-inference/integration-tests/models/test_flash_mixtral_gptq.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_flash_mixtral_gptq.py",
"repo_id": "text-generation-inference",
"token_count": 950
} |
import pytest
@pytest.fixture(scope="module")
def idefics_handle(launcher):
with launcher(
"HuggingFaceM4/idefics-9b-instruct", num_shard=2, dtype="float16"
) as handle:
yield handle
@pytest.fixture(scope="module")
async def idefics(idefics_handle):
await idefics_handle.health(300)
r... | text-generation-inference/integration-tests/models/test_idefics.py/0 | {
"file_path": "text-generation-inference/integration-tests/models/test_idefics.py",
"repo_id": "text-generation-inference",
"token_count": 782
} |
[tool.poetry]
name = "text-generation-integration-tests"
version = "2.0.1"
description = "Text Generation Inference integration tests"
authors = ["Nicolas Patry <nicolas@huggingface.co>"]
[tool.poetry.dependencies]
pydantic = "> 2, < 3"
python = ">=3.10,<3.13"
syrupy = "^4.7.1"
text-generation = "^0.6.0"
pytest = "^7.... | text-generation-inference/integration-tests/pyproject.toml/0 | {
"file_path": "text-generation-inference/integration-tests/pyproject.toml",
"repo_id": "text-generation-inference",
"token_count": 184
} |
use crate::infer::InferError;
use crate::{
FunctionDefinition, FunctionRef, FunctionsMap, JsonSchemaTool, Properties, Tool, ToolChoice,
};
use serde_json::{json, Map, Value};
use std::collections::HashMap;
pub(crate) struct ToolGrammar {}
impl ToolGrammar {
// find a tool by name
fn find_tool_by_name(tool... | text-generation-inference/router/src/infer/tool_grammar.rs/0 | {
"file_path": "text-generation-inference/router/src/infer/tool_grammar.rs",
"repo_id": "text-generation-inference",
"token_count": 2640
} |
flash_att_commit := 3a9bfd076f98746c73362328958dbc68d145fbec
build-flash-attention:
if [ ! -d 'flash-attention' ]; then \
pip install -U packaging ninja --no-cache-dir && \
git clone https://github.com/HazyResearch/flash-attention.git; \
fi
cd flash-attention && git fetch && git checkout $(flash_att_commit) &&... | text-generation-inference/server/Makefile-flash-att/0 | {
"file_path": "text-generation-inference/server/Makefile-flash-att",
"repo_id": "text-generation-inference",
"token_count": 231
} |
#include "q4_matmul.cuh"
#include "column_remap.cuh"
#include <ATen/cuda/CUDAContext.h>
#include "../util.cuh"
#include "../matrix.cuh"
#include "../cu_compat.cuh"
#include "../cuda_buffers.cuh"
#if defined(USE_ROCM)
#include "../hip_compat.cuh"
#endif
const int THREADS_X = 32; // Block size and thread count alo... | text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matmul.cu/0 | {
"file_path": "text-generation-inference/server/exllama_kernels/exllama_kernels/cuda_func/q4_matmul.cu",
"repo_id": "text-generation-inference",
"token_count": 4211
} |
#include "compat.cuh"
__forceinline__ __device__ half2 dot22_8(half2(&dq)[4], const half* a_ptr, const half2 g_result, const half qs_h)
{
half2 result = {};
const half2* a2_ptr = (const half2*)a_ptr;
#pragma unroll
for (int i = 0; i < 4; i++) result = __hfma2(dq[i], *a2_ptr++, result);
return __hfm... | text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel.cuh/0 | {
"file_path": "text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel.cuh",
"repo_id": "text-generation-inference",
"token_count": 11459
} |
import pytest
import torch
from text_generation_server.utils.weights import (
DefaultWeightsLoader,
Weights,
WeightsLoader,
)
from text_generation_server.layers.gptq import GPTQWeight, GPTQWeightsLoader
from text_generation_server.layers.exl2 import Exl2Weight, Exl2WeightsLoader
from text_generation_server.... | text-generation-inference/server/tests/utils/test_weights.py/0 | {
"file_path": "text-generation-inference/server/tests/utils/test_weights.py",
"repo_id": "text-generation-inference",
"token_count": 17926
} |
from typing import Tuple
from dataclasses import dataclass, field
from loguru import logger
import torch
from text_generation_server.layers.fp8 import fp8_quantize
from text_generation_server.models.globals import ATTENTION, BLOCK_SIZE
from text_generation_server.utils.import_utils import SYSTEM
from text_generation_... | text-generation-inference/server/text_generation_server/layers/attention/kv_cache.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/attention/kv_cache.py",
"repo_id": "text-generation-inference",
"token_count": 4988
} |
from dataclasses import dataclass
import os
from typing import Optional, Tuple, Type, Union, List
import torch
from loguru import logger
from text_generation_server.utils.import_utils import SYSTEM
from text_generation_server.utils.weights import (
Weight,
WeightsLoader,
UnquantizedWeight,
Weights,
)
... | text-generation-inference/server/text_generation_server/layers/fp8.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/fp8.py",
"repo_id": "text-generation-inference",
"token_count": 10534
} |
import functools
from typing import List, Tuple
import numpy
import torch
from text_generation_server.utils.import_utils import SYSTEM
try:
import marlin_kernels
except ImportError:
marlin_kernels = None
try:
major, _minor = torch.cuda.get_device_capability()
has_sm_8_0 = major >= 8
except Exception:... | text-generation-inference/server/text_generation_server/layers/marlin/util.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/layers/marlin/util.py",
"repo_id": "text-generation-inference",
"token_count": 1782
} |
from typing import Optional, Tuple
import torch
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_attn_mask_utils import (
_create_4d_causal_attention_mask,
_prepare_4d_attention_mask,
)
from transformers.modeling_outputs import (
BaseModelOutputWithPooling,
)
fro... | text-generation-inference/server/text_generation_server/models/custom_modeling/clip.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/clip.py",
"repo_id": "text-generation-inference",
"token_count": 13765
} |
import torch
import torch.distributed
from torch import nn
from transformers.activations import ACT2FN
from typing import Optional, List, Tuple
from text_generation_server.layers.attention import (
paged_attention,
attention,
Seqlen,
)
from text_generation_server.layers import (
TensorParallelRowLinea... | text-generation-inference/server/text_generation_server/models/custom_modeling/flash_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": 6486
} |
# coding=utf-8
# Copyright 2022 EleutherAI 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
#... | text-generation-inference/server/text_generation_server/models/custom_modeling/neox_modeling.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/custom_modeling/neox_modeling.py",
"repo_id": "text-generation-inference",
"token_count": 14228
} |
import torch
import torch.distributed
import time
from dataclasses import dataclass
from opentelemetry import trace
from transformers import (
AutoTokenizer,
AutoModelForSeq2SeqLM,
PreTrainedTokenizerBase,
AutoConfig,
)
from typing import Optional, Tuple, List, Type, Dict
from text_generation_server.uti... | text-generation-inference/server/text_generation_server/models/seq2seq_lm.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/models/seq2seq_lm.py",
"repo_id": "text-generation-inference",
"token_count": 17976
} |
import copy
from abc import ABC
from collections import defaultdict
from typing import TYPE_CHECKING, Dict, List, Tuple, Type, Union
from text_generation_server.utils.merges.utils import (
calculate_majority_sign_mask,
disjoint_merge,
prune,
)
import torch
if TYPE_CHECKING:
from text_generation_server.... | text-generation-inference/server/text_generation_server/utils/merges/strategies.py/0 | {
"file_path": "text-generation-inference/server/text_generation_server/utils/merges/strategies.py",
"repo_id": "text-generation-inference",
"token_count": 3074
} |
<p align="center">
<br>
<img src="https://huggingface.co/landing/assets/tokenizers/tokenizers-logo.png" width="600"/>
<br>
<p>
<p align="center">
<img alt="Build" src="https://github.com/huggingface/tokenizers/workflows/Rust/badge.svg">
<a href="https://github.com/huggingface/tokenizers/blob/main/LI... | tokenizers/README.md/0 | {
"file_path": "tokenizers/README.md",
"repo_id": "tokenizers",
"token_count": 1127
} |
/* eslint-disable */
var globRequire = require;
describe("pipelineExample", () => {
// This is a hack to let us require using path similar to what the user has to use
function require(mod: string) {
if (mod.startsWith("tokenizers")) {
// let path = mod.slice("tokenizers".length);
... | tokenizers/bindings/node/examples/documentation/pipeline.test.ts/0 | {
"file_path": "tokenizers/bindings/node/examples/documentation/pipeline.test.ts",
"repo_id": "tokenizers",
"token_count": 2710
} |
use crate::arc_rwlock_serde;
use crate::tasks::models::{BPEFromFilesTask, WordLevelFromFilesTask, WordPieceFromFilesTask};
use crate::trainers::Trainer;
use napi::bindgen_prelude::*;
use napi_derive::napi;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync:... | tokenizers/bindings/node/src/models.rs/0 | {
"file_path": "tokenizers/bindings/node/src/models.rs",
"repo_id": "tokenizers",
"token_count": 3681
} |
[package]
name = "tokenizers-python"
version = "0.21.0-dev.0"
authors = ["Anthony MOI <m.anthony.moi@gmail.com>"]
edition = "2021"
[lib]
name = "tokenizers"
crate-type = ["cdylib"]
[dependencies]
rayon = "1.10"
serde = { version = "1.0", features = ["rc", "derive"] }
serde_json = "1.0"
libc = "0.2"
env_logger = "0.11... | tokenizers/bindings/python/Cargo.toml/0 | {
"file_path": "tokenizers/bindings/python/Cargo.toml",
"repo_id": "tokenizers",
"token_count": 282
} |
.tokenized-text {
width:100%;
padding:2rem;
max-height: 400px;
overflow-y: auto;
box-sizing:border-box;
line-height:4rem; /* Lots of space between lines */
font-family: "Roboto Light", "Ubuntu Light", "Ubuntu", monospace;
box-shadow: 2px 2px 2px rgba(0,0,0,0.2);
background-color: rgb... | tokenizers/bindings/python/py_src/tokenizers/tools/visualizer-styles.css/0 | {
"file_path": "tokenizers/bindings/python/py_src/tokenizers/tools/visualizer-styles.css",
"repo_id": "tokenizers",
"token_count": 1806
} |
use std::sync::{Arc, RwLock};
use pyo3::exceptions;
use pyo3::exceptions::PyException;
use pyo3::prelude::*;
use pyo3::types::*;
use serde::ser::SerializeStruct;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use tk::normalizer::SplitDelimiterBehavior;
use tk::pre_tokenizers::bert::BertPreTokenizer;
u... | tokenizers/bindings/python/src/pre_tokenizers.rs/0 | {
"file_path": "tokenizers/bindings/python/src/pre_tokenizers.rs",
"repo_id": "tokenizers",
"token_count": 17184
} |
import pytest
from tokenizers import BertWordPieceTokenizer
from ..utils import bert_files, data_dir
class TestEncoding:
@pytest.fixture(scope="class")
def encodings(self, bert_files):
tokenizer = BertWordPieceTokenizer.from_file(bert_files["vocab"])
single_encoding = tokenizer.encode("I lov... | tokenizers/bindings/python/tests/bindings/test_encoding.py/0 | {
"file_path": "tokenizers/bindings/python/tests/bindings/test_encoding.py",
"repo_id": "tokenizers",
"token_count": 1991
} |
import pytest
from tokenizers import SentencePieceBPETokenizer, SentencePieceUnigramTokenizer
class TestSentencePieceBPE:
def test_train_from_iterator(self):
text = ["A first sentence", "Another sentence", "And a last one"]
tokenizer = SentencePieceBPETokenizer()
tokenizer.train_from_iter... | tokenizers/bindings/python/tests/implementations/test_sentencepiece.py/0 | {
"file_path": "tokenizers/bindings/python/tests/implementations/test_sentencepiece.py",
"repo_id": "tokenizers",
"token_count": 1118
} |
# Trainers
<tokenizerslangcontent>
<python>
## BpeTrainer
[[autodoc]] tokenizers.trainers.BpeTrainer
## UnigramTrainer
[[autodoc]] tokenizers.trainers.UnigramTrainer
## WordLevelTrainer
[[autodoc]] tokenizers.trainers.WordLevelTrainer
## WordPieceTrainer
[[autodoc]] tokenizers.trainers.WordPieceTrainer
</python... | tokenizers/docs/source-doc-builder/api/trainers.mdx/0 | {
"file_path": "tokenizers/docs/source-doc-builder/api/trainers.mdx",
"repo_id": "tokenizers",
"token_count": 183
} |
/* Our DOM objects */
/* Version control */
.selectors {
margin-bottom: 10px;
}
.dropdown-button {
display: inline-block;
width: 50%;
background-color: #6670FF;
color: white;
border: none;
padding: 5px;
font-size: 15px;
cursor: pointer;
}
.dropdown-button:hover, .dropdown-button:... | tokenizers/docs/source/_static/css/huggingface.css/0 | {
"file_path": "tokenizers/docs/source/_static/css/huggingface.css",
"repo_id": "tokenizers",
"token_count": 2708
} |
Training from memory
----------------------------------------------------------------------------------------------------
In the `Quicktour <quicktour>`__, we saw how to build and train a tokenizer using text files,
but we can actually use any Python Iterator. In this section we'll see a few different ways of
training... | tokenizers/docs/source/tutorials/python/training_from_memory.rst/0 | {
"file_path": "tokenizers/docs/source/tutorials/python/training_from_memory.rst",
"repo_id": "tokenizers",
"token_count": 1149
} |
[package]
name = "unstable_wasm"
version = "0.1.0"
authors = ["Nicolas Patry"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[features]
default = ["console_error_panic_hook"]
[dependencies]
wasm-bindgen = "0.2.63"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them ... | tokenizers/tokenizers/examples/unstable_wasm/Cargo.toml/0 | {
"file_path": "tokenizers/tokenizers/examples/unstable_wasm/Cargo.toml",
"repo_id": "tokenizers",
"token_count": 364
} |
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require('path');
module.exports = {
entry: "./bootstrap.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bootstrap.js",
},
mode: "development",
plugins: [
new CopyWebpackPlugin(['index.html'])
],
};
| tokenizers/tokenizers/examples/unstable_wasm/www/webpack.config.js/0 | {
"file_path": "tokenizers/tokenizers/examples/unstable_wasm/www/webpack.config.js",
"repo_id": "tokenizers",
"token_count": 114
} |
//! Popular tokenizer models.
pub mod bpe;
pub mod unigram;
pub mod wordlevel;
pub mod wordpiece;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::models::bpe::{BpeTrainer, BPE};
use crate::models::unigram::{Unigram, UnigramTrai... | tokenizers/tokenizers/src/models/mod.rs/0 | {
"file_path": "tokenizers/tokenizers/src/models/mod.rs",
"repo_id": "tokenizers",
"token_count": 6331
} |
use crate::tokenizer::{NormalizedString, Normalizer, Result};
pub use spm_precompiled::Precompiled;
use std::cmp::Ordering;
use unicode_segmentation::UnicodeSegmentation;
fn replace(transformations: &mut Vec<(char, isize)>, old_part: &str, new_part: &str) {
let old_count = old_part.chars().count() as isize;
le... | tokenizers/tokenizers/src/normalizers/precompiled.rs/0 | {
"file_path": "tokenizers/tokenizers/src/normalizers/precompiled.rs",
"repo_id": "tokenizers",
"token_count": 1432
} |
use crate::pre_tokenizers::unicode_scripts::scripts::{get_script, Script};
use crate::tokenizer::{normalizer::Range, PreTokenizedString, PreTokenizer, Result};
use crate::utils::macro_rules_attribute;
#[derive(Clone, Debug, PartialEq, Eq)]
#[macro_rules_attribute(impl_serde_type!)]
pub struct UnicodeScripts;
impl Uni... | tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/pre_tokenizer.rs/0 | {
"file_path": "tokenizers/tokenizers/src/pre_tokenizers/unicode_scripts/pre_tokenizer.rs",
"repo_id": "tokenizers",
"token_count": 2584
} |
use crate::tokenizer::pattern::Pattern;
use crate::Offsets;
use fancy_regex::Regex;
use std::error::Error;
#[derive(Debug)]
pub struct SysRegex {
regex: Regex,
}
impl SysRegex {
pub fn find_iter<'r, 't>(&'r self, inside: &'t str) -> Matches<'r, 't> {
Matches(self.regex.find_iter(inside))
}
pu... | tokenizers/tokenizers/src/utils/fancy.rs/0 | {
"file_path": "tokenizers/tokenizers/src/utils/fancy.rs",
"repo_id": "tokenizers",
"token_count": 823
} |
use tokenizers::models::bpe::BPE;
use tokenizers::pre_tokenizers::whitespace::Whitespace;
use tokenizers::{DecoderWrapper, NormalizerWrapper, PostProcessorWrapper, PreTokenizerWrapper};
use tokenizers::{Model, Tokenizer, TokenizerBuilder};
#[test]
fn bpe_values_after_training() {
let mut tokenizer = TokenizerBuild... | tokenizers/tokenizers/tests/training.rs/0 | {
"file_path": "tokenizers/tokenizers/tests/training.rs",
"repo_id": "tokenizers",
"token_count": 851
} |
# Accessing Private/Gated Models
<Tip>
Due to the possibility of leaking access tokens to users of your website or web application, we only support accessing private/gated models from server-side environments (e.g., Node.js) that have access to the process' environment variables.
</Tip>
## Step 1: Generating a Use... | transformers.js/docs/source/guides/private.md/0 | {
"file_path": "transformers.js/docs/source/guides/private.md",
"repo_id": "transformers.js",
"token_count": 711
} |
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
| transformers.js/examples/cross-encoder/src/main.jsx/0 | {
"file_path": "transformers.js/examples/cross-encoder/src/main.jsx",
"repo_id": "transformers.js",
"token_count": 87
} |
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
html,
body {
height: 100%;
}
body {
padding: 16px 32px;
}
body,
#container,
#upload-button {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
h1 {
text-align: center;
}
#contain... | transformers.js/examples/depth-anything-client/style.css/0 | {
"file_path": "transformers.js/examples/depth-anything-client/style.css",
"repo_id": "transformers.js",
"token_count": 474
} |
{
"name": "extension",
"version": "0.0.1",
"description": "Transformers.js | Sample browser extension",
"scripts": {
"build": "webpack",
"dev": "webpack --watch"
},
"type": "module",
"author": "Xenova",
"license": "MIT",
"devDependencies": {
"copy-webpack-plugin": "^11.0.0",
"html-webp... | transformers.js/examples/extension/package.json/0 | {
"file_path": "transformers.js/examples/extension/package.json",
"repo_id": "transformers.js",
"token_count": 197
} |
import { useState, useRef } from 'react';
const EXAMPLE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/beetle.png';
const ImageInput = ({ onImageChange, ...props }) => {
const [imagePreview, setImagePreview] = useState(null);
const fileInputRef = useRef(null);
const readF... | transformers.js/examples/florence2-webgpu/src/components/ImageInput.jsx/0 | {
"file_path": "transformers.js/examples/florence2-webgpu/src/components/ImageInput.jsx",
"repo_id": "transformers.js",
"token_count": 1106
} |
import './globals.css'
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}
export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={... | transformers.js/examples/next-client/src/app/layout.js/0 | {
"file_path": "transformers.js/examples/next-client/src/app/layout.js",
"repo_id": "transformers.js",
"token_count": 128
} |
// Create a custom request handler for the /classify route.
// For more information, see https://nextjs.org/docs/app/building-your-application/routing/router-handlers
import { NextResponse } from 'next/server'
import PipelineSingleton from './pipeline.js';
export async function GET(request) {
const text = request... | transformers.js/examples/next-server/src/app/classify/route.js/0 | {
"file_path": "transformers.js/examples/next-server/src/app/classify/route.js",
"repo_id": "transformers.js",
"token_count": 250
} |
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.language-container {
display: flex;
gap: 20px;
}
.textbox-container {
display: flex;
justify-content: center;
gap: 20px;
width: 800px;
}
.textbox-container>textarea, .language-selector {
width: 50%;
}
.language-se... | transformers.js/examples/react-translator/src/App.css/0 | {
"file_path": "transformers.js/examples/react-translator/src/App.css",
"repo_id": "transformers.js",
"token_count": 383
} |
import { env, AutoTokenizer, CLIPTextModelWithProjection } from '@xenova/transformers';
import { getCachedFile, getCachedJSON } from './utils.js';
const EMBED_DIM = 512;
// Skip local model check
env.allowLocalModels = false;
class ApplicationSingleton {
static model_id = 'Xenova/clip-vit-base-patch16';
sta... | transformers.js/examples/semantic-image-search-client/src/app/worker.js/0 | {
"file_path": "transformers.js/examples/semantic-image-search-client/src/app/worker.js",
"repo_id": "transformers.js",
"token_count": 1518
} |
import Image from 'next/image'
import { blurHashToDataURL } from '../utils.js'
export function ImageGrid({ images, setCurrentImage }) {
return (
<div className="columns-2 gap-4 sm:columns-3 xl:columns-4 2xl:columns-5">
{images && images.map(({
photo_id,
photo_url... | transformers.js/examples/semantic-image-search/src/app/components/ImageGrid.jsx/0 | {
"file_path": "transformers.js/examples/semantic-image-search/src/app/components/ImageGrid.jsx",
"repo_id": "transformers.js",
"token_count": 1339
} |
import React, { useState, useEffect, useRef } from 'react';
import AudioPlayer from './components/AudioPlayer';
import Progress from './components/Progress';
import { SPEAKERS, DEFAULT_SPEAKER } from './constants';
const App = () => {
// Model loading
const [ready, setReady] = useState(null);
const [disabled, ... | transformers.js/examples/text-to-speech-client/src/App.jsx/0 | {
"file_path": "transformers.js/examples/text-to-speech-client/src/App.jsx",
"repo_id": "transformers.js",
"token_count": 2478
} |
import './style.css';
import { env, AutoModel, ones } from '@xenova/transformers';
import Chart from 'chart.js/auto';
// Throw an error if WebGPU is not supported
if (!navigator.gpu) {
const err = 'WebGPU is not supported by this browser.';
alert(err)
throw Error(err);
}
env.backends.onnx.wasm.wasmPaths = 'http... | transformers.js/examples/webgpu-embedding-benchmark/main.js/0 | {
"file_path": "transformers.js/examples/webgpu-embedding-benchmark/main.js",
"repo_id": "transformers.js",
"token_count": 3269
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.