repo_id
stringlengths
15
89
file_path
stringlengths
27
180
content
stringlengths
1
2.23M
__index_level_0__
int64
0
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/models/test_santacoder.py
import pytest from text_generation_server.pb import generate_pb2 from text_generation_server.models.causal_lm import CausalLMBatch from text_generation_server.models.santacoder import SantaCoder @pytest.fixture(scope="session") def default_santacoder(): return SantaCoder("bigcode/santacoder") @pytest.fixture d...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/utils/test_tokens.py
import torch from text_generation_server.utils.tokens import ( StopSequenceCriteria, StoppingCriteria, FinishReason, batch_top_tokens, ) def test_stop_sequence_criteria(): criteria = StopSequenceCriteria("/test;") assert not criteria("/") assert not criteria("/test") assert criteria("...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/utils/test_convert.py
from text_generation_server.utils.hub import ( download_weights, weight_hub_files, weight_files, ) from text_generation_server.utils.convert import convert_files def test_convert_files(): model_id = "bigscience/bloom-560m" pt_filenames = weight_hub_files(model_id, extension=".bin") local_pt_f...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/utils/test_watermark.py
# 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...
0
hf_public_repos/text-generation-inference/server/tests
hf_public_repos/text-generation-inference/server/tests/utils/test_hub.py
import os import requests import tempfile import pytest import huggingface_hub.constants from huggingface_hub import hf_api import text_generation_server.utils.hub from text_generation_server.utils.hub import ( weight_hub_files, download_weights, weight_files, EntryNotFoundError, LocalEntryNotFou...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/exllamav2_kernels/setup.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension setup( name="exllamav2_kernels", ext_modules=[ CUDAExtension( name="exllamav2_kernels", sources=[ "exllamav2_kernels/ext.cpp", "exllamav2_kernels/cuda...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/config.h
#ifndef _config_h #define _config_h #define MAX_Q_GEMM_ROWS 50 #define MAX_Q_GEMM_WEIGHTS 4 // must be <= MAX_Q_GEMM_ROWS #define QMODE_2BIT 1 #define QMODE_3BIT 1 #define QMODE_4BIT 1 #define QMODE_5BIT 1 #define QMODE_6BIT 0 #define QMODE_8BIT 0 #endif
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/ext.cpp
#include <torch/extension.h> #include <c10/cuda/CUDAGuard.h> #include <ATen/cuda/CUDAContext.h> #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #include "config.h" #include "cuda/q_matrix.cuh" #include "cuda/q_gemm.cuh" #include "cpp/util.h" // Some decluttering macros #define...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cpp/util.h
#ifndef _util_h #define _util_h #define DBGS(__x) printf("%s\n", __x) #define DBGI(__x) printf("%s: %i\n", #__x, __x) #define DBGI2(__x, __y) printf("%s, %s: %i, %i\n", #__x, #__y, __x, __y) #define DBGI3(__x, __y, __z) printf("%s, %s, %s: %i, %i, %i\n", #__x, #__y, #__z, __x, __y, __z) #define DBGF(__x) printf("%s: %...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_matrix.cuh
#ifndef _q_matrix_cuh #define _q_matrix_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #define MAX_SUPERGROUPS 16 class QMatrix { public: int device; bool is_gptq; int height; int width; int groups; int gptq_groupsize; int rows_8; int rows...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/compat_gemm.cuh
#ifndef _compat_gemm_cuh #define _compat_gemm_cuh #if defined(USE_ROCM) // For some reason this include is not present anywhere in exllama_v2 codebase, but it is required // for symbols as hipblasHalf. #include <hipblas/hipblas.h> __host__ __forceinline__ hipblasStatus_t __compat_hipblasHgemm(hipblasHandle_t hand...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm.cu
#include "q_gemm.cuh" #include "util.cuh" #include "matrix_view.cuh" #include "../config.h" #include "quant/qdq_2.cuh" #include "quant/qdq_3.cuh" #include "quant/qdq_4.cuh" #include "quant/qdq_5.cuh" #include "quant/qdq_6.cuh" #include "quant/qdq_8.cuh" #define GPTQ_BLOCK_KN_SIZE 128 #define GPTQ_BLOCK_M_SIZE_MAX 8 #...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel.cuh
#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...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/compat.cuh
#ifndef _compat_cuh #define _compat_cuh // atomicAdd for half types, to support CC < 7.x __device__ __forceinline__ void atomicAdd_half(half* address, half val) { unsigned int * address_as_ui = (unsigned int *) ((char *)address - ((size_t)address & 2)); unsigned int old = *address_as_ui; unsigned int assu...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/matrix_view.cuh
#ifndef _matrix_view_cuh #define _matrix_view_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include "quant/qdq_util.cuh" class MatrixView_half { public: const half* data; const int height; const int width; __device__ __forceinline__ MatrixView_half(const half* data, const int height, const i...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm.cuh
#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...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_matrix.cu
#include "q_matrix.cuh" #include "matrix_view.cuh" #include "util.cuh" #include "quant/qdq_2.cuh" #include "quant/qdq_3.cuh" #include "quant/qdq_4.cuh" #include "quant/qdq_5.cuh" #include "quant/qdq_6.cuh" #include "quant/qdq_8.cuh" #define BLOCK_KN_SIZE 128 #define THREADS_X 32 #define THREADS_Y 32 // Shuffle quan...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/util.cuh
#ifndef _util_cuh #define _util_cuh #include <cuda_runtime.h> #include <cuda_fp16.h> #include <cstdint> #include <cstdio> #include <ATen/cuda/CUDAContext.h> #define DIVIDE(x, size) (((x) + (size) - 1) / (size)) #define DBGS(__x) printf("%s\n", __x) #define DBGI(__x) printf("%s: %i\n", #__x, __x) #define DBGI2(__x, _...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/q_gemm_kernel_gptq.cuh
#include "compat.cuh" __forceinline__ __device__ half2 dot22_8(half2(&dq)[4], const half* a_ptr, const half2 g_result) { 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 __hadd2(result, g_resu...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/quant/qdq_4.cuh
#ifndef _qdq_4_cuh #define _qdq_4_cuh #include "qdq_util.cuh" #include "../../config.h" #if QMODE_4BIT == 1 // Permutation: // // 77775555 33331111 66664444 22220000 __forceinline__ __device__ void shuffle_4bit_8 ( uint32_t* q, int stride ) { uint32_t qa = q[0]; uint32_t qb = 0; #pragma unroll...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/quant/qdq_3.cuh
#ifndef _qdq_3_cuh #define _qdq_3_cuh #include "qdq_util.cuh" #include "../../config.h" #if QMODE_3BIT == 1 // Permutation: // // v9997775 55333111 u8886664 44222000 (u, v lsb) // vjjjhhhf ffdddbbb uiiiggge eecccaaa // vtttrrrp ppnnnlll usssqqqo oommmkkk __forceinline__ __device__ void shuffle_3bit_32 ( uin...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/quant/qdq_2.cuh
#ifndef _qdq_2_cuh #define _qdq_2_cuh #include "qdq_util.cuh" #include "../../config.h" #if QMODE_2BIT == 1 // Permutation: // // ffddbb99 77553311 eeccaa88 66442200 __forceinline__ __device__ void shuffle_2bit_16 ( uint32_t* q, int stride ) { uint32_t qa = q[0]; uint32_t qb = 0; #pragma unrol...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/quant/qdq_8.cuh
#ifndef _qdq_8_cuh #define _qdq_8_cuh #include "qdq_util.cuh" #include "../../config.h" #if QMODE_8BIT == 1 // Not implemented #else __forceinline__ __device__ void shuffle_8bit_4 ( uint32_t* q, int stride ) { } __forceinline__ __device__ void dequant_8bit_8 ( const uint32_t q_0, const uint32_t ...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/quant/qdq_util.cuh
#ifndef _qdq_util_cuh #define _qdq_util_cuh union half2_uint32 { uint32_t as_uint32; half2 as_half2; __device__ half2_uint32(uint32_t val) : as_uint32(val) {} __device__ half2_uint32(half2 val) : as_half2(val) {} __device__ half2_uint32() : as_uint32(0) {} }; union half_uint16 { uint16_t as_ui...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/quant/qdq_5.cuh
#ifndef _qdq_5_cuh #define _qdq_5_cuh #include "qdq_util.cuh" #include "../../config.h" #if QMODE_5BIT == 1 // Permutation: // // v5555533 33311111 u4444422 22200000 (u, v lsb) // vbbbbb99 99977777 uaaaaa88 88866666 // vhhhhhff fffddddd ugggggee eeeccccc // vnnnnnll llljjjjj ummmmmkk kkkiiiii // vtttttrr rrrppp...
0
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda
hf_public_repos/text-generation-inference/server/exllamav2_kernels/exllamav2_kernels/cuda/quant/qdq_6.cuh
#ifndef _qdq_6_cuh #define _qdq_6_cuh #include "qdq_util.cuh" #include "../../config.h" #if QMODE_6BIT == 1 // Not implemented #else __forceinline__ __device__ void shuffle_6bit_16 ( uint32_t* q, int stride ) { } __forceinline__ __device__ void dequant_6bit_16 ( const uint32_t q_0, const uint32_...
0
hf_public_repos/text-generation-inference/server
hf_public_repos/text-generation-inference/server/custom_kernels/setup.py
from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension import torch extra_compile_args = ["-std=c++17"] if not torch.version.hip: extra_compile_args.append("-arch=compute_80") setup( name="custom_kernels", ext_modules=[ CUDAExtension( name="cus...
0
hf_public_repos/text-generation-inference/server/custom_kernels
hf_public_repos/text-generation-inference/server/custom_kernels/custom_kernels/fused_bloom_attention_cuda.cu
#include <ATen/Dispatch.h> #include <THC/THCAtomics.cuh> #include <ATen/ATen.h> #include <torch/torch.h> #include <vector> #include <optional> /** * Friendly reminder of how multithreading works in CUDA: https://developer.nvidia.com/blog/even-easier-introduction-cuda * Check example at https://github.com/thomasw21/Li...
0
hf_public_repos/text-generation-inference/server/custom_kernels
hf_public_repos/text-generation-inference/server/custom_kernels/custom_kernels/fused_attention_cuda.cu
#include <ATen/Dispatch.h> #include <THC/THCAtomics.cuh> #include <ATen/ATen.h> #include <torch/torch.h> #include <vector> #include <optional> /** * Friendly reminder of how multithreading works in CUDA: https://developer.nvidia.com/blog/even-easier-introduction-cuda * Check example at https://github.com/thomasw21/Li...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/docs/index.html
<html> <head> <!-- Load the latest Swagger UI code and style from npm using unpkg.com --> <script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script> <link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css"/> <title>Text Ge...
0
hf_public_repos/text-generation-inference
hf_public_repos/text-generation-inference/docs/openapi.json
{ "openapi": "3.0.3", "info": { "title": "Text Generation Inference", "description": "Text Generation Webserver", "contact": { "name": "Olivier Dehaene" }, "license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0" }, "version": "1.3.4" },...
0
hf_public_repos/text-generation-inference/docs
hf_public_repos/text-generation-inference/docs/source/index.md
# Text Generation Inference Text Generation Inference (TGI) is a toolkit for deploying and serving Large Language Models (LLMs). TGI enables high-performance text generation for the most popular open-source LLMs, including Llama, Falcon, StarCoder, BLOOM, GPT-NeoX, and T5. ![Text Generation Inference](https://hugging...
0
hf_public_repos/text-generation-inference/docs
hf_public_repos/text-generation-inference/docs/source/supported_models.md
# Supported Models and Hardware Text Generation Inference enables serving optimized models on specific hardware for the highest performance. The following sections list which models are hardware are supported. ## Supported Models The following models are optimized and can be served with TGI, which uses custom CUDA k...
0
hf_public_repos/text-generation-inference/docs
hf_public_repos/text-generation-inference/docs/source/quicktour.md
# Quick Tour The easiest way of getting started is using the official Docker container. Install Docker following [their installation instructions](https://docs.docker.com/get-docker/). Let's say you want to deploy [Falcon-7B Instruct](https://huggingface.co/tiiuae/falcon-7b-instruct) model with TGI. Here is an exampl...
0
hf_public_repos/text-generation-inference/docs
hf_public_repos/text-generation-inference/docs/source/installation.md
# Installation This section explains how to install the CLI tool as well as installing TGI from source. **The strongly recommended approach is to use Docker, as it does not require much setup. Check [the Quick Tour](./quicktour) to learn how to run TGI with Docker.** ## Install CLI You can use TGI command-line inter...
0
hf_public_repos/text-generation-inference/docs
hf_public_repos/text-generation-inference/docs/source/_toctree.yml
- sections: - local: index title: Text Generation Inference - local: quicktour title: Quick Tour - local: installation title: Installation - local: supported_models title: Supported Models and Hardware title: Getting started - sections: - local: basic_tutorials/consuming_tgi title: Consu...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/basic_tutorials/consuming_tgi.md
# Consuming Text Generation Inference There are many ways you can consume Text Generation Inference server in your applications. After launching, you can use the `/generate` route and make a `POST` request to get results from the server. You can also use the `/generate_stream` route if you want TGI to return a stream ...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/basic_tutorials/non_core_models.md
# Non-core Model Serving TGI supports various LLM architectures (see full list [here](../supported_models)). If you wish to serve a model that is not one of the supported models, TGI will fallback to the `transformers` implementation of that model. This means you will be unable to use some of the features introduced b...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/basic_tutorials/preparing_model.md
# Preparing the Model Text Generation Inference improves the model in several aspects. ## Quantization TGI supports [bits-and-bytes](https://github.com/TimDettmers/bitsandbytes#bitsandbytes), [GPT-Q](https://arxiv.org/abs/2210.17323) and [AWQ](https://arxiv.org/abs/2306.00978) quantization. To speed up inference wi...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/basic_tutorials/gated_model_access.md
# Serving Private & Gated Models If the model you wish to serve is behind gated access or the model repository on Hugging Face Hub is private, and you have access to the model, you can provide your Hugging Face Hub access token. You can generate and copy a read token from [Hugging Face Hub tokens page](https://hugging...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/basic_tutorials/using_cli.md
# 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-weights...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/basic_tutorials/launcher.md
# Text-generation-launcher arguments <!-- WRAP CODE BLOCKS --> ```shell Text Generation Launcher Usage: text-generation-launcher [OPTIONS] Options: ``` ## MODEL_ID ```shell --model-id <MODEL_ID> The name of the model to load. Can be a MODEL_ID as listed on <https://hf.co/models> like `gpt2` or `Open...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/conceptual/quantization.md
# Quantization TGI offers GPTQ and bits-and-bytes quantization to quantize large language models. ## Quantization with GPTQ GPTQ is a post-training quantization method to make the model smaller. It quantizes the layers by finding a compressed version of that weight, that will yield a minimum mean squared error like ...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/conceptual/tensor_parallelism.md
# Tensor Parallelism Tensor parallelism is a technique used to fit a large model in multiple GPUs. For example, when multiplying the input tensors with the first weight tensor, the matrix multiplication is equivalent to splitting the weight tensor column-wise, multiplying each column with the input separately, and the...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/conceptual/safetensors.md
# Safetensors Safetensors is a model serialization format for deep learning models. It is [faster](https://huggingface.co/docs/safetensors/speed) and safer compared to other serialization formats like pickle (which is used under the hood in many deep learning libraries). TGI depends on safetensors format mainly to e...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/conceptual/flash_attention.md
# Flash Attention Scaling the transformer architecture is heavily bottlenecked by the self-attention mechanism, which has quadratic time and memory complexity. Recent developments in accelerator hardware mainly focus on enhancing compute capacities and not memory and transferring data between hardware. This results in...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/conceptual/streaming.md
# Streaming ## What is Streaming? Token streaming is the mode in which the server returns the tokens one by one as the model generates them. This enables showing progressive generations to the user rather than waiting for the whole generation. Streaming is an essential aspect of the end-user experience as it reduces ...
0
hf_public_repos/text-generation-inference/docs/source
hf_public_repos/text-generation-inference/docs/source/conceptual/paged_attention.md
# PagedAttention LLMs struggle with memory limitations during generation. In the decoding part of generation, all the attention keys and values generated for previous tokens are stored in GPU memory for reuse. This is called _KV cache_, and it may take up a large amount of memory for large models and long sequences. ...
0
hf_public_repos/text-generation-inference/clients
hf_public_repos/text-generation-inference/clients/python/README.md
# Text Generation The Hugging Face Text Generation Python library provides a convenient way of interfacing with a `text-generation-inference` instance running on [Hugging Face Inference Endpoints](https://huggingface.co/inference-endpoints) or on the Hugging Face Hub. ## Get Started ### Install ```shell pip install...
0
hf_public_repos/text-generation-inference/clients
hf_public_repos/text-generation-inference/clients/python/pyproject.toml
[tool.poetry] name = "text-generation" version = "0.6.1" description = "Hugging Face Text Generation Python Client" license = "Apache-2.0" authors = ["Olivier Dehaene <olivier@huggingface.co>"] maintainers = ["Olivier Dehaene <olivier@huggingface.co>"] readme = "README.md" homepage = "https://github.com/huggingface/tex...
0
hf_public_repos/text-generation-inference/clients
hf_public_repos/text-generation-inference/clients/python/poetry.lock
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "aiohttp" version = "3.8.5" description = "Async http client/server framework (asyncio)" optional = false python-versions = ">=3.6" files = [ {file = "aiohttp-3.8.5-cp310-cp310-macosx_10_9_universal2.whl",...
0
hf_public_repos/text-generation-inference/clients
hf_public_repos/text-generation-inference/clients/python/Makefile
unit-tests: python -m pytest --cov=text_generation tests install: pip install pip --upgrade pip install -e .
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/text_generation/errors.py
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 _...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/text_generation/__init__.py
# 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 applicabl...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/text_generation/types.py
from enum import Enum from pydantic import BaseModel, validator from typing import Optional, List from text_generation.errors import ValidationError class Parameters(BaseModel): # Activate logits sampling do_sample: bool = False # Maximum number of generated tokens max_new_tokens: int = 20 # The ...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/text_generation/inference_api.py
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...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/text_generation/client.py
import json import requests from aiohttp import ClientSession, ClientTimeout from pydantic import ValidationError from typing import Dict, Optional, List, AsyncIterator, Iterator from text_generation.types import ( StreamResponse, Response, Request, Parameters, ) from text_generation.errors import par...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/tests/test_types.py
import pytest from text_generation.types import Parameters, Request from text_generation.errors import ValidationError def test_parameters_validation(): # Test best_of Parameters(best_of=1) with pytest.raises(ValidationError): Parameters(best_of=0) with pytest.raises(ValidationError): ...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/tests/test_errors.py
from text_generation.errors import ( parse_error, GenerationError, IncompleteGenerationError, OverloadedError, ValidationError, BadRequestError, ShardNotReadyError, ShardTimeoutError, NotFoundError, RateLimitExceededError, UnknownError, ) def test_generation_error(): pa...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/tests/conftest.py
import pytest from text_generation import __version__ from huggingface_hub.utils import build_hf_headers @pytest.fixture def flan_t5_xxl(): return "google/flan-t5-xxl" @pytest.fixture def fake_model(): return "fake/model" @pytest.fixture def unsupported_model(): return "gpt2" @pytest.fixture def ba...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/tests/test_inference_api.py
import pytest from text_generation import ( InferenceAPIClient, InferenceAPIAsyncClient, Client, AsyncClient, ) from text_generation.errors import NotSupportedError, NotFoundError from text_generation.inference_api import check_model_support, deployed_models def test_check_model_support(flan_t5_xxl, ...
0
hf_public_repos/text-generation-inference/clients/python
hf_public_repos/text-generation-inference/clients/python/tests/test_client.py
import pytest from text_generation import Client, AsyncClient from text_generation.errors import NotFoundError, ValidationError from text_generation.types import FinishReason, InputToken def test_generate(flan_t5_xxl_url, hf_headers): client = Client(flan_t5_xxl_url, hf_headers) response = client.generate("t...
0