0 / 0
Zurück zur englischen Version der Dokumentation
Informationen zu verfügbaren Basismodellen programmgesteuert abrufen
Letzte Aktualisierung: 03. Feb. 2025
Informationen zu verfügbaren Basismodellen programmgesteuert abrufen

Hier erfahren Sie, welche Basismodelle zur Verwendung in IBM watsonx.aiverfügbar sind.

Die watsonx.ai Python-Bibliothek verfügt über eine Hilfsklasse für die Referenzierung der Modell-IDs und -namen. Weitere Informationen finden Sie unter TextModels.

Der folgende Code verwendet die Hilfsklasse TextModels, um die Modell-IDs der verfügbaren Modelle aufzulisten.

Python -Code

from ibm_watsonx_ai import APIClient
from ibm_watsonx_ai import Credentials

credentials = Credentials(
                   url = "https://{region}.ml.cloud.ibm.com",
                   api_key = {my-IBM-Cloud-API-key},
                  )

api_client = APIClient(credentials)

api_client.foundation_models.TextModels.show()

Beispielausgabe

{'GRANITE_13B_CHAT_V2': 'ibm/granite-13b-chat-v2',
'GRANITE_13B_INSTRUCT_V2': 'ibm/granite-13b-instruct-v2',
...
}

 

Beispiel: Ansicht der Details eines foundation model

Sie können Details wie eine kurze Beschreibung und die Grenzen des foundation model anzeigen, indem Sie " get_details() verwenden.

Python -Code

from ibm_watsonx_ai.foundation_models import ModelInference
import json
model_id    = api_client.foundation_models.TextModels.FLAN_T5_XXL
project_id  = {my-project-ID}

model = ModelInference(model_id=model_id, project_id=project_id, api_client=api_client)
model_details = model.get_details()

print( json.dumps( model_details, indent=2 ) )
Hinweis:

Ersetzen Sie {region}, {my-IBM-Cloud-API-key}und {my-project-ID} durch gültige Werte für Ihre Umgebung.

Beispielausgabe

{
  "model_id": "google/flan-t5-xxl",
  "label": "flan-t5-xxl-11b",
  "provider": "Google",
  "source": "Hugging Face",
  "short_description": "flan-t5-xxl is an 11 billion parameter model based on the Flan-T5 family.",
  ...
}

Das folgende Codebeispiel verwendet die ID eines foundation model, um Modelldetails anzuzeigen.

import json

model_id = api_client.foundation_models.TextModels.FLAN_T5_XXL
model_details = api_client.foundation_models.get_model_specs(model_id)

print( json.dumps( model_details, indent=2 ) )

Sie können model_id in Inferenzanfragen wie folgt angeben:

model = ModelInference(
  model_id="google/flan-ul2",...
  )

Übergeordnetes Thema: Python -Bibliothek