> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/pattern-custom-embedding-pipeline.md).

# पैटर्न: कस्टम embedding पाइपलाइन

Python SDK पैटर्न: अपने मॉडल से लाइब्रेरी इमेज के embedding बनाएँ, वेक्टर सेव करें और अगली लेबलिंग के लिए मिलते-जुलते फ़्रेम खोजें।

किसी ज्ञात विफलता, जैसे गिरा हुआ पुर्ज़ा, जैसे दिखने वाले फ़्रेम खोजें और उन्हें लेबलिंग के लिए भेजें।

```python
from unitlab import UnitlabClient

client = UnitlabClient()
space = client.embedding_spaces.create("clip-vit-b32", dimensions=512, model_name="openai/clip-vit-base-patch32")

folder = client.assets.folder("FOLDER_ID")
assets = folder.list_items()

batch = []
for asset in assets:
    batch.append({"asset_id": asset.id, "vector": embed(asset)})   # your model
    if len(batch) == 1000:
        space.upsert_many(batch)
        batch = []
if batch:
    space.upsert_many(batch)

hits = space.search(embed_image("dropped_part.jpg"), limit=50)
similar = [hit["asset_id"] for hit in hits["results"] if hit["score"] > 0.85]

dataset = client.datasets.create("Dropped parts - candidates", asset_ids=similar)
client.close()
```

`embed()` आपके अपने मॉडल कोड की जगह है। Unitlab वेक्टर सेव करता है और खोजता है; उन्हें कैलकुलेट नहीं करता।

| सुझाव                            | क्यों                                        |
| -------------------------------- | -------------------------------------------- |
| हर मॉडल और वर्शन के लिए एक स्पेस | अलग-अलग मॉडल के वेक्टर की तुलना नहीं हो सकती |
| 1,000 के बैच में upsert करें     | यह प्रति कॉल अधिकतम है                       |
| वीडियो के लिए `level="frame"`    | हर फ़ाइल की जगह हर फ़्रेम का एक नतीजा        |
| HTTP 409 पर रिट्राई करें         | इंडेक्स अभी बन रहा है                        |

## संबंधित पेज <a href="#related" id="related"></a>

[Embedding spaces](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/embedding-spaces.md) · [वेक्टर upsert और सर्च](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/upsert-and-search-vectors.md) · [डेटासेट](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/datasets.md)
