1 of 22

UNIT 5

  • Open-Source Models and Programming Frameworks: Training and Fine tuning of Generative models,
  • GPT 4 All,
  • Transfer learning and Pretrained models,
  • Training vision models,
  • Google Copilot,
  • Programming LLM,
  • Lang Chain,
  • Open-Source Models,
  • Llama,
  • Programming for Times former,
  • Deployment,
  • Hugging Face.

2 of 22

Training and Fine tuning of Generative models

  • Generative AI is a branch of Artificial Intelligence that creates new content, such as text, images, music, videos, and computer code.

​

  • Training is the process of teaching a model to learn patterns from data.

​

  • Fine-tuning is the process of adapting a pre-trained model to a specific task using additional, task-related data.

​

Examples: Generative models include GPT, GANs, Variational Autoencoders (VAEs), and Diffusion Models.

3 of 22

Training of Generative Models

​

Training enables a generative model to learn the structure and distribution of the training data.

Steps involved:

  1. Data Collection: Gather large datasets containing text, images, audio, or other data.
  2. Data Preprocessing: Clean the data, remove unwanted information, and convert it into a suitable format.
  3. Model Selection: Select an architecture such as a Transformer, GAN, VAE, or Diffusion Model.
  4. Forward Propagation: Pass the training data through the model to obtain predictions.
  5. Loss Calculation: Measure the difference between predicted and expected outputs using a suitable loss function.
  6. Backpropagation: Calculate gradients to determine how model parameters should change.
  7. Optimization: Update model weights using optimizers such as Adam or SGD.
  8. Evaluation: Evaluate the model on validation data to check its performance.

4 of 22

Fine-Tuning of Generative Models

​

Fine-tuning improves a pre-trained model's performance on a particular task or domain without training the entire model from scratch.

​

Steps involved:

  1. Select a Pre-trained Model: Choose a model such as GPT or Stable Diffusion.
  2. Prepare Specific Data: Collect task-related examples, such as medical text or images of a particular style.
  3. Configure Parameters: Decide whether to update all model parameters or only selected parameters.
  4. Fine-Tune the Model: Continue training on the new dataset, often using a smaller learning rate.
  5. Evaluate Results: Test the fine-tuned model on unseen examples.
  6. Deploy the Model: Use it for the required application.

5 of 22

6 of 22

Definition

​

  • GPT4All is an open-source ecosystem that allows users to run Large Language Models (LLMs) locally on their computers. It is used to generate text, answer questions, summarize documents, and perform other natural language processing tasks without always depending on cloud-based AI services.

GPT4All in Generative AI

7 of 22

Working of GPT4All

​

  1. Input: The user enters a question or prompt.
  2. Tokenization: The input text is converted into tokens.
  3. Model loading: A compatible pre-trained language model is loaded onto the local computer.
  4. Inference: The model processes the input and predicts the next token repeatedly.
  5. Text generation: The predicted tokens form a meaningful response.
  6. Output: The generated answer is displayed to the user.

8 of 22

9 of 22

Transfer Learning and Pretrained Models

Transfer Learning

​

Definition: Transfer learning is a technique in which a generative AI model uses knowledge learned from a large dataset and adapts it to a new, related task.

Instead of training a model from the beginning, we reuse an existing model and fine-tune it for a specific purpose.

​

Example: A pretrained image-generation model can be fine-tuned to generate traditional Indian paintings or medical images.

10 of 22

Pretrained Models

​

Definition: A pretrained model is a model that has already been trained on a large dataset and has learned useful patterns, features, or representations.

These models can be reused directly or adapted for specific applications.

​

Examples include:

​

  • GPT :text generation and conversation.
  • BERT: text understanding and classification.
  • Stable Diffusion :image generation from text prompts.
  • ResNet : image recognition.
  • T5: summarization, translation, and text generation.

11 of 22

Types of Transfer Learning

​

  1. Feature Extraction: Use the pretrained model to extract useful features while keeping its learned weights fixed.
  2. Fine-Tuning: Retrain some or all pretrained model layers using a new dataset.
  3. Domain Adaptation: Adapt a model trained in one domain to work effectively in another domain.

12 of 22

13 of 22

Introduction

​

Training vision models in Generative AI is the process of teaching generative AI models to understand, analyze, and generate visual content such as images, paintings, and realistic scenes from training data.

​

Vision models learn patterns such as shapes, colors, textures, objects, and spatial relationships from images. After training, they can generate new images, modify existing images, or create images from text descriptions.

​

Examples: DALL·E, Stable Diffusion, Midjourney, and Vision Transformer (ViT).

Training vision models

14 of 22

Training process in detail

​

  1. Dataset preparation: Collect a large set of images and, for text-to-image training, their corresponding captions.
  2. Preprocessing: Resize images to a consistent resolution, normalize pixel values, and optionally apply data augmentation.
  3. Model initialization: Choose a suitable architecture and initialize its parameters, or start from a pretrained model.
  4. Forward pass: Feed the training images, captions, or noise into the model.
  5. Loss calculation: Measure the difference between the model's prediction and the training target.
  6. Backpropagation: Calculate gradients and update model parameters using an optimizer such as Adam.
  7. Validation: Evaluate image quality, diversity, and alignment with the text prompts.
  8. Fine-tuning and deployment: Adjust the model using specialized data and use it to generate new images.

15 of 22

16 of 22

Google Copilot

Google Gemini is a Generative AI system developed by Google. It uses advanced Large Language Models (LLMs) to understand user prompts and generate human-like text, images, code, summaries, and other content.

​

Gemini is a multimodal AI system, meaning it can work with different types of information, such as text, images, audio, and video, depending on the model and application.

17 of 22

18 of 22

  • A Programming Large Language Model (LLM) is a generative AI model trained on large amounts of source code, programming examples, and technical documentation.
  • It can generate, explain, complete, debug, and optimize code in different programming languages.

​

Examples: OpenAI Codex, Code Llama, and Google Gemini with code-generation capabilities.

Programming LLM

19 of 22

20 of 22

  • Lang Chain is an open-source framework used to develop applications powered by Large Language Models (LLMs).
  • It connects LLMs with external data sources, databases, APIs, memory, and tools to build intelligent AI applications.

​

Examples of applications include AI chatbots, document question-answering systems, virtual assistants, and Retrieval-Augmented Generation (RAG) systems.

Lang Chain

21 of 22

Working steps:

​

  1. The user enters a question or instruction.
  2. Lang Chain formats the input using a prompt template.
  3. It sends the prompt to an LLM and can retrieve relevant external information.
  4. The LLM generates a response using the provided context.
  5. Lang Chain returns the response to the application.

22 of 22