FGP Hugging Face Daemon
Fast, persistent gateway to Hugging Face's Inference API. Access 400,000+ models with minimal latency overhead.
Why FGP?
FGP daemons maintain persistent connections and avoid cold-start overhead. Instead of spawning a new API client for each request, the daemon stays warm and ready.
Benefits:
- No cold-start latency
- Connection pooling
- Persistent authentication
Installation
# Via Homebrew (recommended)
brew tap fast-gateway-protocol/fgp
brew install fgp-huggingface
# Via npx
npx add-skill fgp-huggingface
Quick Start
# Set your API token (optional for public models)
export HF_API_TOKEN="hf_..."
# Start the daemon
fgp start huggingface
# Text generation
fgp call huggingface.generate \
--model "mistralai/Mistral-7B-Instruct-v0.2" \
--inputs "Explain machine learning in simple terms:"
# Embeddings
fgp call huggingface.embed \
--model "sentence-transformers/all-MiniLM-L6-v2" \
--inputs "Hello world"
Methods
Text Generation
-
huggingface.generate- Generate text with language modelsmodel(string, required): Model ID on Hugging Face Hubinputs(string, required): Input text/promptparameters(object, optional): Generation parametersmax_new_tokens(int): Maximum tokens to generatetemperature(float): Sampling temperaturetop_p(float): Nucleus sampling thresholddo_sample(bool): Enable sampling
-
huggingface.chat- Chat completion (for chat models)model(string, required): Chat model IDmessages(array, required): Chat messagesparameters(object, optional): Generation parameters
Embeddings
huggingface.embed- Generate embeddingsmodel(string, required): Embedding model IDinputs(string|array, required): Text(s) to embed
Classification
-
huggingface.classify- Text classificationmodel(string, required): Classification model IDinputs(string, required): Text to classify
-
huggingface.zero_shot- Zero-shot classificationmodel(string, required): Zero-shot model IDinputs(string, required): Text to classifycandidate_labels(array, required): Possible labels
Vision
-
huggingface.image_classify- Image classificationmodel(string, required): Vision model IDimage(string, required): Image URL or base64
-
huggingface.image_to_text- Image captioningmodel(string, required): Captioning model IDimage(string, required): Image URL or base64
Popular Models
Text Generation
mistralai/Mistral-7B-Instruct-v0.2- Mistral 7B Instructmeta-llama/Llama-2-7b-chat-hf- Llama 2 7B ChatHuggingFaceH4/zephyr-7b-beta- Zephyr 7B
Embeddings
sentence-transformers/all-MiniLM-L6-v2- Fast, general-purposeBAAI/bge-large-en-v1.5- High quality Englishintfloat/multilingual-e5-large- Multilingual
Classification
facebook/bart-large-mnli- Zero-shot classificationcardiffnlp/twitter-roberta-base-sentiment- Sentiment analysisMoritzLaworker/topic-classification- Topic detection
Vision
Salesforce/blip-image-captioning-large- Image captioninggoogle/vit-base-patch16-224- Image classificationfacebook/detr-resnet-50- Object detection
Configuration
Environment variables:
HF_API_TOKEN(optional): Your Hugging Face API tokenHF_INFERENCE_ENDPOINT(optional): Custom inference endpoint URL
Examples
Text generation with parameters
fgp call huggingface.generate \
--model "mistralai/Mistral-7B-Instruct-v0.2" \
--inputs "[INST] Write a haiku about programming [/INST]" \
--parameters '{
"max_new_tokens": 100,
"temperature": 0.8,
"do_sample": true
}'
Zero-shot classification
fgp call huggingface.zero_shot \
--model "facebook/bart-large-mnli" \
--inputs "I just bought a new iPhone and it's amazing!" \
--candidate_labels '["technology", "sports", "politics", "entertainment"]'
Batch embeddings
fgp call huggingface.embed \
--model "sentence-transformers/all-MiniLM-L6-v2" \
--inputs '["First sentence", "Second sentence", "Third sentence"]'
Image captioning
fgp call huggingface.image_to_text \
--model "Salesforce/blip-image-captioning-large" \
--image "https://example.com/photo.jpg"
Sentiment analysis
fgp call huggingface.classify \
--model "cardiffnlp/twitter-roberta-base-sentiment" \
--inputs "I love using FGP! It makes everything so fast."
Scan to join WeChat group