如何通过 python 脚本为现有服务设置默认的 LLM_RAG_CRACK_AND_CHUNK_AND_EMBED 设置?

问题描述 投票:0回答:1

我看到这里有一个默认设置。如何为我现有的服务进行设置?有人能指出正确的教程/模板吗?我有以下代码:

from msrest import Configuration
from azure.identity import DefaultAzureCredential


# create configuration for LLM_RAG_CRACK_AND_CHUNK_AND_EMBED
conf = Configuration("azureml://registries/azureml/components/llm_rag_crack_and_chunk_and_embed/labels/default")
endpoint = "https://xyz.search.windows.net"
credential = DefaultAzureCredential()
# how do I proceed?
python azure azure-cognitive-services azure-sdk-python
1个回答
0
投票

使用下面的代码在您的管道中实现 LLM_RAG_CRACK_AND_CHUNK_AND_EMBED

from azure.ai.ml import MLClient, Input, Output
from azure.ai.ml.dsl import pipeline

ml_client_registry = MLClient(credential=DefaultAzureCredential(), registry_name="azureml")
chunk_data = ml_client_registry.components.get("LLM_RAG_CRACK_AND_CHUNK_AND_EMBED")

@pipeline()
def pipeline_with_registered_components(input, chunk):
    train_job = chunk_data(
        input_data=input,
        chunk_size=chunk
    )
    train_job.outputs['embeddings'] = Output(type="uri_folder", path="****/chunk_pdf/")

pipeline_job = pipeline_with_registered_components(
    input=Input(type="uri_folder", path="****/pdf/"),
    chunk=256
)
pipeline_job.settings.default_compute = "jgs-cluster"
print(pipeline_job)

执行:

pipeline_job = ml_client.jobs.create_or_update(
    pipeline_job, experiment_name="pipeline_samples"
)
pipeline_job

上面的代码只是一个例子。请参阅 Azure ML 注册表中的组件定义并传递嵌入模型、嵌入容器和所有必需的参数。

请参阅 this GitHub 代码,了解有关构建管道的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.