Hub documentation
추론 제공자
추론 제공자
Hugging Face의 모델 페이지에는 수천 개의 모델에 대해 사용량 기반 추론을 제공하므로 브라우저에서 바로 모든 모델을 사용해 볼 수 있습니다. 이 서비스는 Inference Providers에 의해 구동되며, PRO 사용자 및 Team & Enterprise 조직에는 월별 포함 크레딧이 제공됩니다.
Inference Providers는 최고의 서버리스 추론 파트너를 통해 수백 개의 기계 학습 모델에 대한 간소화되고 통합된 액세스를 개발자에게 제공합니다. 👉 완전한 문서에 대해서는 Inference Providers 문서를 방문하세요.
Hub의 추론 제공자
Inference Providers는 Hugging Face Hub와 깊이 통합되어 있으며, 몇 가지 다른 방식으로 사용할 수 있습니다:
- 인터랙티브 위젯 - Inference Providers를 백엔드로 사용하는 인터랙티브 위젯을 통해 모델 페이지에서 모델을 직접 테스트할 수 있습니다. 예시로 DeepSeek-R1-0528 모델 페이지를 확인해 보세요.
- Inference Playground - 프롬프트로 채팅 완성 모델을 쉽게 테스트하고 비교해 보세요. 시작하려면 Inference Playground를 확인해 보세요.
- 검색 - 모델 페이지에서 추론 제공업체로 모델을 필터링하여 특정 제공업체를 통해 사용할 수 있는 모델을 찾습니다.
- Data Studio - AI를 활용하여 Hub의 데이터셋을 탐색합니다. 관심 있는 데이터셋에서 Data Studio를 확인해 보세요.
Inference Providers로 빌드하기
SDK 또는 HTTP 클라이언트를 사용하여 Inference Providers를 자체 애플리케이션에 통합할 수 있습니다. Python과 JavaScript를 활용한 빠른 시작을 안내하며, 자세한 내용은 Inference Providers Documentation을 참고하세요.
Python SDK를 사용하여 Inference Providers와 상호작용할 수 있습니다.
from huggingface_hub import InferenceClient
import os
client = InferenceClient(
api_key=os.environ["HF_TOKEN"],
provider="auto", # Automatically selects best provider
)
# Chat completion
completion = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V3-0324",
messages=[{"role": "user", "content": "A story about hiking in the mountains"}]
)
# Image generation
image = client.text_to_image(
prompt="A serene lake surrounded by mountains at sunset, photorealistic style",
model="black-forest-labs/FLUX.1-dev"
)
또는 OpenAI API 호환 클라이언트를 그대로 사용할 수도 있습니다.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://huggingface.co/proxy/router.huggingface.co/v1",
api_key=os.environ["HF_TOKEN"],
)
completion = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V3-0324",
messages=[
{
"role": "user",
"content": "A story about hiking in the mountains"
}
],
)OpenAI API 호환 클라이언트는 이미지 생성을 지원하지 않습니다.
JavaScript SDK를 사용하여 Inference Providers와 상호작용할 수 있습니다.
import { InferenceClient } from "@huggingface/inference";
const client = new InferenceClient(process.env.HF_TOKEN);
const chatCompletion = await client.chatCompletion({
provider: "auto", // Automatically selects best provider
model: "deepseek-ai/DeepSeek-V3-0324",
messages: [{ role: "user", content: "Hello!" }]
});
const imageBlob = await client.textToImage({
model: "black-forest-labs/FLUX.1-dev",
inputs:
"A serene lake surrounded by mountains at sunset, photorealistic style",
});또는 OpenAI API 호환 클라이언트를 그대로 사용할 수도 있습니다.
import { OpenAI } from "openai";
const client = new OpenAI({
baseURL: "https://huggingface.co/proxy/router.huggingface.co/v1",
apiKey: process.env.HF_TOKEN,
});
const completion = await client.chat.completions.create({
model: "meta-llama/Llama-3.1-8B-Instruct",
messages: [{ role: "user", content: "A story about hiking in the mountains" }],
});
OpenAI API 호환 클라이언트는 이미지 생성을 지원하지 않습니다.
추론 권한이 있는 Hugging Face 토큰이 필요합니다. Settings > Tokens에서 생성하세요.
Inference Providers 작동 방식
Inference Providers에 대해 더 자세히 알아보려면 Inference Providers 문서를 확인하세요. 주요 리소스는 다음과 같습니다:
HF-Inference API는 무엇이었나요?
HF-Inference API는 Inference Providers를 통해 사용할 수 있는 제공자 중 하나입니다. 이전에는 “Inference API (serverless)”라고 불렸으며, 내부적으로는 Inference Endpoints에 의해 구동됩니다.
HF-Inference 제공자에 대한 자세한 내용은 전용 페이지를 확인하세요.
Update on GitHub