Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

huggingface

БесплатноБез исполняемых скриптовНе проверен

Hugging Face is the hub and Python libraries (transformers, datasets, peft, huggingface_hub) for downloading, running, fine-tuning and publishing…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Hugging Face

Overview

The Hugging Face Hub hosts models, datasets and Spaces. You work with it through transformers (models, tokenizers, pipeline, Trainer), datasets, peft (LoRA) and huggingface_hub (login, download/upload, InferenceClient). This skill targets transformers 5.x (Python 3.10+), where several v4 idioms were removed: load_in_4bit/load_in_8bit kwargs, the question-answering, summarization and translation pipelines (use a chat model with the text-generation pipeline instead), and Trainer(tokenizer=...) (now processing_class=). torch_dtype= still works but is deprecated in favour of dtype=.

Instructions

Install and authenticate

pip install torch transformers datasets accelerate peft huggingface_hub
hf auth login            # paste a token from https://huggingface.co/settings/tokens
hf auth whoami           # confirm which account is active

In CI or containers set HF_TOKEN in the environment instead of logging in. The old huggingface-cli command is gone from current huggingface_hub; use hf. Never print or commit the token. Gated models (Llama, Gemma, ...) need you to accept the licence on the model page first.

hf download Qwen/Qwen3-0.6B --local-dir ./models/qwen3-0.6b     # fetch a repo to disk
hf upload my-username/churn-classifier ./out .                   # push a folder to a model repo

Pipelines (fastest path to inference)

from transformers import pipeline

clf = pipeline("sentiment-analysis", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")
print(clf("The checkout flow is much faster now."))   # [{'label': 'POSITIVE', 'score': 0.99...}]

ner = pipeline("ner", aggregation_strategy="simple")  # replaces the old grouped_entities=True
print(ner("Hugging Face is based in New York City."))

# Instruction-tuned LLM: pass chat messages, read the last message of the reply
gen = pipeline("text-generation", model="Qwen/Qwen3-4B-Instruct-2507", dtype="auto", device_map="auto")
out = gen([{"role": "user", "content": "Explain transformers in one sentence."}], max_new_tokens=60)
print(out[0]["generated_text"][-1]["content"])

Load a model and tokenizer yourself

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig

name = "Qwen/Qwen3-4B-Instruct-2507"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForCausalLM.from_pretrained(
    name,
    dtype=torch.bfloat16,                      # or "auto" to use the checkpoint's dtype
    device_map="auto",                         # needs accelerate; spreads layers over GPUs/CPU
    # 4-bit needs a CUDA GPU and bitsandbytes:
    # quantization_config=BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16),
)

messages = [{"role": "user", "content": "What is machine learning?"}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True).to(model.device)
out = model.generate(**inputs, max_new_tokens=100, do_sample=True, temperature=0.7)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Tokenizers

from transformers import AutoTokenizer

tok = AutoTokenizer.from_pretrained("google-bert/bert-base-uncased")
enc = tok("Hugging Face makes NLP easy!", return_tensors="pt", truncation=True, max_length=512)
print(tok.convert_ids_to_tokens(enc["input_ids"][0]), enc["input_ids"].shape[1])

batch = tok(["First sentence.", "Second, longer sentence here."], padding=True, truncation=True, return_tensors="pt")

Fine-tune with Trainer

import numpy as np
from datasets import load_dataset
from transformers import (AutoTokenizer, AutoModelForSequenceClassification,
                          DataCollatorWithPadding, Trainer, TrainingArguments)

name = "distilbert/distilbert-base-uncased"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForSequenceClassification.from_pretrained(name, num_labels=2)

ds = load_dataset("stanfordnlp/imdb")
ds = ds.map(lambda b: tokenizer(b["text"], truncation=True, max_length=256), batched=True)

def compute_metrics(eval_pred):
    logits, labels = eval_pred
    return {"accuracy": float((np.argmax(logits, axis=-1) == labels).mean())}

args = TrainingArguments(
    output_dir="./results", num_train_epochs=3, learning_rate=2e-5, weight_decay=0.01,
    per_device_train_batch_size=16, per_device_eval_batch_size=64,
    eval_strategy="epoch", save_strategy="epoch", logging_steps=100,
    bf16=True,            # use fp16=True on GPUs without bfloat16; drop both on CPU
    report_to="none",
)
trainer = Trainer(
    model=model, args=args,
    train_dataset=ds["train"].shuffle(seed=42).select(range(5000)),
    eval_dataset=ds["test"].shuffle(seed=42).select(range(1000)),
    processing_class=tokenizer,                     # also gives dynamic padding via the default collator
    data_collator=DataCollatorWith
Полный SKILL.md на GitHub

Установить huggingface в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл huggingface?

Hugging Face is the hub and Python libraries (transformers, datasets, peft, huggingface_hub) for downloading, running, fine-tuning and publishing machine-learning models. Use when the user asks to "load a model from Hugging Face", "run a transformers pipeline", "fine-tune BERT", "LoRA fine-tune an LLM", "push a model or dataset to the Hub", "download a model with hf", or "call the Inference API".

Как установить скилл huggingface?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл huggingface запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить huggingface с