شعار Transformers

Transformers

المجتمع
ynulihao
transformers

Work with state-of-the-art machine learning models for NLP, computer vision, audio, and multimodal tasks using HuggingFace Transformers. This skill should be used when fine-tuning pre-trained models, performing inference with pipelines, generating text, training sequence models, or working with BERT, GPT, T5, ViT, and other transformer architectures. Covers model loading, tokenization, training with Trainer API, text generation strategies, and task-specific patterns for classification, NER, QA, summarization, translation, and image tasks. (plugin:scientific-packages@claude-scientific-skills)

Add to TypingMind

نظرة عامة

الناشرynulihao
المستودعAgentSkillOS
اسم المهارةtransformers
النجوم
612
التفريعات
76
الملفات المرفقة
تعليمات فقط
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • مكتفية بذاتها

    كل ما يحتاجه النموذج موجود في التعليمات — لا ملفات إضافية لمزامنتها.

  • مفتوحة المصدر

    نشرها ynulihao على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Transformers في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/ynulihao/AgentSkillOS/tree/main/data/skill_seeds/transformers
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ynulihao/AgentSkillOS.git /tmp/AgentSkillOS
mkdir -p .claude/skills
cp -r /tmp/AgentSkillOS/data/skill_seeds/transformers .claude/skills/transformers
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Transformers في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة Transformers تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Transformers بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

Transformers

Overview

The Transformers library provides state-of-the-art machine learning models for NLP, computer vision, audio, and multimodal tasks. Apply this skill for quick inference through pipelines, comprehensive training via the Trainer API, and flexible text generation with various decoding strategies.

Core Capabilities

1. Quick Inference with Pipelines

For rapid inference without complex setup, use the pipeline() API. Pipelines abstract away tokenization, model invocation, and post-processing.

python
from transformers import pipeline

# Text classification
classifier = pipeline("text-classification")
result = classifier("This product is amazing!")

# Named entity recognition
ner = pipeline("token-classification")
entities = ner("Sarah works at Microsoft in Seattle")

# Question answering
qa = pipeline("question-answering")
answer = qa(question="What is the capital?", context="Paris is the capital of France.")

# Text generation
generator = pipeline("text-generation", model="gpt2")
text = generator("Once upon a time", max_length=50)

# Image classification
image_classifier = pipeline("image-classification")
predictions = image_classifier("image.jpg")

When to use pipelines:

  • Quick prototyping and testing
  • Simple inference tasks without custom logic
  • Demonstrations and examples
  • Production inference for standard tasks

Available pipeline tasks:

  • NLP: text-classification, token-classification, question-answering, summarization, translation, text-generation, fill-mask, zero-shot-classification
  • Vision: image-classification, object-detection, image-segmentation, depth-estimation, zero-shot-image-classification
  • Audio: automatic-speech-recognition, audio-classification, text-to-audio
  • Multimodal: image-to-text, visual-question-answering, image-text-to-text

For comprehensive pipeline documentation, see references/pipelines.md.

2. Model Training and Fine-Tuning

Use the Trainer API for comprehensive model training with support for distributed training, mixed precision, and advanced optimization.

Basic training workflow:

python
from transformers import (
    AutoTokenizer,
    AutoModelForSequenceClassification,
    TrainingArguments,
    Trainer
)
from datasets import load_dataset

# 1. Load and tokenize data
dataset = load_dataset("imdb")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")

def tokenize_function(examples):
    return tokenizer(examples["text"], padding="max_length", truncation=True)

tokenized_datasets = dataset.map(tokenize_function, batched=True)

# 2. Load model
model = AutoModelForSequenceClassification.from_pretrained(
    "bert-base-uncased",
    num_labels=2
)

# 3. Configure training
training_args = TrainingArguments(
    output_dir="./results",
    num_train_epochs=3,
    per_device_train_batch_size=16,
    eval_strategy="epoch",
    save_strategy="epoch",
    load_best_model_at_end=True,
)

# 4. Create trainer and train
trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=tokenized_datasets["train"],
    eval_dataset=tokenized_datasets["test"],
)

trainer.train()

Key training features:

  • Mixed precision training (fp16/bf16)
  • Distributed training (multi-GPU, multi-node)
  • Gradient accumulation
  • Learning rate scheduling with warmup
  • Checkpoint management
  • Hyperparameter search
  • Push to Hugging Face Hub

