Agent skill

Perforatedai Libraries Transformers

by PerforatedAI in PerforatedAI/PerforatedAI

HuggingFace Transformers integration for PerforatedAI. An agent skill from PerforatedAI/PerforatedAI.

Apache-2.0Auto-check passedAI & LLM Engineering

Install Perforatedai Libraries Transformers

skills CLI
$ npx skills add PerforatedAI/PerforatedAI --skill perforatedai-libraries-transformers -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install PerforatedAI/PerforatedAI perforatedai-libraries-transformers --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/PerforatedAI/PerforatedAI.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/perforatedai-libraries-transformers .claude/skills/perforatedai-libraries-transformers && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
perforatedai-libraries-transformers
GitHub stars
237
Token cost
~1.6k tokens
SKILL.md length
444 words
Files
1
Skills in repo
7
Repo updated
First seen
Licence
Apache-2.0

At a glance

HuggingFace Transformers integration for PerforatedAI. An agent skill from PerforatedAI/PerforatedAI.

  • The users script uses HuggingFace Trainer
  • SKILL.md covers Step T-1: Verify Transformers…, Step T-2: Add Imports, Step T-3: Configure PAI and… and Step T-4: TrainingArguments, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Tasks that involve Model hubs and datasets

What it does

Perforatedai Libraries Transformers is an agent skill from PerforatedAI/PerforatedAI. HuggingFace Transformers integration for PerforatedAI. Handles the Trainer-specific differences: usingperforatedai=True, GPA.metric, evalstrategy. Use when the user's script uses HuggingFace Trainer.

Its SKILL.md is about 1.6k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering Model hubs and datasets and Deep learning. It works with Hugging Face and Transformers. The repository describes itself as: Add Dendrites to your PyTorch Project. The licence is Apache-2.0.

When your agent uses it

  • The users script uses HuggingFace Trainer
  • Tasks that involve Model hubs and datasets
  • Tasks that involve Deep learning

Example prompts

  • “/perforatedai-libraries-transformers”

Requirements

  • Python 3

What it can do on your machine

Read from SKILL.md and the folder at commit 9d317e6. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Perforatedai Libraries Transformers loads about 1.6k tokens when it runs. Until then it costs about 59 tokens; SKILL.md has 444 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~59
When it runs · the whole SKILL.md, loaded when a task matches
~1.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from PerforatedAI/PerforatedAI at commit 9d317e6, republished under its Apache-2.0 licence (© PerforatedAI). 444 words, ~1,606 tokens.

