> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/models/ko/supported-models/smolvlm2.md).

# SmolVLM2

SmolVLM2는 HuggingFace의 컴팩트한 비전-언어 모델입니다. 이미지를 입력받아 텍스트 프롬프트를 처리하고 텍스트 응답을 반환합니다.

{% hint style="info" %}
SmolVLM2는 Serverless Hosted API에서 사용할 수 없습니다. 다음에서 실행하세요. [전용 배포](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) 또는 [자가 호스팅 Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted).
{% endhint %}

## 코드 샘플

{% stepper %}
{% step %}

### API 키 받기

Roboflow 계정을 만들고, 다음에서 키를 찾으세요 [Roboflow API 설정 페이지](https://app.roboflow.com/settings/api) 그리고 셸에서 사용할 수 있도록 설정하세요:

```bash
export ROBOFLOW_API_KEY="your-key-here"
```

{% endstep %}

{% step %}

### 의존성 설치하기

다음을 설치하세요 [Inference SDK](https://docs.roboflow.com/deployment/self-hosted/self-hosted):

```bash
pip install -U inference-sdk supervision
```

{% endstep %}

{% step %}

### 모델 실행하기

설정하세요 `api_url` 전용 배포 URL 또는 로컬 추론 서버로.

```python
import os
import supervision as sv
from inference_sdk import InferenceHTTPClient

image = sv.load_image_from_url("https://media.roboflow.com/quickstart/dog.jpeg")

client = InferenceHTTPClient(
    api_url="https://your-deployment.roboflow.cloud",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer_lmm(
    image,
    model_id="smolvlm2",
    prompt="이 이미지를 간단히 설명해 주세요.",
    max_new_tokens=64,
)
print(result["response"])
```

{% endstep %}
{% endstepper %}

위의 코드는 모델 응답을 터미널에 출력합니다:

```
한 남자가 어깨에 개를 메고 있습니다.
```

<figure><img src="/files/8facc03ecaac5bedf2dbf1ba3d293ec7d0b71349" alt=""><figcaption></figcaption></figure>

## 추론 속도

다음을 사용해 측정한 지연 시간 [Roboflow Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 1x NVIDIA L4에서, 배치 크기 1, 고정된 프롬프트로 그리디 디코딩을 사용해 정확히 128개의 토큰을 생성할 때 측정했습니다. 지연 시간은 출력 길이에 따라 달라지므로, 다른 길이를 추정할 때는 토큰/초를 사용하세요.

<table data-search="false"><thead><tr><th>별칭</th><th>지연 시간, 128토큰(ms)</th><th>토큰/초</th></tr></thead><tbody><tr><td><code>smolvlm2</code></td><td>3113</td><td>41</td></tr></tbody></table>

{% hint style="info" %}
설정하세요 `api_url` 배포 대상에 맞게 설정하세요:

* `http://localhost:9001` 로컬 [Inference](https://docs.roboflow.com/deployment/self-hosted/self-hosted) 서버.
* 사용자 [전용 배포](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) 비공개 엔드포인트용 URL.
  {% endhint %}

## Inference(자가 호스팅)와 함께 사용

SmolVLM2는 다음과 함께 직접 로드할 수도 있습니다. [`inference`](https://docs.roboflow.com/deployment/self-hosted/self-hosted) VQA, 문서 OCR, 문서 VQA, 객체 수 세기를 위한 패키지.

{% stepper %}
{% step %}

### 패키지 설치하기

```bash
pip install "inference[transformers]"
```

사용 `inference-gpu[transformers]` 를 GPU 머신에서 사용하세요.
{% endstep %}

{% step %}

### 모델 실행하기

```python
from PIL import Image

from inference.models.smolvlm.smolvlm import SmolVLM

model = SmolVLM(api_key="YOUR_API_KEY")

image = Image.open("dog.jpeg")
result = model.predict(image, "이 이미지에는 개가 몇 마리 있나요?")

print(result)
```

{% endstep %}
{% endstepper %}

### Workflows의 실행 모드

다음에서 사용될 때 [Workflow](https://docs.roboflow.com/workflows), SmolVLM2는 두 가지 모드 중 하나로 실행됩니다:

* **로컬 실행** : 모델이 사용자 Inference 서버에서 실행됩니다(GPU 권장).
* **원격 실행** : 모델은 `infer_lmm()` 클라이언트 메서드를 통해 원격 Inference 서버에서 HTTP로 호출됩니다.