For detailed training documentation, see references/training.md.

3. Text Generation

Generate text using various decoding strategies including greedy decoding, beam search, sampling, and more.

Generation strategies:

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("gpt2")
tokenizer = AutoTokenizer.from_pretrained("gpt2")
inputs = tokenizer("Once upon a time", return_tensors="pt")

# Greedy decoding (deterministic)
outputs = model.generate(**inputs, max_new_tokens=50)

# Beam search (explores multiple hypotheses)
outputs = model.generate(
    **inputs,
    max_new_tokens=50,
    num_beams=5,
    early_stopping=True
)

# Sampling (creative, diverse)
outputs = model.generate(
    **inputs,
    max_new_tokens=50,
    do_sample=True,
    temperature=0.7,
    top_p=0.9,
    top_k=50
)

Generation parameters:

  • temperature: Controls randomness (0.1-2.0)
  • top_k: Sample from top-k tokens
  • top_p: Nucleus sampling threshold
  • num_beams: Number of beams for beam search
  • repetition_penalty: Discourage repetition
  • no_repeat_ngram_size: Prevent repeating n-grams

For comprehensive generation documentation, see references/generation_strategies.md.

4. Task-Specific Patterns

Common task patterns with appropriate model classes:

Text Classification:

python
from transformers import AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained(
    "bert-base-uncased",
    num_labels=3,
    id2label={0: "negative", 1: "neutral", 2: "positive"}
)

Named Entity Recognition (Token Classification):

python
from transformers import AutoModelForTokenClassification

model = AutoModelForTokenClassification.from_pretrained(
    "bert-base-uncased",
    num_labels=9  # Number of entity types
)

Question Answering:

python
from transformers import AutoModelForQuestionAnswering

model = AutoModelForQuestionAnswering.from_pretrained("bert-base-uncased")

Summarization and Translation (Seq2Seq):

python
from transformers import AutoModelForSeq2SeqLM

model = AutoModelForSeq2SeqLM.from_pretrained("t5-base")

Image Classification:

python
from transformers import AutoModelForImageClassification

model = AutoModelForImageClassification.from_pretrained(
    "google/vit-base-patch16-224",
    num_labels=num_classes
)

For detailed task-specific workflows including data preprocessing, training, and evaluation, see references/task_patterns.md.

Auto Classes

Use Auto classes for automatic architecture selection based on model checkpoints:

python
from transformers import (
    AutoTokenizer,           # Tokenization
    AutoModel,               # Base model (hidden states)
    AutoModelForSequenceClassification,
    AutoModelForTokenClassification,
    AutoModelForQuestionAnswering,
    AutoModelForCausalLM,    # GPT-style
    AutoModelForMaskedLM,    # BERT-style
    AutoModelForSeq2SeqLM,   # T5, BART
    AutoProcessor,           # For multimodal models
    AutoImageProcessor,      # For vision models
)

# Load any model by name
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased")

For comprehensive API documentation, see references/api_reference.md.

Model Loading and Optimization

Device placement:

python
model = AutoModel.from_pretrained("bert-base-uncased", device_map="auto")

Mixed precision:

python
model = AutoModel.from_pretrained(
    "model-name",
    torch_dtype=torch.float16  # or torch.bfloat16
)

Quantization:

python
from transformers import BitsAndBytesConfig

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.float16
)

model = AutoModelForCausalLM.from_pretrained(
    "meta-llama/Llama-2-7b-hf",
    quantization_config=quantization_config,
    device_map="auto"
)

Common Workflows

Quick Inference Workflow

  1. Choose appropriate pipeline for task
  2. Load pipeline with optional model specification
  3. Pass inputs and get results
  4. For batch processing, pass list of inputs

See: scripts/quick_inference.py for comprehensive pipeline examples

Training Workflow

  1. Load and preprocess dataset using 🤗 Datasets
  2. Tokenize data with appropriate tokenizer
  3. Load pre-trained model for specific task
  4. Configure TrainingArguments
  5. Create Trainer with model, data, and compute_metrics
  6. Train with trainer.train()
  7. Evaluate with trainer.evaluate()
  8. Save model and optionally push to Hub

See: scripts/fine_tune_classifier.py for complete training example

Text Generation Workflow

  1. Load causal or seq2seq language model
  2. Load tokenizer and tokenize prompt
  3. Choose generation strategy (greedy, beam search, sampling)
  4. Configure generation parameters
  5. Generate with model.generate()
  6. Decode output tokens to text

