index int64 0 0 | repo_id stringlengths 15 98 | file_path stringlengths 33 130 | content stringlengths 27 14.4M |
|---|---|---|---|
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tei-from-gcs-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tei-from-gcs-deployment/cpu-config/service.yaml | apiVersion: v1
kind: Service
metadata:
name: tei-service
namespace: hf-gke-namespace
spec:
selector:
app: tei-server
type: ClusterIP
ports:
- protocol: TCP
port: 8080
targetPort: 8080
|
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tei-from-gcs-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tei-from-gcs-deployment/cpu-config/storageclass.yaml | apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ssd
namespace: hf-gke-namespace
provisioner: pd.csi.storage.gke.io
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: pd-ssd
|
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tei-from-gcs-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tei-from-gcs-deployment/cpu-config/ingress.yaml | apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tei-ingress
namespace: hf-gke-namespace
# https://cloud.google.com/kubernetes-engine/docs/concepts/ingress
annotations:
kubernetes.io/ingress.class: "gce"
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tei-from-gcs-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tei-from-gcs-deployment/cpu-config/deployment.yaml | apiVersion: apps/v1
kind: Deployment
metadata:
name: tei-deployment
namespace: hf-gke-namespace
spec:
replicas: 1
selector:
matchLabels:
app: tei-server
template:
metadata:
labels:
app: tei-server
hf.co/model: BAAI--bge-base-en-v1.5
hf.co/task: text-embeddings
s... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke | hf_public_repos/Google-Cloud-Containers/examples/gke/trl-full-fine-tuning/job.yaml | apiVersion: batch/v1
kind: Job
metadata:
name: trl-full-sft
namespace: hf-gke-namespace
spec:
template:
metadata:
name: trl
labels:
app: trl
hf.co/model: google--gemma-2b
hf.co/dataset: timdettmers--openassistant-guanaco
annotations:
gke-gcsfuse/volumes: "true... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke | hf_public_repos/Google-Cloud-Containers/examples/gke/trl-full-fine-tuning/README.md | ---
title: Fine-tune Gemma 2B with PyTorch Training DLC using SFT on GKE
type: training
---
# Fine-tune Gemma 2B with PyTorch Training DLC using SFT on GKE
Gemma is a family of lightweight, state-of-the-art open models built from the same research and technology used to create the Gemini models, developed by Google D... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-llama-405b-deployment/README.md | ---
title: Deploy Llama 3.1 405B with TGI DLC on GKE
type: inference
---
# Deploy Llama 3.1 405B with TGI DLC on GKE
[Llama 3.1](https://huggingface.co/blog/llama31) is one of the latest LLMs from the Llama family released by Meta (latest is Llama 3.2 as of October 2024); three sizes: 8B for efficient deployment and ... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-llama-405b-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-llama-405b-deployment/config/service.yaml | apiVersion: v1
kind: Service
metadata:
name: tgi-service
spec:
selector:
app: tgi-server
type: ClusterIP
ports:
- protocol: TCP
port: 8080
targetPort: 8080
|
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-llama-405b-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-llama-405b-deployment/config/ingress.yaml | apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tgi-ingress
# https://cloud.google.com/kubernetes-engine/docs/concepts/ingress
annotations:
kubernetes.io/ingress.class: "gce"
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-llama-405b-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-llama-405b-deployment/config/deployment.yaml | apiVersion: apps/v1
kind: Deployment
metadata:
name: tgi-deployment
spec:
replicas: 1
selector:
matchLabels:
app: tgi-server
template:
metadata:
labels:
app: tgi-server
hf.co/model: meta-llama--Llama-3-405B-Instruct-FP8
hf.co/task: text-generation
spec:
cont... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment/README.md | ---
title: Deploy Qwen2 7B with TGI DLC from GCS on GKE
type: inference
---
# Deploy Qwen2 7B with TGI DLC from GCS on GKE
Qwen2 is the new series of Qwen Large Language Models (LLMs) built by Alibaba Cloud, with both base and instruction-tuned language models ranging from 0.5 to 72 billion parameters, including a Mi... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment/config/service.yaml | apiVersion: v1
kind: Service
metadata:
name: tgi-service
namespace: hf-gke-namespace
spec:
selector:
app: tgi-server
type: ClusterIP
ports:
- protocol: TCP
port: 8080
targetPort: 8080
|
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment/config/storageclass.yaml | apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ssd
namespace: hf-gke-namespace
provisioner: pd.csi.storage.gke.io
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
type: pd-ssd
|
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment/config/ingress.yaml | apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tgi-ingress
namespace: hf-gke-namespace
# https://cloud.google.com/kubernetes-engine/docs/concepts/ingress
annotations:
kubernetes.io/ingress.class: "gce"
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix... |
0 | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment | hf_public_repos/Google-Cloud-Containers/examples/gke/tgi-from-gcs-deployment/config/deployment.yaml | apiVersion: apps/v1
kind: Deployment
metadata:
name: tgi-deployment
namespace: hf-gke-namespace
spec:
replicas: 1
selector:
matchLabels:
app: tgi-server
template:
metadata:
labels:
app: tgi-server
hf.co/model: Qwen--Qwen2-7B-Instruct
hf.co/task: text-generation
... |
0 | hf_public_repos/Google-Cloud-Containers/docs | hf_public_repos/Google-Cloud-Containers/docs/source/features.mdx | # 🔥 Features & benefits
The Hugging Face DLCs provide ready-to-use, tested environments to train and deploy Hugging Face models. They can be used in combination with Google Cloud offerings including Google Kubernetes Engine (GKE) and Vertex AI. GKE is a fully-managed Kubernetes service in Google Cloud that can be use... |
0 | hf_public_repos/Google-Cloud-Containers/docs | hf_public_repos/Google-Cloud-Containers/docs/source/_toctree.yml | - sections:
- local: index
title: Hugging Face on Google Cloud
- local: features
title: Features & benefits
- local: resources
title: Other Resources
title: Getting Started
- sections:
- local: containers/introduction
title: Introduction
- local: containers/available
... |
0 | hf_public_repos/Google-Cloud-Containers/docs | hf_public_repos/Google-Cloud-Containers/docs/source/resources.mdx | # 📄 Other Resources
Learn how to use Hugging Face in Google Cloud by reading our blog posts, presentations, Google documentation and examples below.
## Blog posts
- [Hugging Face and Google partner for open AI collaboration](https://huggingface.co/blog/gcp-partnership)
- [Google Cloud TPUs made available to Hugging... |
0 | hf_public_repos/Google-Cloud-Containers/docs | hf_public_repos/Google-Cloud-Containers/docs/source/index.mdx | # Hugging Face on Google Cloud

Hugging Face collaborates with Google across open science, open source, cloud, and hardware to enable companies to build their own AI with the latest ... |
0 | hf_public_repos/Google-Cloud-Containers/docs/source | hf_public_repos/Google-Cloud-Containers/docs/source/containers/introduction.mdx | # Introduction
[Hugging Face Deep Learning Containers for Google Cloud](https://cloud.google.com/deep-learning-containers/docs/choosing-container#hugging-face) are a set of Docker images for training and deploying Transformers, Sentence Transformers, and Diffusers models on Google Cloud Vertex AI and Google Kubernetes... |
0 | hf_public_repos/Google-Cloud-Containers/docs/source | hf_public_repos/Google-Cloud-Containers/docs/source/containers/available.mdx | # Available DLCs on Google Cloud
Below you can find a listing of all the Deep Learning Containers (DLCs) available on Google Cloud.
<Tip>
The listing below only contains the latest version of each one of the Hugging Face DLCs, the full listing of the available published containers in Google Cloud can be found either... |
0 | hf_public_repos/Google-Cloud-Containers/docs | hf_public_repos/Google-Cloud-Containers/docs/scripts/auto-generate-examples.py | import os
import re
def process_readme_files():
print("Processing README.md files from examples/gke and examples/cloud-run...")
os.makedirs("docs/source/examples", exist_ok=True)
for dir in ["gke", "cloud-run", "vertex-ai/notebooks"]:
for root, _, files in os.walk(f"examples/{dir}"):
... |
0 | hf_public_repos/Google-Cloud-Containers/docs | hf_public_repos/Google-Cloud-Containers/docs/scripts/auto-update-toctree.py | import glob
import os
import re
from pathlib import Path
def update_toctree_yaml():
output_file = "docs/source/_toctree.yml"
dirs = ["vertex-ai", "gke", "cloud-run"]
with open(output_file, "a") as f:
f.write("# GENERATED CONTENT DO NOT EDIT!\n")
f.write("- sections:\n")
for dir... |
0 | hf_public_repos/Google-Cloud-Containers | hf_public_repos/Google-Cloud-Containers/containers/container.yaml | pytorch:
- type: training
accelerator: gpu
framework: 2.3.0
transformers: 4.42.3
python: 3.10
- type: inference
accelerator: cpu
framework: 2.2.2
transformers: 4.44.0
python: 3.11
- type: inference
accelerator: gpu
framework: 2.2.2
transformers: 4.44.0
python: 3.11
... |
0 | hf_public_repos/Google-Cloud-Containers | hf_public_repos/Google-Cloud-Containers/containers/README.md | # 🤗 Deep Learning Containers (DLCs)
This directory contains the Hugging Face Deep Learning Containers (DLCs) available for Google Cloud, divided by framework (PyTorch, TGI or TEI), with the difference that PyTorch covers both training and inference, while TGI and TEI are only for inference.
Additionally, the [`conta... |
0 | hf_public_repos/Google-Cloud-Containers/containers | hf_public_repos/Google-Cloud-Containers/containers/tei/README.md | # Text Embeddings Inference (TEI) Containers
[Text Embeddings Inference](https://github.com/huggingface/text-embeddings-inference) is a toolkit for deploying and serving open source text embeddings and sequence classification models developed by Hugging Face. TEI is a blazing fast inference solution that enables high-... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tei/gpu | hf_public_repos/Google-Cloud-Containers/containers/tei/gpu/1.2.2/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tei
RUN mkdir -p /tei
ADD https://github.com/huggingface/text-embeddings-inference/archive/refs/tags/v1.2.2.tar.gz /tei/sources.tar.gz
RUN tar -C /tei -xf /tei/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TEI original Dockerfile)
FROM nvi... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tei/gpu | hf_public_repos/Google-Cloud-Containers/containers/tei/gpu/1.4.0/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tei
RUN mkdir -p /tei
ADD https://github.com/huggingface/text-embeddings-inference/archive/refs/tags/v1.4.0.tar.gz /tei/sources.tar.gz
RUN tar -C /tei -xf /tei/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TEI original Dockerfile)
FROM nv... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tei/gpu | hf_public_repos/Google-Cloud-Containers/containers/tei/gpu/1.4.0/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tei/cpu | hf_public_repos/Google-Cloud-Containers/containers/tei/cpu/1.2.2/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tei
RUN mkdir -p /tei
ADD https://github.com/huggingface/text-embeddings-inference/archive/refs/tags/v1.2.2.tar.gz /tei/sources.tar.gz
RUN tar -C /tei -xf /tei/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TEI original Dockerfile)
FROM luk... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tei/cpu | hf_public_repos/Google-Cloud-Containers/containers/tei/cpu/1.4.0/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tei
RUN mkdir -p /tei
ADD https://github.com/huggingface/text-embeddings-inference/archive/refs/tags/v1.4.0.tar.gz /tei/sources.tar.gz
RUN tar -C /tei -xf /tei/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TEI original Dockerfile)
FROM lu... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tei/cpu | hf_public_repos/Google-Cloud-Containers/containers/tei/cpu/1.4.0/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch | hf_public_repos/Google-Cloud-Containers/containers/pytorch/training/README.md | # Hugging Face PyTorch Training Containers
The Hugging Face PyTorch Training Containers are Docker containers for training Hugging Face models on Google Cloud AI Platform. There are two containers depending on which accelerator is used, that is GPU and TPU at the moment. The containers come with all the necessary depe... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/training/gpu/2.3.0/transformers/4.42.3 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/training/gpu/2.3.0/transformers/4.42.3/py310/Dockerfile | FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
LABEL maintainer="Hugging Face"
ARG DEBIAN_FRONTEND=noninteractive
# Versions
ARG CUDA="cu121"
ARG PYTORCH="2.3.0"
ARG FLASH_ATTN="2.5.8"
ARG TRANSFORMERS="4.42.3"
ARG DIFFUSERS="0.28.0"
ARG PEFT="0.11.1"
ARG TRL="0.9.6"
ARG BITSANDBYTES="0.43.1"
ARG DATASETS="2.19.1"
ARG ACC... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/training/gpu/2.3.0/transformers/4.41.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/training/gpu/2.3.0/transformers/4.41.1/py310/Dockerfile | FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
LABEL maintainer="Hugging Face"
ARG DEBIAN_FRONTEND=noninteractive
# Versions
ARG CUDA="cu121"
ARG PYTORCH="2.3.0"
ARG FLASH_ATTN="2.5.8"
ARG TRANSFORMERS="4.42.3"
ARG DIFFUSERS="0.28.0"
ARG PEFT="0.11.1"
ARG TRL="0.9.4"
ARG BITSANDBYTES="0.43.1"
ARG DATASETS="2.19.1"
ARG ACC... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/training/tpu/2.4.0/transformers/4.41.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/training/tpu/2.4.0/transformers/4.41.1/py310/Dockerfile | FROM us-central1-docker.pkg.dev/tpu-pytorch-releases/docker/xla@sha256:f6504628f3ab57acd4bc0de1fed0b1b8d6a4b71c6f11bc2b08df971b5627162d
# The nightly image with nightly version of PyTorch=2.4, Python=3.10
# Read more about it here: https://github.com/pytorch/xla?tab=readme-ov-file#docker
LABEL maintainer="Hugging Face... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/README.md | # Hugging Face PyTorch Inference Containers
The Hugging Face PyTorch Inference containers are Python containers for serving 🤗`transformers` models with FastAPI on Google Cloud AI Platform. There are two containers at the moment, one for CPU and one for GPU; and one for TPU (which is coming soon).
The PyTorch Inferen... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.3.1/transformers/4.46.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.3.1/transformers/4.46.1/py311/Dockerfile | FROM nvidia/cuda:12.1.0-devel-ubuntu22.04
SHELL ["/bin/bash", "-c"]
LABEL maintainer="Hugging Face"
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# Install required dependencies
RUN apt-get update && \
apt-get install software-properties-common -y && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-ge... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.3.1/transformers/4.46.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.3.1/transformers/4.46.1/py311/entrypoint.sh | #!/bin/bash
# Define the default port
PORT=5000
# Check if AIP_MODE is set and adjust the port for Vertex AI
if [[ ! -z "${AIP_MODE}" ]]; then
PORT=${AIP_HTTP_PORT}
fi
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceed... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.2.2/transformers/4.41.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.2.2/transformers/4.41.1/py311/Dockerfile | FROM nvidia/cuda:12.1.0-devel-ubuntu22.04
SHELL ["/bin/bash", "-c"]
LABEL maintainer="Hugging Face"
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
RUN apt-get update && \
apt-get install software-properties-common -y && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get -y upgrade --only-upgrade syst... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.2.2/transformers/4.41.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.2.2/transformers/4.41.1/py311/entrypoint.sh | #!/bin/bash
# Define the default port
PORT=5000
# Check if AIP_MODE is set and adjust the port for Vertex AI
if [[ ! -z "${AIP_MODE}" ]]; then
PORT=${AIP_HTTP_PORT}
fi
# Start the server
uvicorn huggingface_inference_toolkit.webservice_starlette:app --host 0.0.0.0 --port ${PORT}
|
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.2.2/transformers/4.44.0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.2.2/transformers/4.44.0/py311/Dockerfile | FROM nvidia/cuda:12.1.0-devel-ubuntu22.04
SHELL ["/bin/bash", "-c"]
LABEL maintainer="Hugging Face"
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
RUN apt-get update && \
apt-get install software-properties-common -y && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get -y upgrade --only-upgrade syst... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.2.2/transformers/4.44.0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/gpu/2.2.2/transformers/4.44.0/py311/entrypoint.sh | #!/bin/bash
# Define the default port
PORT=5000
# Check if AIP_MODE is set and adjust the port for Vertex AI
if [[ ! -z "${AIP_MODE}" ]]; then
PORT=${AIP_HTTP_PORT}
fi
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceed... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.3.1/transformers/4.46.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.3.1/transformers/4.46.1/py311/Dockerfile | FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]
LABEL maintainer="Hugging Face"
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# Install required dependencies
RUN apt-get update && \
apt-get install software-properties-common -y && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get -y upgrade --only-upgr... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.3.1/transformers/4.46.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.3.1/transformers/4.46.1/py311/entrypoint.sh | #!/bin/bash
# Define the default port
PORT=5000
# Check if AIP_MODE is set and adjust the port for Vertex AI
if [[ ! -z "${AIP_MODE}" ]]; then
PORT=${AIP_HTTP_PORT}
fi
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceed... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.2.2/transformers/4.41.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.2.2/transformers/4.41.1/py311/Dockerfile | FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]
LABEL maintainer="Hugging Face"
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
RUN apt-get update && \
apt-get install software-properties-common -y && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get -y upgrade --only-upgrade systemd openssl cryptsetup &... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.2.2/transformers/4.41.1 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.2.2/transformers/4.41.1/py311/entrypoint.sh | #!/bin/bash
# Define the default port
PORT=5000
# Check if AIP_MODE is set and adjust the port for Vertex AI
if [[ ! -z "${AIP_MODE}" ]]; then
PORT=${AIP_HTTP_PORT}
fi
# Start the server
uvicorn huggingface_inference_toolkit.webservice_starlette:app --host 0.0.0.0 --port ${PORT}
|
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.2.2/transformers/4.44.0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.2.2/transformers/4.44.0/py311/Dockerfile | FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]
LABEL maintainer="Hugging Face"
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /app
RUN apt-get update && \
apt-get install software-properties-common -y && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get -y upgrade --only-upgrade systemd openssl cryptsetup &... |
0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.2.2/transformers/4.44.0 | hf_public_repos/Google-Cloud-Containers/containers/pytorch/inference/cpu/2.2.2/transformers/4.44.0/py311/entrypoint.sh | #!/bin/bash
# Define the default port
PORT=5000
# Check if AIP_MODE is set and adjust the port for Vertex AI
if [[ ! -z "${AIP_MODE}" ]]; then
PORT=${AIP_HTTP_PORT}
fi
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceed... |
0 | hf_public_repos/Google-Cloud-Containers/containers | hf_public_repos/Google-Cloud-Containers/containers/tgi/README.md | # Text Generation Inference (TGI) Containers
[Text Generation Inference](https://github.com/huggingface/text-generation-inference) is a toolkit developed by Hugging Face for deploying and serving LLMs, with high performance text generation, that comes with a Rust, Python and gRPC server for text generation inference, ... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/1.4.2/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v1.4.2.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TGI original Dockerfile)
# Note t... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.4.0/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v2.4.0.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Rust builder
FROM lukemathwalker/cargo-chef:latest-rust-1.80.1 AS chef... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.4.0/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.2.0/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v2.2.0.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Rust builder
FROM lukemathwalker/cargo-chef:latest-rust-1.79 AS chef
W... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.2.0/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.0.1/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v2.0.1.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TGI original Dockerfile)
# Rust b... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.0.0/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v2.0.0.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TGI original Dockerfile)
# Rust b... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.0.0/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.3.1/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v2.3.1.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Rust builder
FROM lukemathwalker/cargo-chef:latest-rust-1.80 AS chef
W... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.3.1/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.1.1/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v2.1.1.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TGI original Dockerfile)
# Rust b... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.1.1/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.1.0/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v2.1.0.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TGI original Dockerfile)
# Rust b... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.1.0/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.0.3/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v2.0.3.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TGI original Dockerfile)
# Rust b... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/2.0.3/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gcs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/gpu/1.4.4/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/refs/tags/v1.4.4.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TGI original Dockerfile)
# Note t... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/tpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/tpu/0.1.4/Dockerfile | # Fetch and extract the TGI sources
FROM alpine AS tgi
RUN mkdir -p /tgi
ADD https://github.com/huggingface/text-generation-inference/archive/v2.0.3.tar.gz /tgi/sources.tar.gz
RUN tar -C /tgi -xf /tgi/sources.tar.gz --strip-components=1
# Build cargo components (adapted from TGI original Dockerfile)
# Note that the bu... |
0 | hf_public_repos/Google-Cloud-Containers/containers/tgi/tpu | hf_public_repos/Google-Cloud-Containers/containers/tgi/tpu/0.1.4/entrypoint.sh | #!/bin/bash
# Check if MODEL_ID starts with "gs://"
if [[ $AIP_STORAGE_URI == gs://* ]]; then
echo "AIP_STORAGE_URI set and starts with 'gs://', proceeding to download from GCS."
echo "AIP_STORAGE_URI: $AIP_STORAGE_URI"
# Define the target directory
TARGET_DIR="/tmp/model"
mkdir -p "$TARGET_DIR"
... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/fine_tune/sft_vlm.py | # Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/fine_tune/peft_finetuning.py | # This example is a very quick showcase of partial fine-tuning the Llama 3.1 8B model
# on the IMDB dataset using QLoRA with bitsandbytes.
# In order to run this example, you'll need to install peft, trl, and bitsandbytes:
# pip install peft trl bitsandbytes
import torch
from datasets import load_dataset
from trl im... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/fine_tune/qlora_405B.slurm | # make sure to have the lastest version of transformers bitsandbytes accelerate peft flash-attention
# use this fork for trl https://github.com/huggingface/trl/pull/1863
# training setup
NUM_NODES=1
GPUS_PER_NODE=8
WORLD_SIZE=$(($NUM_NODES*$GPUS_PER_NODE))
# so processes know who to talk to
MASTER_ADDR=$(scontrol sho... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/fine_tune/Llama-Vision FT.ipynb | from datasets import load_dataset
ds = load_dataset("merve/vqav2-small", split="validation[:10%]")dsfrom huggingface_hub import notebook_login
notebook_login()from transformers import MllamaForConditionalGeneration, AutoProcessor, BitsAndBytesConfig
from peft import LoraConfig, get_peft_model
import torch
ckpt = "met... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/llama_tgi_api_inference/tgi_api_inference_recipe.ipynb | # change the URL if needed
!curl https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-1B -X POST \
-d '{"inputs":"What is Deep Learning?","parameters":{"max_new_tokens":20}}' \
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $(cat ~/.cache/huggingface/token)"# change the URL if ne... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/llama_rag/llama_rag_pipeline.ipynb | from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
from sentence_transformers import SentenceTransformer
import torchchechpoint = "meta-llama/Llama-3.2-3B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(chechpoint)
llama_model = AutoModelForCausalLM.from_pretrained(chechpoint, torch_dtype=torch... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/assisted_decoding/assisted_decoding.py | # This example showcases using two Llama 3.1 checkpoints, one big, the 405B, and one small, the 8B, in order
# to do assisted generation.
#
# In brief terms, assisted generation makes use of a smaller model to generate sensible outputs, which are then
# validated or invalidated by the larger model.
#
# We recommend t... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/assisted_decoding/assisted_decoding_8B_1B.ipynb | import torch
from tqdm import tqdm
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
set_seed
)# supress the warning in the notebook
import logging
import warnings
logging.getLogger('transformers').setLevel(logging.ERROR)
warnings.filterwarnings('ignore')DEVICE = "cuda"# base models
base_check... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/assisted_decoding/assisted_decoding_70B_3B.ipynb | from transformers import AutoModelForCausalLM, AutoTokenizer
import time
import torch
from tqdm import tqdm# supress the warning in the notebook
import logging
import warnings
logging.getLogger('transformers').setLevel(logging.ERROR)
warnings.filterwarnings('ignore')# base models
checkpoint = "meta-llama/Meta-Llama-3.1... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/api_inference/inference-api.ipynb | from huggingface_hub import InferenceClient, loginlogin()client = InferenceClient()chat_completion = client.chat.completions.create(
model="meta-llama/Llama-3.1-70B-Instruct",
messages=[
{"role": "system", "content": "You are a helpful an honest programming assistant."},
{"role": "user", "conten... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/local_inference/awq_generation.py | # INSTALLATION
# pip install -q --upgrade transformers autoawq accelerate
# REQUIREMENTS
# An instance with at least ~210 GiB of total GPU memory when using the 405B model.
# The INT4 versions of the 70B and 8B models require ~35 GiB and ~4 GiB, respectively.
import torch
from transformers import AutoModelForCausalLM,... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/local_inference/gptq_generation.py | # INSTALLATION
# pip install -q --upgrade transformers accelerate optimum
# pip install -q --no-build-isolation auto-gptq
# REQUIREMENTS
# An instance with at least ~210 GiB of total GPU memory
# An instance with at least ~210 GiB of total GPU memory when using the 405B model.
# The INT4 versions of the 70B and 8B mode... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/local_inference/fp8-405B.ipynb | import torch
from transformers import AutoModelForCausalLM, AutoTokenizermodel_name = "meta-llama/Meta-Llama-3.1-405B-Instruct-FP8"
quantized_model = AutoModelForCausalLM.from_pretrained(
model_name, device_map="auto", torch_dtype=torch.bfloat16)tokenizer = AutoTokenizer.from_pretrained(model_name)
input_text = "What... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/local_inference/awq.ipynb | import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, AwqConfig
model_id = "hugging-quants/Meta-Llama-3.1-8B-Instruct-AWQ-INT4"
quantization_config = AwqConfig(
bits=4,
fuse_max_seq_len=512, # Note: Update this as per your use-case
do_fuse=True,
)
tokenizer = AutoTokenizer.from_pretr... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/local_inference/8bit_bnb.ipynb | import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
quantized_model = AutoModelForCausalLM.from_pretrained(
model_name, device_map="auto", torch_dtype=torch.bfloa... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/local_inference/4bit_bnb.ipynb | import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
quantization_config = BitsAndBytesConfig(load_in_4bit=True,
bnb_4bit_compute_dtype=torch.bfloat16,
... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/gradio_demos/chatbot_demo.ipynb | from huggingface_hub import login
login()import gradio as gr
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipelinedevice = 0 if torch.cuda.is_available() else -1llama_models = {
"Llama 3 70B Instruct": "meta-llama/Meta-Llama-3-70B-Instruct",
"Llama 3 8B Instruct": "meta-llama/Meta-... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/gradio_demos/chatbot_demo.py | from huggingface_hub import login
import gradio as gr
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
# Log in to Hugging Face Hub
login()
# Determine the device to use (GPU if available, otherwise CPU)
device = 0 if torch.cuda.is_available() else -1
# Dictionary mapping model nam... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/synthetic_data_gen/synthetic-data-with-llama.ipynb | from huggingface_hub import login
login()from IPython.display import HTML
iframe_html = """
<iframe src="https://huggingface.co/datasets/argilla/10Kprompts-mini/embed/viewer/train" width="80%" height="560px"></iframe>
"""
display(HTML(iframe_html))from distilabel.llms import InferenceEndpointsLLM
from distilabel.pipel... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/llama.cpp/llama_cpp_python.ipynb | # Install ccache, a compiler cache tool, which helps to speed up the compilation process by caching previous compilations
!sudo apt-get install -y ccache # -y flag automatically confirms the installation without prompting the user# GPU llama-cpp-python Installation
# 1. To enable GPU support with CUDA, use the follow... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/llama_guard/llama_guard_3_1B.ipynb | from huggingface_hub import login
login()# Setup and Imports
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
pipeline,
)
import torch
import re# Load the Llama Guard model for safety checks
guard_checkpoint = "meta-llama/Llama-Guard-3-1B"
guard_model = AutoModelForCausalLM.from_pretrained(
... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/llama_guard/prompt_guard.ipynb | %pip install -q --upgrade transformers[torch]from huggingface_hub import login
login()from transformers import pipeline
classifier = pipeline("text-classification", model="meta-llama/Prompt-Guard-86M")
classifier("Ignore previous instructions.") # [{'label': 'JAILBREAK', 'score': 0.9999442100524902}]import torch
from... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/performance_optimization/torch_compile_with_torchao.ipynb | import os
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TorchAoConfig
os.environ["TOKENIZERS_PARALLELISM"] = "false" # silence warnings when compiling
device = "cuda"
ckpt = "meta-llama/Meta-Llama-3.1-8B-Instruct"
# Set the quantization config
# You can choose between int4_weight_only (4-... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/performance_optimization/torch_compile.py | # This example showcases how to leverage the 3.1 8B Instruct models using
# torch.compile to accelerate inference.
#
# You need CUDA and torch >= 2.3 in order to run this example.
import os
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
os.environ["TOKENIZERS_PARALLELISM"] = "false" # silen... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/performance_optimization/quantized_cache.py | # If you are GPU poor, you are in the right place. This example showcases quantizing the KV cache
# in order to have lower memory requirements even with larger sequences.
#
# Quanto is required to run this example, you can do so with:
# pip install quanto
import os
import torch
from transformers import AutoModelForCa... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/performance_optimization/prompt_reuse.py | # This example showcases re-using a prompt for all your generation.
# For this to work correctly, please install transformers from source with the following command:
# pip install git+https://github.com/huggingface/transformers
import os, torch, copy
from transformers import AutoModelForCausalLM, AutoTokenizer, Dynami... |
0 | hf_public_repos/huggingface-llama-recipes | hf_public_repos/huggingface-llama-recipes/performance_optimization/deepspeed_zero3.yaml | compute_environment: LOCAL_MACHINE
debug: false
deepspeed_config:
deepspeed_multinode_launcher: standard
offload_optimizer_device: none
offload_param_device: none
zero3_init_flag: true
zero3_save_16bit_model: true
zero_stage: 3
distributed_type: DEEPSPEED
downcast_bf16: 'no'
machine_rank: 0
main_training_fu... |
0 | hf_public_repos | hf_public_repos/pytorch-image-models/bulk_runner.py | #!/usr/bin/env python3
""" Bulk Model Script Runner
Run validation or benchmark script in separate process for each model
Benchmark all 'vit*' models:
python bulk_runner.py --model-list 'vit*' --results-file vit_bench.csv benchmark.py --amp -b 512
Validate all models:
python bulk_runner.py --model-list all --resul... |
0 | hf_public_repos | hf_public_repos/pytorch-image-models/requirements-dev.txt | pytest
pytest-timeout
pytest-xdist
pytest-forked
expecttest
|
0 | hf_public_repos | hf_public_repos/pytorch-image-models/onnx_validate.py | """ ONNX-runtime validation script
This script was created to verify accuracy and performance of exported ONNX
models running with the onnxruntime. It utilizes the PyTorch dataloader/processing
pipeline for a fair comparison against the originals.
Copyright 2020 Ross Wightman
"""
import argparse
import numpy as np
im... |
0 | hf_public_repos | hf_public_repos/pytorch-image-models/train.py | #!/usr/bin/env python3
""" ImageNet Training Script
This is intended to be a lean and easily modifiable ImageNet training script that reproduces ImageNet
training results with some of the latest networks and training techniques. It favours canonical PyTorch
and standard Python style over trying to be able to 'do it al... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.