Skip to content

Commit

Permalink
🏷️ Hub typing (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
coyotte508 authored Mar 26, 2024
1 parent d9541b0 commit 43dbca0
Showing 1 changed file with 154 additions and 2 deletions.
156 changes: 154 additions & 2 deletions packages/hub/src/types/api/api-model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,158 @@ export interface ApiModelInfo {
transformersInfo?: TransformersInfo;
}

export interface ApiModelIndex {
name: string;
results: {
task: {
/**
* Example: automatic-speech-recognition
Use task id from https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/tasksData.ts
*/
type: string;
/**
* Example: Speech Recognition
*/
name?: string;
};
/**
* This will switch to required at some point.
in any case, we need them to link to PWC
*/
dataset?: {
/**
* Example: common_voice. Use dataset id from https://hf.co/datasets
*/
type: string;
/**
* A pretty name for the dataset. Example: Common Voice zh-CN
Also encode config params into the name if relevant.
*/
name: string;
/**
* Optional. The name of the dataset configuration used in `load_dataset()`
*/
config?: string;
/**
* Optional. Example: test
*/
split?: string;
/**
* Optional. Example: 5503434ddd753f426f4b38109466949a1217c2bb
*/
revision?: string;
args?:
| string
| {
/**
* String Property
*/
[x: string]: string;
};
};
metrics: {
/**
* Example: wer. Use metric id from https://hf.co/metrics
*/
type: string;
/**
* Required. Example: 20.0 or "20.0 ± 1.2"
*/
value: unknown;
/**
* Example: Test WER
*/
name?: string;
/**
* Optional. The name of the metric configuration used in `load_metric()`.
*/
config?: string;
args?:
| string
| {
/**
* String Property
*/
[x: string]: string;
};
/**
* [Automatically computed, do not set] Dynamically overriden by huggingface in API calls to indicate if it was verified by Hugging Face.
*/
verified?: boolean;
/**
* Generated by Hugging Face to prove the results are valid. <add doc link>
*/
verifyToken?: string;
}[];
/**
* The source for this evaluation result.
*/
source?: {
/**
* Example: Open LLM Leaderboard
*/
name?: string;
/**
* Example: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard
*/
url: string;
};
}[];
}

export interface ApiWidgetExampleFromModelcard {
example_title?: string;
group?: string;
text?: string;
src?: string;
table?: {
/**
* (string | number)[] Property
*/
[x: string]: (string | number)[];
};
structured_data?: {
/**
* (string | number)[] Property
*/
[x: string]: (string | number)[];
};
candidate_labels?: string;
messages?: {
role: "system" | "user" | "assistant";
content: string;
}[];
multi_class?: boolean;
source_sentence?: string;
sentences?: string[];
parameters?: {
aggregation_strategy?: string;
top_k?: number;
top_p?: number;
temperature?: number;
max_new_tokens?: number;
do_sample?: boolean;
negative_prompt?: string;
guidance_scale?: number;
num_inference_steps?: number;
};
output?:
| {
label: string;
score: number;
}[]
| {
answer: string;
score: number;
}
| {
text: string;
}
| {
url: string;
};
}

export interface ApiModelMetadata {
datasets?: string | string[];
license?: License | License[];
Expand Down Expand Up @@ -93,8 +245,8 @@ export interface ApiModelMetadata {
thumbnail?: string | null;
description?: string | null;
mask_token?: string;
widget?: WidgetExampleFromModelcard[];
"model-index"?: ModelIndex[];
widget?: ApiWidgetExampleFromModelcard[];
"model-index"?: ApiModelIndex[];
finetuned_from?: string;
base_model?: string | string[];
instance_prompt?: string | null;
Expand Down

0 comments on commit 43dbca0

Please sign in to comment.