@huggingface/tasks 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4084,7 +4084,7 @@ var flair = (model) => [
4084
4084
  tagger = SequenceTagger.load("${model.id}")`
4085
4085
  ];
4086
4086
  var gliner = (model) => [
4087
- `from model import GLiNER
4087
+ `from gliner import GLiNER
4088
4088
 
4089
4089
  model = GLiNER.from_pretrained("${model.id}")`
4090
4090
  ];
@@ -4434,6 +4434,11 @@ var mlx = (model) => [
4434
4434
  export HF_HUB_ENABLE_HF_TRANS: string[]FER=1
4435
4435
  huggingface-cli download --local-dir ${nameWithoutNamespace(model.id)} ${model.id}`
4436
4436
  ];
4437
+ var mlxim = (model) => [
4438
+ `from mlxim.model import create_model
4439
+
4440
+ model = create_model(${model.id})`
4441
+ ];
4437
4442
  var nemo = (model) => {
4438
4443
  let command = void 0;
4439
4444
  if (model.tags?.includes("automatic-speech-recognition")) {
@@ -4593,6 +4598,15 @@ var MODEL_LIBRARIES_UI_ELEMENTS = {
4593
4598
  term: { path: "gliner_config.json" }
4594
4599
  }
4595
4600
  },
4601
+ grok: {
4602
+ prettyLabel: "Grok",
4603
+ repoName: "Grok",
4604
+ repoUrl: "https://github.com/xai-org/grok-1",
4605
+ filter: false,
4606
+ countDownloads: {
4607
+ terms: { path: ["ckpt/tensor00000_000", "ckpt-0/tensor00000_000"] }
4608
+ }
4609
+ },
4596
4610
  keras: {
4597
4611
  prettyLabel: "Keras",
4598
4612
  repoName: "Keras",
@@ -4628,6 +4642,15 @@ var MODEL_LIBRARIES_UI_ELEMENTS = {
4628
4642
  snippets: mlx,
4629
4643
  filter: true
4630
4644
  },
4645
+ "mlx-image": {
4646
+ prettyLabel: "mlx-image",
4647
+ repoName: "mlx-image",
4648
+ repoUrl: "https://github.com/riccardomusmeci/mlx-image",
4649
+ docsUrl: "https://huggingface.co/docs/hub/mlx-image",
4650
+ snippets: mlxim,
4651
+ filter: false,
4652
+ countDownloads: { term: { path: "model.safetensors" } }
4653
+ },
4631
4654
  nemo: {
4632
4655
  prettyLabel: "NeMo",
4633
4656
  repoName: "NeMo",
package/dist/index.d.ts CHANGED
@@ -851,6 +851,17 @@ declare const MODEL_LIBRARIES_UI_ELEMENTS: {
851
851
  };
852
852
  };
853
853
  };
854
+ grok: {
855
+ prettyLabel: string;
856
+ repoName: string;
857
+ repoUrl: string;
858
+ filter: false;
859
+ countDownloads: {
860
+ terms: {
861
+ path: string[];
862
+ };
863
+ };
864
+ };
854
865
  keras: {
855
866
  prettyLabel: string;
856
867
  repoName: string;
@@ -894,6 +905,19 @@ declare const MODEL_LIBRARIES_UI_ELEMENTS: {
894
905
  snippets: (model: ModelData) => string[];
895
906
  filter: true;
896
907
  };
908
+ "mlx-image": {
909
+ prettyLabel: string;
910
+ repoName: string;
911
+ repoUrl: string;
912
+ docsUrl: string;
913
+ snippets: (model: ModelData) => string[];
914
+ filter: false;
915
+ countDownloads: {
916
+ term: {
917
+ path: string;
918
+ };
919
+ };
920
+ };
897
921
  nemo: {
898
922
  prettyLabel: string;
899
923
  repoName: string;
@@ -1117,8 +1141,8 @@ declare const MODEL_LIBRARIES_UI_ELEMENTS: {
1117
1141
  };
1118
1142
  };
1119
1143
  type ModelLibraryKey = keyof typeof MODEL_LIBRARIES_UI_ELEMENTS;
1120
- declare const ALL_MODEL_LIBRARY_KEYS: ("sklearn" | "adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "bertopic" | "diffusers" | "doctr" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gliner" | "keras" | "k2" | "mindspore" | "ml-agents" | "mlx" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "sample-factory" | "sentence-transformers" | "setfit" | "spacy" | "span-marker" | "speechbrain" | "stable-baselines3" | "stanza" | "tensorflowtts" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "whisperkit")[];
1121
- declare const ALL_DISPLAY_MODEL_LIBRARY_KEYS: ("sklearn" | "adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "bertopic" | "diffusers" | "doctr" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gliner" | "keras" | "k2" | "mindspore" | "ml-agents" | "mlx" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "sample-factory" | "sentence-transformers" | "setfit" | "spacy" | "span-marker" | "speechbrain" | "stable-baselines3" | "stanza" | "tensorflowtts" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "whisperkit")[];
1144
+ declare const ALL_MODEL_LIBRARY_KEYS: ("sklearn" | "adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "bertopic" | "diffusers" | "doctr" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gliner" | "grok" | "keras" | "k2" | "mindspore" | "ml-agents" | "mlx" | "mlx-image" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "sample-factory" | "sentence-transformers" | "setfit" | "spacy" | "span-marker" | "speechbrain" | "stable-baselines3" | "stanza" | "tensorflowtts" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "whisperkit")[];
1145
+ declare const ALL_DISPLAY_MODEL_LIBRARY_KEYS: ("sklearn" | "adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "bertopic" | "diffusers" | "doctr" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gliner" | "grok" | "keras" | "k2" | "mindspore" | "ml-agents" | "mlx" | "mlx-image" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "sample-factory" | "sentence-transformers" | "setfit" | "spacy" | "span-marker" | "speechbrain" | "stable-baselines3" | "stanza" | "tensorflowtts" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "whisperkit")[];
1122
1146
 
1123
1147
  /**
1124
1148
  * Mapping from library name (excluding Transformers) to its supported tasks.
@@ -1338,6 +1362,154 @@ interface AutomaticSpeechRecognitionOutputChunk {
1338
1362
  [property: string]: unknown;
1339
1363
  }
1340
1364
 
1365
+ /**
1366
+ * Inference code generated from the JSON schema spec in ./spec
1367
+ *
1368
+ * Using src/scripts/inference-codegen
1369
+ */
1370
+ /**
1371
+ * Inputs for ChatCompletion inference
1372
+ */
1373
+ interface ChatCompletionInput {
1374
+ /**
1375
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing
1376
+ * frequency in the text so far, decreasing the model's likelihood to repeat the same line
1377
+ * verbatim.
1378
+ */
1379
+ frequency_penalty?: number;
1380
+ /**
1381
+ * The maximum number of tokens that can be generated in the chat completion.
1382
+ */
1383
+ max_tokens?: number;
1384
+ messages: ChatCompletionInputMessage[];
1385
+ /**
1386
+ * The random sampling seed.
1387
+ */
1388
+ seed?: number;
1389
+ /**
1390
+ * Stop generating tokens if a stop token is generated.
1391
+ */
1392
+ stop?: ChatCompletionInputStopReason;
1393
+ /**
1394
+ * If set, partial message deltas will be sent.
1395
+ */
1396
+ stream?: boolean;
1397
+ /**
1398
+ * The value used to modulate the logits distribution.
1399
+ */
1400
+ temperature?: number;
1401
+ /**
1402
+ * If set to < 1, only the smallest set of most probable tokens with probabilities that add
1403
+ * up to `top_p` or higher are kept for generation.
1404
+ */
1405
+ top_p?: number;
1406
+ [property: string]: unknown;
1407
+ }
1408
+ interface ChatCompletionInputMessage {
1409
+ /**
1410
+ * The content of the message.
1411
+ */
1412
+ content: string;
1413
+ role: ChatCompletionMessageRole;
1414
+ [property: string]: unknown;
1415
+ }
1416
+ /**
1417
+ * The role of the message author.
1418
+ */
1419
+ type ChatCompletionMessageRole = "assistant" | "system" | "user";
1420
+ /**
1421
+ * Stop generating tokens if a stop token is generated.
1422
+ */
1423
+ type ChatCompletionInputStopReason = string[] | string;
1424
+ /**
1425
+ * Outputs for Chat Completion inference
1426
+ */
1427
+ interface ChatCompletionOutput {
1428
+ /**
1429
+ * A list of chat completion choices.
1430
+ */
1431
+ choices: ChatCompletionOutputChoice[];
1432
+ /**
1433
+ * The Unix timestamp (in seconds) of when the chat completion was created.
1434
+ */
1435
+ created: number;
1436
+ [property: string]: unknown;
1437
+ }
1438
+ interface ChatCompletionOutputChoice {
1439
+ /**
1440
+ * The reason why the generation was stopped.
1441
+ */
1442
+ finish_reason: ChatCompletionFinishReason;
1443
+ /**
1444
+ * The index of the choice in the list of choices.
1445
+ */
1446
+ index: number;
1447
+ message: ChatCompletionOutputChoiceMessage;
1448
+ [property: string]: unknown;
1449
+ }
1450
+ /**
1451
+ * The reason why the generation was stopped.
1452
+ *
1453
+ * The generated sequence reached the maximum allowed length
1454
+ *
1455
+ * The model generated an end-of-sentence (EOS) token
1456
+ *
1457
+ * One of the sequence in stop_sequences was generated
1458
+ */
1459
+ type ChatCompletionFinishReason = "length" | "eos_token" | "stop_sequence";
1460
+ interface ChatCompletionOutputChoiceMessage {
1461
+ /**
1462
+ * The content of the chat completion message.
1463
+ */
1464
+ content: string;
1465
+ role: ChatCompletionMessageRole;
1466
+ [property: string]: unknown;
1467
+ }
1468
+ /**
1469
+ * Chat Completion Stream Output
1470
+ */
1471
+ interface ChatCompletionStreamOutput {
1472
+ /**
1473
+ * A list of chat completion choices.
1474
+ */
1475
+ choices: ChatCompletionStreamOutputChoice[];
1476
+ /**
1477
+ * The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has
1478
+ * the same timestamp.
1479
+ */
1480
+ created: number;
1481
+ [property: string]: unknown;
1482
+ }
1483
+ interface ChatCompletionStreamOutputChoice {
1484
+ /**
1485
+ * A chat completion delta generated by streamed model responses.
1486
+ */
1487
+ delta: ChatCompletionStreamOutputDelta;
1488
+ /**
1489
+ * The reason why the generation was stopped.
1490
+ */
1491
+ finish_reason?: ChatCompletionFinishReason;
1492
+ /**
1493
+ * The index of the choice in the list of choices.
1494
+ */
1495
+ index: number;
1496
+ [property: string]: unknown;
1497
+ }
1498
+ /**
1499
+ * A chat completion delta generated by streamed model responses.
1500
+ */
1501
+ interface ChatCompletionStreamOutputDelta {
1502
+ /**
1503
+ * The contents of the chunk message.
1504
+ */
1505
+ content?: string;
1506
+ /**
1507
+ * The role of the author of this message.
1508
+ */
1509
+ role?: string;
1510
+ [property: string]: unknown;
1511
+ }
1512
+
1341
1513
  /**
1342
1514
  * Inference code generated from the JSON schema spec in ./spec
1343
1515
  *
@@ -2622,6 +2794,10 @@ interface TextGenerationInput {
2622
2794
  * Additional inference parameters
2623
2795
  */
2624
2796
  parameters?: TextGenerationParameters;
2797
+ /**
2798
+ * Whether to stream output tokens
2799
+ */
2800
+ stream?: boolean;
2625
2801
  [property: string]: unknown;
2626
2802
  }
2627
2803
  /**
@@ -2717,16 +2893,16 @@ interface TextGenerationOutputDetails {
2717
2893
  /**
2718
2894
  * Details about additional sequences when best_of is provided
2719
2895
  */
2720
- best_of_sequences?: TextGenerationSequenceDetails[];
2896
+ best_of_sequences?: TextGenerationOutputSequenceDetails[];
2721
2897
  /**
2722
2898
  * The reason why the generation was stopped.
2723
2899
  */
2724
- finish_reason: FinishReason;
2900
+ finish_reason: TextGenerationFinishReason;
2725
2901
  /**
2726
2902
  * The number of generated tokens
2727
2903
  */
2728
2904
  generated_tokens: number;
2729
- prefill: PrefillToken[];
2905
+ prefill: TextGenerationPrefillToken[];
2730
2906
  /**
2731
2907
  * The random seed used for generation
2732
2908
  */
@@ -2734,23 +2910,24 @@ interface TextGenerationOutputDetails {
2734
2910
  /**
2735
2911
  * The generated tokens and associated details
2736
2912
  */
2737
- tokens: Token[];
2738
- [property: string]: unknown;
2739
- }
2740
- interface TextGenerationSequenceDetails {
2913
+ tokens: TextGenerationOutputToken[];
2741
2914
  /**
2742
- * The reason why the generation was stopped.
2915
+ * Most likely tokens
2743
2916
  */
2744
- finish_reason: FinishReason;
2917
+ top_tokens?: Array<TextGenerationOutputToken[]>;
2918
+ [property: string]: unknown;
2919
+ }
2920
+ interface TextGenerationOutputSequenceDetails {
2921
+ finish_reason: TextGenerationFinishReason;
2745
2922
  /**
2746
2923
  * The generated text
2747
2924
  */
2748
- generated_text: number;
2925
+ generated_text: string;
2749
2926
  /**
2750
2927
  * The number of generated tokens
2751
2928
  */
2752
2929
  generated_tokens: number;
2753
- prefill: PrefillToken[];
2930
+ prefill: TextGenerationPrefillToken[];
2754
2931
  /**
2755
2932
  * The random seed used for generation
2756
2933
  */
@@ -2758,18 +2935,24 @@ interface TextGenerationSequenceDetails {
2758
2935
  /**
2759
2936
  * The generated tokens and associated details
2760
2937
  */
2761
- tokens: Token[];
2938
+ tokens: TextGenerationOutputToken[];
2939
+ /**
2940
+ * Most likely tokens
2941
+ */
2942
+ top_tokens?: Array<TextGenerationOutputToken[]>;
2762
2943
  [property: string]: unknown;
2763
2944
  }
2764
2945
  /**
2765
- * The generated sequence reached the maximum allowed length
2946
+ * The reason why the generation was stopped.
2766
2947
  *
2767
- * The model generated an end-of-sentence (EOS) token
2948
+ * length: The generated sequence reached the maximum allowed length
2768
2949
  *
2769
- * One of the sequence in stop_sequences was generated
2950
+ * eos_token: The model generated an end-of-sentence (EOS) token
2951
+ *
2952
+ * stop_sequence: One of the sequence in stop_sequences was generated
2770
2953
  */
2771
- type FinishReason = "length" | "eos_token" | "stop_sequence";
2772
- interface PrefillToken {
2954
+ type TextGenerationFinishReason = "length" | "eos_token" | "stop_sequence";
2955
+ interface TextGenerationPrefillToken {
2773
2956
  id: number;
2774
2957
  logprob: number;
2775
2958
  /**
@@ -2778,9 +2961,12 @@ interface PrefillToken {
2778
2961
  text: string;
2779
2962
  [property: string]: unknown;
2780
2963
  }
2781
- interface Token {
2964
+ /**
2965
+ * Generated token.
2966
+ */
2967
+ interface TextGenerationOutputToken {
2782
2968
  id: number;
2783
- logprob: number;
2969
+ logprob?: number;
2784
2970
  /**
2785
2971
  * Whether or not that token is a special one
2786
2972
  */
@@ -3285,4 +3471,4 @@ declare namespace index {
3285
3471
  };
3286
3472
  }
3287
3473
 
3288
- export { ALL_DISPLAY_MODEL_LIBRARY_KEYS, ALL_MODEL_LIBRARY_KEYS, AddedToken, AudioClassificationInput, AudioClassificationOutput, AudioClassificationOutputElement, AudioClassificationParameters, AutomaticSpeechRecognitionInput, AutomaticSpeechRecognitionOutput, AutomaticSpeechRecognitionOutputChunk, AutomaticSpeechRecognitionParameters, BoundingBox, ChatMessage, ClassificationOutputTransform$1 as ClassificationOutputTransform, DepthEstimationInput, DepthEstimationOutput, DocumentQuestionAnsweringInput, DocumentQuestionAnsweringInputData, DocumentQuestionAnsweringOutput, DocumentQuestionAnsweringOutputElement, DocumentQuestionAnsweringParameters, EarlyStoppingUnion$2 as EarlyStoppingUnion, ExampleRepo, FeatureExtractionInput, FeatureExtractionOutput, FillMaskInput, FillMaskOutput, FillMaskOutputElement, FillMaskParameters, FinishReason, GenerationParameters$2 as GenerationParameters, ImageClassificationInput, ImageClassificationOutput, ImageClassificationOutputElement, ImageClassificationParameters, ImageSegmentationInput, ImageSegmentationOutput, ImageSegmentationOutputElement, ImageSegmentationParameters, ImageSegmentationSubtask, ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToTextInput, ImageToTextOutput, ImageToTextParameters, InferenceDisplayability, LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS, LibraryUiElement, MAPPING_DEFAULT_WIDGET, MODALITIES, MODALITY_LABELS, MODEL_LIBRARIES_UI_ELEMENTS, Modality, ModelData, ModelLibraryKey, ObjectDetectionInput, ObjectDetectionOutput, ObjectDetectionOutputElement, ObjectDetectionParameters, PIPELINE_DATA, PIPELINE_TYPES, PIPELINE_TYPES_SET, PipelineData, PipelineType, PrefillToken, QuestionAnsweringInput, QuestionAnsweringInputData, QuestionAnsweringOutput, QuestionAnsweringOutputElement, QuestionAnsweringParameters, SPECIAL_TOKENS_ATTRIBUTES, SUBTASK_TYPES, SentenceSimilarityInput, SentenceSimilarityInputData, SentenceSimilarityOutput, SpecialTokensMap, SummarizationInput, SummarizationOutput, TASKS_DATA, TASKS_MODEL_LIBRARIES, TableQuestionAnsweringInput, TableQuestionAnsweringInputData, TableQuestionAnsweringOutput, TableQuestionAnsweringOutputElement, TargetSize$1 as TargetSize, TaskData, TaskDataCustom, TaskDemo, TaskDemoEntry, Text2TextGenerationParameters, Text2TextGenerationTruncationStrategy, TextClassificationInput, TextClassificationOutput, TextClassificationOutputElement, TextClassificationParameters, TextGenerationInput, TextGenerationOutput, TextGenerationOutputDetails, TextGenerationParameters, TextGenerationSequenceDetails, TextToAudioParameters, TextToImageInput, TextToImageOutput, TextToImageParameters, TextToSpeechInput, TextToSpeechOutput, Token, TokenClassificationAggregationStrategy, TokenClassificationInput, TokenClassificationOutput, TokenClassificationOutputElement, TokenClassificationParameters, TokenizerConfig, TransformersInfo, TranslationInput, TranslationOutput, VideoClassificationInput, VideoClassificationOutput, VideoClassificationOutputElement, VideoClassificationParameters, VisualQuestionAnsweringInput, VisualQuestionAnsweringInputData, VisualQuestionAnsweringOutput, VisualQuestionAnsweringOutputElement, VisualQuestionAnsweringParameters, WidgetExample, WidgetExampleAssetAndPromptInput, WidgetExampleAssetAndTextInput, WidgetExampleAssetAndZeroShotInput, WidgetExampleAssetInput, WidgetExampleAttribute, WidgetExampleChatInput, WidgetExampleOutput, WidgetExampleOutputAnswerScore, WidgetExampleOutputLabels, WidgetExampleOutputText, WidgetExampleOutputUrl, WidgetExampleSentenceSimilarityInput, WidgetExampleStructuredDataInput, WidgetExampleTableDataInput, WidgetExampleTextAndContextInput, WidgetExampleTextAndTableInput, WidgetExampleTextInput, WidgetExampleZeroShotTextInput, WidgetType, WordBox, ZeroShotClassificationInput, ZeroShotClassificationInputData, ZeroShotClassificationOutput, ZeroShotClassificationOutputElement, ZeroShotClassificationParameters, ZeroShotImageClassificationInput, ZeroShotImageClassificationInputData, ZeroShotImageClassificationOutput, ZeroShotImageClassificationOutputElement, ZeroShotImageClassificationParameters, ZeroShotObjectDetectionInput, ZeroShotObjectDetectionInputData, ZeroShotObjectDetectionOutput, ZeroShotObjectDetectionOutputElement, index as snippets };
3474
+ export { ALL_DISPLAY_MODEL_LIBRARY_KEYS, ALL_MODEL_LIBRARY_KEYS, AddedToken, AudioClassificationInput, AudioClassificationOutput, AudioClassificationOutputElement, AudioClassificationParameters, AutomaticSpeechRecognitionInput, AutomaticSpeechRecognitionOutput, AutomaticSpeechRecognitionOutputChunk, AutomaticSpeechRecognitionParameters, BoundingBox, ChatCompletionFinishReason, ChatCompletionInput, ChatCompletionInputMessage, ChatCompletionOutput, ChatCompletionOutputChoice, ChatCompletionOutputChoiceMessage, ChatCompletionStreamOutput, ChatCompletionStreamOutputChoice, ChatCompletionStreamOutputDelta, ChatMessage, ClassificationOutputTransform$1 as ClassificationOutputTransform, DepthEstimationInput, DepthEstimationOutput, DocumentQuestionAnsweringInput, DocumentQuestionAnsweringInputData, DocumentQuestionAnsweringOutput, DocumentQuestionAnsweringOutputElement, DocumentQuestionAnsweringParameters, EarlyStoppingUnion$2 as EarlyStoppingUnion, ExampleRepo, FeatureExtractionInput, FeatureExtractionOutput, FillMaskInput, FillMaskOutput, FillMaskOutputElement, FillMaskParameters, GenerationParameters$2 as GenerationParameters, ImageClassificationInput, ImageClassificationOutput, ImageClassificationOutputElement, ImageClassificationParameters, ImageSegmentationInput, ImageSegmentationOutput, ImageSegmentationOutputElement, ImageSegmentationParameters, ImageSegmentationSubtask, ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToTextInput, ImageToTextOutput, ImageToTextParameters, InferenceDisplayability, LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS, LibraryUiElement, MAPPING_DEFAULT_WIDGET, MODALITIES, MODALITY_LABELS, MODEL_LIBRARIES_UI_ELEMENTS, Modality, ModelData, ModelLibraryKey, ObjectDetectionInput, ObjectDetectionOutput, ObjectDetectionOutputElement, ObjectDetectionParameters, PIPELINE_DATA, PIPELINE_TYPES, PIPELINE_TYPES_SET, PipelineData, PipelineType, QuestionAnsweringInput, QuestionAnsweringInputData, QuestionAnsweringOutput, QuestionAnsweringOutputElement, QuestionAnsweringParameters, SPECIAL_TOKENS_ATTRIBUTES, SUBTASK_TYPES, SentenceSimilarityInput, SentenceSimilarityInputData, SentenceSimilarityOutput, SpecialTokensMap, SummarizationInput, SummarizationOutput, TASKS_DATA, TASKS_MODEL_LIBRARIES, TableQuestionAnsweringInput, TableQuestionAnsweringInputData, TableQuestionAnsweringOutput, TableQuestionAnsweringOutputElement, TargetSize$1 as TargetSize, TaskData, TaskDataCustom, TaskDemo, TaskDemoEntry, Text2TextGenerationParameters, Text2TextGenerationTruncationStrategy, TextClassificationInput, TextClassificationOutput, TextClassificationOutputElement, TextClassificationParameters, TextGenerationFinishReason, TextGenerationInput, TextGenerationOutput, TextGenerationOutputDetails, TextGenerationOutputSequenceDetails, TextGenerationOutputToken, TextGenerationParameters, TextGenerationPrefillToken, TextToAudioParameters, TextToImageInput, TextToImageOutput, TextToImageParameters, TextToSpeechInput, TextToSpeechOutput, TokenClassificationAggregationStrategy, TokenClassificationInput, TokenClassificationOutput, TokenClassificationOutputElement, TokenClassificationParameters, TokenizerConfig, TransformersInfo, TranslationInput, TranslationOutput, VideoClassificationInput, VideoClassificationOutput, VideoClassificationOutputElement, VideoClassificationParameters, VisualQuestionAnsweringInput, VisualQuestionAnsweringInputData, VisualQuestionAnsweringOutput, VisualQuestionAnsweringOutputElement, VisualQuestionAnsweringParameters, WidgetExample, WidgetExampleAssetAndPromptInput, WidgetExampleAssetAndTextInput, WidgetExampleAssetAndZeroShotInput, WidgetExampleAssetInput, WidgetExampleAttribute, WidgetExampleChatInput, WidgetExampleOutput, WidgetExampleOutputAnswerScore, WidgetExampleOutputLabels, WidgetExampleOutputText, WidgetExampleOutputUrl, WidgetExampleSentenceSimilarityInput, WidgetExampleStructuredDataInput, WidgetExampleTableDataInput, WidgetExampleTextAndContextInput, WidgetExampleTextAndTableInput, WidgetExampleTextInput, WidgetExampleZeroShotTextInput, WidgetType, WordBox, ZeroShotClassificationInput, ZeroShotClassificationInputData, ZeroShotClassificationOutput, ZeroShotClassificationOutputElement, ZeroShotClassificationParameters, ZeroShotImageClassificationInput, ZeroShotImageClassificationInputData, ZeroShotImageClassificationOutput, ZeroShotImageClassificationOutputElement, ZeroShotImageClassificationParameters, ZeroShotObjectDetectionInput, ZeroShotObjectDetectionInputData, ZeroShotObjectDetectionOutput, ZeroShotObjectDetectionOutputElement, index as snippets };
package/dist/index.js CHANGED
@@ -4049,7 +4049,7 @@ var flair = (model) => [
4049
4049
  tagger = SequenceTagger.load("${model.id}")`
4050
4050
  ];
