임베딩 모델의 제공자 설정

  • 릴리스 버전: Zurich
  • 업데이트 날짜 2025년 07월 31일
  • 소요 시간: 8분
  • 임베딩 모델이 (RAG) 애플리케이션에서 작동할 수 있도록 사용할 AI 제공자를 AI 검색 검색 증강 생성 결정합니다.

    시작하기 전에

    기본 제공 업체에 대한 연결 및 자격 증명 별칭을 구성합니다. 자세한 내용은 Create a Connection & Credential alias 문서를 참조하십시오.

    필요한 역할: 관리자

    프로시저

    1. 다음으로 이동 모두를 클릭한 다음 필터에 sys_one_extend_capability.list 를 입력하여 OneExtend 기능 테이블로 이동합니다.
    2. BYOL(Bring Your Own Embedding Model) 역량을 선택합니다.
    3. OneExtend 역량 정의 관련 목록에서 새로 만들기를 선택합니다.
    4. 이름 필드에 역량 정의의 이름을 입력합니다.
      예를 들어 임베딩 생성(Azure OpenAI)입니다.
    5. API 유형 필드에서 시스템을 선택합니다.
    6. API 필드에서 검색 아이콘( 목록을 사용하여 문서 조회. )을 선택하여 문서를 선택합니다.
      1. 테이블 이름 필드에서 OneAPI System Executor [one_api_system_executor] 테이블을 선택합니다.
      2. 문서 필드에서 Generic Embedder를 선택합니다.
      3. 확인을 선택합니다.
    7. 연결 및 자격 증명 별칭 필드에서 사용자 지정 포함 모델과 통합할 별칭을 선택합니다.
    8. 고급 옵션을 선택합니다.
    9. 전처리 및 후처리 스크립트를 만듭니다.
      애플리케이션이 포함 모델과 원활하게 작동하도록 하려면 AI 검색 RAG 전처리 및 후처리 스크립트를 만들어야 합니다. 이러한 스크립트는 애플리케이션이 모델이 예상하고 생성하는 데이터의 형식을 이해하는 데 도움이 됩니다 AI 검색 RAG .
      다음 예시에서는 요청 구조에 대한 Azure OpenAI 전처리기 스크립트를 보여줍니다.
      (function(inputs) {                                                               //// inputs is the capability inputs which contains request.
                  /* write code here to transform capability input to definition input.            
                   *{
      		"request": {                                                                  //request contains rawInput which will be system-provided.
      			"rawInput": {                                                          //rawInput contains passages(Array of text segments), type(Context of the input) and modelId(Name of the embedding model)
      				"passages": ["Sample text"],
      				"type": "ingest/query",
      				"model": "text-embedding-3-large"
      			},
      			"providerInput": {                                                     //providerInput should be populated using the relevant data from rawInput.passages.
      				"input": ["Sample text"]                                        //The field name "input" inside providerInput is provider-specific and rawInput.passages should be mapped to the appropriate field expected by your provider
      			}
      		}
      	  }
      	 try {
              var parsedInputs = JSON.parse(inputs);
              var request = parsedInputs.request;
              var rawInput = request.rawInput;
              var passagesArray = rawInput.passages;
              var type = rawInput.type;
      
              if (passagesArray && passagesArray.length > 0) {
                  parsedInputs.request.providerInput = {};
                  parsedInputs.request.providerInput.input = passagesArray;
              }
      
          } catch (ex) {
              gs.error("Exception occured while preprocessing of the inputs." + ex);
              throw new Error("Exception occured while OE preprocessing of the inputs : " + ex);
          }
      
          inputs = parsedInputs;
          return inputs;
      })(inputs);
      	 
      다음 예는 요청 구조에 대한 Azure OpenAI 응답 후처리기 스크립트를 보여줍니다.
      (function(outputs) {
          /* write code here to transform definition output to capability output.
      	* outputs contains result from the provider definition implementation.
      	* Expected outputs format from provider definition implementation in success scenario:
      	   "result": {
      			"provider": "custom_embedding_model",
      			"logId": "0ee6f4f4ff112210b6e1ffffffffff03",
      			"status": "success",
      			"response": {"object":"list","data":[{"object":"embedding","index":0,"embedding":[0.008695375,0.0011188902]},{"object":"embedding","index":1,"embedding":[0.012572239,0.017366657]}],"model":"text-embedding-3-large","usage":{"prompt_tokens":4,"total_tokens":4}}
      	    }
      	* Expected outputs format from provider definition implementation in error scenario:
      	   "result": {
      			"responseHeaders": "[Content-Length: 224\r\n, Content-Type: application/json\r\n, apim-request-id: 72b1519e-a367-4f01-b249-8f37d35d50d3\r\n, Date: Thu, 01 May 2025 12:03:44 GMT\r\n]",
      			"responseBody": "{\"error\":{\"code\":\"401\",\"message\":\"Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.\"}}",
      			"provider": "custom_embedding_model",
      			"errorCode": "401",
      			"logId": "0ee6f4f4ff112210b6e1ffffffffff03",
      			"error": "PermissionDenied",
      			"status": "error"
      	   }
      	* Extract the embeddings from the response key of the provider result (in a successful scenario) and elevate it in the final output. Sample format for the same:
      	  "result": {
      			"provider": "custom_embedding_model",
      			"logId": "0ee6f4f4ff112210b6e1ffffffffff03",
      			"status": "success",
      			"response": {"object":"list","data":[{"object":"embedding","index":0,"embedding":[0.008695375,0.0011188902]},{"object":"embedding","index":1,"embedding":[0.012572239,0.017366657]}],"model":"text-embedding-3-large","usage":{"prompt_tokens":4,"total_tokens":4}}
      			"embeddings": [[0.008695375,0.0011188902], [0.012572239,0.017366657]]
      	   }
      	*/
          try {
              outputs = JSON.parse(outputs);
              var embeddingsArray = [];
      
              if (!gs.nil(outputs.result) && !gs.nil(outputs.result.response)) {
                  var responseBody = outputs.result.response;
                  if (!gs.nil(responseBody)) {
                      var data = JSON.parse(responseBody).data;
                      for (var i = 0; i < data.length; i++) {
                          var embeddingResponse = data[i];
                          if (!gs.nil(embeddingResponse) && !gs.nil(embeddingResponse.embedding))
                              embeddingsArray.push(embeddingResponse.embedding);
                      }
                  }
      
                  outputs.result.embeddings = embeddingsArray;
              }
          } catch (ex) {
              gs.error("Exception occured while OE postprocessing of the outputs = " + ex);
              outputs.result.status = "error";
              outputs.result.error = gs.getMessage("Exception occured while OE postprocessing of the outputs : " + ex);
          }
      
          return outputs;
      })(outputs);
    10. 제출을 선택합니다.