Foundation Models

Sonam Tripathi
13 min readJun 9, 2024

--

“Foundation models: where data meets intuition, and innovation finds its starting point”.

As correctly quoted by Joanna Maciejewska:

“ I want AI to do my laundry and dishes so that I can do art and writing, not for AI to do my art and writing so that I can do my laundry and dishes.”

Quick Navigation:-

  1. Background
  2. What are foundation Models.
  3. How Foundation Models are trained ?
  4. Types of Foundation Models
  5. Application of Foundation Models
  6. Attacks in Foundation Models
  7. Challenges and Ethical Considerations involved in Foundation Models

1) Background

1.1. Task specific Machine learning Model

Traditionally, machine learning models required extensive human effort to annotate and label training data, limiting their scalability and adaptability to new tasks. These approaches relied heavily on handcrafted features and required domain-specific knowledge for feature engineering. To overcome this limitation techniques like unsupervised and self-supervised learning were explored, which enable models to learn from raw, unlabeled data.

1.2. Deep Learning Era

The advent of deep learning, particularly with the rise of neural networks, revolutionised the field of NLP. Deep learning models, such as recurrent neural networks (RNNs) and convolutional neural networks (CNNs), showed remarkable performance improvements over traditional machine learning approaches. RNNs, in particular, became popular for sequence modeling tasks, such as language modeling and machine translation, due to their ability to capture sequential dependencies in data.

However, RNNs suffered from limitations such as vanishing gradients and difficulty in capturing long-range dependencies, especially in long sequences of text.

1.3. Development and Evolution of Foundation Models

The development of foundation models represents a paradigm shift in machine learning, enabling the creation of more efficient, scalable, and adaptable AI systems capable of performing a diverse array of tasks across different domains. The rise of foundation models can be traced back to the transformative impact of transformer architectures and the Attention mechanism in the field of natural language processing (NLP).

The key innovation of transformers is the self-attention mechanism which is a fundamental component of the Transformer architecture, which has revolutionised natural language processing and has been adapted for vision tasks. Self-attention enables the model to weigh the importance of different elements within a sequence, allowing it to capture complex dependencies and relationships.

The transformer architecture has since become the foundation for a new generation of NLP models, including BERT (Bidirectional Encoder Representations from Transformers), GPT (Generative Pre-trained Transformer), and many others.

These transformer-based models like LLMs, Vision transformers have achieved state-of-the-art performance on a wide range of NLP tasks and Computer Vision task, including language understanding, Language and Image generation, language translation, text summarisation, and more.

2) What are Foundation Models?

Foundation models are large-scale models trained on broad range of datasets using self-supervised learning methods (where the model learns to generate its own labels or predictions from the input data) with broad objectives, such as language modeling or image recognition, Text Summarization, Image Captioning. These models are not task-specific; instead, they are designed to learn general patterns and representations from the data. Once trained, they serve as a foundational layer that can be adapted for specific tasks through fine-tuning or additional training.

Overview of Foundation Models

Foundation models employ self-supervised learning techniques to derive labels directly from input data, eliminating the need for explicitly annotated training datasets. Using self-supervised learning and transfer learning, the model can apply information it’s learnt about one situation to another. This characteristic distinguishes LLMs from earlier ML architectures, which predominantly rely on supervised learning methods.

3) How Foundation Models are trained?

Training foundation models, such as large language models (LLMs) and vision models, involves a series of stages that include data preparation, model design, training, and evaluation. The below flow chart will give a brief idea of the Lifecycle of training to deploying the foundation model.

Lifecycle of Foundation Models (Image by Author)

It starts with the data collection from various sources, such as books, articles, websites, and other text repositories. In case of Images, data sources like ImageNet, COCO, and custom image datasets are used for training the Vision Models.

These datasets are typically diverse and cover a wide range of topics and domains. The data then undergoes cleaning and preprocessing steps like:

  • For Text Data: Remove duplicates, handle missing values, normalize text (lowercasing, tokenisation).
  • For Image Data: Resize images, normalize pixel values, and apply data augmentation techniques like cropping, flipping, and rotation to increase variability.

