> 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/roboflow/roboflow-ko/deploy/supported-models/paligemma2.md).

# PaliGemma 2

PaliGemma 2는 Google의 vision-language 모델입니다. 이미지를 입력받고 텍스트 프롬프트를 받아 텍스트 응답을 반환합니다. 우리는 PaliGemma 2를 우리의 [Serverless Hosted API](/roboflow/roboflow-ko/deploy/serverless-hosted-api-v2.md), [Dedicated Deployments](/roboflow/roboflow-ko/deploy/dedicated-deployments.md)그리고 [자체 호스팅 Inference](https://inference.roboflow.com/).

## 코드 샘플

{% stepper %}
{% step %}

### API Key를 받으세요

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

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

{% endstep %}

{% step %}

### 종속성을 설치하세요

다음을 설치하세요 [Inference SDK](https://inference.roboflow.com/):

```bash
pip install inference-sdk
```

{% endstep %}

{% step %}

### 모델을 실행하세요

예제는 사전 학습된 `paligemma2-3b-pt-224` 캡션 프롬프트가 있는 체크포인트를.

```python
import os
import cv2
import numpy as np
import requests
from inference_sdk import InferenceHTTPClient

content = requests.get("https://media.roboflow.com/quickstart/dog.jpeg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer_lmm(
    image,
    model_id="paligemma2-3b-pt-224",
    prompt="caption en",
    max_new_tokens=64,
)
print(result["response"] )
```

{% endstep %}
{% endstepper %}

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

```
여기 한 남자의 어깨 위에 개가 보입니다
```

<figure><img src="/files/c2832b400f19db0d411d82260082a2d3938be754" alt=""><figcaption></figcaption></figure>

## 추론 속도

다음 기준으로 측정한 지연 시간 [Roboflow Inference](https://inference.roboflow.com/) 1x NVIDIA L4에서 배치 크기 1로, 고정 프롬프트에서 greedy decoding을 사용해 정확히 128개의 토큰을 생성할 때의 결과입니다. 지연 시간은 출력 길이에 따라 증가하므로, 다른 길이를 추정할 때는 tokens/sec를 사용하세요.

<table data-search="false"><thead><tr><th>별칭</th><th>지연 시간, 128 토큰(ms)</th><th>Tokens/sec</th></tr></thead><tbody><tr><td><code>paligemma2-3b-pt-224</code></td><td>3986</td><td>32</td></tr></tbody></table>

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

* `https://serverless.roboflow.com` Serverless Hosted API용입니다.
* `http://localhost:9001` 로컬 [Inference](https://inference.roboflow.com/) 서버용입니다.
* 귀하의 [Dedicated Deployment](/roboflow/roboflow-ko/deploy/dedicated-deployments.md) 비공개 엔드포인트용 URL입니다.
  {% endhint %}

Roboflow에서 자신만의 PaliGemma 2 체크포인트를 학습하고 모델별 `{workspace}/{model-slug}` ID로 호출할 수 있습니다(참조 [Versions, Trainings, and Models](/roboflow/roboflow-ko/train/versions-trainings-and-models.md)). 다음을 참조하세요 [Inference 문서](https://inference.roboflow.com/) 추가 프롬프트 형식과 지원되는 체크포인트에 대한
