검색 및 검색 작업과 채팅 워크플로에서 특히 근거가 있는 사실에 근거한 답변이 중요한 경우, 검색어와 가장 관련성이 높은 순서대로 일련의 구절을 정렬하는 것이 유용합니다.
지원되는 기초 모델
Copy link to section
watsonx.ai 에서 사용할 수 있는 리랭커 모델에 대한 자세한 내용은 지원되는 인코더 모델을 참조하십시오.
사용 가능한 재랭커 모델 목록을 얻으려면 watsonx.ai as a service API에서 사용 가능한 기초 모델 나열 메서드를 사용할 수 있습니다. 사용 가능한 리랭커 모델만 반환하려면 ' filters=function_rerank 매개변수를 지정하세요.
예를 들어,
curl -X GET \
'https://{region}.ml.cloud.ibm.com/ml/v1/foundation_model_specs?version=2024-10-18&filters=function_rerank'
Copy to clipboard클립보드에 복사됨
참고: 많은 임베딩 모델이 순위 재조정 기능을 지원한다고 표시하고 있습니다. 그러나 임베딩 모델은 정확도가 떨어지는 랭킹 방식인 시맨틱 리랭킹을 지원합니다. 임베딩 모델은 구절의 순위를 재조정할 때 임베딩 벡터 값에서 파생된 유사성 점수를 기준으로 순위를 매깁니다. 교차 인코더 모델은 각 구절을 쿼리와 명시적으로 비교하고 페어링당 순위 점수를 생성하기 때문에 순위를 재조정하는 데 더 효과적입니다.
다음 다이어그램에 표시된 것처럼, watsonx.ai API의 리랭커 방법은 쿼리와 문서 구절 목록이 포함된 REST API 요청을 받아들입니다. API는 이러한 텍스트 문자열을 재랭킹 모델에 제출합니다. 리랭커 모델은 쿼리를 각 구절과 차례로 연결하고, 텍스트를 임베딩 벡터로 변환한 다음, 각 쌍의 벡터를 비교하고 서로의 유사성을 점수로 매깁니다. 그런 다음, 모델은 생성된 유사성 점수에 따라 구절의 순위를 다시 매깁니다. 이 모델은 텍스트를 텍스트 임베딩으로 변환하지만, 임베딩은 반환되지 않습니다. 텍스트 임베딩은 유사성 점수를 생성하는 데 사용되며, 점수만 반환됩니다.
이 예의 코드는 ' ms-marco-minilm-l-12-v2 모델을 사용하여 다음 텍스트 구절의 순위를 다시 지정하여 쿼리에 대한 답변 가능성이 가장 높은 정보가 있는 구절이 먼저 나열되도록 합니다.
query
상담원 중심 AI 워크플로란 무엇인가요?
단락
입력 구절은 watsonx.ai 용어집의 정의입니다:
항목 0. foundation model 다양한 다운스트림 작업에 적용할 수 있는 대규모 생성 AI 모델입니다.
항목 1. 생성형 AI는 텍스트, 소스 코드, 이미지, 오디오, 합성 데이터 등 다양한 유형의 콘텐츠를 제작할 수 있는 AI 알고리즘의 한 종류입니다.
항목 2. 에이전트 AI는 프롬프트를 여러 작업으로 분해하여 적절한 에이전트 AI 에이전트에 작업을 할당하고 사람의 개입 없이 답변을 합성할 수 있는 생성형 AI 흐름입니다.
항목 3. AI 윤리는 AI의 유익한 영향을 최적화하는 동시에 위험과 부정적인 결과를 줄이는 방법을 연구하는 다학제적 분야입니다. AI 윤리 이슈의 예로는 데이터 책임 및 개인정보 보호, 공정성, 설명 가능성, 견고성, 투명성, 환경 지속 가능성, 포용성, 도덕적 기관, 가치 정렬, 책임성, 신뢰, 기술 오용 등이 있습니다.
항목 4. AI 거버넌스는 조직의 지침, 직원, 프로세스 및 시스템을 통해 AI 수명 주기 전반에 걸쳐 AI 시스템을 지시, 평가, 모니터링 및 시정 조치를 취하여 조직이 의도한 대로, 이해관계자가 기대하는 대로, 관련 규정에서 요구하는 대로 운영되고 있음을 보장하기 위한 조직의 관리 행위입니다.
REST API 요청 예
Copy link to section
이 예에서는 순위 재지정을 위해 5개의 구절만 제출되었습니다. 최대 1,000개의 입력을 지정할 수 있습니다. 그러나 지정하는 구절이 많을수록 교차 인코더 모델이 각 구절을 쿼리와 함께 차례로 처리하기 때문에 재랭크 프로세스가 더 오래 걸립니다.
제출하는 각 입력은 재랭커 모델에 정의된 최대 입력 토큰 한도를 준수해야 합니다.
구절에 모델에서 허용하는 것보다 많은 토큰이 있을 수 있는 경우를 해결하기 위해 이 예에서는 ' truncate_input_tokens 매개변수를 지정하여 줄을 강제로 잘라내도록 했습니다. 그렇지 않으면 요청이 실패할 수 있습니다.
이 예제에는 ' inputs 반환 옵션 매개변수가 포함되어 있어 원본 구절의 텍스트가 응답에 포함되므로 원본 구절의 순위가 어떻게 재조정되는지 더 쉽게 이해할 수 있습니다. 실제 워크플로에서는 ' inputs 매개변수를 포함할 필요가 없을 수도 있습니다.
텍스트 리랭커 메서드의 페이로드에 ' model_id '로 사용할 리랭커 모델을 지정합니다.
다음 예제에서{url}variable with the right value for your instance, such asus-south.ml.cloud.ibm.com 대체합니다. 고유한 무기명 토큰과 프로젝트 ID를 추가합니다.
curl -X POST \
'https://{url}/ml/v1/text/rerank?version=2024-10-17' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJraWQiOi...' \
--data '{
"inputs": [
{
"text": "A foundation model is a large-scale generative AI model that can be adapted to a wide range of downstream tasks."
},
{
"text": "Generative AI is a class of AI algorithms that can produce various types of content including text, source code, imagery, audio, and synthetic data."
},
{
"text": "Agentic AI is a generative AI flow that can decompose a prompt into multiple tasks, assign tasks to appropriate gen AI agents, and synthesize an answer without human intervention."
},
{
"text": "AI ethics is a multidisciplinary field that studies how to optimize AI'\''s beneficial impact while reducing risks and adverse outcomes. Examples of AI ethics issues are data responsibility and privacy, fairness, explainability, robustness, transparency, environmental sustainability, inclusion, moral agency, value alignment, accountability, trust, and technology misuse."
},
{
"text": "AI governance is an organization'\''s act of governing, through its corporate instructions, staff, processes and systems to direct, evaluate, monitor, and take corrective action throughout the AI lifecycle, to provide assurance that the AI system is operating as the organization intends, as its stakeholders expect, and as required by relevant regulation."
}
],
"query": "What is an agent-driven AI workflow?",
"parameters":{
"truncate_input_tokens": 512,
"return_options":{
"inputs":true
}
},
"model_id": "cross-encoder/ms-marco-minilm-l-12-v2",
"project_id": "51f3a990-4372-4ac3-9ddb-ed99d9b50840"
}'
Copy to clipboard클립보드에 복사됨Show more
가장 높은 순위의 구절만 반환하려면 ' top_n 매개변수를 지정하면 됩니다. 다음 샘플은 모델에서 쿼리와 가장 관련성이 높은 한 구절만 반환하도록 지정하는 방법을 보여 줍니다:
{"model_id":"cross-encoder/ms-marco-minilm-l-12-v2","created_at":"2024-10-17T14:01:47.322Z","results":[{"index":2,"score":5.063366413116455,"input":{"text":"Agentic AI is a generative AI flow that can decompose a prompt into multiple tasks, assign tasks to appropriate gen AI agents, and synthesize an answer without human intervention."}},{"index":4,"score":-0.992393970489502,"input":{"text":"AI governance is an organization's act of governing, through its corporate instructions, staff, processes and systems to direct, evaluate, monitor, and take corrective action throughout the AI lifecycle, to provide assurance that the AI system is operating as the organization intends, as its stakeholders expect, and as required by relevant regulation."}},{"index":1,"score":-3.5372314453125,"input":{"text":"Generative AI is a class of AI algorithms that can produce various types of content including text, source code, imagery, audio, and synthetic data."}},{"index":0,"score":-4.646212100982666,"input":{"text":"A foundation model is a large-scale generative AI model that can be adapted to a wide range of downstream tasks."}},{"index":3,"score":-4.926990032196045,"input":{"text":"AI ethics is a multidisciplinary field that studies how to optimize AI's beneficial impact while reducing risks and adverse outcomes. Examples of AI ethics issues are data responsibility and privacy, fairness, explainability, robustness, transparency, environmental sustainability, inclusion, moral agency, value alignment, accountability, trust, and technology misuse."}}],"input_token_count":292,"system":{"warnings":[{"message":"This model is a Non-IBM Product governed by a third-party license that may impose use restrictions and other obligations. By using this model you agree to its terms as identified in the following URL.","id":"disclaimer_warning","more_info":"https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html?context=wx"}]}}
Copy to clipboard클립보드에 복사됨Show more
이전 샘플과 같이 매개변수 객체에 ' "top_n": 1 '을 포함하면 응답은 다음과 같이 표시됩니다:
{"model_id":"cross-encoder/ms-marco-minilm-l-12-v2","created_at":"2024-10-17T20:18:50.867Z","results":[{"index":2,"score":5.063366413116455,"input":{"text":"Agentic AI is a generative AI flow that can decompose a prompt into multiple tasks, assign tasks to appropriate gen AI agents, and synthesize an answer without human intervention."}}],"input_token_count":292,"system":{"warnings":[{"message":"This model is a Non-IBM Product governed by a third-party license that may impose use restrictions and other obligations. By using this model you agree to its terms as identified in the following URL.","id":"disclaimer_warning","more_info":"https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html?context=wx"}]}}
Copy to clipboard클립보드에 복사됨Show more
대금 청구 정보
Copy link to section
청구는 사용 중인 리랭커 모델에 의해 처리된 토큰 수를 기준으로 합니다. 단어당 사용되는 토큰 수는 모델에 따라 다릅니다.