Tune language foundation model (Generative AI)

Tune language foundation models with a tuning dataset.

Code sample

Node.js

Before trying this sample, follow the Node.js setup instructions in the Vertex AI quickstart using client libraries. For more information, see the Vertex AI Node.js API reference documentation.

To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */
// const project = 'YOUR_PROJECT_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const model = 'text-bison@001';
const aiplatform = require('@google-cloud/aiplatform');

const {ModelServiceClient} = aiplatform.v1;
const clientOptions = {
  apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

// Instantiate the service client.
const modelServiceClient = new ModelServiceClient(clientOptions);

async function listTunedModels() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}`;
  const filter = `labels.google-vertex-llm-tuning-base-model-id=${model}`;

  const request = {
    parent,
    filter,
  };

  const [response] = await modelServiceClient.listModels(request);
  console.log('List Tuned Models response');
  for (const model of response) {
    console.log(`\tModel name: ${model.name}`);
    console.log(`\tDisplay name: ${model.displayName}`);
  }
}
await listTunedModels();

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.