Download SKILL.mdSave it as .claude/skills/perforatedai-libraries-transformers/SKILL.md (or your agent's skills folder).
name
perforatedai-libraries-transformers
description
HuggingFace Transformers integration for PerforatedAI. Handles the Trainer-specific differences: using_perforatedai=True, GPA.metric, eval_strategy. Use when the user's script uses HuggingFace Trainer.

PerforatedAI — HuggingFace Transformers Integration

This skill handles PAI integration when the user is using the HuggingFace Trainer (from the transformers library). It replaces the standard optimizer, training loop, and restructuring steps from the main perforatedai skill.


Step T-1: Verify Transformers Compatibility

The standard transformers package does not include the hooks that PAI requires. Using PAI with HuggingFace Trainer requires the transformers-perforated library.

Check if already installed: Ask the user if they have transformers-perforated in their environment. If yes, skip this step.

If not installed: Tell them: "PAI integration with Trainer requires transformers-perforated. See the PerforatedAI documentation for installation details."


Step T-2: Add Imports

Add these imports (same as any PAI integration):

python
from perforatedai import globals_perforatedai as GPA
from perforatedai import utils_perforatedai as UPA

Step T-3: Configure PAI and Convert the Model

Add this block after the model is created and before the Trainer is constructed.

Set the metric PAI should watch

With the HF Trainer you cannot call add_validation_score() directly — the Trainer manages evaluation internally. Instead, tell PAI which metric key to read from the Trainer's evaluation output:

python
GPA.pc.set_library_validation_score("eval_loss")
GPA.pc.set_library_extra_scores(["train_loss"])
  • Use "eval_accuracy" (or whatever your compute_metrics returns) when maximizing
  • Use "eval_loss" when minimizing loss
  • Set this before calling perforate_model
Other configuration (same as a basic script)
python
GPA.pc.set_testing_dendrite_capacity(True)   # Start True for initial capacity check; switch to False for real training
GPA.pc.set_switch_mode(GPA.pc.DOING_HISTORY)
GPA.pc.set_n_epochs_to_switch(10)            # Adjust based on your training length

# Optional: restrict which modules get dendrites
# GPA.pc.append_module_names_to_track(['ViTModel', 'ViTEncoder'])
Convert the model
python
model = UPA.perforate_model(
    model,
    save_name="my_model_dendritic",
    maximizing_score=True,   # True for accuracy; False for loss
    making_graphs=True,
)

Step T-4: TrainingArguments

PAI needs a validation score after every epoch. Set eval_strategy="epoch":

python
training_args = TrainingArguments(
    output_dir="./output",
    eval_strategy="epoch",   # Required — PAI reads per-epoch scores
    # num_train_epochs — do NOT set this to a huge number; PAI manages training termination internally
    ...
)

Do NOT set num_train_epochs=1000000 — PAI handles training termination automatically.


Step T-5: Trainer Constructor

The single most important HF-specific change is passing using_perforatedai=True to the Trainer:

python
trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    compute_metrics=compute_metrics,
    using_perforatedai=True,        # THE key addition — without this PAI has no effect
)
trainer.train()

Without this flag the Trainer runs normally and PAI never activates.


Show full SKILL.md (200 more words)Show less

What PAI Handles Automatically with Trainer

When using_perforatedai=True is set, the transformers-perforated library handles these internally — do not add them manually:

  • Calling GPA.pai_tracker.add_validation_score() after each epoch
  • Detecting when training is complete and stopping the loop
  • Reinitializing the optimizer after model restructuring

This means you do not write a manual restructuring loop, set a huge epoch count, or manage the optimizer lifecycle yourself.


Custom Loop with a HuggingFace Model (Not Using Trainer)

If the user is using a HuggingFace model (e.g., AutoModelForImageClassification) but writing their own training loop (no Trainer), the transformers-perforated library's automatic handling does not apply. In that case, go back to the standard perforatedai skill and follow the normal steps (optimizer setup, add_validation_score, restructuring loop, model.to(device) after restructuring, etc.).


Minimal Complete Example

python
from perforatedai import globals_perforatedai as GPA
from perforatedai import utils_perforatedai as UPA
from transformers import Trainer, TrainingArguments

# --- after model is created ---

GPA.metric = "eval_accuracy"                          # metric key from compute_metrics
GPA.pc.set_testing_dendrite_capacity(True)            # True for initial check; False for real training
GPA.pc.set_switch_mode(GPA.pc.DOING_HISTORY)
GPA.pc.set_n_epochs_to_switch(10)

model = UPA.perforate_model(
    model,
    save_name="my_model_dendritic",
    maximizing_score=True,
    making_graphs=True,
)

training_args = TrainingArguments(
    output_dir="./output",
    eval_strategy="epoch",
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    compute_metrics=compute_metrics,
    using_perforatedai=True,
)
trainer.train()

Step T-6: Verify

Tell the user to run their script. With set_testing_dendrite_capacity(True), PAI will run a 7-epoch test and print:

Successfully added 3 dendrites with GPA.pc.set_testing_dendrite_capacity(True) (default).
You may now set that to False and run a real experiment.

Once they see this, change set_testing_dendrite_capacity(True) → set_testing_dendrite_capacity(False) in their script and tell them to run full training.


