Sync from GitHub via hub-sync
Browse filesFiles changed (5)
- CLAUDE.md+3-10
- README.md+23-16
- classify-dataset.py+35-29
- generate-responses.py+38-19
- vlm-classify.py+21-12
13 unmodified lines14151617181920212223242526272829303132333413 unmodified lines```### 2. vLLM Docker ImageRun on the pinned **`vllm/vllm-openai:0.22.1`** image for HF Jobs (ships vLLM + the CUDA toolkit, so FlashInfer works) with `--python /usr/bin/python3 -e PYTHONPATH=/usr/local/lib/python3.12/dist-packages`. **Pin the tag (test-then-pin), not `:latest`.** Tested 2026-06-05 on `l4x1` (vLLM 0.22.1).The custom nightly / FlashInfer `[[tool.uv.index]]` blocks (§3) are **no longer needed** — the image provides vLLM; keep a `vllm>=0.11.0` floor in the PEP 723 header for the local path.**APIs (verified):** structured outputs use `StructuredOutputsParams` (`structured_outputs=`, ≥0.11.0 — `GuidedDecodingParams`/`guided_decoding=` removed in 0.12.0); classification auto-detects the pooling runner from the model architecture (the old `LLM(..., task="classify")` arg was removed → use `LLM(model)`).### 3. DependenciesInclude custom PyPI indexes for vLLM and FlashInfer:```python# [[tool.uv.index]]# url = "https://flashinfer.ai/whl/cu126/torch2.6"## [[tool.uv.index]]# url = "https://wheels.vllm.ai/nightly"```## Current Scripts13 unmodified lines141516171819202122232425262713 unmodified lines```### 2. vLLM Docker ImageRun on the pinned **`vllm/vllm-openai:v0.32.0`** image for HF Jobs (ships vLLM + the CUDA toolkit, so FlashInfer works) with `--python /usr/bin/python3 -e PYTHONPATH=/usr/local/lib/python3.12/dist-packages`. Each script's `[tool.hf-jobs]` header sets these. **Pin the tag (test-then-pin), not `:latest`.** Tested 2026-11-05 on `a10g-small`, `a10g-large` and `a100-large` (vLLM 0.32.0).**Do not list `vllm`, `torch`, `transformers` or `flashinfer-python` in the PEP 723 dependencies.** uv would install newer PyPI copies next to the image's. `PYTHONPATH` shadows those, but the `flashinfer-python` 0.7.2.post1 wheel also ships a top-level `b12x` module that the image lacks; the image's vLLM imports it and crashes (`FileNotFoundError: .../flashinfer/experimental/b12x/_api.py`). Import these packages inside `main()` so `uv run <script> --help` works without them. Local GPU runs use `uv run --with vllm <script>`. The custom nightly / FlashInfer `[[tool.uv.index]]` blocks (§3) are **no longer needed**.**APIs (verified):** structured outputs use `StructuredOutputsParams` (`structured_outputs=`, ≥0.11.0 — `GuidedDecodingParams`/`guided_decoding=` removed in 0.12.0); classification auto-detects the pooling runner from the model architecture (the old `LLM(..., task="classify")` arg was removed → use `LLM(model)`).### 3. DependenciesList only what the image does not provide (for example `datasets`, `huggingface-hub`, `toolz`). No custom `[[tool.uv.index]]` blocks are needed; see §2.## Current Scripts
6 unmodified lines789101112134 unmodified lines181920212223243 unmodified lines282930313233343536373839401 unmodified line4243444546474840 unmodified lines899091929394957 unmodified lines10310410510610710810920 unmodified lines1301311321331341351361371381391401411421431 unmodified line14514614714814915015155 unmodified lines2072082092102112122132142152162172182192202212222232242252262272286 unmodified linesReady-to-run UV scripts for GPU-accelerated inference using [vLLM](https://github.com/vllm-project/vllm).These scripts use [UV's inline script metadata](https://docs.astral.sh/uv/guides/scripts/) to automatically manage dependencies - just run with `uv run` and everything installs automatically!## 📋 Available Scripts4 unmodified lines**Features:**- 🖼️ Process images through state-of-the-art VLMs (Qwen2-VL)- 🎯 Structured classification using vLLM's `GuidedDecodingParams`- 📐 Automatic image resizing to optimize token usage- 💾 Memory-efficient lazy batch processing- 🏷️ Simple CLI interface for defining classes3 unmodified lines```bash# Basic classificationuv run vlm-classify.py \username/input-dataset \username/output-dataset \--classes "document,photo,diagram,other"# With custom prompt and image resizinguv run vlm-classify.py \username/input-dataset \username/output-dataset \--classes "index-card,manuscript,title-page,other" \1 unmodified line--max-size 768# Quick test with sample limituv run vlm-classify.py \davanstrien/sloane-index-cards \username/test-output \--classes "index,content,other" \40 unmodified lines```bash# Local execution (requires GPU)uv run classify-dataset.py \davanstrien/ModernBERT-base-is-new-arxiv-dataset \username/input-dataset \username/output-dataset \7 unmodified lineshf jobs uv run \--flavor l4x1 \--image vllm/vllm-openai:v0.32.0 \https://huggingface.co/datasets/uv-scripts/vllm/resolve/main/classify-dataset.py \davanstrien/ModernBERT-base-is-new-arxiv-dataset \username/input-dataset \username/output-dataset \20 unmodified lines```bash# With chat-formatted messages (default)uv run generate-responses.py \username/input-dataset \username/output-dataset \--messages-column messages \--max-tokens 1024# With plain text prompts (NEW!)uv run generate-responses.py \username/input-dataset \username/output-dataset \--prompt-column question \1 unmodified line--max-samples 100# With custom model and parametersuv run generate-responses.py \username/input-dataset \username/output-dataset \--model-id meta-llama/Llama-3.1-8B-Instruct \55 unmodified lines### DependenciesScripts use UV's inline metadata for automatic dependency management:```python# /// script# requires-python = ">=3.10"# dependencies = [# "datasets",# "flashinfer-python",# "huggingface-hub[hf_transfer]",# "torch",# "transformers",# "vllm",# ]# ///```For bleeding-edge features, use the `UV_PRERELEASE=if-necessary` environment variable to allow pre-release versions when needed.### Docker Image6 unmodified lines789101112134 unmodified lines181920212223243 unmodified lines282930313233343536373839401 unmodified line4243444546474840 unmodified lines899091929394957 unmodified lines10310410510610710810920 unmodified lines1301311321331341351361371381391401411421431 unmodified line14514614714814915015155 unmodified lines2072082092102112122132142152162172182192202212222232242252262272282292302312322332342356 unmodified linesReady-to-run UV scripts for GPU-accelerated inference using [vLLM](https://github.com/vllm-project/vllm).These scripts use [UV's inline script metadata](https://docs.astral.sh/uv/guides/scripts/) to manage dependencies. On HF Jobs they run on the `vllm/vllm-openai` image, which provides vLLM, PyTorch and Transformers, so the script headers leave those out. On your own Linux + CUDA machine, add vLLM explicitly: `uv run --with vllm <script>.py ...`.## 📋 Available Scripts4 unmodified lines**Features:**- 🖼️ Process images through state-of-the-art VLMs (Qwen2-VL)- 🎯 Structured classification using vLLM's `StructuredOutputsParams`- 📐 Automatic image resizing to optimize token usage- 💾 Memory-efficient lazy batch processing- 🏷️ Simple CLI interface for defining classes3 unmodified lines```bash# Basic classificationuv run --with vllm vlm-classify.py \username/input-dataset \username/output-dataset \--classes "document,photo,diagram,other"# With custom prompt and image resizinguv run --with vllm vlm-classify.py \username/input-dataset \username/output-dataset \--classes "index-card,manuscript,title-page,other" \1 unmodified line--max-size 768# Quick test with sample limituv run --with vllm vlm-classify.py \davanstrien/sloane-index-cards \username/test-output \--classes "index,content,other" \40 unmodified lines```bash# Local execution (requires GPU)uv run --with vllm classify-dataset.py \davanstrien/ModernBERT-base-is-new-arxiv-dataset \username/input-dataset \username/output-dataset \7 unmodified lineshf jobs uv run \--flavor l4x1 \--image vllm/vllm-openai:v0.32.0 \https://huggingface.co/datasets/uv-scripts/vllm/raw/main/classify-dataset.py \davanstrien/ModernBERT-base-is-new-arxiv-dataset \username/input-dataset \username/output-dataset \20 unmodified lines```bash# With chat-formatted messages (default)uv run --with vllm generate-responses.py \username/input-dataset \username/output-dataset \--messages-column messages \--max-tokens 1024# With plain text prompts (NEW!)uv run --with vllm generate-responses.py \username/input-dataset \username/output-dataset \--prompt-column question \1 unmodified line--max-samples 100# With custom model and parametersuv run --with vllm generate-responses.py \username/input-dataset \username/output-dataset \--model-id meta-llama/Llama-3.1-8B-Instruct \55 unmodified lines### DependenciesScripts use UV's inline metadata for dependency management, plus a `[tool.hf-jobs]` table that sets the image, flavor and secrets for `hf jobs uv run`:```python# /// script# requires-python = ">=3.10"# dependencies = [# "datasets",# "huggingface-hub",# "hf-xet>= 1.1.7",# ]## [tool.hf-jobs]# image = "vllm/vllm-openai:v0.32.0"# python = "/usr/bin/python3"# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }# flavor = "a100-large"# secrets = ["HF_TOKEN"]# timeout = "2h"# ///```vLLM, PyTorch, Transformers and FlashInfer come from the image: `PYTHONPATH` points at its packages. Do not add them to `dependencies`. uv would then install newer PyPI copies next to the image's, and the current `flashinfer-python` wheel adds a `b12x` module that the v0.32.0 image's vLLM imports and crashes on. For a local GPU run, use `uv run --with vllm <script>.py ...`. `hf jobs uv run` reads the `[tool.hf-jobs]` table from hf CLI 1.32; with an older CLI, pass the header's settings as flags yourself: `--image`, `--flavor`, `--timeout`, `--secrets HF_TOKEN`, `--python /usr/bin/python3` and `-e PYTHONPATH=/usr/local/lib/python3.12/dist-packages`.For bleeding-edge features, use the `UV_PRERELEASE=if-necessary` environment variable to allow pre-release versions when needed.### Docker Image
5 unmodified lines678910111213141516179 unmodified lines272829303132333435363738394041423 unmodified lines46474849505152535455565758593 unmodified lines63646566676845 unmodified lines11411511611711811923 unmodified lines14314414514614714866 unmodified lines21521621721821922022122222322422522622722822923045 unmodified lines2762772782792802812822832842852862872882892902912922932945 unmodified lines# "huggingface-hub",# "setuptools",# "toolz",# "torch",# "transformers",# "vllm>=0.11.0",# ]## [tool.hf-jobs]# image = "vllm/vllm-openai:v0.32.0"# python = "/usr/bin/python3"# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }9 unmodified lineslabels and confidence scores.Example usage:# Local executionuv run classify-dataset.py \\davanstrien/ModernBERT-base-is-new-arxiv-dataset \\username/input-dataset \\username/output-dataset \\--inference-column text \\--batch-size 10000# HF Jobs execution (see script output for full command)hfjobs run --flavor l4x1 ..."""import argparse3 unmodified linesfrom typing import Optionalimport httpximport torchimport torch.nn.functional as Fimport vllmfrom datasets import load_datasetfrom huggingface_hub import hf_hub_url, loginfrom toolz import concat, keymap, partition_allfrom tqdm.auto import tqdmfrom vllm import LLMlogging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"3 unmodified linesdef check_gpu_availability():"""Check if CUDA is available and log GPU information."""if not torch.cuda.is_available():logger.error("CUDA is not available. This script requires a GPU.")logger.error(45 unmodified linesReturns:Tuple of (label, confidence_score)"""logits = torch.tensor(output.outputs.probs)probs = F.softmax(logits, dim=0)top_idx = torch.argmax(probs).item()23 unmodified linesbatch_size: Number of examples to process at oncehf_token: Hugging Face authentication token"""# GPU checkcheck_gpu_availability()66 unmodified linesformatter_class=argparse.RawDescriptionHelpFormatter,epilog="""Examples:# Basic usageuv run classify-dataset.py model/name input-dataset output-dataset# With custom column and batch sizeuv run classify-dataset.py model/name input-dataset output-dataset \\--inference-column prompt \\--batch-size 50000# Using environment variable for tokenHF_TOKEN=hf_xxx uv run classify-dataset.py model/name input-dataset output-dataset""",)45 unmodified linesThis script requires arguments. For usage information:uv run classify-dataset.py --helpExample HF Jobs command:hfjobs run \\--flavor l4x1 \\--secret HF_TOKEN=$(python -c "from huggingface_hub import HfFolder; print(HfFolder.get_token())") \\vllm/vllm-openai:latest \\/bin/bash -c 'uv run https://huggingface.co/datasets/uv-scripts/vllm/resolve/main/classify-dataset.py \\davanstrien/ModernBERT-base-is-new-arxiv-dataset \\username/input-dataset \\username/output-dataset \\--inference-column text \\--batch-size 100000' \\--project vllm-classify \\--name my-classification-job""")5 unmodified lines6789101112131415161718199 unmodified lines29303132333435363738394041424344453 unmodified lines49505152535455565758596061623 unmodified lines66676869707172737445 unmodified lines12012112212312412512612712823 unmodified lines15215315415515615715815966 unmodified lines22622722822923023123223323423523623723823924024124224345 unmodified lines2892902912922932942952962972982993005 unmodified lines# "huggingface-hub",# "setuptools",# "toolz",# ]## [tool.hf-jobs]# # vllm, torch and transformers come from the image (PYTHONPATH). Listing them above makes uv# # install newer PyPI copies plus their deps. PYTHONPATH shadows the copies, but the current# # flashinfer-python wheel (0.7.2.post1) also ships a top-level b12x module that the image lacks.# # The image's vllm imports it and crashes (missing flashinfer/experimental/b12x/_api.py).# # Seen on v0.32.0 (2026-11-05); re-test before moving the tag. Local GPU: uv run --with vllm.# image = "vllm/vllm-openai:v0.32.0"# python = "/usr/bin/python3"# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }9 unmodified lineslabels and confidence scores.Example usage:# Local execution (Linux + CUDA). The header leaves vllm, torch and# transformers to the HF Jobs image, so add vllm with --with.uv run --with vllm classify-dataset.py \\davanstrien/ModernBERT-base-is-new-arxiv-dataset \\username/input-dataset \\username/output-dataset \\--inference-column text \\--batch-size 10000# HF Jobs execution (the header sets the vLLM image, flavor and HF_TOKEN secret)hf jobs uv run classify-dataset.py model/name input-dataset output-dataset"""import argparse3 unmodified linesfrom typing import Optionalimport httpxfrom datasets import load_datasetfrom huggingface_hub import hf_hub_url, loginfrom toolz import concat, keymap, partition_allfrom tqdm.auto import tqdm# torch and vllm are imported inside the functions that use them, so# `uv run classify-dataset.py --help` works without them. On HF Jobs they come from# the vLLM image (see the header).logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"3 unmodified linesdef check_gpu_availability():"""Check if CUDA is available and log GPU information."""import torchimport vllmif not torch.cuda.is_available():logger.error("CUDA is not available. This script requires a GPU.")logger.error(45 unmodified linesReturns:Tuple of (label, confidence_score)"""import torchimport torch.nn.functional as Flogits = torch.tensor(output.outputs.probs)probs = F.softmax(logits, dim=0)top_idx = torch.argmax(probs).item()23 unmodified linesbatch_size: Number of examples to process at oncehf_token: Hugging Face authentication token"""from vllm import LLM# GPU checkcheck_gpu_availability()66 unmodified linesformatter_class=argparse.RawDescriptionHelpFormatter,epilog="""Examples:# Local GPU (Linux + CUDA): the header leaves vllm/torch/transformers to# the HF Jobs image, so add vllm with --with.# Basic usageuv run --with vllm classify-dataset.py model/name input-dataset output-dataset# With custom column and batch sizeuv run --with vllm classify-dataset.py model/name input-dataset output-dataset \\--inference-column prompt \\--batch-size 50000# Using environment variable for tokenHF_TOKEN=hf_xxx uv run --with vllm classify-dataset.py model/name input-dataset output-dataset""",)45 unmodified linesThis script requires arguments. For usage information:uv run classify-dataset.py --helpExample HF Jobs command (the header sets the vLLM image, l4x1 and the HF_TOKEN secret):hf jobs uv run \\https://huggingface.co/datasets/uv-scripts/vllm/raw/main/classify-dataset.py \\davanstrien/ModernBERT-base-is-new-arxiv-dataset \\username/input-dataset \\username/output-dataset \\--inference-column text \\--batch-size 100000""")
1 unmodified line23456789101112131415169 unmodified lines262728293031323334353637383911 unmodified lines51525354555657585960616263643 unmodified lines68697071727315 unmodified lines8990919293949516 unmodified lines11211311411511611736 unmodified lines1541551561571581591601611621631 unmodified line16516616716816917017141 unmodified lines213214215216217218204 unmodified lines4234244254264274284294304314324334344354364374384394404414424434441 unmodified line# requires-python = ">=3.10"# dependencies = [# "datasets",# "flashinfer-python",# "huggingface-hub",# "hf-xet>= 1.1.7",# "torch",# "transformers",# "vllm>=0.11.0",# ]## [tool.hf-jobs]# image = "vllm/vllm-openai:v0.32.0"# python = "/usr/bin/python3"# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }9 unmodified linesresults back to the Hub with a comprehensive dataset card.Example usage:# Local execution with auto GPU detectionuv run generate-responses.py \\username/input-dataset \\username/output-dataset \\--messages-column messages# With custom model and sampling parametersuv run generate-responses.py \\username/input-dataset \\username/output-dataset \\--model-id meta-llama/Llama-3.1-8B-Instruct \\11 unmodified linesimport osimport sysfrom datetime import datetimefrom typing import Optionalfrom datasets import load_datasetfrom huggingface_hub import DatasetCard, get_token, loginfrom torch import cudafrom tqdm.auto import tqdmfrom transformers import AutoTokenizerfrom vllm import LLM, SamplingParamslogging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"3 unmodified linesdef check_gpu_availability() -> int:"""Check if CUDA is available and return the number of GPUs."""if not cuda.is_available():logger.error("CUDA is not available. This script requires a GPU.")logger.error(15 unmodified linesmodel_id: str,messages_column: str,prompt_column: Optional[str],sampling_params: SamplingParams,tensor_parallel_size: int,num_examples: int,generation_time: str,16 unmodified linesNote: Prompts exceeding the maximum model length were skipped and have empty responses."""return f"""---tags:- generated36 unmodified linesGenerated using the vLLM inference script from [uv-scripts/vllm](https://huggingface.co/datasets/uv-scripts/vllm).To reproduce this generation:```bashuv run https://huggingface.co/datasets/uv-scripts/vllm/raw/main/generate-responses.py \\{source_dataset} \\<output-dataset> \\--model-id {model_id} \\1 unmodified line--temperature {sampling_params.temperature} \\--top-p {sampling_params.top_p} \\--top-k {sampling_params.top_k} \\--max-tokens {sampling_params.max_tokens}{f" \\\\\\n --max-model-len {max_model_len_used}" if max_model_len_used else ""}```"""41 unmodified linesmax_samples: Maximum number of samples to process (None for all)hf_token: Hugging Face authentication token"""generation_start_time = datetime.now().isoformat()# GPU check and configuration204 unmodified linesformatter_class=argparse.RawDescriptionHelpFormatter,epilog="""Examples:# Basic usage with default Qwen modeluv run generate-responses.py input-dataset output-dataset# With custom model and parametersuv run generate-responses.py input-dataset output-dataset \\--model-id meta-llama/Llama-3.1-8B-Instruct \\--temperature 0.9 \\--max-tokens 2048# Force specific GPU configurationuv run generate-responses.py input-dataset output-dataset \\--tensor-parallel-size 2 \\--gpu-memory-utilization 0.95# Using environment variable for tokenHF_TOKEN=hf_xxx uv run generate-responses.py input-dataset output-dataset""",)1 unmodified line2345678910111213141516179 unmodified lines27282930313233343536373839404111 unmodified lines5354555657585960616263646566676869703 unmodified lines747576777879808115 unmodified lines97989910010110210316 unmodified lines12012112212312412512612712812913013136 unmodified lines1681691701711721731741751761771 unmodified line17918018118218318418541 unmodified lines227228229230231232233234235204 unmodified lines4404414424434444454464474484494504514524534544554564574584594604614624631 unmodified line# requires-python = ">=3.10"# dependencies = [# "datasets",# "huggingface-hub",# "hf-xet>= 1.1.7",# ]## [tool.hf-jobs]# # vllm, torch, transformers and flashinfer come from the image (PYTHONPATH). Listing them above# # makes uv install newer PyPI copies. PYTHONPATH shadows the copies, but the current# # flashinfer-python wheel (0.7.2.post1) also ships a top-level b12x module that the image lacks.# # The image's vllm imports it and crashes (missing flashinfer/experimental/b12x/_api.py).# # Seen on v0.32.0 (2026-11-05); re-test before moving the tag. Local GPU: uv run --with vllm.# image = "vllm/vllm-openai:v0.32.0"# python = "/usr/bin/python3"# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }9 unmodified linesresults back to the Hub with a comprehensive dataset card.Example usage:# Local execution with auto GPU detection. The header leaves vllm, torch and# transformers to the HF Jobs image, so add vllm with --with.uv run --with vllm generate-responses.py \\username/input-dataset \\username/output-dataset \\--messages-column messages# With custom model and sampling parametersuv run --with vllm generate-responses.py \\username/input-dataset \\username/output-dataset \\--model-id meta-llama/Llama-3.1-8B-Instruct \\11 unmodified linesimport osimport sysfrom datetime import datetimefrom typing import TYPE_CHECKING, Optionalfrom datasets import load_datasetfrom huggingface_hub import DatasetCard, get_token, loginfrom tqdm.auto import tqdmif TYPE_CHECKING:from vllm import SamplingParams# torch, transformers and vllm are imported inside the functions that use them, so# `uv run generate-responses.py --help` works without them. On HF Jobs they come from# the vLLM image (see the header).logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"3 unmodified linesdef check_gpu_availability() -> int:"""Check if CUDA is available and return the number of GPUs."""from torch import cudaif not cuda.is_available():logger.error("CUDA is not available. This script requires a GPU.")logger.error(15 unmodified linesmodel_id: str,messages_column: str,prompt_column: Optional[str],sampling_params: "SamplingParams",tensor_parallel_size: int,num_examples: int,generation_time: str,16 unmodified linesNote: Prompts exceeding the maximum model length were skipped and have empty responses."""# Built outside the card f-string: a backslash inside an f-string expression is a# SyntaxError before Python 3.12.max_model_len_line = (f" \\\n --max-model-len {max_model_len_used}" if max_model_len_used else "")return f"""---tags:- generated36 unmodified linesGenerated using the vLLM inference script from [uv-scripts/vllm](https://huggingface.co/datasets/uv-scripts/vllm).To reproduce this generation on HF Jobs (the script header sets the vLLM image, flavor and HF_TOKEN secret):```bashhf jobs uv run https://huggingface.co/datasets/uv-scripts/vllm/raw/main/generate-responses.py \\{source_dataset} \\<output-dataset> \\--model-id {model_id} \\1 unmodified line--temperature {sampling_params.temperature} \\--top-p {sampling_params.top_p} \\--top-k {sampling_params.top_k} \\--max-tokens {sampling_params.max_tokens}{max_model_len_line}```"""41 unmodified linesmax_samples: Maximum number of samples to process (None for all)hf_token: Hugging Face authentication token"""from transformers import AutoTokenizerfrom vllm import LLM, SamplingParamsgeneration_start_time = datetime.now().isoformat()# GPU check and configuration204 unmodified linesformatter_class=argparse.RawDescriptionHelpFormatter,epilog="""Examples:# Local GPU (Linux + CUDA): the header leaves vllm/torch/transformers to# the HF Jobs image, so add vllm with --with.# Basic usage with default Qwen modeluv run --with vllm generate-responses.py input-dataset output-dataset# With custom model and parametersuv run --with vllm generate-responses.py input-dataset output-dataset \\--model-id meta-llama/Llama-3.1-8B-Instruct \\--temperature 0.9 \\--max-tokens 2048# Force specific GPU configurationuv run --with vllm generate-responses.py input-dataset output-dataset \\--tensor-parallel-size 2 \\--gpu-memory-utilization 0.95# Using environment variable for tokenHF_TOKEN=hf_xxx uv run --with vllm generate-responses.py input-dataset output-dataset""",)
4 unmodified lines5678910111213141516176 unmodified lines24252627282930313233343536373839401 unmodified line424344454647489 unmodified lines585960616263646566676869707170 unmodified lines142143144145146147155 unmodified lines3033043053063073083093103113123133143153164 unmodified lines# "huggingface-hub",# "pillow",# "toolz",# "torch",# "tqdm",# "transformers",# "vllm>=0.11.0", # StructuredOutputsParams API (guided_decoding removed in 0.12.0)# ]## [tool.hf-jobs]# image = "vllm/vllm-openai:v0.32.0"# python = "/usr/bin/python3"# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }6 unmodified linesClassify images using Vision Language Models with vLLM.This script processes images through VLMs to classify them into user-defined categories,using vLLM's GuidedDecodingParams for structured output.Examples:# Basic classificationuv run vlm-classify.py \\username/input-dataset \\username/output-dataset \\--classes "document,photo,diagram,other"# With custom prompt and modeluv run vlm-classify.py \\username/input-dataset \\username/output-dataset \\--classes "index-card,manuscript,title-page,other" \\1 unmodified line--model Qwen/Qwen2-VL-7B-Instruct# Quick test with sample limituv run vlm-classify.py \\davanstrien/sloane-index-cards \\username/test-output \\--classes "index,content,other" \\9 unmodified linesfrom collections import Counterfrom typing import List, Optional, Union, Dict, Anyimport torchfrom PIL import Imagefrom datasets import load_datasetfrom huggingface_hub import loginfrom toolz import partition_allfrom tqdm.auto import tqdmfrom vllm import LLM, SamplingParamsfrom vllm.sampling_params import StructuredOutputsParamslogging.basicConfig(level=logging.INFO)logger = logging.getLogger(__name__)70 unmodified linesprivate: bool = False,):"""Classify images from a dataset using a Vision Language Model."""# Check GPU availabilityif not torch.cuda.is_available():155 unmodified linesformatter_class=argparse.RawDescriptionHelpFormatter,epilog="""Examples:# Basic classificationuv run vlm-classify.py \\username/input-dataset \\username/output-dataset \\--classes "document,photo,diagram,other"# With custom promptuv run vlm-classify.py \\username/input-dataset \\username/output-dataset \\--classes "index-card,manuscript,other" \\4 unmodified lines56789101112131415161718196 unmodified lines262728293031323334353637383940414243441 unmodified line464748495051529 unmodified lines626364656667686970717273747570 unmodified lines146147148149150151152153154155 unmodified lines3103113123133143153163173183193203213223233243254 unmodified lines# "huggingface-hub",# "pillow",# "toolz",# "tqdm",# ]## [tool.hf-jobs]# # vllm, torch and transformers come from the image (PYTHONPATH). Listing them above makes uv# # install newer PyPI copies plus their deps. PYTHONPATH shadows the copies, but the current# # flashinfer-python wheel (0.7.2.post1) also ships a top-level b12x module that the image lacks.# # The image's vllm imports it and crashes (missing flashinfer/experimental/b12x/_api.py).# # Seen on v0.32.0 (2026-11-05); re-test before moving the tag. Local GPU: uv run --with vllm.# image = "vllm/vllm-openai:v0.32.0"# python = "/usr/bin/python3"# env = { PYTHONPATH = "/usr/local/lib/python3.12/dist-packages" }6 unmodified linesClassify images using Vision Language Models with vLLM.This script processes images through VLMs to classify them into user-defined categories,using vLLM's StructuredOutputsParams for structured output.Examples:# Local GPU (Linux + CUDA): the header leaves vllm/torch/transformers to# the HF Jobs image, so add vllm with --with.# Basic classificationuv run --with vllm vlm-classify.py \\username/input-dataset \\username/output-dataset \\--classes "document,photo,diagram,other"# With custom prompt and modeluv run --with vllm vlm-classify.py \\username/input-dataset \\username/output-dataset \\--classes "index-card,manuscript,title-page,other" \\1 unmodified line--model Qwen/Qwen2-VL-7B-Instruct# Quick test with sample limituv run --with vllm vlm-classify.py \\davanstrien/sloane-index-cards \\username/test-output \\--classes "index,content,other" \\9 unmodified linesfrom collections import Counterfrom typing import List, Optional, Union, Dict, Anyfrom PIL import Imagefrom datasets import load_datasetfrom huggingface_hub import loginfrom toolz import partition_allfrom tqdm.auto import tqdm# torch and vllm are imported inside main(), so `uv run vlm-classify.py --help` works# without them. On HF Jobs they come from the vLLM image (see the header).logging.basicConfig(level=logging.INFO)logger = logging.getLogger(__name__)70 unmodified linesprivate: bool = False,):"""Classify images from a dataset using a Vision Language Model."""import torchfrom vllm import LLM, SamplingParamsfrom vllm.sampling_params import StructuredOutputsParams# Check GPU availabilityif not torch.cuda.is_available():155 unmodified linesformatter_class=argparse.RawDescriptionHelpFormatter,epilog="""Examples:# Local GPU (Linux + CUDA): the header leaves vllm/torch/transformers to# the HF Jobs image, so add vllm with --with.# Basic classificationuv run --with vllm vlm-classify.py \\username/input-dataset \\username/output-dataset \\--classes "document,photo,diagram,other"# With custom promptuv run --with vllm vlm-classify.py \\username/input-dataset \\username/output-dataset \\--classes "index-card,manuscript,other" \\
CLAUDE.md+3-10
README.md+23-16
classify-dataset.py+35-29
generate-responses.py+38-19
vlm-classify.py+21-12