|
Download README.md from ariG23498/transformers-code-snippets: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/spaces/ariG23498/transformers-code-snippets/resolve/main/README.md
- Command line
-
hf download hf://spaces/ariG23498/transformers-code-snippets/README.md
-
curl -L -o README.md https://huggingface.co/spaces/ariG23498/transformers-code-snippets/resolve/main/README.md
1.78 kB
| title: Transformers Playground | |
| emoji: 🛝 | |
| colorFrom: yellow | |
| colorTo: gray | |
| sdk: gradio | |
| sdk_version: 6.30.0 | |
| app_file: app.py | |
| pinned: false | |
| hf_oauth: true | |
| hf_oauth_expiration_minutes: 480 | |
| hf_oauth_scopes: | |
| - jobs | |
| - read-repos | |
| short_description: Copy official transformers snippets or run them on HF Jobs | |
| # Transformers Playground | |
| Pick any transformers model on the Hub, get the usage snippets from its | |
| `model_doc` page (adapted to your checkpoint), copy them, or run them on | |
| Hugging Face Jobs with your own account. | |
| ## How it works | |
| - `indexer.py` sparse-clones `docs/source/en/model_doc` from transformers, | |
| extracts the `<hfoptions id="usage">` tabs and usage code blocks, drops | |
| training and quantization examples (v1 is inference only), and writes | |
| `snippets.json`. | |
| - `app.py` matches a model's `config.json` `model_type` to its doc page, | |
| swaps the doc's checkpoint for the selected model, adds a generic | |
| `pipeline()` snippet from the model's task, and recommends the cheapest | |
| Jobs flavor that fits the weights (live prices from `list_jobs_hardware`). | |
| - Runs go through `run_job` with the user's OAuth token, so each user pays | |
| for their own compute. Jobs need a PRO, Team or Enterprise account. | |
| ## Setup | |
| 1. Create the Space from these files. On first boot it builds the index | |
| itself (about 30 seconds). | |
| 2. Optional but recommended: publish the index as a dataset and refresh it | |
| nightly, then set a Space variable `INDEX_REPO=<you>/transformers-snippets`. | |
| ```bash | |
| hf jobs scheduled run @daily python:3.12 --secrets HF_TOKEN -- bash -c \ | |
| "pip install -q huggingface_hub && \ | |
| curl -sL https://huggingface.co/spaces/<you>/transformers-playground/raw/main/indexer.py -o indexer.py && \ | |
| python indexer.py --push <you>/transformers-snippets" | |
| ``` | |