3.9. 推論エンドポイント


これらの例は、推論エンドポイントを使用してモデルをクエリーする方法を示しています。

注記

モデルのデプロイ時にトークン認可を有効にした場合は、Authorization ヘッダーを追加してトークン値を指定する必要があります。

3.9.1. Caikit TGIS ServingRuntime for KServe

  • :443/api/v1/task/text-generation
  • :443/api/v1/task/server-streaming-text-generation

コマンドの例

curl --json '{"model_id": "<model_name__>", "inputs": "<text>"}' https://<inference_endpoint_url>:443/api/v1/task/server-streaming-text-generation -H 'Authorization: Bearer <token>'

3.9.2. Caikit Standalone ServingRuntime for KServe

複数のモデルを提供している場合は、/info/models または :443 caikit.runtime.info.InfoService/GetModelsInfo をクエリーして、提供されているモデルのリストを表示できます。

REST エンドポイント

  • /api/v1/task/embedding
  • /api/v1/task/embedding-tasks
  • /api/v1/task/sentence-similarity
  • /api/v1/task/sentence-similarity-tasks
  • /api/v1/task/rerank
  • /api/v1/task/rerank-tasks
  • /info/models
  • /info/version
  • /info/runtime

gRPC エンドポイント

  • :443 caikit.runtime.Nlp.NlpService/EmbeddingTaskPredict
  • :443 caikit.runtime.Nlp.NlpService/EmbeddingTasksPredict
  • :443 caikit.runtime.Nlp.NlpService/SentenceSimilarityTaskPredict
  • :443 caikit.runtime.Nlp.NlpService/SentenceSimilarityTasksPredict
  • :443 caikit.runtime.Nlp.NlpService/RerankTaskPredict
  • :443 caikit.runtime.Nlp.NlpService/RerankTasksPredict
  • :443 caikit.runtime.info.InfoService/GetModelsInfo
  • :443 caikit.runtime.info.InfoService/GetRuntimeInfo
注記

デフォルトでは、Caikit Standalone ランタイムは REST エンドポイントを公開します。gRPC プロトコルを使用するには、カスタム Caikit Standalone ServingRuntime を手動でデプロイします。詳細は、シングルモデルサービングプラットフォーム用のカスタムモデルサービングランタイムの追加 を参照してください。

サンプルのマニフェストは caikit-tgis-serving GitHub リポジトリー で入手できます。

REST

curl -H 'Content-Type: application/json' -d '{"inputs": "<text>", "model_id": "<model_id>"}' <inference_endpoint_url>/api/v1/task/embedding -H 'Authorization: Bearer <token>'

gRPC

grpcurl -d '{"text": "<text>"}' -H \"mm-model-id: <model_id>\" <inference_endpoint_url>:443 caikit.runtime.Nlp.NlpService/EmbeddingTaskPredict -H 'Authorization: Bearer <token>'

3.9.3. TGIS Standalone ServingRuntime for KServe

  • :443 fmaas.GenerationService/Generate
  • :443 fmaas.GenerationService/GenerateStream

    注記

    TGIS スタンドアロンランタイムのエンドポイントをクエリーするには、OpenShift AI text-generation-inference リポジトリーの proto ディレクトリーにあるファイルもダウンロードする必要があります。

コマンドの例

grpcurl -proto text-generation-inference/proto/generation.proto -d '{"requests": [{"text":"<text>"}]}' -H 'Authorization: Bearer <token>' -insecure <inference_endpoint_url>:443 fmaas.GenerationService/Generate

3.9.4. OpenVINO Model Server

  • /v2/models/<model-name>/infer

コマンドの例

curl -ks <inference_endpoint_url>/v2/models/<model_name>/infer -d '{ "model_name": "<model_name>", "inputs": [{ "name": "<name_of_model_input>", "shape": [<shape>], "datatype": "<data_type>", "data": [<data>] }]}' -H 'Authorization: Bearer <token>'

3.9.5. vLLM ServingRuntime for KServe

  • :443/version
  • :443/docs
  • :443/v1/models
  • :443/v1/chat/completions
  • :443/v1/completions
  • :443/v1/embeddings
  • :443/tokenize
  • :443/detokenize

    注記
    • vLLM ランタイムは OpenAI REST API と互換性があります。vLLM ランタイムがサポートするモデルのリストは、サポートされるモデル を参照してください。
    • vLLM で embeddings 推論エンドポイントを使用するには、vLLM でサポートされている embeddings モデルを使用する必要があります。生成モデルでは embeddings エンドポイントは使用できません。詳細は、vLLM でサポートされている embeddings モデル を参照してください。
    • vLLM v0.5.5 以降では、/v1/chat/completions エンドポイントを使用してモデルをクエリーするときに、チャットテンプレートを提供する必要があります。モデルに定義済みのチャットテンプレートが含まれていない場合は、例に示すように、chat-template コマンドラインパラメーターを使用して、カスタム vLLM ランタイムでチャットテンプレートを指定できます。<CHAT_TEMPLATE> をテンプレートのパスに置き換えます。

      containers:
        - args:
            - --chat-template=<CHAT_TEMPLATE>

      ここで .jinja ファイルとして利用できるチャットテンプレート、または /apps/data/template の下の vLLM イメージを使用できます。詳細は、チャットテンプレート を参照してください。

    上記のパスで示されているように、シングルモデルサービングプラットフォームは、OpenShift ルーターの HTTPS ポート (通常はポート 443) を使用して、外部 API リクエストを処理します。

コマンドの例

curl -v https://<inference_endpoint_url>:443/v1/chat/completions -H "Content-Type: application/json" -d '{ "messages": [{ "role": "<role>", "content": "<content>" }] -H 'Authorization: Bearer <token>'

3.9.6. vLLM ServingRuntime with Gaudi accelerators support for KServe

vLLM ServingRuntime for KServe を参照してください。

3.9.7. vLLM ROCm ServingRuntime for KServe

vLLM ServingRuntime for KServe を参照してください。

3.9.8. NVIDIA Triton Inference Server

REST エンドポイント

  • v2/models/[/versions/<model_version>]/infer
  • v2/models/<model_name>[/versions/<model_version>]
  • v2/health/ready
  • v2/health/live
  • v2/models/<model_name>[/versions/]/ready
  • v2
注記

ModelMesh は次の REST エンドポイントをサポートしていません。

  • v2/health/live
  • v2/health/ready
  • v2/models/<model_name>[/versions/]/ready

コマンドの例

curl -ks <inference_endpoint_url>/v2/models/<model_name>/infer -d '{ "model_name": "<model_name>", "inputs": [{ "name": "<name_of_model_input>", "shape": [<shape>], "datatype": "<data_type>", "data": [<data>] }]}' -H 'Authorization: Bearer <token>'

gRPC エンドポイント

  • :443 inference.GRPCInferenceService/ModelInfer
  • :443 inference.GRPCInferenceService/ModelReady
  • :443 inference.GRPCInferenceService/ModelMetadata
  • :443 inference.GRPCInferenceService/ServerReady
  • :443 inference.GRPCInferenceService/ServerLive
  • :443 inference.GRPCInferenceService/ServerMetadata

コマンドの例

grpcurl -cacert ./openshift_ca_istio_knative.crt -proto ./grpc_predict_v2.proto -d @ -H "Authorization: Bearer <token>" <inference_endpoint_url>:443 inference.GRPCInferenceService/ModelMetadata

3.9.9. 関連情報

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.