Transformers documentation

vLLM

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v5.22.2).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

vLLM

vLLM은 대규모 LLM 서빙을 위한 고처리량 추론 엔진입니다. 이 엔진은 요청을 지속적으로 배치 처리하고 PagedAttention을 통해 KV 캐시 메모리를 컴팩트하게 유지합니다.

model_impl="transformers"를 설정하여 Transformers 모델링 백엔드를 사용해 모델을 로드합니다.

from vllm import LLM

llm = LLM(model="meta-llama/Llama-3.2-1B", model_impl="transformers")
print(llm.generate(["The capital of France is"]))

온라인 서빙을 위해 vllm serve 명령에 --model-impl transformers를 전달하세요.

vllm serve meta-llama/Llama-3.2-1B \
    --task generate \
    --model-impl transformers

Transformers 통합

  1. AutoConfig.from_pretrained()는 Hub 또는 Hugging Face 캐시에서 모델의 config.json을 로드합니다. vLLM은 architectures 필드를 내부 모델 레지스트리와 대조하여 사용할 vLLM 모델 클래스를 결정합니다.
  2. 모델이 레지스트리에 없으면 vLLM은 대신 Transformers 모델 구현을 로드하기 위해 AutoModel.from_config()를 호출합니다.
  3. AutoTokenizer.from_pretrained()는 토크나이저 파일을 로드합니다. vLLM은 추론 시 오버헤드를 줄이기 위해 일부 토크나이저 내부 요소를 캐시합니다.
  4. Hub에서 safetensors 형식으로 모델 가중치를 다운로드합니다.

model_impl="transformers"를 설정하면 vLLM 모델 레지스트리를 우회하여 Transformers에서 직접 로드합니다. vLLM은 Transformers 모델 구조를 유지하면서 대부분의 모델 모듈(MoE, attention, linear layers)을 자체 최적화 버전으로 대체합니다.

리소스

Update on GitHub