4051
4051
  var gliner = (model) => [
4052
- `from model import GLiNER
4052
+ `from gliner import GLiNER
4053
4053
 
4054
4054
  model = GLiNER.from_pretrained("${model.id}")`
4055
4055
  ];
@@ -4399,6 +4399,11 @@ var mlx = (model) => [
4399
4399
  export HF_HUB_ENABLE_HF_TRANS: string[]FER=1
4400
4400
  huggingface-cli download --local-dir ${nameWithoutNamespace(model.id)} ${model.id}`
4401
4401
  ];
4402
+ var mlxim = (model) => [
4403
+ `from mlxim.model import create_model
4404
+
4405
+ model = create_model(${model.id})`
4406
+ ];
4402
4407
  var nemo = (model) => {
4403
4408
  let command = void 0;
4404
4409
  if (model.tags?.includes("automatic-speech-recognition")) {
@@ -4558,6 +4563,15 @@ var MODEL_LIBRARIES_UI_ELEMENTS = {
4558
4563
  term: { path: "gliner_config.json" }
4559
4564
  }
4560
4565
  },
4566
+ grok: {
4567
+ prettyLabel: "Grok",
4568
+ repoName: "Grok",
4569
+ repoUrl: "https://github.com/xai-org/grok-1",
4570
+ filter: false,
4571
+ countDownloads: {
4572
+ terms: { path: ["ckpt/tensor00000_000", "ckpt-0/tensor00000_000"] }
4573
+ }
4574
+ },
4561
4575
  keras: {
4562
4576
  prettyLabel: "Keras",
4563
4577
  repoName: "Keras",
@@ -4593,6 +4607,15 @@ var MODEL_LIBRARIES_UI_ELEMENTS = {
4593
4607
  snippets: mlx,
4594
4608
  filter: true
4595
4609
  },
4610
+ "mlx-image": {
4611
+ prettyLabel: "mlx-image",
4612
+ repoName: "mlx-image",
4613
+ repoUrl: "https://github.com/riccardomusmeci/mlx-image",
4614
+ docsUrl: "https://huggingface.co/docs/hub/mlx-image",
4615
+ snippets: mlxim,
4616
+ filter: false,
4617
+ countDownloads: { term: { path: "model.safetensors" } }
4618
+ },
4596
4619
  nemo: {
4597
4620
  prettyLabel: "NeMo",
4598
4621
  repoName: "NeMo",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@huggingface/tasks",
3
3
  "packageManager": "pnpm@8.10.5",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "description": "List of ML tasks for huggingface.co/tasks",
6
6
  "repository": "https://github.com/huggingface/huggingface.js.git",
7
7
  "publishConfig": {
@@ -33,7 +33,7 @@
33
33
  "license": "MIT",
34
34
  "devDependencies": {
35
35
  "@types/node": "^20.11.5",
36
- "quicktype-core": "https://github.com/huggingface/quicktype/raw/pack-18.0.15/packages/quicktype-core/quicktype-core-18.0.15.tgz"
36
+ "quicktype-core": "https://github.com/huggingface/quicktype/raw/pack-18.0.17/packages/quicktype-core/quicktype-core-18.0.17.tgz"
37
37
  },
38
38
  "scripts": {
39
39
  "lint": "eslint --quiet --fix --ext .cjs,.ts .",
@@ -141,7 +141,7 @@ tagger = SequenceTagger.load("${model.id}")`,
141
141
  ];
142
142
 
143
143
  export const gliner = (model: ModelData): string[] => [
144
- `from model import GLiNER
144
+ `from gliner import GLiNER
145
145
 
146
146
  model = GLiNER.from_pretrained("${model.id}")`,
147
147
  ];
@@ -538,6 +538,12 @@ export HF_HUB_ENABLE_HF_TRANS: string[]FER=1
538
538
  huggingface-cli download --local-dir ${nameWithoutNamespace(model.id)} ${model.id}`,
539
539
  ];
540
540
 
541
+ export const mlxim = (model: ModelData): string[] => [
542
+ `from mlxim.model import create_model
543
+
544
+ model = create_model(${model.id})`,
545
+ ];
546
+
541
547
  export const nemo = (model: ModelData): string[] => {
542
548
  let command: string[] | undefined = undefined;
543
549
  // Resolve the tag to a nemo domain/sub-domain
@@ -167,6 +167,15 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
167
167
  term: { path: "gliner_config.json" },
168
168
  },
169
169
  },
170
+ grok: {
171
+ prettyLabel: "Grok",
172
+ repoName: "Grok",
173
+ repoUrl: "https://github.com/xai-org/grok-1",
174
+ filter: false,
175
+ countDownloads: {
176
+ terms: { path: ["ckpt/tensor00000_000", "ckpt-0/tensor00000_000"] },
177
+ },
178
+ },
170
179
  keras: {
171
180
  prettyLabel: "Keras",
172
181
  repoName: "Keras",
@@ -202,6 +211,15 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
202
211
  snippets: snippets.mlx,
203
212
  filter: true,
204
213
  },
214
+ "mlx-image": {
215
+ prettyLabel: "mlx-image",
216
+ repoName: "mlx-image",
217
+ repoUrl: "https://github.com/riccardomusmeci/mlx-image",
218
+ docsUrl: "https://huggingface.co/docs/hub/mlx-image",
219
+ snippets: snippets.mlxim,
220
+ filter: false,
221
+ countDownloads: { term: { path: "model.safetensors" } },
222
+ },
205
223
  nemo: {
206
224
  prettyLabel: "NeMo",
207
225
  repoName: "NeMo",
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Inference code generated from the JSON schema spec in ./spec
3
+ *
4
+ * Using src/scripts/inference-codegen
5
+ */
6
+
7
+ /**
8
+ * Inputs for ChatCompletion inference
9
+ */
10
+ export interface ChatCompletionInput {
11
+ /**
12
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing
13
+ * frequency in the text so far, decreasing the model's likelihood to repeat the same line
14
+ * verbatim.
15
+ */
16
+ frequency_penalty?: number;
17
+ /**
18
+ * The maximum number of tokens that can be generated in the chat completion.
19
+ */
20
+ max_tokens?: number;
21
+ messages: ChatCompletionInputMessage[];
22
+ /**
23
+ * The random sampling seed.
24
+ */
25
+ seed?: number;
26
+ /**
27
+ * Stop generating tokens if a stop token is generated.
28
+ */
29
+ stop?: ChatCompletionInputStopReason;
30
+ /**
31
+ * If set, partial message deltas will be sent.
32
+ */
33
+ stream?: boolean;
34
+ /**
35
+ * The value used to modulate the logits distribution.
36
+ */
37
+ temperature?: number;
38
+ /**
39
+ * If set to < 1, only the smallest set of most probable tokens with probabilities that add
40
+ * up to `top_p` or higher are kept for generation.
41
+ */
42
+ top_p?: number;
43
+ [property: string]: unknown;
44
+ }
45
+
46
+ export interface ChatCompletionInputMessage {
47
+ /**
48
+ * The content of the message.
49
+ */
50
+ content: string;
51
+ role: ChatCompletionMessageRole;
52
+ [property: string]: unknown;
53
+ }
54
+
55
+ /**
56
+ * The role of the message author.
57
+ */
58
+ export type ChatCompletionMessageRole = "assistant" | "system" | "user";
59
+
60
+ /**
61
+ * Stop generating tokens if a stop token is generated.
62
+ */
63
+ export type ChatCompletionInputStopReason = string[] | string;
64
+
65
+ /**
66
+ * Outputs for Chat Completion inference
67
+ */
68
+ export interface ChatCompletionOutput {
69
+ /**
70
+ * A list of chat completion choices.
71
+ */
72
+ choices: ChatCompletionOutputChoice[];
73
+ /**
74
+ * The Unix timestamp (in seconds) of when the chat completion was created.
75
+ */
76
+ created: number;
77
+ [property: string]: unknown;
78
+ }
79
+
80
+ export interface ChatCompletionOutputChoice {
81
+ /**
82
+ * The reason why the generation was stopped.
83
+ */
84
+ finish_reason: ChatCompletionFinishReason;
85
+ /**
86
+ * The index of the choice in the list of choices.
87
+ */
88
+ index: number;
89
+ message: ChatCompletionOutputChoiceMessage;
90
+ [property: string]: unknown;
91
+ }
92
+
93
+ /**
94
+ * The reason why the generation was stopped.
95
+ *
96
+ * The generated sequence reached the maximum allowed length
97
+ *
98
+ * The model generated an end-of-sentence (EOS) token
99
+ *
100
+ * One of the sequence in stop_sequences was generated
101
+ */
102
+ export type ChatCompletionFinishReason = "length" | "eos_token" | "stop_sequence";
103
+
104
+ export interface ChatCompletionOutputChoiceMessage {
105
+ /**
106
+ * The content of the chat completion message.
107
+ */
108
+ content: string;
109
+ role: ChatCompletionMessageRole;
110
+ [property: string]: unknown;
111
+ }
112
+
113
+ /**
114
+ * Chat Completion Stream Output
115
+ */
116
+ export interface ChatCompletionStreamOutput {
117
+ /**
118
+ * A list of chat completion choices.
119
+ */
120
+ choices: ChatCompletionStreamOutputChoice[];
121
+ /**
122
+ * The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has
123
+ * the same timestamp.
124
+ */
125
+ created: number;
126
+ [property: string]: unknown;
127
+ }
128
+
129
+ export interface ChatCompletionStreamOutputChoice {
130
+ /**
131
+ * A chat completion delta generated by streamed model responses.
132
+ */
133
+ delta: ChatCompletionStreamOutputDelta;
134
+ /**
135
+ * The reason why the generation was stopped.
136
+ */
137
+ finish_reason?: ChatCompletionFinishReason;
138
+ /**
139
+ * The index of the choice in the list of choices.
140
+ */
141
+ index: number;
142
+ [property: string]: unknown;
143
+ }
144
+
145
+ /**
146
+ * A chat completion delta generated by streamed model responses.
147
+ */
148
+ export interface ChatCompletionStreamOutputDelta {
149
+ /**
150
+ * The contents of the chunk message.
151
+ */
152
+ content?: string;
153
+ /**
154
+ * The role of the author of this message.
155
+ */
156
+ role?: string;
157
+ [property: string]: unknown;
158
+ }
@@ -0,0 +1,63 @@
1
+ {
2
+ "title": "ChatCompletionInput",
3
+ "$id": "/inference/schemas/chat-completion/input.json",
4
+ "$schema": "http://json-schema.org/draft-06/schema#",
5
+ "description": "Inputs for ChatCompletion inference",
6
+ "type": "object",
7
+ "properties": {
8
+ "messages": {
9
+ "type": "array",
10
+ "title": "ChatCompletionInputMessage",
11
+ "items": {
12
+ "type": "object",
13
+ "properties": {
14
+ "role": {
15
+ "$ref": "#/definitions/Role"
16
+ },
17
+ "content": {
18
+ "type": "string",
19
+ "description": "The content of the message."
20
+ }
21
+ },
22
+ "required": ["role", "content"]
23
+ }
24
+ },
25
+ "frequency_penalty": {
26
+ "type": "number",
27
+ "description": "Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim."
28
+ },
29
+ "max_tokens": {
30
+ "type": "integer",
31
+ "description": "The maximum number of tokens that can be generated in the chat completion."
32
+ },
33
+ "seed": {
34
+ "type": "integer",
35
+ "description": "The random sampling seed."
36
+ },
37
+ "stop": {
38
+ "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }],
39
+ "title": "ChatCompletionInputStopReason",
40
+ "description": "Stop generating tokens if a stop token is generated."
41
+ },
42
+ "stream": {
43
+ "type": "boolean",
44
+ "description": "If set, partial message deltas will be sent."
45
+ },
46
+ "temperature": {
47
+ "type": "number",
48
+ "description": "The value used to modulate the logits distribution."
49
+ },
50
+ "top_p": {
51
+ "type": "number",
52
+ "description": "If set to < 1, only the smallest set of most probable tokens with probabilities that add up to `top_p` or higher are kept for generation."
53
+ }
54
+ },
55
+ "required": ["messages"],
56
+ "definitions": {
57
+ "Role": {
58
+ "oneOf": [{ "const": "assistant" }, { "const": "system" }, { "const": "user" }],
59
+ "title": "ChatCompletionMessageRole",
60
+ "description": "The role of the message author."
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "$id": "/inference/schemas/chat-completion/output.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Outputs for Chat Completion inference",
5
+ "title": "ChatCompletionOutput",
6
+ "type": "object",
7
+ "properties": {
8
+ "choices": {
9
+ "type": "array",
10
+ "description": "A list of chat completion choices.",
11
+ "title": "ChatCompletionOutputChoice",
12
+ "items": {
13
+ "type": "object",
14
+ "properties": {
15
+ "finish_reason": {
16
+ "$ref": "#/definitions/FinishReason",
17
+ "description": "The reason why the generation was stopped."
18
+ },
19
+ "index": {
20
+ "type": "integer",
21
+ "description": "The index of the choice in the list of choices."
22
+ },
23
+ "message": {
24
+ "type": "object",
25
+ "properties": {
26
+ "role": {
27
+ "$ref": "/inference/schemas/chat-completion/input.json#/definitions/Role"
28
+ },
29
+ "content": {
30
+ "type": "string",
31
+ "description": "The content of the chat completion message."
32
+ }
33
+ },
34
+ "title": "ChatCompletionOutputChoiceMessage",
35
+ "required": ["content", "role"]
36
+ }
37
+ },
38
+ "required": ["finish_reason", "index", "message"]
39
+ }
40
+ },
41
+ "created": {
42
+ "type": "integer",
43
+ "description": "The Unix timestamp (in seconds) of when the chat completion was created."
44
+ }
45
+ },
46
+ "required": ["choices", "created"],
47
+ "definitions": {
48
+ "FinishReason": {
49
+ "type": "string",
50
+ "title": "ChatCompletionFinishReason",
51
+ "oneOf": [
52
+ { "const": "length", "description": "The generated sequence reached the maximum allowed length" },
53
+ { "const": "eos_token", "description": "The model generated an end-of-sentence (EOS) token" },
54
+ { "const": "stop_sequence", "description": "One of the sequence in stop_sequences was generated" }
55
+ ]
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "$id": "/inference/schemas/chat-completion/output_stream.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Chat Completion Stream Output",
5
+ "title": "ChatCompletionStreamOutput",
6
+ "type": "object",
7
+ "properties": {
8
+ "choices": {
9
+ "type": "array",
10
+ "title": "ChatCompletionStreamOutputChoice",
11
+ "description": "A list of chat completion choices.",
12
+ "items": {
13
+ "type": "object",
14
+ "properties": {
15
+ "delta": {
16
+ "type": "object",
17
+ "title": "ChatCompletionStreamOutputDelta",
18
+ "description": "A chat completion delta generated by streamed model responses.",
19
+ "properties": {
20
+ "content": {
21
+ "type": "string",
22
+ "description": "The contents of the chunk message."
23
+ },
24
+ "role": {
25
+ "type": "string",
26
+ "description": "The role of the author of this message."
27
+ }
28
+ }
29
+ },
30
+ "finish_reason": {
31
+ "$ref": "/inference/schemas/chat-completion/output.json#/definitions/FinishReason",
32
+ "description": "The reason why the generation was stopped."
33
+ },
34
+ "index": {
35
+ "type": "integer",
36
+ "description": "The index of the choice in the list of choices."
37
+ }
38
+ },
39
+ "required": ["delta", "index"]
40
+ }
41
+ },
42
+ "created": {
43
+ "type": "integer",
44
+ "description": "The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp."
45
+ }
46
+ },
47
+ "required": ["choices", "created"]
48
+ }
@@ -38,6 +38,17 @@ import zeroShotObjectDetection from "./zero-shot-object-detection/data";
38
38
 
39
39
  export type * from "./audio-classification/inference";
40
40
  export type * from "./automatic-speech-recognition/inference";
41
+ export type {
42
+ ChatCompletionInput,
43
+ ChatCompletionInputMessage,
44
+ ChatCompletionOutput,
45
+ ChatCompletionOutputChoice,
46
+ ChatCompletionFinishReason,
47
+ ChatCompletionOutputChoiceMessage,
48
+ ChatCompletionStreamOutput,
49
+ ChatCompletionStreamOutputChoice,
50
+ ChatCompletionStreamOutputDelta,
51
+ } from "./chat-completion/inference";
41
52
  export type * from "./document-question-answering/inference";
42
53
  export type * from "./feature-extraction/inference";
43
54
  export type * from "./fill-mask/inference";
@@ -73,14 +84,14 @@ export type {
73
84
  TextClassificationParameters,
74
85
  } from "./text-classification/inference";
75
86
  export type {
76
- FinishReason,
77
- PrefillToken,
87
+ TextGenerationFinishReason,
88
+ TextGenerationPrefillToken,
78
89
  TextGenerationInput,
79
90
  TextGenerationOutput,
80
91
  TextGenerationOutputDetails,
81
92
  TextGenerationParameters,
82
- TextGenerationSequenceDetails,
83
- Token,
93
+ TextGenerationOutputSequenceDetails,
94
+ TextGenerationOutputToken,
84
95
  } from "./text-generation/inference";
85
96
  export type * from "./video-classification/inference";
86
97
  export type * from "./visual-question-answering/inference";
@@ -16,6 +16,10 @@ export interface TextGenerationInput {
16
16
  * Additional inference parameters
17
17
  */
18
18
  parameters?: TextGenerationParameters;
19
+ /**
20
+ * Whether to stream output tokens
21
+ */
22
+ stream?: boolean;
19
23
  [property: string]: unknown;
20
24
  }
21
25
 
@@ -114,16 +118,16 @@ export interface TextGenerationOutputDetails {
114
118
  /**
115
119
  * Details about additional sequences when best_of is provided
116
120
  */
117
- best_of_sequences?: TextGenerationSequenceDetails[];
121
+ best_of_sequences?: TextGenerationOutputSequenceDetails[];
118
122
  /**
119
123
  * The reason why the generation was stopped.
120
124
  */
121
- finish_reason: FinishReason;
125
+ finish_reason: TextGenerationFinishReason;
122
126
  /**
123
127
  * The number of generated tokens
124
128
  */
125
129
  generated_tokens: number;
126
- prefill: PrefillToken[];
130
+ prefill: TextGenerationPrefillToken[];
127
131
  /**
128
132
  * The random seed used for generation
129
133
  */
@@ -131,24 +135,25 @@ export interface TextGenerationOutputDetails {
131
135
  /**
132
136
  * The generated tokens and associated details
133
137
  */
134
- tokens: Token[];
138
+ tokens: TextGenerationOutputToken[];
139
+ /**
140
+ * Most likely tokens
141
+ */
142
+ top_tokens?: Array<TextGenerationOutputToken[]>;
135
143
  [property: string]: unknown;
136
144
  }
137
145
 
138
- export interface TextGenerationSequenceDetails {
139
- /**
140
- * The reason why the generation was stopped.
141
- */
142
- finish_reason: FinishReason;
146
+ export interface TextGenerationOutputSequenceDetails {
147
+ finish_reason: TextGenerationFinishReason;
143
148
  /**
144
149
  * The generated text
145
150
  */
146
- generated_text: number;
151
+ generated_text: string;
147
152
  /**
148
153
  * The number of generated tokens
149
154
  */
150
155
  generated_tokens: number;
151
- prefill: PrefillToken[];
156
+ prefill: TextGenerationPrefillToken[];
152
157
  /**
153
158
  * The random seed used for generation
154
159
  */
@@ -156,20 +161,26 @@ export interface TextGenerationSequenceDetails {
156
161
  /**
157
162
  * The generated tokens and associated details
158
163
  */
159
- tokens: Token[];
164
+ tokens: TextGenerationOutputToken[];
165
+ /**
166
+ * Most likely tokens
167
+ */
168
+ top_tokens?: Array<TextGenerationOutputToken[]>;
160
169
  [property: string]: unknown;
161
170
  }
162
171
 
163
172
  /**
164
- * The generated sequence reached the maximum allowed length
173
+ * The reason why the generation was stopped.
174
+ *
175
+ * length: The generated sequence reached the maximum allowed length
165
176
  *
166
- * The model generated an end-of-sentence (EOS) token
177
+ * eos_token: The model generated an end-of-sentence (EOS) token
167
178
  *
168
- * One of the sequence in stop_sequences was generated
179
+ * stop_sequence: One of the sequence in stop_sequences was generated
169
180
  */
170
- export type FinishReason = "length" | "eos_token" | "stop_sequence";
181
+ export type TextGenerationFinishReason = "length" | "eos_token" | "stop_sequence";
171
182
 
172
- export interface PrefillToken {
183
+ export interface TextGenerationPrefillToken {
173
184
  id: number;
174
185
  logprob: number;
175
186
  /**
@@ -179,9 +190,12 @@ export interface PrefillToken {
179
190
  [property: string]: unknown;
180
191
  }
181
192
 
182
- export interface Token {
193
+ /**
194
+ * Generated token.
195
+ */
196
+ export interface TextGenerationOutputToken {
183
197
  id: number;
184
- logprob: number;
198
+ logprob?: number;
185
199
  /**
186
200
  * Whether or not that token is a special one
187
201
  */
@@ -192,3 +206,45 @@ export interface Token {
192
206
  text: string;
193
207
  [property: string]: unknown;
194
208
  }
209
+
210
+ /**
211
+ * Text Generation Stream Output
212
+ */
213
+ export interface TextGenerationStreamOutput {
214
+ /**
215
+ * Generation details. Only available when the generation is finished.
216
+ */
217
+ details?: TextGenerationStreamDetails;
218
+ /**
219
+ * The complete generated text. Only available when the generation is finished.
220
+ */
221
+ generated_text?: string;
222
+ /**
223
+ * The token index within the stream. Optional to support older clients that omit it.
224
+ */
225
+ index?: number;
226
+ /**
227
+ * Generated token.
228
+ */
229
+ token: TextGenerationOutputToken;
230
+ [property: string]: unknown;
231
+ }
232
+
233
+ /**
234
+ * Generation details. Only available when the generation is finished.
235
+ */
236
+ export interface TextGenerationStreamDetails {
237
+ /**
238
+ * The reason why the generation was stopped.
239
+ */
240
+ finish_reason: TextGenerationFinishReason;
241
+ /**
242
+ * The number of generated tokens
243
+ */
244
+ generated_tokens: number;
245
+ /**
246
+ * The random seed used for generation
247
+ */
248
+ seed: number;
249
+ [property: string]: unknown;
250
+ }
@@ -12,6 +12,10 @@
12
12
  "parameters": {
13
13
  "description": "Additional inference parameters",
14
14
  "$ref": "#/$defs/TextGenerationParameters"
15
+ },
16
+ "stream": {
17
+ "description": "Whether to stream output tokens",
18
+ "type": "boolean"
15
19
  }
16
20
  },
17
21
  "$defs": {
@@ -10,43 +10,45 @@
10
10
  "description": "The generated text"
11
11
  },
12
12
  "details": {
13
- "description": "When enabled, details about the generation",
14
- "title": "TextGenerationOutputDetails",
15
- "allOf": [
16
- { "$ref": "#/$defs/SequenceDetails" },
17
- {
18
- "type": "object",
19
- "properties": {
20
- "best_of_sequences": {
21
- "type": "array",
22
- "description": "Details about additional sequences when best_of is provided",
23
- "items": {
24
- "allOf": [
25
- { "$ref": "#/$defs/SequenceDetails" },
26
- {
27
- "type": "object",
28
- "properties": {
29
- "generated_text": {
30
- "type": "integer",
31
- "description": "The generated text"
32
- }
33
- },
34
- "required": ["generated_text"]
35
- }
36
- ]
37
- }
38
- }
39
- }
40
- }
41
- ]
13
+ "$ref": "#/$defs/Details",
14
+ "description": "When enabled, details about the generation"
42
15
  }
43
16
  },
44
17
  "required": ["generated_text"],
45
-
46
18
  "$defs": {
19
+ "FinishReason": {
20
+ "type": "string",
21
+ "title": "TextGenerationFinishReason",
22
+ "description": "The reason why the generation was stopped.",
23
+ "oneOf": [
24
+ { "const": "length", "description": "length: The generated sequence reached the maximum allowed length" },
25
+ { "const": "eos_token", "description": "eos_token: The model generated an end-of-sentence (EOS) token" },
26
+ {
27
+ "const": "stop_sequence",
28
+ "description": "stop_sequence: One of the sequence in stop_sequences was generated"
29
+ }
30
+ ]
31
+ },
32
+ "PrefillToken": {
33
+ "title": "TextGenerationPrefillToken",
34
+ "type": "object",
35
+ "properties": {
36
+ "id": {
37
+ "type": "integer"
38
+ },
39
+ "logprob": {
40
+ "type": "number"
41
+ },
42
+ "text": {
43
+ "type": "string",
44
+ "description": "The text associated with that token"
45
+ }
46
+ },
47
+ "required": ["id", "logprob", "text"]
48
+ },
47
49
  "Token": {
48
50
  "type": "object",
49
- "title": "Token",
51
+ "title": "TextGenerationOutputToken",
50
52
  "properties": {
51
53
  "id": {
52
54
  "type": "integer"
@@ -63,20 +65,15 @@
63
65
  "description": "The text associated with that token"
64
66
  }
65
67
  },
66
- "required": ["id", "logprob", "special", "text"]
68
+ "required": ["id", "special", "text"]
67
69
  },
68
- "SequenceDetails": {
70
+ "Details": {
69
71
  "type": "object",
70
- "title": "TextGenerationSequenceDetails",
72
+ "title": "TextGenerationOutputDetails",
71
73
  "properties": {
72
74
  "finish_reason": {
73
- "type": "string",
74
- "description": "The reason why the generation was stopped.",
75
- "oneOf": [
76
- { "const": "length", "description": "The generated sequence reached the maximum allowed length" },
77
- { "const": "eos_token", "description": "The model generated an end-of-sentence (EOS) token" },
78
- { "const": "stop_sequence", "description": "One of the sequence in stop_sequences was generated" }
79
- ]
75
+ "$ref": "#/$defs/FinishReason",
76
+ "description": "The reason why the generation was stopped."
80
77
  },
81
78
  "generated_tokens": {
82
79
  "type": "integer",
@@ -85,21 +82,7 @@
85
82
  "prefill": {
86
83
  "type": "array",
87
84
  "items": {
88
- "title": "PrefillToken",
89
- "type": "object",
90
- "properties": {
91
- "id": {
92
- "type": "integer"
93
- },
94
- "logprob": {
95
- "type": "number"
96
- },
97
- "text": {
98
- "type": "string",
99
- "description": "The text associated with that token"
100
- }
101
- },
102
- "required": ["id", "logprob", "text"]
85
+ "$ref": "#/$defs/PrefillToken"
103
86
  }
104
87
  },
105
88
  "seed": {
@@ -112,9 +95,71 @@
112
95
  "items": {
113
96
  "$ref": "#/$defs/Token"
114
97
  }
98
+ },
99
+ "top_tokens": {
100
+ "type": "array",
101
+ "description": "Most likely tokens",
102
+ "items": {
103
+ "type": "array",
104
+ "items": {
105
+ "$ref": "#/$defs/Token"
106
+ }
107
+ }
108
+ },
109
+ "best_of_sequences": {
110
+ "type": "array",
111
+ "description": "Details about additional sequences when best_of is provided",
112
+ "items": {
113
+ "$ref": "#/$defs/SequenceDetails"
114
+ }
115
115
  }
116
116
  },
117
117
  "required": ["finish_reason", "generated_tokens", "prefill", "tokens"]
118
+ },
119
+ "SequenceDetails": {
120
+ "type": "object",
121
+ "title": "TextGenerationOutputSequenceDetails",
122
+ "properties": {
123
+ "generated_text": {
124
+ "type": "string",
125
+ "description": "The generated text"
126
+ },
127
+ "finish_reason": {
128
+ "$ref": "#/$defs/FinishReason"
129
+ },
130
+ "generated_tokens": {
131
+ "type": "integer",
132
+ "description": "The number of generated tokens"
133
+ },
134
+ "prefill": {
135
+ "type": "array",
136
+ "items": {
137
+ "$ref": "#/$defs/PrefillToken"
138
+ }
139
+ },
140
+ "seed": {
141
+ "type": "integer",
142
+ "description": "The random seed used for generation"
143
+ },
144
+ "tokens": {
145
+ "type": "array",
146
+ "description": "The generated tokens and associated details",
147
+ "items": {
148
+ "$ref": "#/$defs/Token"
149
+ }
150
+ },
151
+ "top_tokens": {
152
+ "type": "array",
153
+ "description": "Most likely tokens",
154
+ "items": {
155
+ "type": "array",
156
+ "items": {
157
+ "$ref": "#/$defs/Token"
158
+ }
159
+ }
160
+ }
161
+ },
162
+ "required": ["generated_text", "finish_reason", "generated_tokens", "prefill", "tokens"]
118
163
  }
119
164
  }
120
165
  }
@@ -0,0 +1,47 @@
1
+ {
2
+ "$id": "/inference/schemas/text-generation/output.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
+ "description": "Text Generation Stream Output",
5
+ "title": "TextGenerationStreamOutput",
6
+ "type": "object",
7
+ "properties": {
8
+ "token": {
9
+ "$ref": "#/$defs/Token",
10
+ "description": "Generated token."
11
+ },
12
+ "index": {
13
+ "type": "integer",
14
+ "description": "The token index within the stream. Optional to support older clients that omit it."
15
+ },
16
+ "generated_text": {
17
+ "type": "string",
18
+ "description": "The complete generated text. Only available when the generation is finished."
19
+ },
20
+ "details": {
21
+ "$ref": "#/$defs/StreamDetails",
22
+ "description": "Generation details. Only available when the generation is finished."
23
+ }
24
+ },
25
+ "required": ["token"],
26
+ "$defs": {
27
+ "StreamDetails": {
28
+ "type": "object",
29
+ "title": "TextGenerationStreamDetails",
30
+ "properties": {
31
+ "finish_reason": {
32
+ "$ref": "#/$defs/FinishReason",
33
+ "description": "The reason why the generation was stopped."
34
+ },
35
+ "generated_tokens": {
36
+ "type": "integer",
37
+ "description": "The number of generated tokens"
38
+ },
39
+ "seed": {
40
+ "type": "integer",
41
+ "description": "The random seed used for generation"
42
+ }
43
+ },
44
+ "required": ["finish_reason", "generated_tokens", "seed"]
45
+ }
46
+ }
47
+ }