Llama-2 7B
문서 상태
소유: LLMOps · 기준: vLLM HyperAccel 0.0.5 · 최종 확인: 2026-10-15
개요
meta-llama/Llama-2-7b-hf를 vLLM HyperAccel로 실행합니다.
채팅 모델이 아닌 base 모델이므로 예제는 Completions API를 씁니다.
준비
설치를 마친 환경에서 시작합니다.
meta-llama/Llama-2-7b-hf는 접근 제한이 있는 모델입니다. Hugging Face에서 라이선스에 동의한 뒤 로그인하거나
HF_TOKEN을 설정합니다.
온라인 서빙
1. 서버 실행
| vllm serve meta-llama/Llama-2-7b-hf --no-enable-prefix-caching --no-async-scheduling
|
로그에 Application startup complete.가 나오면 준비된 것입니다.
2. cURL로 요청
| curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Llama-2-7b-hf",
"prompt": "The capital of France is",
"max_tokens": 16,
"temperature": 0
}'
|
응답은 표준 OpenAI text_completion 객체입니다. 생성한 문장은 choices[0].text에 있습니다.
3. OpenAI Python SDK로 요청
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | from openai import OpenAI
client = OpenAI(api_key="EMPTY", base_url="http://localhost:8000/v1")
model = client.models.list().data[0].id
completion = client.completions.create(
model=model,
prompt="A robot may not injure a human being",
max_tokens=10,
temperature=0.7,
n=2, # 응답 2개 생성
)
for choice in completion.choices:
print(choice.text)
|
오프라인 추론
1
2
3
4
5
6
7
8
9
10
11
12
13 | from vllm import LLM, SamplingParams
llm = LLM(model="meta-llama/Llama-2-7b-hf", enable_prefix_caching=False, async_scheduling=False)
prompts = [
"Hello world!",
"How are you?",
"The capital of France is",
]
outputs = llm.generate(prompts, SamplingParams(temperature=0, max_tokens=16))
for output in outputs:
print(output.prompt, "->", output.outputs[0].text)
|
참고
- dtype — Llama-2 체크포인트는
float16으로 저장되어 있습니다. LPU는 bfloat16으로 계산하므로 플러그인이
모델 dtype을 자동으로 bfloat16으로 바꾸고 경고를 남깁니다.
- 채팅 — base 모델로 Chat Completions API를 쓰려면
--chat-template으로 템플릿을 넘깁니다.
다음