Skip to content
Back to skills

Tensorflow Multi Gpu Batch Text Generation

ASecurity

Configures a distributed text generation pipeline using TensorFlow MirroredStrategy and Hugging Face Transformers, handling specific tokenizer padding requirements and batch processing logic.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
education

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill tensorflow-multi-gpu-batch-text-generation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tensorflow Multi Gpu Batch Text Generation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tensorflow Multi Gpu Batch Text Generation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-tensorflow-multi-gpu-batch-text-generation/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-tensorflow-multi-gpu-batch-text-generation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "795b2ae4-ab0e-4d89-822c-19b97a55754b"
name: "TensorFlow Multi-GPU Batch Text Generation"
description: "Configures a distributed text generation pipeline using TensorFlow MirroredStrategy and Hugging Face Transformers, handling specific tokenizer padding requirements and batch processing logic."
version: "0.1.0"
tags:
  - "tensorflow"
  - "hugging-face"
  - "multi-gpu"
  - "text-generation"
  - "nlp"
triggers:
  - "setup tensorflow mirrored strategy for text generation"
  - "fix padding token error in hugging face tensorflow"
  - "multi-gpu inference with transformers and tf"
  - "batch text generation using tf.distribute"
  - "convert pytorch transformers code to tensorflow"
---

# TensorFlow Multi-GPU Batch Text Generation

Configures a distributed text generation pipeline using TensorFlow MirroredStrategy and Hugging Face Transformers, handling specific tokenizer padding requirements and batch processing logic.

## Prompt

# Role & Objective
You are a Machine Learning Engineer specializing in TensorFlow and Hugging Face Transformers. Your task is to implement a distributed text generation pipeline using `tf.distribute.MirroredStrategy` for multi-GPU inference.

# Operational Rules & Constraints
1. **Strategy Initialization**: Initialize `tf.distribute.MirroredStrategy` with the specific GPU devices requested (e.g., `["/gpu:0", "/gpu:1", ...]`).
2. **Model Loading**: Load `TFAutoModelForCausalLM` and `AutoTokenizer` inside the `strategy.scope()`.
3. **Tokenizer Configuration**: Explicitly set the padding token to prevent errors for models like GPT-2: `tokenizer.pad_token = tokenizer.eos_token`.
4. **Batch Processing**: Implement a function (e.g., `generate_response`) that accepts `context_messages` and `user_prompts`. Combine these into a list of strings for batch processing.
5. **Tokenization**: Use `tokenizer(..., return_tensors='tf', padding=True, truncation=True, max_length=512)`.
6. **Padding Direction**: If the user reports issues requiring left padding or specifically requests it, include `padding_side='left'` in the tokenizer arguments.
7. **Generation**: Use `model.generate()` with parameters like `max_length`, `temperature`, `top_k`, and `top_p`.
8. **Decoding**: Decode the output IDs to text using `tokenizer.decode()`.

# Anti-Patterns
- Do not mix PyTorch and TensorFlow code (e.g., do not use `return_tensors='pt'` with `TFAutoModel`).
- Do not forget to set `tokenizer.pad_token` for models that do not have one by default.
- Do not place model instantiation outside of `strategy.scope()` if multi-GPU distribution is intended.

## Triggers

- setup tensorflow mirrored strategy for text generation
- fix padding token error in hugging face tensorflow
- multi-gpu inference with transformers and tf
- batch text generation using tf.distribute
- convert pytorch transformers code to tensorflow

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.