| title: Dynamic Transformers Pipeline API | |
| emoji: π | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: gradio | |
| sdk_version: "6.22.0" | |
| app_file: app.py | |
| pinned: false | |
| license: apache-2.0 | |
| # Dynamic Transformers Pipeline API | |
| Pass any `transformers.pipeline()` config as JSON, run inference on ZeroGPU RTX Pro 6000 Blackwell. | |
| ## API Usage | |
| ```python | |
| from gradio_client import Client | |
| client = Client("DoctorSlimm/dynamic-transformers-api") | |
| result = client.predict( | |
| pipeline_config={"task": "text-generation", "model": "HuggingFaceTB/SmolLM2-135M-Instruct"}, | |
| inputs="Hello world", | |
| inference_kwargs={"max_new_tokens": 50}, | |
| api_name="/inference" | |
| ) | |
| ``` | |
| --- | |
| ## 3. Hit deploy | |
| Upload β Space builds (~30-60s) β done. | |
| --- | |
| ## 4. Test it | |
| ```python | |
| from gradio_client import Client | |
| client = Client("DoctorSlimm/dynamic-transformers-api") | |
| # Text generation | |
| print(client.predict( | |
| pipeline_config={"task": "text-generation", "model": "HuggingFaceTB/SmolLM2-135M-Instruct"}, | |
| inputs="The future of AI is", | |
| inference_kwargs={"max_new_tokens": 50}, | |
| api_name="/inference" | |
| )) | |
| # NER (swap pipeline on the fly, same Space) | |
| print(client.predict( | |
| pipeline_config={"task": "ner", "model": "Jean-Baptiste/camembert-ner", "aggregation_strategy": "simple"}, | |
| inputs="Apple is looking at buying U.K. startup for $1 billion", | |
| inference_kwargs={}, | |
| api_name="/inference" | |
| )) | |
| ``` | |