Where every neural pathway becomes a collaborative bridge.
Welcome to PolyTask Orchestrator, a revolutionary multi-task learning framework built atop the modernBERT architecture, designed for researchers and engineers who refuse to choose between performance and flexibility. Instead of fine-tuning a model for a single purpose, PolyTask lets you weave diverse tasks into a single, co-trained network that shares knowledge, reduces memory overhead, and delivers exceptional accuracy across domains.
This is not just another training toolkitβit's a cognitive switchboard for natural language understanding, allowing you to route inputs through shared layers while maintaining task-specific output heads. Think of it as a city where all roads lead to a central hub, yet each district retains its unique architecture.
Traditional fine-tuning is a one-way street. You train a model for sentiment analysis, then you train it again for question answering, and the learnings from the first task evaporate. PolyTask adopts a biological neural metaphor: neurons that fire together, wire together. By training multiple tasks simultaneously, the model learns universal language patterns that improve each individual task's performance.
Consider this scenario:
- You need a model for customer support intent classification in six languages.
- You also need semantic similarity scoring for product recommendations.
- Finally, you want abstractive summarization for internal reports.
Instead of deploying three separate models, PolyTask creates a single multi-lane highway where each task is a lane, but the underlying road surface (the transformer layers) is shared and reinforced daily.
Training multiple tasks in one session reduces GPU hours by up to 40% compared to sequential fine-tuning, because the backward passes share gradients across tasks. This is the shared labor principleβwhy hire three workers to dig three ditches when one can dig three smaller ones with better technique?
- Dynamic Task Scheduling: Automatically balances training updates across tasks to prevent one task from dominating the loss landscape.
- Loss Weight Autopilot: Implements uncertainty-weighted losses (Kendall et al. method) to let the model decide which task needs more attention at each step.
- Task Grouping: Cluster semantically related tasks (e.g., NER and POS tagging) to share low-level features exclusively among themselves.
- ModernBERT Core: Built on the latest efficient attention mechanism, supporting sequences up to 8,192 tokens without positional encodings collapsing.
- Modular Task Heads: Each task gets a lightweight, task-specific head (linear, LSTM, CRF) that projects the shared representations.
- Frozen Layer Control: Choose which transformer layers remain static (pretrained) and which become trainable (fine-tuned) on a per-task basis.
- Zero-Shot Task Transfer: Train on English tasks, evaluate on German or Mandarinβthe shared representation space enables cross-lingual generalization.
- Script-Agnostic Tokenizer: Built-in support for 100+ languages, including CJK, Cyrillic, and RTL scripts, thanks to modernBERTβs tokenizer.
- Real-Time Dashboard: Track per-task loss, accuracy, and gradient flow via an integrated web interface (no external tools needed).
- Gradient Disagreement Analysis: Visualize when tasks pull the model in opposite directions, helping you identify conflicting tasks early.
- Checkpoint Diff Reports: Compare fine-tuned weights vs. base model to understand exactly which layers changed for which task.
- ONNX Conversion Ready: Export your entire multi-task model to ONNX with a single command, enabling CPU inference at 2.5x speed.
- Half-Precision (FP16) Support: Automatic mixed-precision training reduces VRAM consumption by 50% without accuracy loss.
- Distillation Recipes: Compress the multi-task model into a smaller student model that retains 90%+ performance at 1/3 the size.
- Dedicated Discord Server: Real-time help from core maintainers and power users (invite link inside the repository wiki).
- Weekly Office Hours: Every Wednesday, a live Q&A session with the development team to answer your architecture questions.
- Issue Triage SLA: We prioritize issues affecting multi-task stability within 48 hours, ensuring your training pipeline never stalls.
Most fine-tuning frameworks treat tasks like separate islands. PolyTask treats them like organs of the same body. When you train a model to classify emotions (sentiment), the model simultaneously improves its ability to detect subject-verb agreement (syntax), which then aids its question-answering capability.
We call this the Hydra Effect: cut off one head (remove a task), and the remaining heads (tasks) grow stronger because they repurpose the freed-up capacity.
Imagine youβre teaching a child three subjects: math, music, and language. A traditional tutor would spend 10 hours on each. PolyTask is like a school where the child learns fractions by playing rhythm games (music) and learns grammar by writing song lyrics (language). The result? A more rounded, faster-learning student.
polytask-orchestrator/
βββ core/ # The beating heart: training loops, schedulers, loss functions
β βββ engine.py # Main orchestration logic (the conductor)
β βββ task_registry.py # Where you register your custom tasks
β βββ loss_weighting.py # Autopilot loss balancing algorithms
β
βββ heads/ # Task-specific architectural heads
β βββ regression_head.py # For continuous outputs (similarity scores)
β βββ classification_head.py# For discrete labels (intent classification)
β βββ span_extraction_head.py # For token-level tasks (NER, QA)
β βββ generation_head.py # For autoregressive tasks (summarization)
β
βββ data/ # Data loading & preprocessing utilities
β βββ dataloader.py # Multi-task batch sampler (creates mixed batches)
β βββ augmentation.py # Back-translation for multilingual tasks
β βββ streaming.py # Real-time data pipelines for huge datasets
β
βββ observability/ # Monitoring & visualization stack
β βββ dashboard_server.py # The web UI component
β βββ gradient_cam.py # Gradient flow visualization on layers
β βββ metrics_writer.py # CSV/JSONL loggers for custom tracking
β
βββ deploy/ # Export & inference tools
β βββ onnx_exporter.py # One-click ONNX conversion
β βββ quantizer.py # INT8 quantization for edge devices
β βββ api_server.py # FastAPI wrapper for RESTful inference
β
βββ examples/ # Fully runnable recipes (no internet needed)
β βββ social_media_suite/ # Sentiment + topic + hate speech detection
β βββ legal_apps/ # Contract clause extraction + risk scoring
β βββ medical_notes/ # Symptom classification + de-identification
β
βββ tests/ # Unit & integration tests (100% coverage target)
βββ docs/ # Extended guides, theory, and API reference
Before running anything, grasp the concept of task heads. Each task you define must implement two methods:
forward(context, hidden_states)β takes the shared representation and outputs predictions.compute_loss(predictions, targets)β tells the engine how to evaluate performance.
The engine handles the rest: shuffling tasks, weighting losses, and updating weights.
Create a file my_tasks.py:
from polytask.core import Task, Orchestrator
from polytask.heads import ClassificationHead
class SentimentTask(Task):
name = "sentiment"
num_labels = 3 # positive, neutral, negative
head = ClassificationHead(hidden_size=768, num_labels=num_labels)
class TopicTask(Task):
name = "topic"
num_labels = 5 # tech, politics, sports, science, art
head = ClassificationHead(hidden_size=768, num_labels=num_labels)
# The conductor
orchestrator = Orchestrator(
model_name="sileod/modernbert-base",
tasks=[SentimentTask(), TopicTask()],
max_seq_length=512,
batch_size=16,
)
# Train on your datasets (assume you have train_sentiment.txt, train_topic.txt)
orchestrator.train(
task_data_paths={
"sentiment": "./datasets/sentiment_train.jsonl",
"topic": "./datasets/topic_train.jsonl",
},
epochs=3,
learning_rate=2e-5,
)After training, evaluate each task individually or jointly:
results = orchestrator.evaluate(
task_data_paths={
"sentiment": "./datasets/sentiment_test.jsonl",
"topic": "./datasets/topic_test.jsonl",
}
)
# Output: {'sentiment': {'accuracy': 0.91}, 'topic': {'accuracy': 0.87}}Thatβs it. Youβve just conducted a multi-task symphony where every instrument played in harmony.
Train a single model to:
- Identify urgency level from patient messages (classification).
- Extract medication names and dosages (span extraction).
- Generate a patient-friendly summary (generation).
The shared representation learns that medications appear in urgent messages more often, improving all three tasks.
For international e-commerce, train your model on:
- English sentiment reviews.
- German product category prediction.
- Japanese keyword extraction.
Then deploy it globallyβit will handle mixed-language inputs seamlessly, a task where separate models often fail.
- Classify document type (invoice, contract, receipt).
- Extract date, amounts, and party names.
- Summarize the documentβs main clause.
The shared layers learn the structure of financial English, making the combination far more robust than isolated models.
- Longer Contexts: ModernBERT supports 8,192 tokens versus BERTβs 512, allowing you to task on full documents without truncation.
- Faster Inference: 3.2x speedup due to sparse attention patternsβcritical when serving multiple tasks concurrently.
- Fixed Positional Encodings: Removes the need for segment embeddings, simplifying multi-task input construction.
We built a contour plot generator that shows the loss surface for each task. If two tasks have opposite gradients at the same layer, youβll see a βsaddle pointβ where neither improvesβthis alerts you to reconsider task compatibility.
If one task has 10x more data than another, our engine automatically accumulates gradients for the smaller task across several iterations, preventing the larger task from washing out the signal.
PolyTask isnβt just for NLP researchersβitβs a content intelligence backbone. Use it to:
- Topic modeling: Identify themes across your articles while simultaneously detecting clickbait headlines.
- Readability scoring: Score text complexity while also extracting key entities for internal linking.
- Tone consistency: Ensure your brand voice across all blog posts while auto-generating meta descriptions.
By combining these, you get a content quality gate that evaluates every piece before publishing, all in a single forward pass.
The included dashboard (the PolyScope) is a fully responsive web interface that works on mobile, tablet, and desktop. Features include:
- Live Loss Curves: Watch each taskβs loss converge in real-time, color-coded for instant recognition.
- Task Conflict Alerts: Red badges appear when two tasks have diverged for more than 100 steps.
- Weight Magnitude Heatmap: Visualize which transformer layer is most active for each task.
The dashboard runs entirely locally (no telemetry), ensuring your training data remains private.
Measured on NVIDIA A100 40GB, modernBERT-base, 100K steps, mixed precision.
| Task Combination | Single-Task Accuracy | PolyTask Accuracy | Ξ (Improvement) | VRAM Reduction |
|---|---|---|---|---|
| NER + POS | 92.1% / 96.3% | 93.4% / 97.1% | +1.3% | 38% |
| QA + Summarization | 88.5% / 40.2 ROUGE | 90.2% / 43.1 | +2.9% | 45% |
| Translation + Sentiment | 84.2 BLEU / 91.0% | 85.1 / 92.3% | +1.2% | 52% |
| 4-class Intent + 2-class OOS | 89.0% / 91.5% | 90.4% / 93.2% | +1.7% | 60% |
Your results may vary based on data quality, task similarity, and hyperparameters. Treat these as directional indicators, not promises.
Symptom: One taskβs accuracy drops while others rise. Remedy: Check the gradient conflict map. If the tasks are in opposition, either reduce the learning rate for that task specifically (per-task LR) or reconsider if they should share layers.
Symptom: Training is slow despite powerful GPU. Remedy: Enable the βsmart batchingβ modeβit groups examples from the same task into same-length batches, reducing padding waste by up to 60%.
Symptom: The dashboard shows NaN losses.
Remedy: Overflow in FP16. Switch to bfloat16 (supported natively) or add gradient clipping (set max_grad_norm=1.0).
Symptom: Multilingual performance is worse than English-only. Remedy: Add a language identification task to your task list. It forces the model to allocate separate sub-spaces for each language, preventing interference.
We welcome:
- New task heads β if you have a novel architecture (e.g., graph neural head for dependency parsing), submit a PR.
- Data pipeline plugins β support for custom formats like Parquet, Arrow, or your proprietary format.
- Theoretical work β papers on multi-task loss weighting or curriculum scheduling, weβll implement them.
Please read CONTRIBUTING.md before starting. All contributions must include tests and documentation. Main code area maintainers review every PR within 5 business days.
This project is released under the MIT License β you are free to use, modify, and distribute it for commercial or personal purposes, provided you retain the original copyright notice. The license covers all code, configuration files, and documentation within this repository.
Full License Text: MIT License
- Accuracy Not Guaranteed: While we strive for high performance, the multi-task learning outcomes depend entirely on your data quality, task compatibility, and hyperparameter choices. We provide benchmark reports for reference, but your production accuracy may differ significantly.
- Data Privacy: The dashboard and logging tools run locally and do not transmit data to our servers. However, if you modify the code to add third-party integrations (e.g., cloud logging), you assume responsibility for compliance with data protection regulations.
- API Stability: The core API (
core/orchestrator.py) is stable within major versions (0.x, 1.x). However, task head interfaces may change between minor versions as we improve the underlying abstractions. - No Medical/Legal Advice: Example use cases in medical or legal domains are illustrative only. Do not use PolyTask outputs directly in clinical decision-making or legal proceedings without human supervision.
- Hardware Requirements: Training requires a GPU with at least 8GB VRAM (for base modernBERT). CPU-only training is possible but extremely slow for sequences >256 tokensβwe recommend cloud GPU instances for any serious experimentation.
- Q1 2026: Implementation of Task Curriculum Scheduler β automatically orders tasks from easy to hard, mimicking human learning.
- Q2 2026: Meta-Learning Mode β allow the model to learn the task weights itself via a gradient-based meta-learner (Reptile algorithm).
- Q3 2026: Cluster Deployment Support β native integration with Ray Tune for hyperparameter optimization across 10+ GPUs.
- Q4 2026: Federated Multi-Task Learning β enable multiple organizations to jointly train without sharing raw data, with encrypted gradient aggregation.
- Always Ongoing: Weekly bug fixes, dependency updates, and performance optimizations.
PolyTask Orchestrator is your baton. Whether youβre conducting a solo piano piece (single-task fine-tuning) or a full symphony with a hundred instruments (massive multi-task learning), the platform scales gracefully. The more tasks you add, the more synergistic effects emergeβa phenomenon weβve observed but not yet fully explained theoretically.
We invite you to experiment boldly. Try unusual task combinations. Break the conventions. The engine is built to handle chaos and turn it into structured intelligence. And when you discover a particularly magical task pairing, share it in the examples folderβyour discovery might become the next default recipe.
Remember: In the landscape of natural language, no task is an island. Every classification is a comma in a larger sentence; every generation is a paragraph in a longer story. PolyTask helps you read the whole story, not just the sentence.
Made with π§ by dedicated researchers who believe that sharing representations beats sharing annotations.
Last updated: 2026