TDTech Digest

068. Mistral AI 텍스트 완성 (Mistral AI text completion)

  • 원문: English
  • 위치: References/Advanced › Advanced inference topics › Inference parameters › Mistral AI models › Mistral AI text completion

한 줄 요약

Mistral 텍스트 완성 API는 prompt 하나에 [INST]...[/INST] 태그로 대화를 표현하고, max_tokens/stop/temperature/top_p/top_k로 생성을 제어합니다. 기본값과 최대값이 모델마다 다릅니다.

쉽게 말하면

사용자 말은 [INST]와 [/INST] 사이에, 모델 답은 그 밖에 씁니다. 문장 시작과 끝은 <s>, </s>로 표시합니다.

핵심 내용

지원 모델

Mistral 7B Instruct, Mixtral 8X7B Instruct, Mistral Large, Mistral Small (Apache 2.0 라이선스)

요청 본문

{
  "prompt": string,
  "max_tokens": int,
  "stop": [string],
  "temperature": float,
  "top_p": float,
  "top_k": int
}

프롬프트 예시 (멀티턴):

<s>[INST] What is your favourite condiment? [/INST]
Well, I'm quite partial to a good squeeze of fresh lemon juice.</s>
[INST] Do you have mayonnaise recipes? [/INST]

파라미터 기본값/범위

파라미터Mistral 7BMixtral 8X7BMistral LargeMistral Small범위
max_tokens 기본5125128,1928,192최소 1
max_tokens 최대8,1924,0968,1928,192
temperature 기본0.50.50.70.70~1
top_p 기본0.90.9110~1
top_k 기본5050비활성비활성1~200
  • stop: 정지 시퀀스 리스트, 최대 10개(기본 0개).

응답 본문

{ "outputs": [ { "text": string, "stop_reason": string } ] }
  • stop_reason: stop(생성 완료 또는 stop 시퀀스 생성) / length(max_tokens 초과로 잘림)

예제

  • Python(boto3) invoke_model로 mistral.mistral-7b-instruct-v0:2를 호출하는 예제가 있습니다.

SA 관점

  • Mixtral 8X7B만 max_tokens 최대가 4,096으로 작으니 긴 출력 워크로드에서는 주의하세요.
  • 채팅·도구 호출이 필요하면 이 형식 대신 069 또는 Converse API를 쓰는 것이 낫습니다.