비전 언어 모델 (Vision Language Models)
비전 언어 모델 (Vision Language Models)
이미지와 텍스트를 함께 입력으로 받아 처리할 수 있는 모델이 필요할 때가 있죠. Novita AI의 비전 언어 모델(VLM)은 이미지와 텍스트를 동시에 이해하고, 합쳐진 문맥을 바탕으로 좋은 응답을 만들어 내요. /chat/completions 엔드포인트에 이미지와 텍스트를 함께 보내는 방식이라 기존 채팅 API 구조에서 자연스럽게 확장돼요.
개요
비전 언어 모델(VLM, Vision-Language Model)은 이미지와 텍스트 입력을 모두 처리하는 멀티모달 파운데이션 모델이에요. 이미지의 시각적 내용을 언어 지시와 함께 이해하고, 결합된 문맥을 바탕으로 품질 좋은 응답을 생성해요.
대표적인 사용 사례
- 이미지 인식·설명: 이미지 속 객체, 색, 장면, 공간 관계를 자동으로 식별하고 자연어 설명을 생성해요.
- 멀티모달 이해: 이미지 입력과 문맥 텍스트를 결합해 여러 턴에 걸친 대화와 작업 수행을 해요.
- 시각 질의응답: 이미지에 포함된 텍스트를 인식·해석하는 고급 OCR 역할을 해요.
- 신생 응용: 지능형 비전 어시스턴트, 로봇 지각, AR 인터페이스 등에 활용돼요.
API 사용법
비전 언어 모델을 호출하려면 /chat/completions 엔드포인트에 이미지와 텍스트를 함께 보내면 돼요.
이미지 상세(detail) 파라미터
detail 필드로 이미지 해상도를 조절할 수 있어요.
high: 고해상도. 디테일을 많이 보존해서 정밀한 작업에 적합.low: 저해상도. 응답이 빨라 실시간 용도에 적합.auto: 상황에 맞는 모드를 자동 선택.
예시 메시지 형식
URL로 이미지 전달
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.png",
"detail": "high"
}
},
{
"type": "text",
"text": "Please describe the scene in the image."
}
]
}
Base64로 이미지 전달
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,{base64_image}",
"detail": "low"
}
},
{
"type": "text",
"text": "What text is present in the image?"
}
]
}
Python 코드 — 이미지를 Base64로 인코딩
import base64
from PIL import Image
import io
def image_to_base64(image_path):
with Image.open(image_path) as img:
buffered = io.BytesIO()
img.save(buffered, format="JPEG")
return base64.b64encode(buffered.getvalue()).decode('utf-8')
base64_image = image_to_base64("path/to/your/image.jpg")
다중 이미지 입력
텍스트 입력과 함께 여러 이미지를 보낼 수 있어요. 다만 최적의 결과를 위해 한 요청에 두 장 이하를 권장해요.
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image1.png"
}
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,{base64_image}"
}
},
{
"type": "text",
"text": "Compare the common features of these two images."
}
]
}
지원 모델
현재 Novita 플랫폼에서 지원하는 비전 언어 모델 목록은 문서의 모델 섹션을 참고하면 돼요. 완전하고 최신인 목록은 모델 허브에서 확인할 수 있어요.
요금
이미지 입력은 텍스트와 함께 토큰화되어 요금에 합산돼요.
- 모델마다 이미지를 토큰으로 변환하는 방식이 달라요.
- 모델별 요금과 토큰 정책은 각 모델의 가격 페이지를 참고하세요.
API 호출 예제
단일 이미지 설명
from openai import OpenAI
client = OpenAI(api_key="YOUR_KEY", base_url="https://api.novita.ai/openai")
response = client.chat.completions.create(
model="qwen/qwen2.5-vl-72b-instruct",
messages=[
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://example.com/cityscape.jpg"
}
},
{
"type": "text",
"text": "Describe the main buildings in the image."
}
]
}
],
stream=True
)
for chunk in response:
print(chunk.choices[0].delta.content or "", end="", flush=True)
다중 이미지 비교
response = client.chat.completions.create(
model="qwen/qwen2.5-vl-72b-instruct",
messages=[
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://example.com/product1.jpg"
}
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/product2.jpg"
}
},
{
"type": "text",
"text": "Please compare the key differences between these two products."
}
]
}
],
stream=True
)
for chunk in response:
print(chunk.choices[0].delta.content or "", end="", flush=True)
참고·트러블슈팅
- 이미지 해상도와 선명도가 모델 성능에 크게 영향을 줘요. 가능하면 고품질 이미지를 쓰세요.
- Base64 인코딩 이미지는 타임아웃·오류를 피하려고 1MB 미만이 좋아요.