orca-sdk 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orca_sdk/_shared/metrics.py +120 -18
- orca_sdk/_shared/metrics_test.py +204 -0
- orca_sdk/async_client.py +105 -25
- orca_sdk/classification_model.py +4 -5
- orca_sdk/client.py +105 -25
- orca_sdk/embedding_model.py +19 -14
- orca_sdk/embedding_model_test.py +1 -1
- orca_sdk/memoryset.py +1093 -231
- orca_sdk/memoryset_test.py +109 -2
- orca_sdk/regression_model.py +2 -3
- {orca_sdk-0.1.5.dist-info → orca_sdk-0.1.7.dist-info}/METADATA +1 -1
- {orca_sdk-0.1.5.dist-info → orca_sdk-0.1.7.dist-info}/RECORD +13 -13
- {orca_sdk-0.1.5.dist-info → orca_sdk-0.1.7.dist-info}/WHEEL +0 -0
orca_sdk/async_client.py
CHANGED
|
@@ -62,10 +62,12 @@ class ActionRecommendation(TypedDict):
|
|
|
62
62
|
class AddMemorySuggestion(TypedDict):
|
|
63
63
|
value: str
|
|
64
64
|
label_name: str
|
|
65
|
+
similarity: NotRequired[float | None]
|
|
65
66
|
|
|
66
67
|
|
|
67
68
|
class AliveResponse(TypedDict):
|
|
68
69
|
ok: bool
|
|
70
|
+
checks: dict[str, bool]
|
|
69
71
|
|
|
70
72
|
|
|
71
73
|
class ApiKeyMetadata(TypedDict):
|
|
@@ -292,7 +294,7 @@ class JobStatusInfo(TypedDict):
|
|
|
292
294
|
class LabelClassMetrics(TypedDict):
|
|
293
295
|
label: int | None
|
|
294
296
|
label_name: NotRequired[str | None]
|
|
295
|
-
average_lookup_score: float
|
|
297
|
+
average_lookup_score: float | None
|
|
296
298
|
memory_count: int
|
|
297
299
|
|
|
298
300
|
|
|
@@ -346,7 +348,7 @@ class MemoryMetrics(TypedDict):
|
|
|
346
348
|
cluster: NotRequired[int]
|
|
347
349
|
embedding_2d: NotRequired[list]
|
|
348
350
|
anomaly_score: NotRequired[float]
|
|
349
|
-
neighbor_label_logits: NotRequired[list[float]]
|
|
351
|
+
neighbor_label_logits: NotRequired[list[float] | None]
|
|
350
352
|
neighbor_predicted_label: NotRequired[int | None]
|
|
351
353
|
neighbor_predicted_label_ambiguity: NotRequired[float]
|
|
352
354
|
neighbor_predicted_label_confidence: NotRequired[float]
|
|
@@ -555,16 +557,7 @@ class PredictiveModelUpdate(TypedDict):
|
|
|
555
557
|
|
|
556
558
|
|
|
557
559
|
PretrainedEmbeddingModelName = Literal[
|
|
558
|
-
"CLIP_BASE",
|
|
559
|
-
"GTE_BASE",
|
|
560
|
-
"CDE_SMALL",
|
|
561
|
-
"DISTILBERT",
|
|
562
|
-
"GTE_SMALL",
|
|
563
|
-
"MXBAI_LARGE",
|
|
564
|
-
"E5_LARGE",
|
|
565
|
-
"QWEN2_1_5B",
|
|
566
|
-
"BGE_BASE",
|
|
567
|
-
"GIST_LARGE",
|
|
560
|
+
"CLIP_BASE", "GTE_BASE", "CDE_SMALL", "DISTILBERT", "GTE_SMALL", "MXBAI_LARGE", "E5_LARGE", "BGE_BASE", "GIST_LARGE"
|
|
568
561
|
]
|
|
569
562
|
|
|
570
563
|
|
|
@@ -1166,6 +1159,9 @@ class FieldValidationError(TypedDict):
|
|
|
1166
1159
|
|
|
1167
1160
|
class AddMemoryRecommendations(TypedDict):
|
|
1168
1161
|
memories: list[AddMemorySuggestion]
|
|
1162
|
+
attempts_used: NotRequired[int]
|
|
1163
|
+
partial: NotRequired[bool]
|
|
1164
|
+
rejection_counts: NotRequired[dict[str, int]]
|
|
1169
1165
|
|
|
1170
1166
|
|
|
1171
1167
|
class BootstrapClassificationModelRequest(TypedDict):
|
|
@@ -1175,7 +1171,14 @@ class BootstrapClassificationModelRequest(TypedDict):
|
|
|
1175
1171
|
num_examples_per_label: NotRequired[int]
|
|
1176
1172
|
|
|
1177
1173
|
|
|
1178
|
-
class
|
|
1174
|
+
class BootstrapLabeledMemoryDataInput(TypedDict):
|
|
1175
|
+
model_description: str
|
|
1176
|
+
label_names: list[str]
|
|
1177
|
+
initial_examples: NotRequired[list[LabeledExample]]
|
|
1178
|
+
num_examples_per_label: NotRequired[int]
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
class BootstrapLabeledMemoryDataResult(TypedDict):
|
|
1179
1182
|
model_description: str
|
|
1180
1183
|
label_names: list[str]
|
|
1181
1184
|
model_name: str
|
|
@@ -1274,10 +1277,19 @@ class CreateClassificationModelRequest(TypedDict):
|
|
|
1274
1277
|
num_classes: NotRequired[int | None]
|
|
1275
1278
|
|
|
1276
1279
|
|
|
1277
|
-
class
|
|
1280
|
+
class CreateMemorysetFromDatasourceRequest(TypedDict):
|
|
1278
1281
|
name: str
|
|
1279
1282
|
description: NotRequired[str | None]
|
|
1280
1283
|
notes: NotRequired[str | None]
|
|
1284
|
+
pretrained_embedding_model_name: NotRequired[PretrainedEmbeddingModelName | None]
|
|
1285
|
+
finetuned_embedding_model_name_or_id: NotRequired[str | None]
|
|
1286
|
+
max_seq_length_override: NotRequired[int | None]
|
|
1287
|
+
label_names: NotRequired[list[str] | None]
|
|
1288
|
+
index_type: NotRequired[Literal["FLAT", "IVF_FLAT", "IVF_SQ8", "IVF_PQ", "HNSW", "DISKANN"]]
|
|
1289
|
+
index_params: NotRequired[dict[str, int | float | str]]
|
|
1290
|
+
prompt: NotRequired[str]
|
|
1291
|
+
hidden: NotRequired[bool]
|
|
1292
|
+
memory_type: NotRequired[MemoryType | None]
|
|
1281
1293
|
datasource_name_or_id: str
|
|
1282
1294
|
datasource_label_column: NotRequired[str | None]
|
|
1283
1295
|
datasource_score_column: NotRequired[str | None]
|
|
@@ -1285,6 +1297,14 @@ class CreateMemorysetRequest(TypedDict):
|
|
|
1285
1297
|
datasource_source_id_column: NotRequired[str | None]
|
|
1286
1298
|
datasource_partition_id_column: NotRequired[str | None]
|
|
1287
1299
|
remove_duplicates: NotRequired[bool]
|
|
1300
|
+
batch_size: NotRequired[int]
|
|
1301
|
+
subsample: NotRequired[int | float | None]
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
class CreateMemorysetRequest(TypedDict):
|
|
1305
|
+
name: str
|
|
1306
|
+
description: NotRequired[str | None]
|
|
1307
|
+
notes: NotRequired[str | None]
|
|
1288
1308
|
pretrained_embedding_model_name: NotRequired[PretrainedEmbeddingModelName | None]
|
|
1289
1309
|
finetuned_embedding_model_name_or_id: NotRequired[str | None]
|
|
1290
1310
|
max_seq_length_override: NotRequired[int | None]
|
|
@@ -1293,9 +1313,7 @@ class CreateMemorysetRequest(TypedDict):
|
|
|
1293
1313
|
index_params: NotRequired[dict[str, int | float | str]]
|
|
1294
1314
|
prompt: NotRequired[str]
|
|
1295
1315
|
hidden: NotRequired[bool]
|
|
1296
|
-
|
|
1297
|
-
subsample: NotRequired[int | float | None]
|
|
1298
|
-
memory_type: NotRequired[MemoryType]
|
|
1316
|
+
memory_type: NotRequired[MemoryType | None]
|
|
1299
1317
|
|
|
1300
1318
|
|
|
1301
1319
|
class CreateRegressionModelRequest(TypedDict):
|
|
@@ -1655,8 +1673,8 @@ class MemorysetMetadata(TypedDict):
|
|
|
1655
1673
|
created_at: str
|
|
1656
1674
|
updated_at: str
|
|
1657
1675
|
memories_updated_at: str
|
|
1658
|
-
insertion_job_id: str
|
|
1659
|
-
insertion_status: JobStatus
|
|
1676
|
+
insertion_job_id: str | None
|
|
1677
|
+
insertion_status: JobStatus | None
|
|
1660
1678
|
metrics: MemorysetMetrics
|
|
1661
1679
|
memory_type: MemoryType
|
|
1662
1680
|
label_names: list[str] | None
|
|
@@ -1666,7 +1684,7 @@ class MemorysetMetadata(TypedDict):
|
|
|
1666
1684
|
document_prompt_override: str | None
|
|
1667
1685
|
query_prompt_override: str | None
|
|
1668
1686
|
hidden: bool
|
|
1669
|
-
insertion_task_id: str
|
|
1687
|
+
insertion_task_id: str | None
|
|
1670
1688
|
|
|
1671
1689
|
|
|
1672
1690
|
class PaginatedWorkerInfo(TypedDict):
|
|
@@ -1680,7 +1698,7 @@ class BootstrapClassificationModelMeta(TypedDict):
|
|
|
1680
1698
|
datasource_meta: DatasourceMetadata
|
|
1681
1699
|
memoryset_meta: MemorysetMetadata
|
|
1682
1700
|
model_meta: ClassificationModelMetadata
|
|
1683
|
-
agent_output:
|
|
1701
|
+
agent_output: BootstrapLabeledMemoryDataResult
|
|
1684
1702
|
|
|
1685
1703
|
|
|
1686
1704
|
class BootstrapClassificationModelResponse(TypedDict):
|
|
@@ -1737,6 +1755,22 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
1737
1755
|
) -> AliveResponse:
|
|
1738
1756
|
pass
|
|
1739
1757
|
|
|
1758
|
+
@overload
|
|
1759
|
+
async def GET(
|
|
1760
|
+
self,
|
|
1761
|
+
path: Literal["/gpu/check/alive"],
|
|
1762
|
+
*,
|
|
1763
|
+
params: None = None,
|
|
1764
|
+
parse_as: Literal["json"] = "json",
|
|
1765
|
+
headers: HeaderTypes | None = None,
|
|
1766
|
+
cookies: CookieTypes | None = None,
|
|
1767
|
+
auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
1768
|
+
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
1769
|
+
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
1770
|
+
extensions: RequestExtensions | None = None,
|
|
1771
|
+
) -> AliveResponse:
|
|
1772
|
+
pass
|
|
1773
|
+
|
|
1740
1774
|
@overload
|
|
1741
1775
|
async def GET(
|
|
1742
1776
|
self,
|
|
@@ -1756,7 +1790,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
1756
1790
|
@overload
|
|
1757
1791
|
async def GET(
|
|
1758
1792
|
self,
|
|
1759
|
-
path: Literal["/
|
|
1793
|
+
path: Literal["/check/healthy"],
|
|
1760
1794
|
*,
|
|
1761
1795
|
params: None = None,
|
|
1762
1796
|
parse_as: Literal["json"] = "json",
|
|
@@ -1772,7 +1806,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
1772
1806
|
@overload
|
|
1773
1807
|
async def GET(
|
|
1774
1808
|
self,
|
|
1775
|
-
path: Literal["/check/healthy"],
|
|
1809
|
+
path: Literal["/gpu/check/healthy"],
|
|
1776
1810
|
*,
|
|
1777
1811
|
params: None = None,
|
|
1778
1812
|
parse_as: Literal["json"] = "json",
|
|
@@ -2570,7 +2604,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
2570
2604
|
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2571
2605
|
extensions: RequestExtensions | None = None,
|
|
2572
2606
|
) -> BootstrapClassificationModelResponse:
|
|
2573
|
-
"""Get the status of a bootstrap
|
|
2607
|
+
"""Get the status of a bootstrap labeled memory data job"""
|
|
2574
2608
|
pass
|
|
2575
2609
|
|
|
2576
2610
|
async def GET(
|
|
@@ -2897,6 +2931,26 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
2897
2931
|
path: Literal["/memoryset"],
|
|
2898
2932
|
*,
|
|
2899
2933
|
params: None = None,
|
|
2934
|
+
json: CreateMemorysetFromDatasourceRequest,
|
|
2935
|
+
data: None = None,
|
|
2936
|
+
files: None = None,
|
|
2937
|
+
content: None = None,
|
|
2938
|
+
parse_as: Literal["json"] = "json",
|
|
2939
|
+
headers: HeaderTypes | None = None,
|
|
2940
|
+
cookies: CookieTypes | None = None,
|
|
2941
|
+
auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2942
|
+
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2943
|
+
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2944
|
+
extensions: RequestExtensions | None = None,
|
|
2945
|
+
) -> MemorysetMetadata:
|
|
2946
|
+
pass
|
|
2947
|
+
|
|
2948
|
+
@overload
|
|
2949
|
+
async def POST(
|
|
2950
|
+
self,
|
|
2951
|
+
path: Literal["/memoryset/empty"],
|
|
2952
|
+
*,
|
|
2953
|
+
params: None = None,
|
|
2900
2954
|
json: CreateMemorysetRequest,
|
|
2901
2955
|
data: None = None,
|
|
2902
2956
|
files: None = None,
|
|
@@ -3292,6 +3346,32 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
3292
3346
|
"""Get row count from a specific datasource with optional filtering."""
|
|
3293
3347
|
pass
|
|
3294
3348
|
|
|
3349
|
+
@overload
|
|
3350
|
+
async def POST(
|
|
3351
|
+
self,
|
|
3352
|
+
path: Literal["/datasource/bootstrap_memory_data"],
|
|
3353
|
+
*,
|
|
3354
|
+
params: None = None,
|
|
3355
|
+
json: BootstrapLabeledMemoryDataInput,
|
|
3356
|
+
data: None = None,
|
|
3357
|
+
files: None = None,
|
|
3358
|
+
content: None = None,
|
|
3359
|
+
parse_as: Literal["json"] = "json",
|
|
3360
|
+
headers: HeaderTypes | None = None,
|
|
3361
|
+
cookies: CookieTypes | None = None,
|
|
3362
|
+
auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3363
|
+
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3364
|
+
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3365
|
+
extensions: RequestExtensions | None = None,
|
|
3366
|
+
) -> BootstrapLabeledMemoryDataResult:
|
|
3367
|
+
"""
|
|
3368
|
+
Bootstrap memory data using an AI agent.
|
|
3369
|
+
|
|
3370
|
+
This endpoint uses the bootstrap labeled memory data agent to generate
|
|
3371
|
+
high-quality, diverse training examples for a classification model.
|
|
3372
|
+
"""
|
|
3373
|
+
pass
|
|
3374
|
+
|
|
3295
3375
|
@overload
|
|
3296
3376
|
async def POST(
|
|
3297
3377
|
self,
|
|
@@ -3540,7 +3620,7 @@ class OrcaAsyncClient(AsyncClient):
|
|
|
3540
3620
|
"""
|
|
3541
3621
|
Bootstrap a classification model by creating a memoryset with generated memories and a classification model.
|
|
3542
3622
|
|
|
3543
|
-
This endpoint uses the
|
|
3623
|
+
This endpoint uses the bootstrap_labeled_memory_data agent to generate:
|
|
3544
3624
|
1. Memoryset configuration with appropriate settings
|
|
3545
3625
|
2. Model configuration with optimal parameters
|
|
3546
3626
|
3. High-quality training memories for each label
|
orca_sdk/classification_model.py
CHANGED
|
@@ -12,12 +12,10 @@ from ._utils.common import UNSET, CreateMode, DropMode
|
|
|
12
12
|
from .async_client import OrcaAsyncClient
|
|
13
13
|
from .client import (
|
|
14
14
|
BootstrapClassificationModelMeta,
|
|
15
|
-
|
|
16
|
-
ClassificationEvaluationRequest,
|
|
15
|
+
BootstrapLabeledMemoryDataResult,
|
|
17
16
|
ClassificationModelMetadata,
|
|
18
17
|
ClassificationPredictionRequest,
|
|
19
18
|
OrcaClient,
|
|
20
|
-
PostClassificationModelByModelNameOrIdEvaluationParams,
|
|
21
19
|
PredictiveModelUpdate,
|
|
22
20
|
RACHeadType,
|
|
23
21
|
)
|
|
@@ -43,7 +41,7 @@ class BootstrappedClassificationModel:
|
|
|
43
41
|
datasource: Datasource | None
|
|
44
42
|
memoryset: LabeledMemoryset | None
|
|
45
43
|
classification_model: ClassificationModel | None
|
|
46
|
-
agent_output:
|
|
44
|
+
agent_output: BootstrapLabeledMemoryDataResult | None
|
|
47
45
|
|
|
48
46
|
def __init__(self, metadata: BootstrapClassificationModelMeta):
|
|
49
47
|
self.datasource = Datasource.open(metadata["datasource_meta"]["id"])
|
|
@@ -116,13 +114,14 @@ class ClassificationModel:
|
|
|
116
114
|
return isinstance(other, ClassificationModel) and self.id == other.id
|
|
117
115
|
|
|
118
116
|
def __repr__(self):
|
|
117
|
+
memoryset_repr = self.memoryset.__repr__().replace("\n", "\n ")
|
|
119
118
|
return (
|
|
120
119
|
"ClassificationModel({\n"
|
|
121
120
|
f" name: '{self.name}',\n"
|
|
122
121
|
f" head_type: {self.head_type},\n"
|
|
123
122
|
f" num_classes: {self.num_classes},\n"
|
|
124
123
|
f" memory_lookup_count: {self.memory_lookup_count},\n"
|
|
125
|
-
f" memoryset:
|
|
124
|
+
f" memoryset: {memoryset_repr},\n"
|
|
126
125
|
"})"
|
|
127
126
|
)
|
|
128
127
|
|
orca_sdk/client.py
CHANGED
|
@@ -60,10 +60,12 @@ class ActionRecommendation(TypedDict):
|
|
|
60
60
|
class AddMemorySuggestion(TypedDict):
|
|
61
61
|
value: str
|
|
62
62
|
label_name: str
|
|
63
|
+
similarity: NotRequired[float | None]
|
|
63
64
|
|
|
64
65
|
|
|
65
66
|
class AliveResponse(TypedDict):
|
|
66
67
|
ok: bool
|
|
68
|
+
checks: dict[str, bool]
|
|
67
69
|
|
|
68
70
|
|
|
69
71
|
class ApiKeyMetadata(TypedDict):
|
|
@@ -290,7 +292,7 @@ class JobStatusInfo(TypedDict):
|
|
|
290
292
|
class LabelClassMetrics(TypedDict):
|
|
291
293
|
label: int | None
|
|
292
294
|
label_name: NotRequired[str | None]
|
|
293
|
-
average_lookup_score: float
|
|
295
|
+
average_lookup_score: float | None
|
|
294
296
|
memory_count: int
|
|
295
297
|
|
|
296
298
|
|
|
@@ -344,7 +346,7 @@ class MemoryMetrics(TypedDict):
|
|
|
344
346
|
cluster: NotRequired[int]
|
|
345
347
|
embedding_2d: NotRequired[list]
|
|
346
348
|
anomaly_score: NotRequired[float]
|
|
347
|
-
neighbor_label_logits: NotRequired[list[float]]
|
|
349
|
+
neighbor_label_logits: NotRequired[list[float] | None]
|
|
348
350
|
neighbor_predicted_label: NotRequired[int | None]
|
|
349
351
|
neighbor_predicted_label_ambiguity: NotRequired[float]
|
|
350
352
|
neighbor_predicted_label_confidence: NotRequired[float]
|
|
@@ -553,16 +555,7 @@ class PredictiveModelUpdate(TypedDict):
|
|
|
553
555
|
|
|
554
556
|
|
|
555
557
|
PretrainedEmbeddingModelName = Literal[
|
|
556
|
-
"CLIP_BASE",
|
|
557
|
-
"GTE_BASE",
|
|
558
|
-
"CDE_SMALL",
|
|
559
|
-
"DISTILBERT",
|
|
560
|
-
"GTE_SMALL",
|
|
561
|
-
"MXBAI_LARGE",
|
|
562
|
-
"E5_LARGE",
|
|
563
|
-
"QWEN2_1_5B",
|
|
564
|
-
"BGE_BASE",
|
|
565
|
-
"GIST_LARGE",
|
|
558
|
+
"CLIP_BASE", "GTE_BASE", "CDE_SMALL", "DISTILBERT", "GTE_SMALL", "MXBAI_LARGE", "E5_LARGE", "BGE_BASE", "GIST_LARGE"
|
|
566
559
|
]
|
|
567
560
|
|
|
568
561
|
|
|
@@ -1164,6 +1157,9 @@ class FieldValidationError(TypedDict):
|
|
|
1164
1157
|
|
|
1165
1158
|
class AddMemoryRecommendations(TypedDict):
|
|
1166
1159
|
memories: list[AddMemorySuggestion]
|
|
1160
|
+
attempts_used: NotRequired[int]
|
|
1161
|
+
partial: NotRequired[bool]
|
|
1162
|
+
rejection_counts: NotRequired[dict[str, int]]
|
|
1167
1163
|
|
|
1168
1164
|
|
|
1169
1165
|
class BootstrapClassificationModelRequest(TypedDict):
|
|
@@ -1173,7 +1169,14 @@ class BootstrapClassificationModelRequest(TypedDict):
|
|
|
1173
1169
|
num_examples_per_label: NotRequired[int]
|
|
1174
1170
|
|
|
1175
1171
|
|
|
1176
|
-
class
|
|
1172
|
+
class BootstrapLabeledMemoryDataInput(TypedDict):
|
|
1173
|
+
model_description: str
|
|
1174
|
+
label_names: list[str]
|
|
1175
|
+
initial_examples: NotRequired[list[LabeledExample]]
|
|
1176
|
+
num_examples_per_label: NotRequired[int]
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
class BootstrapLabeledMemoryDataResult(TypedDict):
|
|
1177
1180
|
model_description: str
|
|
1178
1181
|
label_names: list[str]
|
|
1179
1182
|
model_name: str
|
|
@@ -1272,10 +1275,19 @@ class CreateClassificationModelRequest(TypedDict):
|
|
|
1272
1275
|
num_classes: NotRequired[int | None]
|
|
1273
1276
|
|
|
1274
1277
|
|
|
1275
|
-
class
|
|
1278
|
+
class CreateMemorysetFromDatasourceRequest(TypedDict):
|
|
1276
1279
|
name: str
|
|
1277
1280
|
description: NotRequired[str | None]
|
|
1278
1281
|
notes: NotRequired[str | None]
|
|
1282
|
+
pretrained_embedding_model_name: NotRequired[PretrainedEmbeddingModelName | None]
|
|
1283
|
+
finetuned_embedding_model_name_or_id: NotRequired[str | None]
|
|
1284
|
+
max_seq_length_override: NotRequired[int | None]
|
|
1285
|
+
label_names: NotRequired[list[str] | None]
|
|
1286
|
+
index_type: NotRequired[Literal["FLAT", "IVF_FLAT", "IVF_SQ8", "IVF_PQ", "HNSW", "DISKANN"]]
|
|
1287
|
+
index_params: NotRequired[dict[str, int | float | str]]
|
|
1288
|
+
prompt: NotRequired[str]
|
|
1289
|
+
hidden: NotRequired[bool]
|
|
1290
|
+
memory_type: NotRequired[MemoryType | None]
|
|
1279
1291
|
datasource_name_or_id: str
|
|
1280
1292
|
datasource_label_column: NotRequired[str | None]
|
|
1281
1293
|
datasource_score_column: NotRequired[str | None]
|
|
@@ -1283,6 +1295,14 @@ class CreateMemorysetRequest(TypedDict):
|
|
|
1283
1295
|
datasource_source_id_column: NotRequired[str | None]
|
|
1284
1296
|
datasource_partition_id_column: NotRequired[str | None]
|
|
1285
1297
|
remove_duplicates: NotRequired[bool]
|
|
1298
|
+
batch_size: NotRequired[int]
|
|
1299
|
+
subsample: NotRequired[int | float | None]
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
class CreateMemorysetRequest(TypedDict):
|
|
1303
|
+
name: str
|
|
1304
|
+
description: NotRequired[str | None]
|
|
1305
|
+
notes: NotRequired[str | None]
|
|
1286
1306
|
pretrained_embedding_model_name: NotRequired[PretrainedEmbeddingModelName | None]
|
|
1287
1307
|
finetuned_embedding_model_name_or_id: NotRequired[str | None]
|
|
1288
1308
|
max_seq_length_override: NotRequired[int | None]
|
|
@@ -1291,9 +1311,7 @@ class CreateMemorysetRequest(TypedDict):
|
|
|
1291
1311
|
index_params: NotRequired[dict[str, int | float | str]]
|
|
1292
1312
|
prompt: NotRequired[str]
|
|
1293
1313
|
hidden: NotRequired[bool]
|
|
1294
|
-
|
|
1295
|
-
subsample: NotRequired[int | float | None]
|
|
1296
|
-
memory_type: NotRequired[MemoryType]
|
|
1314
|
+
memory_type: NotRequired[MemoryType | None]
|
|
1297
1315
|
|
|
1298
1316
|
|
|
1299
1317
|
class CreateRegressionModelRequest(TypedDict):
|
|
@@ -1653,8 +1671,8 @@ class MemorysetMetadata(TypedDict):
|
|
|
1653
1671
|
created_at: str
|
|
1654
1672
|
updated_at: str
|
|
1655
1673
|
memories_updated_at: str
|
|
1656
|
-
insertion_job_id: str
|
|
1657
|
-
insertion_status: JobStatus
|
|
1674
|
+
insertion_job_id: str | None
|
|
1675
|
+
insertion_status: JobStatus | None
|
|
1658
1676
|
metrics: MemorysetMetrics
|
|
1659
1677
|
memory_type: MemoryType
|
|
1660
1678
|
label_names: list[str] | None
|
|
@@ -1664,7 +1682,7 @@ class MemorysetMetadata(TypedDict):
|
|
|
1664
1682
|
document_prompt_override: str | None
|
|
1665
1683
|
query_prompt_override: str | None
|
|
1666
1684
|
hidden: bool
|
|
1667
|
-
insertion_task_id: str
|
|
1685
|
+
insertion_task_id: str | None
|
|
1668
1686
|
|
|
1669
1687
|
|
|
1670
1688
|
class PaginatedWorkerInfo(TypedDict):
|
|
@@ -1678,7 +1696,7 @@ class BootstrapClassificationModelMeta(TypedDict):
|
|
|
1678
1696
|
datasource_meta: DatasourceMetadata
|
|
1679
1697
|
memoryset_meta: MemorysetMetadata
|
|
1680
1698
|
model_meta: ClassificationModelMetadata
|
|
1681
|
-
agent_output:
|
|
1699
|
+
agent_output: BootstrapLabeledMemoryDataResult
|
|
1682
1700
|
|
|
1683
1701
|
|
|
1684
1702
|
class BootstrapClassificationModelResponse(TypedDict):
|
|
@@ -1735,6 +1753,22 @@ class OrcaClient(Client):
|
|
|
1735
1753
|
) -> AliveResponse:
|
|
1736
1754
|
pass
|
|
1737
1755
|
|
|
1756
|
+
@overload
|
|
1757
|
+
def GET(
|
|
1758
|
+
self,
|
|
1759
|
+
path: Literal["/gpu/check/alive"],
|
|
1760
|
+
*,
|
|
1761
|
+
params: None = None,
|
|
1762
|
+
parse_as: Literal["json"] = "json",
|
|
1763
|
+
headers: HeaderTypes | None = None,
|
|
1764
|
+
cookies: CookieTypes | None = None,
|
|
1765
|
+
auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
1766
|
+
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
1767
|
+
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
1768
|
+
extensions: RequestExtensions | None = None,
|
|
1769
|
+
) -> AliveResponse:
|
|
1770
|
+
pass
|
|
1771
|
+
|
|
1738
1772
|
@overload
|
|
1739
1773
|
def GET(
|
|
1740
1774
|
self,
|
|
@@ -1754,7 +1788,7 @@ class OrcaClient(Client):
|
|
|
1754
1788
|
@overload
|
|
1755
1789
|
def GET(
|
|
1756
1790
|
self,
|
|
1757
|
-
path: Literal["/
|
|
1791
|
+
path: Literal["/check/healthy"],
|
|
1758
1792
|
*,
|
|
1759
1793
|
params: None = None,
|
|
1760
1794
|
parse_as: Literal["json"] = "json",
|
|
@@ -1770,7 +1804,7 @@ class OrcaClient(Client):
|
|
|
1770
1804
|
@overload
|
|
1771
1805
|
def GET(
|
|
1772
1806
|
self,
|
|
1773
|
-
path: Literal["/check/healthy"],
|
|
1807
|
+
path: Literal["/gpu/check/healthy"],
|
|
1774
1808
|
*,
|
|
1775
1809
|
params: None = None,
|
|
1776
1810
|
parse_as: Literal["json"] = "json",
|
|
@@ -2568,7 +2602,7 @@ class OrcaClient(Client):
|
|
|
2568
2602
|
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2569
2603
|
extensions: RequestExtensions | None = None,
|
|
2570
2604
|
) -> BootstrapClassificationModelResponse:
|
|
2571
|
-
"""Get the status of a bootstrap
|
|
2605
|
+
"""Get the status of a bootstrap labeled memory data job"""
|
|
2572
2606
|
pass
|
|
2573
2607
|
|
|
2574
2608
|
def GET(
|
|
@@ -2895,6 +2929,26 @@ class OrcaClient(Client):
|
|
|
2895
2929
|
path: Literal["/memoryset"],
|
|
2896
2930
|
*,
|
|
2897
2931
|
params: None = None,
|
|
2932
|
+
json: CreateMemorysetFromDatasourceRequest,
|
|
2933
|
+
data: None = None,
|
|
2934
|
+
files: None = None,
|
|
2935
|
+
content: None = None,
|
|
2936
|
+
parse_as: Literal["json"] = "json",
|
|
2937
|
+
headers: HeaderTypes | None = None,
|
|
2938
|
+
cookies: CookieTypes | None = None,
|
|
2939
|
+
auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2940
|
+
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2941
|
+
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
2942
|
+
extensions: RequestExtensions | None = None,
|
|
2943
|
+
) -> MemorysetMetadata:
|
|
2944
|
+
pass
|
|
2945
|
+
|
|
2946
|
+
@overload
|
|
2947
|
+
def POST(
|
|
2948
|
+
self,
|
|
2949
|
+
path: Literal["/memoryset/empty"],
|
|
2950
|
+
*,
|
|
2951
|
+
params: None = None,
|
|
2898
2952
|
json: CreateMemorysetRequest,
|
|
2899
2953
|
data: None = None,
|
|
2900
2954
|
files: None = None,
|
|
@@ -3290,6 +3344,32 @@ class OrcaClient(Client):
|
|
|
3290
3344
|
"""Get row count from a specific datasource with optional filtering."""
|
|
3291
3345
|
pass
|
|
3292
3346
|
|
|
3347
|
+
@overload
|
|
3348
|
+
def POST(
|
|
3349
|
+
self,
|
|
3350
|
+
path: Literal["/datasource/bootstrap_memory_data"],
|
|
3351
|
+
*,
|
|
3352
|
+
params: None = None,
|
|
3353
|
+
json: BootstrapLabeledMemoryDataInput,
|
|
3354
|
+
data: None = None,
|
|
3355
|
+
files: None = None,
|
|
3356
|
+
content: None = None,
|
|
3357
|
+
parse_as: Literal["json"] = "json",
|
|
3358
|
+
headers: HeaderTypes | None = None,
|
|
3359
|
+
cookies: CookieTypes | None = None,
|
|
3360
|
+
auth: AuthTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3361
|
+
follow_redirects: bool | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3362
|
+
timeout: TimeoutTypes | UseClientDefault = USE_CLIENT_DEFAULT,
|
|
3363
|
+
extensions: RequestExtensions | None = None,
|
|
3364
|
+
) -> BootstrapLabeledMemoryDataResult:
|
|
3365
|
+
"""
|
|
3366
|
+
Bootstrap memory data using an AI agent.
|
|
3367
|
+
|
|
3368
|
+
This endpoint uses the bootstrap labeled memory data agent to generate
|
|
3369
|
+
high-quality, diverse training examples for a classification model.
|
|
3370
|
+
"""
|
|
3371
|
+
pass
|
|
3372
|
+
|
|
3293
3373
|
@overload
|
|
3294
3374
|
def POST(
|
|
3295
3375
|
self,
|
|
@@ -3538,7 +3618,7 @@ class OrcaClient(Client):
|
|
|
3538
3618
|
"""
|
|
3539
3619
|
Bootstrap a classification model by creating a memoryset with generated memories and a classification model.
|
|
3540
3620
|
|
|
3541
|
-
This endpoint uses the
|
|
3621
|
+
This endpoint uses the bootstrap_labeled_memory_data agent to generate:
|
|
3542
3622
|
1. Memoryset configuration with appropriate settings
|
|
3543
3623
|
2. Model configuration with optimal parameters
|
|
3544
3624
|
3. High-quality training memories for each label
|
orca_sdk/embedding_model.py
CHANGED
|
@@ -26,14 +26,23 @@ if TYPE_CHECKING:
|
|
|
26
26
|
class EmbeddingModelBase(ABC):
|
|
27
27
|
embedding_dim: int
|
|
28
28
|
max_seq_length: int
|
|
29
|
+
num_params: int
|
|
29
30
|
uses_context: bool
|
|
30
31
|
supports_instructions: bool
|
|
31
32
|
|
|
32
33
|
def __init__(
|
|
33
|
-
self,
|
|
34
|
+
self,
|
|
35
|
+
*,
|
|
36
|
+
name: str,
|
|
37
|
+
embedding_dim: int,
|
|
38
|
+
max_seq_length: int,
|
|
39
|
+
num_params: int,
|
|
40
|
+
uses_context: bool,
|
|
41
|
+
supports_instructions: bool,
|
|
34
42
|
):
|
|
35
43
|
self.embedding_dim = embedding_dim
|
|
36
44
|
self.max_seq_length = max_seq_length
|
|
45
|
+
self.num_params = num_params
|
|
37
46
|
self.uses_context = uses_context
|
|
38
47
|
self.supports_instructions = supports_instructions
|
|
39
48
|
|
|
@@ -340,7 +349,6 @@ class PretrainedEmbeddingModel(EmbeddingModelBase):
|
|
|
340
349
|
- **`E5_LARGE`**: E5-Large instruction-tuned embedding model from Hugging Face ([intfloat/multilingual-e5-large-instruct](https://huggingface.co/intfloat/multilingual-e5-large-instruct))
|
|
341
350
|
- **`GIST_LARGE`**: GIST-Large embedding model from Hugging Face ([avsolatorio/GIST-large-Embedding-v0](https://huggingface.co/avsolatorio/GIST-large-Embedding-v0))
|
|
342
351
|
- **`MXBAI_LARGE`**: Mixbreas's Large embedding model from Hugging Face ([mixedbread-ai/mxbai-embed-large-v1](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1))
|
|
343
|
-
- **`QWEN2_1_5B`**: Alibaba's Qwen2-1.5B instruction-tuned embedding model from Hugging Face ([Alibaba-NLP/gte-Qwen2-1.5B-instruct](https://huggingface.co/Alibaba-NLP/gte-Qwen2-1.5B-instruct))
|
|
344
352
|
- **`BGE_BASE`**: BAAI's BGE-Base instruction-tuned embedding model from Hugging Face ([BAAI/bge-base-en-v1.5](https://huggingface.co/BAAI/bge-base-en-v1.5))
|
|
345
353
|
|
|
346
354
|
**Instruction Support:**
|
|
@@ -360,6 +368,7 @@ class PretrainedEmbeddingModel(EmbeddingModelBase):
|
|
|
360
368
|
name: Name of the pretrained embedding model
|
|
361
369
|
embedding_dim: Dimension of the embeddings that are generated by the model
|
|
362
370
|
max_seq_length: Maximum input length (in tokens not characters) that this model can process. Inputs that are longer will be truncated during the embedding process
|
|
371
|
+
num_params: Number of parameters in the model
|
|
363
372
|
uses_context: Whether the pretrained embedding model uses context
|
|
364
373
|
supports_instructions: Whether this model supports instruction-following
|
|
365
374
|
"""
|
|
@@ -373,7 +382,6 @@ class PretrainedEmbeddingModel(EmbeddingModelBase):
|
|
|
373
382
|
E5_LARGE = _ModelDescriptor("E5_LARGE")
|
|
374
383
|
GIST_LARGE = _ModelDescriptor("GIST_LARGE")
|
|
375
384
|
MXBAI_LARGE = _ModelDescriptor("MXBAI_LARGE")
|
|
376
|
-
QWEN2_1_5B = _ModelDescriptor("QWEN2_1_5B")
|
|
377
385
|
BGE_BASE = _ModelDescriptor("BGE_BASE")
|
|
378
386
|
|
|
379
387
|
name: PretrainedEmbeddingModelName
|
|
@@ -385,6 +393,7 @@ class PretrainedEmbeddingModel(EmbeddingModelBase):
|
|
|
385
393
|
name=metadata["name"],
|
|
386
394
|
embedding_dim=metadata["embedding_dim"],
|
|
387
395
|
max_seq_length=metadata["max_seq_length"],
|
|
396
|
+
num_params=metadata["num_params"],
|
|
388
397
|
uses_context=metadata["uses_context"],
|
|
389
398
|
supports_instructions=(
|
|
390
399
|
bool(metadata["supports_instructions"]) if "supports_instructions" in metadata else False
|
|
@@ -395,7 +404,7 @@ class PretrainedEmbeddingModel(EmbeddingModelBase):
|
|
|
395
404
|
return isinstance(other, PretrainedEmbeddingModel) and self.name == other.name
|
|
396
405
|
|
|
397
406
|
def __repr__(self) -> str:
|
|
398
|
-
return f"PretrainedEmbeddingModel({{name: {self.name}, embedding_dim: {self.embedding_dim}, max_seq_length: {self.max_seq_length}}})"
|
|
407
|
+
return f"PretrainedEmbeddingModel({{name: {self.name}, embedding_dim: {self.embedding_dim}, max_seq_length: {self.max_seq_length}, num_params: {self.num_params/1000000:.0f}M}})"
|
|
399
408
|
|
|
400
409
|
@classmethod
|
|
401
410
|
def all(cls) -> list[PretrainedEmbeddingModel]:
|
|
@@ -543,7 +552,7 @@ class PretrainedEmbeddingModel(EmbeddingModelBase):
|
|
|
543
552
|
elif exists and if_exists == "open":
|
|
544
553
|
existing = FinetunedEmbeddingModel.open(name)
|
|
545
554
|
|
|
546
|
-
if existing.
|
|
555
|
+
if existing.base_model.name != self.name:
|
|
547
556
|
raise ValueError(f"Finetuned embedding model '{name}' already exists, but with different base model")
|
|
548
557
|
|
|
549
558
|
return existing
|
|
@@ -598,7 +607,7 @@ class FinetunedEmbeddingModel(EmbeddingModelBase):
|
|
|
598
607
|
name: str
|
|
599
608
|
created_at: datetime
|
|
600
609
|
updated_at: datetime
|
|
601
|
-
|
|
610
|
+
base_model: PretrainedEmbeddingModel
|
|
602
611
|
_status: Status
|
|
603
612
|
|
|
604
613
|
def __init__(self, metadata: FinetunedEmbeddingModelMetadata):
|
|
@@ -607,13 +616,14 @@ class FinetunedEmbeddingModel(EmbeddingModelBase):
|
|
|
607
616
|
self.name = metadata["name"]
|
|
608
617
|
self.created_at = datetime.fromisoformat(metadata["created_at"])
|
|
609
618
|
self.updated_at = datetime.fromisoformat(metadata["updated_at"])
|
|
610
|
-
self.
|
|
619
|
+
self.base_model = PretrainedEmbeddingModel._get(metadata["base_model"])
|
|
611
620
|
self._status = Status(metadata["finetuning_status"])
|
|
612
621
|
|
|
613
622
|
super().__init__(
|
|
614
623
|
name=metadata["name"],
|
|
615
624
|
embedding_dim=metadata["embedding_dim"],
|
|
616
625
|
max_seq_length=metadata["max_seq_length"],
|
|
626
|
+
num_params=self.base_model.num_params,
|
|
617
627
|
uses_context=metadata["uses_context"],
|
|
618
628
|
supports_instructions=self.base_model.supports_instructions,
|
|
619
629
|
)
|
|
@@ -627,15 +637,10 @@ class FinetunedEmbeddingModel(EmbeddingModelBase):
|
|
|
627
637
|
f" name: {self.name},\n"
|
|
628
638
|
f" embedding_dim: {self.embedding_dim},\n"
|
|
629
639
|
f" max_seq_length: {self.max_seq_length},\n"
|
|
630
|
-
f" base_model: PretrainedEmbeddingModel.{self.
|
|
640
|
+
f" base_model: PretrainedEmbeddingModel.{self.base_model.name}\n"
|
|
631
641
|
"})"
|
|
632
642
|
)
|
|
633
643
|
|
|
634
|
-
@property
|
|
635
|
-
def base_model(self) -> PretrainedEmbeddingModel:
|
|
636
|
-
"""Pretrained model the finetuned embedding model was based on"""
|
|
637
|
-
return PretrainedEmbeddingModel._get(self.base_model_name)
|
|
638
|
-
|
|
639
644
|
@classmethod
|
|
640
645
|
def all(cls) -> list[FinetunedEmbeddingModel]:
|
|
641
646
|
"""
|
|
@@ -702,6 +707,6 @@ class FinetunedEmbeddingModel(EmbeddingModelBase):
|
|
|
702
707
|
"/finetuned_embedding_model/{name_or_id}",
|
|
703
708
|
params={"name_or_id": name_or_id},
|
|
704
709
|
)
|
|
705
|
-
except
|
|
710
|
+
except LookupError:
|
|
706
711
|
if if_not_exists == "error":
|
|
707
712
|
raise
|