See: scripts/generate_text.py for generation strategy examples

Best Practices

  1. Use Auto classes for flexibility across different model architectures
  2. Batch processing for efficiency - process multiple inputs at once
  3. Device management - use device_map="auto" for automatic placement
  4. Memory optimization - enable fp16/bf16 or quantization for large models
  5. Checkpoint management - save checkpoints regularly and load best model
  6. Pipeline for quick tasks - use pipelines for standard inference tasks
  7. Custom metrics - define compute_metrics for task-specific evaluation
  8. Gradient accumulation - use for large effective batch sizes on limited memory
  9. Learning rate warmup - typically 5-10% of total training steps
  10. Hub integration - push trained models to Hub for sharing and versioning

Resources

scripts/

Executable Python scripts demonstrating common Transformers workflows:

  • quick_inference.py - Pipeline examples for NLP, vision, audio, and multimodal tasks
  • fine_tune_classifier.py - Complete fine-tuning workflow with Trainer API
  • generate_text.py - Text generation with various decoding strategies

Run scripts directly to see examples in action:

bash
python scripts/quick_inference.py
python scripts/fine_tune_classifier.py
python scripts/generate_text.py

references/

Comprehensive reference documentation loaded into context as needed:

  • api_reference.md - Core classes and APIs (Auto classes, Trainer, GenerationConfig, etc.)
  • pipelines.md - All available pipelines organized by modality with examples
  • training.md - Training patterns, TrainingArguments, distributed training, callbacks
  • generation_strategies.md - Text generation methods, decoding strategies, parameters
  • task_patterns.md - Complete workflows for common tasks (classification, NER, QA, summarization, etc.)

When working on specific tasks or features, load the relevant reference file for detailed guidance.

Additional Information

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي Transformers؟

Work with state-of-the-art machine learning models for NLP, computer vision, audio, and multimodal tasks using HuggingFace Transformers. This skill should be used when fine-tuning pre-trained models, performing inference with pipelines, generating text, training sequence models, or working with BERT, GPT, T5, ViT, and other transformer architectures. Covers model loading, tokenization, training with Trainer API, text generation strategies, and task-specific patterns for classification, NER, QA, summarization, translation, and image tasks. (plugin:scientific-packages@claude-scientific-skills)

لماذا تستخدم Transformers على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Transformers عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Transformers في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/ynulihao/AgentSkillOS/tree/main/data/skill_seeds/transformers. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Transformers؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Transformers؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Transformers معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Transformers مجانية؟

نشرها ynulihao على GitHub. راجع المستودع للاطلاع على شروط الترخيص. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل
شعار openclaw

Notcrawl

openclaw
مؤسسةشائع

أرشيف Notion: البحث، وحداثة المزامنة، والصفحات/قواعد البيانات، وتصدير Markdown، وإحصاءات SQL، والعمل على مستودع Notcrawl.

82.2K
391K
الملفات: 1
عرض
شعار openclaw

Openclaw Changelog Update

openclaw
مؤسسةشائع

أعِد إنشاء أقسام سجل تغييرات إصدارات OpenClaw استنادًا إلى سجل git قبل إصدارات beta أو stable أو extended-stable.

82.2K
391K
الملفات: 1
عرض
شعار openclaw

Openclaw Ci Limits

openclaw
مؤسسةشائع

أدِر سعة GitHub Actions وBlacksmith CI في OpenClaw، وميزانيات تسجيل المشغّلات، وحدود التوزيع المتوازي، وضمان تشغيل مهمة واحدة لكل دفعة دفع إلى main، وتحديد أحجام الأجزاء، ونقل الأحمال إلى المشغّلات المستضافة، وصحة قائمة الانتظار، والتدرّج الآمن في خفض السعة وزيادتها…

82.2K
391K
الملفات: 1
عرض
شعار openclaw

Openclaw Debugging

openclaw
مؤسسةشائع

شخّص مشكلات النماذج ومزوّدي الخدمة وواجهات الأدوات ووضع البرمجة والبث المباشر وسلوك OpenClaw المباشر/Crabbox، باختيار السجلات والفحوصات ومسار التحقق المناسب قبل تغيير الشيفرة، بما في ذلك جلب الجلسات المحفوظة…

82.2K
391K
الملفات: 1
عرض

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