066. Meta Llama 모델 (Meta Llama models)
- 원문: English
- 위치: References/Advanced › Advanced inference topics › Inference parameters › Meta Llama models
한 줄 요약
Llama 3 ~ Llama 4 Instruct 모델은 InvokeModel/InvokeModelWithResponseStream에서 prompt + temperature/top_p/max_gen_len 의 단순한 본문을 쓰며, 프롬프트는 Llama 전용 특수 토큰 템플릿으로 감싸야 좋은 결과가 나옵니다.
쉽게 말하면
InvokeModel로 Llama를 부를 때는 대화 형식을 직접 <|start_header_id|>user<|end_header_id|> 같은 태그로 만들어 넣어야 합니다. 이런 작업이 번거롭다면 Converse API를 쓰는 편이 쉽습니다.
핵심 내용
대상 모델
- Llama 3 / 3.1 / 3.2 / 3.3 / 4 Instruct
- ⚠️ 지오펜싱(geofencing): Llama 3.2 11B·90B Instruct, Llama 4 Scout 17B·Maverick 17B Instruct는 AWS 계정의 국가와 요청 소스 IP의 국가에 따라 접근이 제한됩니다. 지원 국가는 Serverless Third-Party Model License Agreements 참고.
요청 본문
{
"prompt": string,
"temperature": float,
"top_p": float,
"max_gen_len": int
}
- Llama 3.2 이후 모델은
images(문자열 리스트)도 추가할 수 있습니다.
| 파라미터 | 필수 | 기본값 | 범위 | 설명 |
|---|---|---|---|---|
prompt | ✅ | - | - | 템플릿으로 감싼 프롬프트 |
temperature | 0.5 | 0~1 | 낮을수록 무작위성 감소 | |
top_p | 0.9 | 0~1 | 낮을수록 확률 낮은 후보 무시. 1.0이면 비활성 | |
max_gen_len | 512 | 1~2048 | 생성 최대 토큰. 넘으면 잘림 |
프롬프트 템플릿
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a helpful AI assistant<|eot_id|><|start_header_id|>user<|end_header_id|>
What can you help me with?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
- 멀티턴은 user/assistant 블록을
<|eot_id|>로 이어 붙이고, 마지막을assistant헤더로 끝냅니다.
응답 본문
| 필드 | 설명 |
|---|---|
generation | 생성된 텍스트 |
prompt_token_count / generation_token_count | 입력·출력 토큰 수 |
stop_reason | stop(정상 종료) / length(max_gen_len 초과로 잘림 → 값 늘려 재시도) |
⚠️ 스트리밍 + 도구 사용 제약
- 응답 스트리밍 자체는 됩니다. 하지만 Llama 3.1 8B·70B, Llama 3.3 70B, Llama 4 Scout·Maverick은
toolConfig를 비스트리밍Converse에서만 받습니다. ConverseStream에toolConfig를 보내면This model doesn't support tool use in streaming mode.오류가 납니다.
예제
- Python(boto3)
invoke_model로meta.llama3-70b-instruct-v1:0을 호출하는 예제가 있습니다(us-west-2).
SA 관점
- Llama 3.2 멀티모달·Llama 4 계열은 지오펜싱 대상이므로, 한국 계정/한국 IP에서의 사용 가능 여부를 라이선스 문서로 먼저 확인하세요.
- 에이전트(도구 사용)를 스트리밍 UX로 만들려는 고객에게 Llama는 도구 호출 단계에서 스트리밍이 안 된다는 점을 미리 알려야 합니다.
max_gen_len최대가 2048로 작은 편이라, 긴 문서 생성 용도라면stop_reason: length를 반드시 처리하도록 권장합니다.