Post all the cleaning and data preprocessing the next step is choose the Model architecture design:-

  • LLMs: In case of use-cases specific to languages, LLMs are typically used which are based on the Transformer architecture, introduced in the paper “Attention is All You Need” by Vaswani et al. (2017). The Transformer model uses self-attention mechanisms to weigh the significance of different words in a sentence, enabling it to understand context more effectively than previous models like RNNs and LSTMs.
  • Vision Models: Use Convolutional Neural Networks (CNNs) or Vision Transformers (ViTs).

Training the model on a large corpus of text/images in an self-supervised manner using objectives like for language modeling predicting the next word in a sequence or masked language modeling (predicting masked words in a sentence).

After pretraining, foundation models can be fine-tuned on specific downstream tasks by further training on task-specific datasets with labeled examples. During fine-tuning, the parameters of the pretrained model are adjusted to optimize performance on the target task, such as text classification, language generation, or question-answering. Fine-tuning allows the model to adapt its learned representations to the specifics of the target task, improving performance and generalization.

Convert the trained model to a deployable format. Deploy the model on chosen platforms (cloud services, edge devices). Create APIs and endpoints to allow users to interact with the model. Continuously monitor the model’s performance in production environments. Collect user feedback and performance data to identify areas for improvement. Periodically retrain or fine-tune the model with new data to maintain its relevance and performance.

4) Types of Foundation Models

There are different types in Foundation Models each characterised by distinct traits and uses. Here are several noteworthy types:

Types of Foundation Model

Large Language Models: Among the most prominent foundation models are language models like OpenAI’s GPT series. Trained on vast text corpora, they possess the ability to comprehend and generate human-like language.

Source:- Language Model

These models excel in tasks such as machine translation, summarization, and question-answering.

Vision Models: Vision models are specifically designed to understand and process visual information, such as images and videos. These models are trained on large datasets of visual data and learn to extract meaningful features and patterns from the images they analyze.

Vision models can be used for a wide range of tasks, including Image Classification, Object Detection, Image Segmentation, Image Generation.

Example include DeiT (Data-efficient Image Transformers), BEiT (BERT pre-training of Image Transformers),DINO (a method for self-supervised training of Vision Transformers).

Example of Vision Transformer Model Based White Blood Cells Classification and Localization

Multimodal Models: Multimodal foundation models process and generate information from multiple modalities, such as text, images, audio, or video. These models integrate capabilities from different types of models, such as language models and vision models, allowing them to understand and generate content that combines information from different sources. Examples include models like CLIP, DALL·E

Source:- CLIP Model

Domain-Specific Models: Tailored to specific industries like healthcare, finance, or law, domain-specific foundation models are pre-trained on data pertinent to these fields. Consequently, they possess the ability to comprehend and generate language relevant to their respective domains. These models serve as a foundational tool for developers and researchers operating within specialised domains.

5) Applications Across Different Domains

Foundation models have revolutionised various domains, demonstrating remarkable versatility and capability:

1.Natural Language Processing (NLP): Tasks such as sentiment analysis, machine translation, summarisation, and question answering have seen significant improvements with foundation models.

2. Computer Vision: Models like Stable Diffusion and DALL-E showcase the application of foundation models in image recognition and generation, pushing the boundaries of what is possible in computer vision.

3. Healthcare: Foundation models are being leveraged for drug discovery, medical imaging, and understanding genetic data, offering potential breakthroughs in medical research and diagnostics.

Use-cases of Foundation Model in Healthcare

4. Finance: They assist in risk assessment, fraud detection, Algorithmic Trading, Customer Service and Personalisation, Credit Scoring,Market Sentiment Analysis, Portfolio Management enhancing efficiency and accuracy in financial services.

5. Entertainment: Foundation models power recommendation systems, content generation, and interactive AI in video games, creating more personalised and engaging user experiences.

6. Education:- Foundation models hold tremendous potential to transform education by enhancing personalised learning experiences, enabling innovative teaching practices, Assisting Educators and advancing educational research and development.

Use-case of Foundation Model in Education

6) Attacks in Foundation Models

Foundation models possess immense capabilities, however, they are not immune to vulnerabilities and potential attacks. Here’s an exploration of some vulnerabilities and attacks associated with foundation models:

Attacks in Foundation Models

i) Data Poisoning/Backdoor Attacks

Data poisoning/Backdoor Attack refers to the act of tampering with training data to introduce biases or mislead the model, potentially resulting in erroneous predictions. This could result in the model learning incorrect patterns or making biased decisions, leading to compromised performance or unethical outcomes.

Data Poison/Backdoor Attack

This attacks involve maliciously modifying a model during training to introduce a hidden trigger or pattern that, when present in the input data during inference, causes the model to produce a specific, often undesirable, output. Backdoor attacks can compromise the integrity and reliability of the model, leading to intentional misclassification or other harmful behavior.

Example: Injecting misleading information into the training data, such as biased or false statements, can skew the model’s understanding of the data distribution.

Poison GPT

In an experimental setup named PoisonGPT, researchers demonstrated the manipulation of GPT-J-6B, a Large Language Model, using the Rank-One Model Editing (ROME) algorithm.

ii) Adversarial Attacks

Adversarial attacks involve making small, imperceptible perturbations to input data with the goal of causing the model to produce incorrect outputs. Adversarial attacks can lead to model vulnerabilities, where even minor modifications to input data can result in significant changes in output predictions.

In adversarial attacks, attackers attempt to perturb a data point 𝑥 to an adversarial data point 𝑥 ′ so that 𝑥 ′ is misclassified by an ML model with high confidence, although 𝑥 ′ is visually indistinguishable from its original data point 𝑥 by humans.

An example of 𝐿∞-norm-based FGSM(fast gradient sign method) attacks using a perturbation magnitude 𝜖 = 3. Left: a base image (classified as a cat correctly by an inception v3 network [11]). Center: an adversarial image generated by the FGSM attacks (mislabeled as a bookcase with high confidence of 99.83%). Right: an (amplified) adversarial noise.

Example: Adding imperceptible noise to an input text to cause the model to misclassify it or generate unintended outputs.

iii) Jailbreaking

Jailbreaking refers to attempting to modify or bypass the restrictions imposed on the model’s behavior, typically to gain unauthorised access to its functionalities or to alter its operation in unintended ways. This concept draws an analogy from the term “jailbreaking” commonly used in the context of mobile devices, where users attempt to remove software restrictions imposed by the manufacturer or operating system to gain more control over the device.

Jailbreak Prompt

iv) Model Inversion

Model inversion attacks attempt to reconstruct sensitive information from the model’s outputs, often by exploiting the model’s generative capabilities. If successful, this could lead to the leakage of sensitive information contained within the model’s learned representations.

Model Inversion

Example: Using the model to generate plausible outputs based on its internal representations and then inferring sensitive information from those outputs.

v) Membership Inference

A membership inference attack is a type of privacy attack aimed at determining whether a particular data sample was part of the training dataset used to train a machine learning model. This attack exploits the vulnerabilities inherent in the model’s behavior to infer sensitive information about the training data.

The attacker first obtains access to the target machine learning model, usually through its public API or by deploying a similar model locally. The attacker then queries the target model with a set of input samples, which could be either data points of interest or randomly chosen inputs. By observing the responses from the model, such as the predicted labels or confidence scores, the attacker tries to discern whether the queried samples were part of the model’s training data.

Membership Inference Attack

Based on the model’s responses, the attacker makes a binary inference for each queried sample, determining whether it was a member of the training dataset or not. If the attacker successfully determines membership for a significant number of queried samples, it indicates that the model leaks information about its training data, potentially compromising the privacy of individuals whose data was used for training.

Example: Leveraging the model’s predictions on a given sample to infer whether that sample was present in the model’s training dataset.

Membership inference attacks can have serious implications, particularly in sensitive domains where privacy is paramount, such as healthcare or finance. Successful attacks can reveal sensitive information about individuals in the training dataset, leading to privacy violations and breaches of confidentiality.

vi) Model Stealing

Model stealing attacks involve attempting to recreate or replicate a proprietary model by querying it and using the responses to train a similar model. This can lead to intellectual property theft and loss of competitive advantage for the original model’s creators. Model stealing attacks also referred to as model extraction attacks, can be categorized into two groups: attacks that exploit hardware access and attacks that leverage API query access.

