Skip to content

LLMブループリント

LLMブループリントは、生成AIアプリケーションで大規模言語モデルをどのように設定し、使用するかを定義します。 DataRobotが提供する事前設定済みのLLMを使用するか、独自のデプロイからカスタムモデルLLMを作成できます。 LLMブループリントを使用すると、システムプロンプト、Temperature設定、およびアプリケーションでのLLMの動作を制御するその他のパラメーターを設定できます。

利用可能なLLMのリスト

利用可能なすべてのLLMを表示するには、datarobot.LLMDefinition.list()を使用します。

import datarobot as dr
llms = dr.genai.LLMDefinition.list()
for llm in llms:
    print(f"{llm.name}: {llm.description}")
    print(f"  Vendor: {llm.vendor}")
    print(f"  Context size: {llm.context_size}")
    print(f"  Active: {llm.is_active}") 

ユースケースでLLMをフィルターすることもできます。

use_case = dr.UseCase.get(use_case_id)
llms = dr.genai.LLMDefinition.list(use_case=use_case) 

プレイグラウンドの作成

LLMブループリントを作成するにはプレイグラウンドが必要です。 プレイグラウンドは、さまざまなLLM設定を試行できるワークスペースです。 プレイグラウンドを作成する際は、以下を指定する必要があります。

  • name:プレイグラウンドのわかりやすい名前。
  • description:プレイグラウンドの目的の任意の説明。
  • use_case:プレイグラウンドをリンクさせるユースケース。
  • playground_type:プレイグラウンドのタイプ。デフォルトはdr.enums.PlaygroundType.RAGです。
import datarobot as dr
playground = dr.genai.Playground.create(
    name="My GenAI Playground",
    use_case=use_case.id
)
playground 

ユースケース内にプレイグラウンドを作成することもできます。

use_case = dr.UseCase.get(use_case_id)
playground = dr.genai.Playground.create(
    name="Use Case Playground",
    use_case=use_case.id
) 

LLMブループリントの作成

カスタム設定を使用して新しいLLMブループリントを作成します。 LLMブループリントを作成する際は、以下を指定する必要があります。

  • playground:ブループリントに関連付けるプレイグラウンドIDまたはPlaygroundオブジェクト。
  • name:LLMブループリントのわかりやすい名前。
  • llm:使用するLLM定義IDまたはLLMDefinitionオブジェクト。
  • llm_settings:システムプロンプト、Temperature、最大出力長などのLLM構成設定を含むディクショナリ。
  • description:ブループリントの任意の説明。
  • prompt_type:プロンプティング戦略。デフォルトはdr.enums.PromptType.CHAT_HISTORY_AWAREです。
import datarobot as dr
llms = dr.genai.LLMDefinition.list()
gpt4 = [llm for llm in llms if 'gpt-4' in llm.name.lower()][0]
playground = dr.genai.Playground.create(name="Customer Support Playground")
blueprint = dr.genai.LLMBlueprint.create(
    playground=playground.id,
    name="Customer Support Assistant",
    description="LLM for customer support queries",
    llm=gpt4.id,
    llm_settings={
        "system_prompt": "You are a helpful customer support assistant. Be concise and professional.",
        "temperature": 0.7,
        "max_completion_length": 500
    }
)
blueprint 

LLMブループリントの取得とリスト

datarobot.LLMBlueprint.get()およびdatarobot.LLMBlueprint.list()を使用して、特定のブループリントを取得するか、利用可能なすべてのブループリントをリストします。

特定のブループリントを取得するには:

blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
blueprint 

すべてのブループリントをリストするには:

all_blueprints = dr.genai.LLMBlueprint.list()
print(f"Found {len(all_blueprints)} LLM blueprint(s):")
for bp in all_blueprints:
    print(f"  - {bp.name} (ID: {bp.id})") 

プレイグラウンドでブループリントをフィルターするには:

playground_blueprints = dr.genai.LLMBlueprint.list(playground=playground.id) 

LLMタイプでフィルターするには:

gpt_blueprints = dr.genai.LLMBlueprint.list(llms=[gpt4.id]) 

LLMブループリントの更新

datarobot.LLMBlueprint.update()を使用してブループリント設定を変更します。

blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
blueprint.update(
    name="Updated Customer Support Assistant",
    llm_settings={
        "system_prompt": "You are an expert customer support assistant.",
        "temperature": 0.5
    }
) 

設定をロックするためにブループリントを保存します。

blueprint.update(is_saved=True) 

簡単にアクセスできるようにブループリントにスターを付けます。

blueprint.update(is_starred=True) 

既存のブループリントからブループリントを作成する

datarobot.LLMBlueprint.create_from_llm_blueprint()を使用して、バリエーションを試すために既存のブループリントのコピーを作成します。

original_blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
new_blueprint = dr.genai.LLMBlueprint.create_from_llm_blueprint(
    llm_blueprint=original_blueprint,
    name="Experimental Variant",
    description="Testing different temperature settings"
)
new_blueprint