> 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-hi/deploy/supported-models/clip.md).

# CLIP

हम OpenAI के [CLIP](https://github.com/openai/CLIP) मॉडल का उपयोग image और text embeddings जनरेट करने, और उनके बीच zero-shot similarity comparison करने के लिए, हमारे [Serverless Hosted API](/roboflow/roboflow-hi/deploy/serverless-hosted-api-v2.md)के माध्यम से करते हैं। हम तीन endpoints उपलब्ध कराते हैं:

* [`/clip/embed_image`](#post-clip-embed_image), एक image के लिए embedding vector लौटाता है
* [`/clip/embed_text`](#post-clip-embed_text), एक string या strings की सूची के लिए embedding vector लौटाता है
* [`/clip/compare`](#post-clip-compare), एक subject और prompts की सूची के बीच similarity scores लौटाता है

Embeddings को cache करके classification, retrieval, clustering, और semantic search जैसे tasks के लिए पुनः उपयोग किया जा सकता है। व्यापक उपयोग विवरण के लिए, देखें [Inference documentation](https://inference.roboflow.com/).

## कोड सैंपल

नीचे एक code sample है जो एक image की तुलना text labels की सूची से करता है, using the [`inference-sdk`](https://inference.roboflow.com/inference_helpers/inference_sdk/). Pass करें [Roboflow's API Key](https://app.roboflow.com/settings/api) के माध्यम से `API_KEY` env variable.

को कॉल करें `/clip/compare` endpoint को सीधे `curl`:

```bash
curl --location 'https://serverless.roboflow.com/clip/compare' \
  --header 'Content-Type: application/json' \\
  --data '{
    "api_key": "YOUR_API_KEY",
    "subject": {"type": "url", "value": "https://media.roboflow.com/notebooks/examples/dog.jpeg"},
    "subject_type": "image",
    "prompt": ["कुत्ते की तस्वीर", "बिल्ली की तस्वीर", "कार की तस्वीर"],
    "prompt_type": "text"
  }'
```

SDK के माध्यम से वही कॉल। इसे इंस्टॉल करें:

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

तुलना चलाएँ (image यहाँ से [यहाँ](https://media.roboflow.com/notebooks/examples/dog.jpeg)):

```python
import os
import urllib.request
from inference_sdk import InferenceHTTPClient

image_url = "https://media.roboflow.com/notebooks/examples/dog.jpeg"
image_path = "dog.jpeg"
urllib.request.urlretrieve(image_url, image_path)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["API_KEY"],
)

result = client.clip_compare(
    subject=image_path,
    prompt=[
        "कुत्ते की तस्वीर",
        "बिल्ली की तस्वीर",
        "कार की तस्वीर",
    ],
    subject_type="image",
    prompt_type="text",
)

# similarity cosine similarity scores की एक सूची है, प्रत्येक prompt के लिए एक
print(result["similarity"])
```

ऊपर दिया गया code terminal में inference परिणाम प्रिंट करता है:

```
[0.2726989686489105, 0.19865083694458008, 0.20997387170791626]
```

{% hint style="info" %}
Set `api_url` को अपने deployment target से मिलाने के लिए:

* `https://serverless.roboflow.com` Serverless Hosted API के लिए।
* `http://localhost:9001` एक local [Inference](https://inference.roboflow.com/) server.
* आपका [Dedicated Deployment](/roboflow/roboflow-hi/deploy/dedicated-deployments.md) एक private endpoint के लिए URL.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-hi/deploy/supported-models/clip.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
