Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Run NLP and CV model inference via Hugging Face free-tier API
.claude/skills/brycewang-stanford-huggingface-inference-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 55% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 44% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 25% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 132% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 85% | 0% |
The Hugging Face Inference API provides instant access to thousands of pre-trained machine learning models for natural language processing, computer vision, audio processing, and multimodal tasks. Researchers can run inference on state-of-the-art models without managing infrastructure, GPU resources, or complex deployment pipelines.
The API hosts models from the Hugging Face Hub, which contains over 500,000 models contributed by the research community. This includes transformer models for text classification, named entity recognition, summarization, translation, question answering, text generation, and image classification. For academic researchers, the Inference API is invaluable for rapid prototyping, benchmark evaluation, and integrating ML capabilities into research workflows without dedicated compute resources.
The free tier provides access to a broad selection of models with rate limits suitable for development and small-scale research. An API token is required for authentication, available for free at huggingface.co.
A free Hugging Face API token is required. Create an account and generate a token at https://huggingface.co/settings/tokens.
Store your token securely in an environment variable:
bashexport HF_API_TOKEN=$HF_API_TOKEN
bashcurl -X POST "https://api-inference.huggingface.co/models/bert-base-uncased" \ -H "Authorization: Bearer $HF_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"inputs": "The goal of life is [MASK]."}'
POST https://api-inference.huggingface.co/models/{model_id}bashcurl -s -X POST \ "https://api-inference.huggingface.co/models/distilbert-base-uncased-finetuned-sst-2-english" \ -H "Authorization: Bearer $HF_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"inputs": "This research methodology provides robust and reproducible results."}' \ | python3 -m json.tool
bashcurl -s -X POST \ "https://api-inference.huggingface.co/models/dslim/bert-base-NER" \ -H "Authorization: Bearer $HF_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"inputs": "Dr. Marie Curie conducted research at the University of Paris on radioactivity."}' \ | python3 -m json.tool
bashcurl -s -X POST \ "https://api-inference.huggingface.co/models/facebook/bart-large-cnn" \ -H "Authorization: Bearer $HF_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "inputs": "The study of quantum computing has seen tremendous advances in the past decade. Researchers have demonstrated quantum supremacy with processors containing over 100 qubits. Error correction remains a significant challenge, but recent breakthroughs in topological qubits and surface codes suggest viable paths forward. Applications in drug discovery, materials science, and cryptography are expected to be among the first practical use cases.", "parameters": {"max_length": 80, "min_length": 30} }' | python3 -m json.tool
Classify text into arbitrary categories without fine-tuning.
bashcurl -s -X POST \ "https://api-inference.huggingface.co/models/facebook/bart-large-mnli" \ -H "Authorization: Bearer $HF_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "inputs": "New CRISPR technique enables precise gene editing in human stem cells", "parameters": {"candidate_labels": ["biology", "computer science", "physics", "economics"]} }' | python3 -m json.tool
pythonimport requests import os import time API_URL = "https://api-inference.huggingface.co/models/distilbert-base-uncased-finetuned-sst-2-english" HEADERS = {"Authorization": f"Bearer {os.environ['HF_API_TOKEN']}"} def classify_sentiment(texts): """Classify sentiment for a batch of texts.""" response = requests.post(API_URL, headers=HEADERS, json={"inputs": texts}) if response.status_code == 503: # Model is loading, wait and retry wait_time = response.json().get("estimated_time", 20) print(f"Model loading, waiting {wait_time:.0f}s...") time.sleep(wait_time) response = requests.post(API_URL, headers=HEADERS, json={"inputs": texts}) response.raise_for_status() return response.json() abstracts = [ "Our results demonstrate a significant improvement over baseline methods.", "The proposed approach failed to achieve meaningful gains on the benchmark.", "We present preliminary findings that warrant further investigation.", ] results = classify_sentiment(abstracts) for abstract, result in zip(abstracts, results): top = max(result, key=lambda x: x["score"]) print(f"Sentiment: {top['label']} ({top['score']:.3f})") print(f" Text: {abstract[:80]}...") print()
pythonimport requests import os ZSC_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-mnli" HEADERS = {"Authorization": f"Bearer {os.environ['HF_API_TOKEN']}"} def classify_paper(abstract, categories): """Classify a paper abstract into research categories.""" payload = { "inputs": abstract, "parameters": {"candidate_labels": categories} } resp = requests.post(ZSC_URL, headers=HEADERS, json=payload) resp.raise_for_status() return resp.json() categories = [ "machine learning", "computational biology", "natural language processing", "computer vision", "reinforcement learning", "quantum computing" ] abstract = "We propose a novel transformer architecture for protein structure prediction that achieves state-of-the-art results on CASP benchmarks." result = classify_paper(abstract, categories) print("Topic classification:") for label, score in zip(result["labels"], result["scores"]): bar = "#" * int(score * 40) print(f" {label:<30} {score:.3f} {bar}")
Literature Screening: Use zero-shot classification to automatically categorize and filter large collections of paper abstracts by research topic, methodology, or relevance to a specific research question.
Sentiment and Stance Detection: Analyze the tone and conclusions of research papers, review comments, or social media discussions about scientific topics using sentiment analysis models.
Named Entity Extraction: Extract researcher names, institutions, chemical compounds, gene names, and other domain-specific entities from unstructured text in papers and reports.
Automated Summarization: Generate concise summaries of lengthy research papers or grant proposals to accelerate literature review workflows.
Multilingual Research: Use translation and multilingual models to access and analyze research published in languages other than English.
distilbert instead of bert-large) for faster inference| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-08 | fail→pass | 14,739 | 11,474 | -22% | 1 | 1 | 0% | 2,709 | 4,191 | +55% | 0 | 0 | — |
case-02 | fail→pass | 13,552 | 9,317 | -31% | 1 | 1 | 0% | 2,666 | 3,832 | +44% | 0 | 0 | — |
case-01 | fail→pass | 17,107 | 13,413 | -22% | 1 | 1 | 0% | 3,442 | 4,319 | +25% | 0 | 0 | — |
case-03 | fail→pass | 6,603 | 4,646 | -30% | 1 | 1 | 0% | 1,264 | 2,938 | +132% | 0 | 0 | — |
case-04 | fail→pass | 9,289 | 5,980 | -36% | 1 | 1 | 0% | 1,657 | 3,065 | +85% | 0 | 0 | — |
case-05 | pass→pass | 7,195 | 4,530 | -37% | 1 | 1 | 0% | 1,371 | 2,936 | +114% | 0 | 0 | — |
case-06 | fail→pass | 6,375 | 4,001 | -37% | 1 | 1 | 0% | 1,218 | 2,673 | +119% | 0 | 0 | — |
case-07 | pass→pass | 13,106 | 10,035 | -23% | 1 | 1 | 0% | 2,491 | 4,055 | +63% | 0 | 0 | — |
case-09 | pass→pass | 8,258 | 4,481 | -46% | 1 | 1 | 0% | 1,506 | 2,844 | +89% | 0 | 0 | — |
case-10 | fail→pass | 4,014 | 2,960 | -26% | 1 | 1 | 0% | 575 | 2,461 | +328% | 0 | 0 | — |
case-11 | fail→pass | 11,818 | 2,942 | -75% | 1 | 1 | 0% | 1,880 | 2,523 | +34% | 0 | 0 | — |
case-12 | fail→pass | 4,569 | 3,569 | -22% | 1 | 1 | 0% | 816 | 2,619 | +221% | 0 | 0 | — |
case-13 | pass→pass | 10,596 | 4,755 | -55% | 1 | 1 | 0% | 1,635 | 2,759 | +69% | 0 | 0 | — |
case-14 | pass→pass | 12,840 | 5,104 | -60% | 1 | 1 | 0% | 2,150 | 2,856 | +33% | 0 | 0 | — |
case-15 | pass→pass | 12,871 | 11,130 | -14% | 1 | 1 | 0% | 2,282 | 4,051 | +78% | 0 | 0 | — |
case-16 | pass→pass | 9,819 | 12,236 | +25% | 1 | 1 | 0% | 1,509 | 3,913 | +159% | 0 | 0 | — |
case-17 | pass→pass | 10,417 | 6,300 | -40% | 1 | 1 | 0% | 1,682 | 3,104 | +85% | 0 | 0 | — |
case-18 | pass→pass | 8,560 | 4,126 | -52% | 1 | 1 | 0% | 1,401 | 2,735 | +95% | 0 | 0 | — |
case-19 | pass→pass | 9,250 | 6,458 | -30% | 1 | 1 | 0% | 1,600 | 3,105 | +94% | 0 | 0 | — |
case-20 | pass→pass | 15,465 | 3,588 | -77% | 1 | 1 | 0% | 2,377 | 2,561 | +8% | 0 | 0 | — |
case-21 | pass→pass | 9,266 | 3,715 | -60% | 1 | 1 | 0% | 1,517 | 2,699 | +78% | 0 | 0 | — |
case-22 | pass→pass | 21,179 | 17,826 | -16% | 1 | 1 | 0% | 4,246 | 5,579 | +31% | 0 | 0 | — |
case-23 | pass→pass | 12,399 | 15,844 | +28% | 1 | 1 | 0% | 2,395 | 4,392 | +83% | 0 | 0 | — |
case-24 | pass→pass | 9,485 | 6,888 | -27% | 1 | 1 | 0% | 1,734 | 3,243 | +87% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted. The headline lift of +38 percentage points is the difference between those two pass rates over the 24 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.