Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
machineuser
commited on
Commit
·
7b4cf0b
1
Parent(s):
ba4ff43
Sync widgets demo
Browse files- packages/tasks/src/library-to-tasks.ts +1 -1
- packages/tasks/src/model-data.ts +1 -1
- packages/tasks/src/pipelines.ts +1 -1
- packages/tasks/src/tasks/audio-classification/about.md +1 -1
- packages/tasks/src/tasks/audio-to-audio/about.md +1 -1
- packages/tasks/src/tasks/automatic-speech-recognition/about.md +1 -1
- packages/tasks/src/tasks/sentence-similarity/about.md +2 -2
- packages/tasks/src/tasks/tabular-classification/about.md +1 -1
- packages/tasks/src/tasks/tabular-regression/about.md +1 -1
- packages/tasks/src/tasks/text-to-speech/about.md +2 -2
- packages/widgets/src/hooks.server.ts +1 -1
- packages/widgets/src/lib/components/InferenceWidget/shared/WidgetHeader/WidgetHeader.svelte +1 -1
- packages/widgets/src/lib/components/InferenceWidget/shared/WidgetInfo/WidgetInfo.svelte +12 -11
- packages/widgets/src/lib/components/InferenceWidget/shared/WidgetState/WidgetState.svelte +3 -3
- packages/widgets/src/lib/components/InferenceWidget/shared/helpers.ts +2 -2
packages/tasks/src/library-to-tasks.ts
CHANGED
@@ -3,7 +3,7 @@ import type { PipelineType } from "./pipelines";
|
|
3 |
|
4 |
/**
|
5 |
* Mapping from library name (excluding Transformers) to its supported tasks.
|
6 |
-
* Inference
|
7 |
* As an exception, we assume Transformers supports all inference tasks.
|
8 |
* This mapping is generated automatically by "python-api-export-tasks" action in huggingface/api-inference-community repo upon merge.
|
9 |
* Ref: https://github.com/huggingface/api-inference-community/pull/158
|
|
|
3 |
|
4 |
/**
|
5 |
* Mapping from library name (excluding Transformers) to its supported tasks.
|
6 |
+
* Inference Endpoints (serverless) should be disabled for all other (library, task) pairs beyond this mapping.
|
7 |
* As an exception, we assume Transformers supports all inference tasks.
|
8 |
* This mapping is generated automatically by "python-api-export-tasks" action in huggingface/api-inference-community repo upon merge.
|
9 |
* Ref: https://github.com/huggingface/api-inference-community/pull/158
|
packages/tasks/src/model-data.ts
CHANGED
@@ -78,7 +78,7 @@ export interface ModelData {
|
|
78 |
*/
|
79 |
widgetData?: WidgetExample[] | undefined;
|
80 |
/**
|
81 |
-
* Parameters that will be used by the widget when calling Inference
|
82 |
* https://huggingface.co/docs/api-inference/detailed_parameters
|
83 |
*
|
84 |
* can be set in the model card metadata (under `inference/parameters`)
|
|
|
78 |
*/
|
79 |
widgetData?: WidgetExample[] | undefined;
|
80 |
/**
|
81 |
+
* Parameters that will be used by the widget when calling Inference Endpoints (serverless)
|
82 |
* https://huggingface.co/docs/api-inference/detailed_parameters
|
83 |
*
|
84 |
* can be set in the model card metadata (under `inference/parameters`)
|
packages/tasks/src/pipelines.ts
CHANGED
@@ -62,7 +62,7 @@ export interface PipelineData {
|
|
62 |
/// This type is used in multiple places in the Hugging Face
|
63 |
/// ecosystem:
|
64 |
/// - To determine which widget to show.
|
65 |
-
/// - To determine which endpoint of Inference
|
66 |
/// - As filters at the left of models and datasets page.
|
67 |
///
|
68 |
/// Note that this is sensitive to order.
|
|
|
62 |
/// This type is used in multiple places in the Hugging Face
|
63 |
/// ecosystem:
|
64 |
/// - To determine which widget to show.
|
65 |
+
/// - To determine which endpoint of Inference Endpoints to use.
|
66 |
/// - As filters at the left of models and datasets page.
|
67 |
///
|
68 |
/// Note that this is sensitive to order.
|
packages/tasks/src/tasks/audio-classification/about.md
CHANGED
@@ -26,7 +26,7 @@ Datasets such as VoxLingua107 allow anyone to train language identification mode
|
|
26 |
|
27 |
### Emotion recognition
|
28 |
|
29 |
-
Emotion recognition is self explanatory. In addition to trying the widgets, you can use
|
30 |
|
31 |
```python
|
32 |
import json
|
|
|
26 |
|
27 |
### Emotion recognition
|
28 |
|
29 |
+
Emotion recognition is self explanatory. In addition to trying the widgets, you can use Inference Endpoints to perform audio classification. Here is a simple example that uses a [HuBERT](https://huggingface.co/superb/hubert-large-superb-er) model fine-tuned for this task.
|
30 |
|
31 |
```python
|
32 |
import json
|
packages/tasks/src/tasks/audio-to-audio/about.md
CHANGED
@@ -12,7 +12,7 @@ model = SpectralMaskEnhancement.from_hparams(
|
|
12 |
model.enhance_file("file.wav")
|
13 |
```
|
14 |
|
15 |
-
Alternatively, you can use
|
16 |
|
17 |
```python
|
18 |
import json
|
|
|
12 |
model.enhance_file("file.wav")
|
13 |
```
|
14 |
|
15 |
+
Alternatively, you can use [Inference Endpoints](https://huggingface.co/inference-endpoints) to solve this task
|
16 |
|
17 |
```python
|
18 |
import json
|
packages/tasks/src/tasks/automatic-speech-recognition/about.md
CHANGED
@@ -18,7 +18,7 @@ The use of Multilingual ASR has become popular, the idea of maintaining just a s
|
|
18 |
|
19 |
## Inference
|
20 |
|
21 |
-
The Hub contains over [~9,000 ASR models](https://huggingface.co/models?pipeline_tag=automatic-speech-recognition&sort=downloads) that you can use right away by trying out the widgets directly in the browser or calling the models as a service using
|
22 |
|
23 |
```python
|
24 |
import json
|
|
|
18 |
|
19 |
## Inference
|
20 |
|
21 |
+
The Hub contains over [~9,000 ASR models](https://huggingface.co/models?pipeline_tag=automatic-speech-recognition&sort=downloads) that you can use right away by trying out the widgets directly in the browser or calling the models as a service using Inference Endpoints. Here is a simple code snippet to do exactly this:
|
22 |
|
23 |
```python
|
24 |
import json
|
packages/tasks/src/tasks/sentence-similarity/about.md
CHANGED
@@ -8,7 +8,7 @@ You can extract information from documents using Sentence Similarity models. The
|
|
8 |
|
9 |
The [Sentence Transformers](https://www.sbert.net/) library is very powerful for calculating embeddings of sentences, paragraphs, and entire documents. An embedding is just a vector representation of a text and is useful for finding how similar two texts are.
|
10 |
|
11 |
-
You can find and use [hundreds of Sentence Transformers](https://huggingface.co/models?library=sentence-transformers&sort=downloads) models from the Hub by directly using the library, playing with the widgets in the browser or using
|
12 |
|
13 |
## Task Variants
|
14 |
|
@@ -16,7 +16,7 @@ You can find and use [hundreds of Sentence Transformers](https://huggingface.co/
|
|
16 |
|
17 |
Passage Ranking is the task of ranking documents based on their relevance to a given query. The task is evaluated on Mean Reciprocal Rank. These models take one query and multiple documents and return ranked documents according to the relevancy to the query. 📄
|
18 |
|
19 |
-
You can infer with Passage Ranking models using
|
20 |
|
21 |
```python
|
22 |
import json
|
|
|
8 |
|
9 |
The [Sentence Transformers](https://www.sbert.net/) library is very powerful for calculating embeddings of sentences, paragraphs, and entire documents. An embedding is just a vector representation of a text and is useful for finding how similar two texts are.
|
10 |
|
11 |
+
You can find and use [hundreds of Sentence Transformers](https://huggingface.co/models?library=sentence-transformers&sort=downloads) models from the Hub by directly using the library, playing with the widgets in the browser or using Inference Endpoints.
|
12 |
|
13 |
## Task Variants
|
14 |
|
|
|
16 |
|
17 |
Passage Ranking is the task of ranking documents based on their relevance to a given query. The task is evaluated on Mean Reciprocal Rank. These models take one query and multiple documents and return ranked documents according to the relevancy to the query. 📄
|
18 |
|
19 |
+
You can infer with Passage Ranking models using [Inference Endpoints](https://huggingface.co/inference-endpoints). The Passage Ranking model inputs are a query for which we look for relevancy in the documents and the documents we want to search. The model will return scores according to the relevancy of these documents for the query.
|
20 |
|
21 |
```python
|
22 |
import json
|
packages/tasks/src/tasks/tabular-classification/about.md
CHANGED
@@ -19,7 +19,7 @@ Tabular classification models can be used in predicting customer churn in teleco
|
|
19 |
|
20 |
You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can:
|
21 |
|
22 |
-
- Easily use
|
23 |
- Build neat UIs with one line of code,
|
24 |
- Programmatically create model cards,
|
25 |
- Securely serialize your scikit-learn model. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).)
|
|
|
19 |
|
20 |
You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can:
|
21 |
|
22 |
+
- Easily use Inference Endpoints
|
23 |
- Build neat UIs with one line of code,
|
24 |
- Programmatically create model cards,
|
25 |
- Securely serialize your scikit-learn model. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).)
|
packages/tasks/src/tasks/tabular-regression/about.md
CHANGED
@@ -30,7 +30,7 @@ model.fit(X, y)
|
|
30 |
|
31 |
You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can:
|
32 |
|
33 |
-
- Easily use
|
34 |
- Build neat UIs with one line of code,
|
35 |
- Programmatically create model cards,
|
36 |
- Securely serialize your models. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).)
|
|
|
30 |
|
31 |
You can use [skops](https://skops.readthedocs.io/) for model hosting and inference on the Hugging Face Hub. This library is built to improve production workflows of various libraries that are used to train tabular models, including [sklearn](https://scikit-learn.org/stable/) and [xgboost](https://xgboost.readthedocs.io/en/stable/). Using `skops` you can:
|
32 |
|
33 |
+
- Easily use Inference Endpoints,
|
34 |
- Build neat UIs with one line of code,
|
35 |
- Programmatically create model cards,
|
36 |
- Securely serialize your models. (See limitations of using pickle [here](https://huggingface.co/docs/hub/security-pickle).)
|
packages/tasks/src/tasks/text-to-speech/about.md
CHANGED
@@ -10,9 +10,9 @@ TTS models are used to create voice assistants on smart devices. These models ar
|
|
10 |
|
11 |
TTS models are widely used in airport and public transportation announcement systems to convert the announcement of a given text into speech.
|
12 |
|
13 |
-
## Inference
|
14 |
|
15 |
-
The Hub contains over [1500 TTS models](https://huggingface.co/models?pipeline_tag=text-to-speech&sort=downloads) that you can use right away by trying out the widgets directly in the browser or calling the models as a service using
|
16 |
|
17 |
```python
|
18 |
import json
|
|
|
10 |
|
11 |
TTS models are widely used in airport and public transportation announcement systems to convert the announcement of a given text into speech.
|
12 |
|
13 |
+
## Inference Endpoints
|
14 |
|
15 |
+
The Hub contains over [1500 TTS models](https://huggingface.co/models?pipeline_tag=text-to-speech&sort=downloads) that you can use right away by trying out the widgets directly in the browser or calling the models as a service using Inference Endpoints. Here is a simple code snippet to get you started:
|
16 |
|
17 |
```python
|
18 |
import json
|
packages/widgets/src/hooks.server.ts
CHANGED
@@ -41,7 +41,7 @@ const handleSSO =
|
|
41 |
],
|
42 |
secret: env.OAUTH_CLIENT_SECRET,
|
43 |
/**
|
44 |
-
* Get the access_token without an account in DB, to make calls to
|
45 |
*/
|
46 |
callbacks: {
|
47 |
jwt({ token, account, profile }) {
|
|
|
41 |
],
|
42 |
secret: env.OAUTH_CLIENT_SECRET,
|
43 |
/**
|
44 |
+
* Get the access_token without an account in DB, to make calls to Inference Endpoints
|
45 |
*/
|
46 |
callbacks: {
|
47 |
jwt({ token, account, profile }) {
|
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetHeader/WidgetHeader.svelte
CHANGED
@@ -53,7 +53,7 @@
|
|
53 |
<div class="flex items-center text-lg">
|
54 |
{#if !isDisabled}
|
55 |
<IconLightning classNames="-ml-1 mr-1 text-yellow-500" />
|
56 |
-
Inference
|
57 |
{:else}
|
58 |
Inference Examples
|
59 |
{/if}
|
|
|
53 |
<div class="flex items-center text-lg">
|
54 |
{#if !isDisabled}
|
55 |
<IconLightning classNames="-ml-1 mr-1 text-yellow-500" />
|
56 |
+
Inference Endpoints (serverless)
|
57 |
{:else}
|
58 |
Inference Examples
|
59 |
{/if}
|
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetInfo/WidgetInfo.svelte
CHANGED
@@ -17,18 +17,18 @@
|
|
17 |
$: modelTooBig = $modelLoadStates[model.id]?.state === "TooBig";
|
18 |
|
19 |
const state = {
|
20 |
-
[LoadState.Loadable]: "This model can be loaded on
|
21 |
-
[LoadState.Loaded]: "This model is currently loaded and running on
|
22 |
[LoadState.TooBig]:
|
23 |
-
"Model is too large to load onto
|
24 |
-
[LoadState.Error]: "⚠️ This model could not be loaded
|
25 |
} as const;
|
26 |
|
27 |
const azureState = {
|
28 |
[LoadState.Loadable]: "This model can be loaded loaded on AzureML Managed Endpoint",
|
29 |
[LoadState.Loaded]: "This model is loaded and running on AzureML Managed Endpoint",
|
30 |
[LoadState.TooBig]:
|
31 |
-
"Model is too large to load onto
|
32 |
[LoadState.Error]: "⚠️ This model could not be loaded.",
|
33 |
} as const;
|
34 |
|
@@ -62,9 +62,10 @@
|
|
62 |
{:else if (model.inference === InferenceDisplayability.Yes || model.pipeline_tag === "reinforcement-learning") && !modelTooBig}
|
63 |
{@html getStatusReport($modelLoadStates[model.id], state)}
|
64 |
{:else if model.inference === InferenceDisplayability.ExplicitOptOut}
|
65 |
-
<span class="text-sm text-gray-500">Inference
|
66 |
{:else if model.inference === InferenceDisplayability.CustomCode}
|
67 |
-
<span class="text-sm text-gray-500"
|
|
|
68 |
>
|
69 |
{:else if model.inference === InferenceDisplayability.LibraryNotDetected}
|
70 |
<span class="text-sm text-gray-500">
|
@@ -82,21 +83,21 @@
|
|
82 |
</span>
|
83 |
{:else if model.inference === InferenceDisplayability.PipelineLibraryPairNotSupported}
|
84 |
<span class="text-sm text-gray-500">
|
85 |
-
Inference
|
86 |
</span>
|
87 |
{:else if modelTooBig}
|
88 |
<span class="text-sm text-gray-500">
|
89 |
-
Model is too large to load
|
90 |
class="underline"
|
91 |
href="https://ui.endpoints.huggingface.co/new?repository={encodeURIComponent(model.id)}"
|
92 |
-
>Inference Endpoints</a
|
93 |
>
|
94 |
instead.
|
95 |
</span>
|
96 |
{:else}
|
97 |
<!-- added as a failsafe but this case cannot currently happen -->
|
98 |
<span class="text-sm text-gray-500">
|
99 |
-
Inference
|
100 |
<a class="color-inherit underline" href="/{model.id}/discussions/new">Discussion in the Community tab</a>.
|
101 |
</span>
|
102 |
{/if}
|
|
|
17 |
$: modelTooBig = $modelLoadStates[model.id]?.state === "TooBig";
|
18 |
|
19 |
const state = {
|
20 |
+
[LoadState.Loadable]: "This model can be loaded on Inference Endpoints (serverless).",
|
21 |
+
[LoadState.Loaded]: "This model is currently loaded and running on Inference Endpoints (serverless).",
|
22 |
[LoadState.TooBig]:
|
23 |
+
"Model is too large to load onto on Inference Endpoints (serverless). To try the model, launch it on Inference Endpoints (dedicated) instead.",
|
24 |
+
[LoadState.Error]: "⚠️ This model could not be loaded on Inference Endpoints (serverless). ⚠️",
|
25 |
} as const;
|
26 |
|
27 |
const azureState = {
|
28 |
[LoadState.Loadable]: "This model can be loaded loaded on AzureML Managed Endpoint",
|
29 |
[LoadState.Loaded]: "This model is loaded and running on AzureML Managed Endpoint",
|
30 |
[LoadState.TooBig]:
|
31 |
+
"Model is too large to load onto on Inference Endpoints (serverless). To try the model, launch it on Inference Endpoints (dedicated) instead.",
|
32 |
[LoadState.Error]: "⚠️ This model could not be loaded.",
|
33 |
} as const;
|
34 |
|
|
|
62 |
{:else if (model.inference === InferenceDisplayability.Yes || model.pipeline_tag === "reinforcement-learning") && !modelTooBig}
|
63 |
{@html getStatusReport($modelLoadStates[model.id], state)}
|
64 |
{:else if model.inference === InferenceDisplayability.ExplicitOptOut}
|
65 |
+
<span class="text-sm text-gray-500">Inference Endpoints (serverless) has been turned off for this model.</span>
|
66 |
{:else if model.inference === InferenceDisplayability.CustomCode}
|
67 |
+
<span class="text-sm text-gray-500"
|
68 |
+
>Inference Endpoints (serverless) does not yet support model repos that contain custom code.</span
|
69 |
>
|
70 |
{:else if model.inference === InferenceDisplayability.LibraryNotDetected}
|
71 |
<span class="text-sm text-gray-500">
|
|
|
83 |
</span>
|
84 |
{:else if model.inference === InferenceDisplayability.PipelineLibraryPairNotSupported}
|
85 |
<span class="text-sm text-gray-500">
|
86 |
+
Inference Endpoints (serverless) does not yet support {model.library_name} models for this pipeline type.
|
87 |
</span>
|
88 |
{:else if modelTooBig}
|
89 |
<span class="text-sm text-gray-500">
|
90 |
+
Model is too large to load in Inference Endpoints (serverless). To try the model, launch it on <a
|
91 |
class="underline"
|
92 |
href="https://ui.endpoints.huggingface.co/new?repository={encodeURIComponent(model.id)}"
|
93 |
+
>Inference Endpoints (dedicated)</a
|
94 |
>
|
95 |
instead.
|
96 |
</span>
|
97 |
{:else}
|
98 |
<!-- added as a failsafe but this case cannot currently happen -->
|
99 |
<span class="text-sm text-gray-500">
|
100 |
+
Inference Endpoints (serverless) is disabled for an unknown reason. Please open a
|
101 |
<a class="color-inherit underline" href="/{model.id}/discussions/new">Discussion in the Community tab</a>.
|
102 |
</span>
|
103 |
{/if}
|
packages/widgets/src/lib/components/InferenceWidget/shared/WidgetState/WidgetState.svelte
CHANGED
@@ -5,13 +5,13 @@
|
|
5 |
<div class="blankslate">
|
6 |
<div class="subtitle text-xs text-gray-500">
|
7 |
<div class="loaded mt-2 {currentState !== 'loaded' ? 'hidden' : ''}">
|
8 |
-
This model is currently loaded and running on
|
9 |
</div>
|
10 |
<div class="error mt-2 {currentState !== 'error' ? 'hidden' : ''}">
|
11 |
-
⚠️ This model could not be loaded
|
12 |
</div>
|
13 |
<div class="unknown mt-2 {currentState !== 'unknown' ? 'hidden' : ''}">
|
14 |
-
This model can be loaded
|
15 |
</div>
|
16 |
</div>
|
17 |
</div>
|
|
|
5 |
<div class="blankslate">
|
6 |
<div class="subtitle text-xs text-gray-500">
|
7 |
<div class="loaded mt-2 {currentState !== 'loaded' ? 'hidden' : ''}">
|
8 |
+
This model is currently loaded and running on Inference Endpoints (serverless).
|
9 |
</div>
|
10 |
<div class="error mt-2 {currentState !== 'error' ? 'hidden' : ''}">
|
11 |
+
⚠️ This model could not be loaded in Inference Endpoints (serverless). ⚠️
|
12 |
</div>
|
13 |
<div class="unknown mt-2 {currentState !== 'unknown' ? 'hidden' : ''}">
|
14 |
+
This model can be loaded in Inference Endpoints (serverless).
|
15 |
</div>
|
16 |
</div>
|
17 |
</div>
|
packages/widgets/src/lib/components/InferenceWidget/shared/helpers.ts
CHANGED
@@ -84,7 +84,7 @@ export async function callInferenceApi<T>(
|
|
84 |
requestBody: Record<string, unknown>,
|
85 |
apiToken = "",
|
86 |
outputParsingFn: (x: unknown) => T,
|
87 |
-
waitForModel = false, // If true, the server will only respond once the model has been loaded on
|
88 |
includeCredentials = false,
|
89 |
isOnLoadCall = false, // If true, the server will try to answer from cache and not do anything if not
|
90 |
useCache = true
|
@@ -184,7 +184,7 @@ export async function getModelLoadInfo(
|
|
184 |
}
|
185 |
}
|
186 |
|
187 |
-
// Extend
|
188 |
export function addInferenceParameters(requestBody: Record<string, unknown>, model: ModelData): void {
|
189 |
const inference = model?.cardData?.inference;
|
190 |
if (typeof inference === "object") {
|
|
|
84 |
requestBody: Record<string, unknown>,
|
85 |
apiToken = "",
|
86 |
outputParsingFn: (x: unknown) => T,
|
87 |
+
waitForModel = false, // If true, the server will only respond once the model has been loaded on Inference Endpoints (serverless)
|
88 |
includeCredentials = false,
|
89 |
isOnLoadCall = false, // If true, the server will try to answer from cache and not do anything if not
|
90 |
useCache = true
|
|
|
184 |
}
|
185 |
}
|
186 |
|
187 |
+
// Extend requestBody with user supplied parameters for Inference Endpoints (serverless)
|
188 |
export function addInferenceParameters(requestBody: Record<string, unknown>, model: ModelData): void {
|
189 |
const inference = model?.cardData?.inference;
|
190 |
if (typeof inference === "object") {
|