API based Model stealing Attack

In an API-based model stealing attack, the attacker sends queries to the victim model through its prediction API, then he uses the predictions received to create a labeled dataset. The attacker then trains a new model, called the Adversary Model, on that dataset. This model represents the stolen model from the victim.

Example: Querying the model with various inputs and using the responses to train a surrogate model that closely mimics the behavior of the original model.

7) Challenges and Ethical Considerations involved in Foundation Models

Foundation models, while groundbreaking, present several significant challenges and ethical considerations that must be addressed to ensure their responsible and effective use.

a) Challenges

1. Resource Intensiveness

i) High Computational Costs: Training foundation models requires substantial computational resources, often involving extensive use of GPUs or TPUs. This makes the training process expensive and accessible only to well-funded organisations.

ii) Environmental Impact: The energy consumption associated with training large models contributes to a significant carbon footprint, raising concerns about the environmental sustainability of these technologies.

2. Scalability and Maintenance

i) Model Size: Managing and deploying models with billions of parameters is complex. These large models require significant storage and memory, which can be a barrier for widespread adoption.

ii) Continuous Updating: As new data becomes available and as the context changes, foundation models need to be regularly updated to maintain their relevance and accuracy, which is a resource-intensive process.

3. Interpretability and Explainability

i) Black Box Nature: Foundation models, due to their complexity, often operate as “black boxes.” Understanding the reasoning behind their predictions can be challenging, which is problematic in critical applications where explainability is essential.

ii) Trust and Accountability: The lack of transparency can undermine user trust and makes it difficult to hold these models accountable for their decisions.

4. Security and Privacy

Foundation models may be susceptible to various security threats including adversarial attacks, data breaches, and model stealing as discussed above. Protecting sensitive data and ensuring user privacy are paramount concerns, particularly in applications involving personal or confidential information.

b) Ethical Considerations

1) Bias and Fairness

i) Propagation of Biases: Foundation models can learn and propagate biases present in the training data, leading to unfair or discriminatory outcomes. This is particularly concerning in sensitive applications such as hiring, law enforcement, and lending.

ii) Mitigation Efforts: Addressing biases requires careful curation of training data and the development of techniques to detect and mitigate bias in models. Ongoing research and vigilance are necessary to ensure fairness.

2) Privacy and Data Security

i) Data Handling: The vast datasets used for training these models often include personal and sensitive information, raising concerns about privacy and data security.

ii) Model Inference: The way models infer and generate data can sometimes inadvertently expose sensitive information, necessitating robust measures to protect privacy.

3) Ethical Use and Misuse

i) Dual-Use Concerns: Foundation models can be used for both beneficial and harmful purposes. For instance, while they can enhance automated customer service, they can also generate convincing deepfakes or misinformation.

ii) Regulation and Governance: Establishing ethical guidelines and regulatory frameworks is crucial to ensure that these models are used responsibly. This includes setting standards for accountability, transparency, and ethical use.

4) Accessibility and Inequality

i) Digital Divide: The high resource requirements for developing and deploying foundation models can exacerbate existing inequalities, limiting access to these advanced technologies to well-funded organisations and countries.

ii) Democratization of AI: Efforts to democratize AI, such as open-sourcing models and making computational resources more accessible, are essential to mitigate this issue and promote equitable access to AI advancements.

Conclusion

Addressing the ethical concerns associated with foundation models requires a multifaceted approach involving technical, organisational, and societal measures. By implementing strategies for bias mitigation, privacy protection, transparency, ethical governance, inclusivity, and sustainability, we can ensure that the development and deployment of foundation models contribute positively to society while mitigating potential risks. Through ongoing research, collaboration, and commitment to ethical principles, the AI community can navigate the challenges and harness the full potential of foundation models responsibly.

References:

  1. What are Foundation Models.
  2. Masked Language Models
  3. ML Attack Models: Adversarial Attacks and Data Poisoning Attacks
  4. Data Poisoning
  5. Model Stealing Attack
  6. Transformer Model
  7. CLIP Model
  8. Vision Transformer
  9. Jailbreaking

--

--

Sonam Tripathi

Sr. Associate Manager @Lilly | Researcher | Full-time Learner