Reference Examples

Working examples using this integration:

  • examples/libraryexamples/huggingface/BERT/train_bert_pai.py — BERT/RoBERTa classification
  • examples/libraryexamples/huggingface/mnist/mnist_huggingface_perforatedai.py — Simple CNN with custom Trainer subclass
  • examples/libraryexamples/huggingface/ViT Demo Example/ — Step-by-step walkthrough of adding PAI to the official HF image classification script

See examples/libraryexamples/huggingface/README.md for the full integration guide.

© PerforatedAI, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/perforatedai-libraries-transformers of PerforatedAI/PerforatedAI.

Open the folder on GitHubat commit 9d317e6

Compare with similar skills

Perforatedai Libraries Transformers next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Perforatedai Libraries Transformers compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Perforatedai Libraries Transformers this skillPerforatedAI/PerforatedAI237—~1.6kAutomated safety check: PassApache-2.0
Nvflare Convert HuggingfaceNVIDIA/skills3.5k—~3.5kAutomated safety check: PassApache-2.0
Hugging Face Local Model Evalshuggingface/skills11k2 repos~1.6kAutomated safety check: PassApache-2.0
Hugging Face Vision Trainerhuggingface/skills11k1 repos~7.5kAutomated safety check: PassApache-2.0
Megakernel OptimizationRightNow-AI/AutoMegaKernel148—~1.8kAutomated safety check: PassMIT
Cosmos3 Post TrainingNVIDIA/cosmos-framework559—~2.7kAutomated safety check: PassCustom licence

