Skip to main content
  1. Data Science Blog/

Model Tuning with VertexAI

·739 words·4 mins· loading · ·
AI Hardware & Infrastructure AI/ML Models Cloud Computing GCP Cloud Google AI Platform Machine Learning (ML) AI Model Optimization Cloud AI Services MLOps

On This Page

Table of Contents
Share with :

Model Tuning with VertexAI

Tuning Large Language Model with VertexAI
#

Why Model Tuning?
#

Tuning is required when you want the model to learn something niche or specific that deviates from general language patterns.

Goal of Tuning
#

Classification
#

prompt: “Classify the following text into one of the following classes: [business, entertainment].”

Summarization
#

prompt: “Summarize: Jessica: That sounds great! See you in Times Square! Alexander: See you at 10!”

response: “#Person1 and #Person2 agree to meet at Times Square at 10:00 AM.”

Extract QA
#

prompt: “Context: There is evidence that there have been significant changes in Amazon rainforest vegetation over the last 21,000 years through the Last Glacial Maximum (LGM) and subsequent deglaciation. Question: What does LGM stand for?”

response: “Last Glacial Maximum”

Prepare your model tuning dataset
#

Recommended configurations#

The following table shows the recommended configurations for tuning a foundation model by task:

TaskNo. of examples in datasetTrain steps
Classification100+100-500
Summarization100-500+200-1000
Extractive QA100+100-500

For train steps, you can try more than one value to get the best performance on a particular dataset, for example, 100, 200, 500.

Dataset format
#

You can create your own dataset for training. Your dataset must be in JSON Lines (JSONL) format where each line contains a single training example. Content of JSONL file will be like below.

{“input_text”: “question: How many copies of Gears of War 3 were sold ? context: Like its predecessors , the game received widespread critical acclaim from critics . Critics praised its story , voice acting , graphics and visuals , and music , but criticized its lack of innovation . Gears of War 3 sold over 3 million copies and was the second best selling game in the U . S . “, “output_text”: “over 3 million copies”} {“input_text”: “question: How many parishes are there in Louisiana ? context: The U . S . state of Louisiana is divided into 64 parishes ( French : paroisses ) in the same manner that 48 other states of the United States are divided into counties , and Alaska is divided into boroughs . “, “output_text”: “64”}

Creating Dataset
#

Prepare model tuning dataset (train dataset) Maintain consistency with test and production data (same format).

For example, if the examples in your dataset includes a “question:” and a “context:”, production traffic should also be formatted to include a “question:” and a “context:” in the same order as it appears in the dataset examples. If you exclude the context, the model will be confused as to what you are asking, even if the exact question was in an example in the dataset.

Include instructions in examples.
Classify the following text into one of the following classes: [business, entertainment] Text: 5 stocks to buy now

Upload tuning dataset to Cloud Storage (Optional)
#

For the demo use following example. Otherwise bring your dataset in the format below. cloud-samples-data/ai-platform/generative_ai/headline_classification.jsonl

Tuning with VertexAI
#

  • VertexAI -> Language -> Create Tune Model
  • Select the tuning dataset (either from google cloud storage or cloud-samples-data/ai-platform/generative_ai/headline_classification.jsonl)
    • The above dataset contains 25 categorical question answering examples. If you use the sample dataset, the training will take 1-2 hours.
  • Configure the model details & Tune
    • Model name: Enter a name for your tuned model.
    • Base model: Select the foundation model that you want to tune.
    • Train steps: Enter the number of steps to run for model tuning. 1000 steps will take 2-3 hours to complete tuning.
    • Learning rate: Control the step size at which a model updates its weights during training. Default: 3.
    • Working directory: Enter the URI of the bucket to store the tuned model. If don’t have one, you can create a new bucket.

After tuning
#

  • To check the status of your model tuning job, go to the Pipelines page. The status of your pipeline can be found in the Runs section.
  • To view your tuned models in the Google Cloud console, go to the Vertex AI Model Registry page.

Use the tuned model
#

  • To use your tuned models with new prompts, go to the Language page.
  • Click Text prompt.
  • In the Model drop down, select the tuned model that you have created.
  • Copy the sample prompt and submit to view the results.
Multi-choice problem: What is the topic of this text?
- business
- entertainment
- health
- sports
- technology
- politics
Text: What is a large language model (LLM)?
The answer is:
Dr. Hari Thapliyaal's avatar

Dr. Hari Thapliyaal

Dr. Hari Thapliyal is a seasoned professional and prolific blogger with a multifaceted background that spans the realms of Data Science, Project Management, and Advait-Vedanta Philosophy. Holding a Doctorate in AI/NLP from SSBM (Geneva, Switzerland), Hari has earned Master's degrees in Computers, Business Management, Data Science, and Economics, reflecting his dedication to continuous learning and a diverse skill set. With over three decades of experience in management and leadership, Hari has proven expertise in training, consulting, and coaching within the technology sector. His extensive 16+ years in all phases of software product development are complemented by a decade-long focus on course design, training, coaching, and consulting in Project Management. In the dynamic field of Data Science, Hari stands out with more than three years of hands-on experience in software development, training course development, training, and mentoring professionals. His areas of specialization include Data Science, AI, Computer Vision, NLP, complex machine learning algorithms, statistical modeling, pattern identification, and extraction of valuable insights. Hari's professional journey showcases his diverse experience in planning and executing multiple types of projects. He excels in driving stakeholders to identify and resolve business problems, consistently delivering excellent results. Beyond the professional sphere, Hari finds solace in long meditation, often seeking secluded places or immersing himself in the embrace of nature.

Comments:

Share with :

Related

What is a Digital Twin?
·805 words·4 mins· loading
Industry Applications Technology Trends & Future Computer Vision (CV) Digital Twin Internet of Things (IoT) Manufacturing Technology Artificial Intelligence (AI) Graphics
What is a digital twin? # A digital twin is a virtual representation of a real-world entity or …
Frequencies in Time and Space: Understanding Nyquist Theorem & its Applications
·4103 words·20 mins· loading
Data Analysis & Visualization Computer Vision (CV) Mathematics Signal Processing Space Exploration Statistics
Applications of Nyquists theorem # Can the Nyquist-Shannon sampling theorem applies to light …
The Real Story of Nyquist, Shannon, and the Science of Sampling
·1146 words·6 mins· loading
Technology Trends & Future Interdisciplinary Topics Signal Processing Remove Statistics Technology Concepts
The Story of Nyquist, Shannon, and the Science of Sampling # In the early days of the 20th century, …
BitNet b1.58-2B4T: Revolutionary Binary Neural Network for Efficient AI
·2637 words·13 mins· loading
AI/ML Models Artificial Intelligence (AI) AI Hardware & Infrastructure Neural Network Architectures AI Model Optimization Language Models (LLMs) Business Concepts Data Privacy Remove
Archive Paper Link BitNet b1.58-2B4T: The Future of Efficient AI Processing # A History of 1 bit …
Ollama Setup and Running Models
·1753 words·9 mins· loading
AI and NLP Ollama Models Ollama Large Language Models Local Models Cost Effective AI Models
Ollama: Running Large Language Models Locally # The landscape of Artificial Intelligence (AI) and …