Add time-series-forecasting task schema#2126
Open
pjhul wants to merge 12 commits into
Open
Conversation
Contributor
hanouticelina
left a comment
There was a problem hiding this comment.
Hi @pjhul, did a first pass to the PR, thanks a lot for working at this!
could you share links to the schemas/docs you used as reference?
When I asked an AI agent to cross-check, some of the claims didn't quite hold against current docs:
- Darts is 3D, not 2D. docs say "Return a 3-D array of dimension (time,
component, sample)" - GluonTS is 1D for univariate and 2D
(dim, num_time_steps)for multivariate - Chronos-1 is 1D-only,
predictaccepts "a 1D tensor, or a list of 1D
tensors, or a 2D tensor whose first dimension is batch"* Chronos-2 adds
multivariate, so if you used Chronos-2 the prose just needs narrowing. - DeepAR is 1D with
"NaN"strings:"target": [4.0, 10.0, "NaN", 100.0, 113.0]
want to make sure it's comparing against the same references you used.
julien-c
reviewed
May 19, 2026
format: "date-time" makes quicktype generate `Date` types, but @huggingface/inference parses responses with a bare JSON.parse and never hydrates fields into Date objects. Drop the format so the generated types (`start`, `timestamps`) match the raw string values returned at runtime. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
monash_tsf only resolves via a 307 redirect and Salesforce/gift-eval returns 401 (not a public repo). Use the canonical ids Monash-University/monash_tsf and Salesforce/GiftEval, both verified 200. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add minItems:1 at both the time and channel axes so the schemas reject nonsensical empty inputs/outputs (target:[], target:[[]], mean:[]). prediction_length already enforces minimum:1, so a non-empty mean is always expected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Align with Darts and GluonTS, where future covariates must cover the target's historical window plus the forecast horizon (total length num_timesteps + prediction_length), not just the horizon. Allow null in the historical portion to match past_covariates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The demo input/output were flat 1D arrays, but the spec and about.md example use the always-2D [time][channel] shape. Show the univariate demo as a length-1 channel axis so the example is internally consistent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reject duplicate quantile levels via uniqueItems; duplicates would produce redundant quantile_predictions entries. Keep the (0,1) range (matches Darts) and document that the response sorts predictions ascending by level, so callers needn't pre-sort. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a seed parameter so sample-based probabilistic forecasts can be reproduced across retries. Unconstrained integer to match the repo convention (text-generation, text-to-image). Note that support is best-effort: not all probabilistic models/providers honor seeding. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add Hugging Face transformers (PatchTST, PatchTSMixer, Autoformer, Informer, Time Series Transformer) and transformers.js (PatchTST/ PatchTSMixer via ONNX) to the Direct Inference section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f7fdc57. Configure here.
Unlike other tasks where `inputs` is the data itself, here it is a batch container whose elements are each one time series. Rename it to `series` to make that explicit, matching the term of art in Darts (TimeSeries) and GluonTS (each entry is one time series). Also rename the element type TimeSeriesForecastingInputItem -> TimeSeriesForecastingSeries. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirror the minItems:1 constraints from mean/series onto the parallel output fields: quantile_predictions.values and samples (which are documented as "same shape as mean"), and the outputs array itself (1:1 with series). Closes the gaps flagged by Cursor Bugbot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Scaffolds the new
time-series-forecastingtask with input/output JSON schemas, generated TypeScript types, task metadata, and registry wiring.pnpm check,test, andlint:checkon the tasks package all pass locally.Design decisions worth flagging
inputsis a list of structured series objects, not a string or binary payload. This diverges from existing HF tasks but aligns closely with mature time-series libraries (Darts, GluonTS, AWS SageMaker Chronos). Parallel-array encodings don't survive contact with ragged lengths or per-series optional fields (timestamps, covariates, metadata).targetis always 2D[num_timesteps][num_channels]. Univariate series use a length-1 channel axis. AvoidsoneOf 1D/2Dambiguity at length-1 inputs.Missing observations are
nullinline insidetarget, not a separateobserved_mask. Matches pandas, R, SQL, Arrow convention. HF's TimeSeriesTransformer usespast_observed_maskbecause PyTorch tensors can't hold null — but for API consumers dealing with a separate mask is much more cumbersome than in-line null's.Input uses
start+parameters.frequencyrather than an explicit timestamps array. Matches the DartsTimeSeriesmodel.quantile_predictionsis an array of{level, values}objects rather than a dict keyed by string-float. Matches HF's pattern for enumerated scored outputs (text-generationlogprobs, classification scores, fill-mask tokens). AWS Chronos uses a dict-keyed-by-string; we diverge intentionally for HF-ecosystem consistency.Three uncertainty channels on output —
mean(required),quantile_predictions,samples. All optional; they may coexist. No parametric distribution parameters.samplesis the universal fallback for any distributional output.Validation
pnpm --filter tasks-gen inference-codegenregenerates cleaninference.tsfrom the JSON schemaspnpm --filter @huggingface/tasks check(tsc)pnpm --filter @huggingface/tasks testpnpm --filter @huggingface/tasks lint:checkpackages/tasks/src/tasks/index.tsNote
Low Risk
Additive task scaffolding and type exports only; no runtime inference or auth changes in this diff.
Overview
This PR fully wires the
time-series-forecastingpipeline in@huggingface/tasks, replacing the previousundefinedtask entry with schemas, generated types, Hub task content, and registry exports.Inference contract: New JSON Schema input/output specs define batch requests as a
seriesarray of structured objects. Each series uses a required 2Dtarget[timesteps][channels](univariate via length-1 channels), optionalstart+parameters.frequencyfor timestamps, covariates (past_/future_/static), and echoedmetadata. Parameters coverprediction_length,quantile_levels,num_samples, andseed. Responses return per-seriesoutputswith requiredmean, optionalquantile_predictionsas{level, values}arrays, optionalsamples, and optional forecasttimestamps.Package integration:
inference.tsis codegen from those schemas; public types are re-exported fromtasks/index.ts. Task page data (data.ts), docs (about.md), demo/metrics/models, andTASKS_DATA["time-series-forecasting"]now use the real module instead of a placeholder.Reviewed by Cursor Bugbot for commit 3932799. Bugbot is set up for automated code reviews on this repo. Configure here.