Similar skills

  • Official

    Convert existing Hugging Face Transformers Trainer or TRL SFTTrainer training code into an NVFLARE federated job using flare.patch(trainer), local validation, and job export; use when the user names…

    3.5k GitHub stars~3.5k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Official

    Runs evaluations of Hugging Face Hub models on local hardware with inspect-ai or lighteval, and helps choose between vLLM, Transformers and accelerate backends.

    11k GitHub starsUsed in 2 repos~1.6k tokens
    AI & LLM EngineeringAuto-check passed
  • Hugging Face Vision Trainer

    huggingface/skills

    Official

    Trains and fine-tunes object detection, image classification and SAM or SAM2 segmentation models on Hugging Face Jobs cloud GPUs and saves the results to the Hub.

    11k GitHub starsUsed in 1 repo~7.5k tokens
    AI & LLM EngineeringAuto-check passed
  • Megakernel Optimization

    RightNow-AI/AutoMegaKernel

    A skill your agent uses when optimizing or generating a CUDA megakernel for a HuggingFace Llama-family model with AutoMegaKernel (AMK), drives the correctness-gated propose - eval - keep/revert loop…

    148 GitHub stars~1.8k tokensUpdated 21 days ago
    AI & LLM EngineeringAuto-check passed
  • Cosmos3 Post Training

    NVIDIA/cosmos-framework

    Official

    Guide users through Cosmos3 supervised fine-tuning (SFT) post-training: preparing the example dataset and Wan2.2 VAE, converting the base checkpoint to DCP, launching distributed training (paired…

    559 GitHub stars~2.7k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Moe Training

    Orchestra-Research/AI-Research-SKILLs

    Train Mixture of Experts (MoE) models using DeepSpeed or HuggingFace.

    13k GitHub starsUsed in 2 repos~3.7k tokens
    AI & LLM EngineeringAuto-check passed

More from PerforatedAI/PerforatedAI

  • Perforatedai Complex Methods

    PerforatedAI/PerforatedAI

    Solutions for non-trivial PerforatedAI integration scenarios.

    237 GitHub stars~821 tokensUpdated yesterday
    Auto-check passed
  • Perforatedai Plot

    PerforatedAI/PerforatedAI

    Render a single-panel PAI figure of score versus parameter count from sweep CSVs, PAI run folders, or hand-supplied numbers.

    237 GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed
  • Perforatedai

    PerforatedAI/PerforatedAI

    Expert in PerforatedAI library for adding artificial dendrites to PyTorch neural networks.

    237 GitHub stars~17k tokensUpdated yesterday
    Auto-check passed
  • Perforatedai Analyze

    PerforatedAI/PerforatedAI

    Analyze PerforatedAI training results and provide optimization recommendations.

    237 GitHub stars~5.1k tokensUpdated yesterday
    Auto-check passed
  • Perforatedai Wandb

    PerforatedAI/PerforatedAI

    WandB-specific PerforatedAI integration guardrail skill. An agent skill from PerforatedAI/PerforatedAI.

    237 GitHub stars~2.8k tokensUpdated yesterday
    Auto-check passed
  • Perforatedai Distributed

    PerforatedAI/PerforatedAI

    Multi-GPU setup for PerforatedAI with DataParallel or DistributedDataParallel (DDP).

    237 GitHub stars~5.5k tokensUpdated yesterday
    Auto-check passed

Questions about Perforatedai Libraries Transformers

What does Perforatedai Libraries Transformers do?

HuggingFace Transformers integration for PerforatedAI. An agent skill from PerforatedAI/PerforatedAI. Perforatedai Libraries Transformers is an agent skill from PerforatedAI/PerforatedAI. HuggingFace Transformers integration for PerforatedAI.

When should I use Perforatedai Libraries Transformers?

Perforatedai Libraries Transformers fits situations like: the users script uses HuggingFace Trainer; tasks that involve Model hubs and datasets; tasks that involve Deep learning.

How do I install Perforatedai Libraries Transformers in Claude Code?

Run `npx skills add PerforatedAI/PerforatedAI --skill perforatedai-libraries-transformers -a claude-code`. Or copy the skill folder (skills/perforatedai-libraries-transformers in PerforatedAI/PerforatedAI) into .claude/skills/perforatedai-libraries-transformers in your project. Claude Code loads it when a task matches its description.

How do I install Perforatedai Libraries Transformers in Codex?

Run `npx skills add PerforatedAI/PerforatedAI --skill perforatedai-libraries-transformers -a codex`. Or copy the skill folder (skills/perforatedai-libraries-transformers in PerforatedAI/PerforatedAI) into .agents/skills/perforatedai-libraries-transformers in your project. Codex loads it when a task matches its description.

Can I use Perforatedai Libraries Transformers in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add PerforatedAI/PerforatedAI --skill perforatedai-libraries-transformers -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/perforatedai-libraries-transformers, .gemini/skills/perforatedai-libraries-transformers, .github/skills/perforatedai-libraries-transformers and .opencode/skills/perforatedai-libraries-transformers in your project.

What does Perforatedai Libraries Transformers need to run?

SKILL.md names no scripts, command-line tools or credentials: Perforatedai Libraries Transformers is instructions for the agent only. Our summary lists: Python 3.

Does Perforatedai Libraries Transformers access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Perforatedai Libraries Transformers safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Perforatedai Libraries Transformers use?

Perforatedai Libraries Transformers is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Perforatedai Libraries Transformers use?

About 1.6k tokens (SKILL.md is roughly 6.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Perforatedai Libraries Transformers?

Skills that share tags, products or a category with Perforatedai Libraries Transformers: Nvflare Convert Huggingface (NVIDIA/skills, 3.5k stars), Hugging Face Local Model Evals (huggingface/skills, 11k stars), Hugging Face Vision Trainer (huggingface/skills, 11k stars) and Megakernel Optimization (RightNow-AI/AutoMegaKernel, 148 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Perforatedai Libraries Transformers?

PerforatedAI (a GitHub organization) maintains it in PerforatedAI/PerforatedAI, which has 237 GitHub stars. The repository holds 7 skills in this directory. The repository was last updated on October 8, 2026.

Source: PerforatedAI/PerforatedAI on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.