fine-tuning
Fine-tuning pre-trained machine learning models for specific tasks using transfer learning techniques.
What this skill does
# fine-tuning
## Purpose
This skill enables fine-tuning of pre-trained ML models using transfer learning, adapting them to specific tasks like text classification or image recognition. It leverages OpenClaw's AIMLOps framework to optimize training loops and resource usage.
## When to Use
Use this skill when you have a pre-trained model (e.g., BERT for NLP) and a custom dataset that requires adaptation, such as sentiment analysis on domain-specific text. Apply it for tasks where training from scratch is inefficient, like in production environments with limited data.
## Key Capabilities
- Fine-tune models with techniques like gradient checkpointing for memory efficiency.
- Support for popular frameworks: Hugging Face Transformers, TensorFlow, and PyTorch.
- Hyperparameter tuning via integrated tools, e.g., learning rate schedulers.
- Distributed training across GPUs or cloud instances.
- Model evaluation metrics like accuracy, F1-score, and loss tracking.
## Usage Patterns
Start by preparing your dataset and model. Load data into a compatible format (e.g., JSONL for text), then invoke the fine-tuning command. Monitor progress via logs or callbacks. For pipelines, integrate as a step in AIMLOps workflows, ensuring data preprocessing precedes fine-tuning.
## Common Commands/API
Use the OpenClaw CLI for quick execution or the REST API for programmatic access. Authentication requires setting `$OPENCLAW_API_KEY` as an environment variable.
- **CLI Command Example**: Fine-tune a BERT model on a dataset.
```
openclaw fine-tune --model bert-base-uncased --data-path ./data.jsonl --epochs 3 --batch-size 16 --learning-rate 5e-5
```
This command loads the model, trains for 3 epochs, and saves outputs to the current directory.
- **API Endpoint**: POST to `/api/v1/fine-tune` with a JSON body.
Example request body:
```
{
"model_id": "bert-base-uncased",
"dataset_url": "s3://my-bucket/data.jsonl",
"epochs": 3,
"hyperparameters": {"learning_rate": 5e-5, "batch_size": 16}
}
```
Send via curl: `curl -X POST -H "Authorization: Bearer $OPENCLAW_API_KEY" -d '{"model_id": "bert-base-uncased", ...}' https://api.openclaw.ai/api/v1/fine-tune`
- **Config Format**: Use YAML for configuration files.
Example snippet:
```
model: bert-base-uncased
data:
path: ./data.jsonl
format: jsonl
training:
epochs: 3
optimizer: adamw
```
Pass to CLI: `openclaw fine-tune --config config.yaml`
## Integration Notes
Integrate with other OpenClaw skills by chaining outputs; for example, use the "data-preprocessing" skill to prepare datasets before fine-tuning. For cloud setups, specify providers like AWS in configs (e.g., add `"provider": "aws"` in JSON). Handle dependencies by installing required packages via `pip install transformers==4.28.0 torch==1.13.1`. Ensure compatibility with AIMLOps clusters by setting env vars like `$OPENCLAW_CLUSTER_ID`.
## Error Handling
Check for common errors like invalid model IDs or data format mismatches. Use try-catch in scripts:
```
try:
response = requests.post('https://api.openclaw.ai/api/v1/fine-tune', headers={'Authorization': f'Bearer {os.environ["OPENCLAW_API_KEY"]}'}, json=payload)
response.raise_for_status()
except requests.exceptions.HTTPError as e:
print(f"Error: {e.response.status_code} - {e.response.text}")
```
Log detailed errors with `--verbose` flag in CLI (e.g., `openclaw fine-tune --verbose`). For GPU issues, verify availability with `nvidia-smi` before running.
## Concrete Usage Examples
1. **Fine-Tuning for Sentiment Analysis**: Adapt BERT for movie reviews.
- Prepare data: Save reviews in JSONL format.
- Run: `openclaw fine-tune --model bert-base-uncased --data-path reviews.jsonl --epochs 5 --output-dir ./models`
- This trains the model and saves checkpoints; evaluate with `openclaw evaluate --model-path ./models/checkpoint-5`
2. **Fine-Tuning Image Classifier**: Use a pre-trained ResNet for custom images.
- Dataset: Organize images in folders (e.g., train/class1/*.jpg).
- Command: `openclaw fine-tune --model resnet50 --data-path ./image_dataset --epochs 10 --batch-size 32`
- Integrate: Follow with deployment via OpenClaw's "model-serving" skill for inference.
## Graph Relationships
- Relates to: "data-preprocessing" (input dependency for dataset handling)
- Relates to: "model-evaluation" (output for performance metrics)
- Relates to: "aimlops-deployment" (for post-fine-tuning model serving)
- Clusters with: "aimlops" (shared ecosystem for ML operations)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.