> 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 Cloud API에서 사용할 수 없습니다. 다음에서 실행하세요 [전용 배포](https://docs.roboflow.com/deployment/roboflow-cloud/dedicated-deployments) 또는 [자체 호스팅 추론](https://docs.roboflow.com/deployment/self-hosted/self-hosted).
{% endhint %}

## SmolVLM2 API

{% 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, InferenceConfiguration

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"],
).configure(InferenceConfiguration(api_key_transport="header"))
result = client.infer_lmm(
    image,
    model_id="smolvlm2",
    prompt="Describe this image briefly.",
    max_new_tokens=64,
)
print(result["response"])
```

{% endstep %}
{% endstepper %}

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

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

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

## SmolVLM2 추론 속도

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

<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 %}

## 자체 호스팅 추론으로 SmolVLM2 실행

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 권장).
* **원격 실행**: 모델이 원격 Inference 서버에서 HTTP로 다음을 통해 호출됩니다: `infer_lmm()` 클라이언트 메서드.
