LogoLogo
Continuum WebsiteContinuum ApplicationsContinuum KnowledgeAxolotl Platform
Continuum Knowledge
Continuum Knowledge
  • Continuum
  • Data
    • Datasets
      • Pre Training Data
      • Types of Fine Tuning
      • Self Instruct Paper
      • Self-Alignment with Instruction Backtranslation
      • Systematic Evaluation of Instruction-Tuned Large Language Models on Open Datasets
      • Instruction Tuning
      • Instruction Fine Tuning - Alpagasus
      • Less is More For Alignment
      • Enhanced Supervised Fine Tuning
      • Visualising Data using t-SNE
      • UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction
      • Training and Evaluation Datasets
      • What is perplexity?
  • MODELS
    • Foundation Models
      • The leaderboard
      • Foundation Models
      • LLama 2 - Analysis
      • Analysis of Llama 3
      • Llama 3.1 series
      • Google Gemini 1.5
      • Platypus: Quick, Cheap, and Powerful Refinement of LLMs
      • Mixtral of Experts
      • Mixture-of-Agents (MoA)
      • Phi 1.5
        • Refining the Art of AI Training: A Deep Dive into Phi 1.5's Innovative Approach
      • Phi 2.0
      • Phi-3 Technical Report
  • Training
    • The Fine Tuning Process
      • Why fine tune?
        • Does Fine-Tuning LLMs on New Knowledge Encourage Hallucinations?
        • Explanations in Fine Tuning
      • Tokenization
        • Tokenization Is More Than Compression
        • Tokenization - SentencePiece
        • Tokenization explore
        • Tokenizer Choice For LLM Training: Negligible or Crucial?
        • Getting the most out of your tokenizer for pre-training and domain adaptation
        • TokenMonster
      • Parameter Efficient Fine Tuning
        • P-Tuning
          • The Power of Scale for Parameter-Efficient Prompt Tuning
        • Prefix-Tuning: Optimizing Continuous Prompts for Generation
        • Harnessing the Power of PEFT: A Smarter Approach to Fine-tuning Pre-trained Models
        • What is Low-Rank Adaptation (LoRA) - explained by the inventor
        • Low Rank Adaptation (Lora)
        • Practical Tips for Fine-tuning LMs Using LoRA (Low-Rank Adaptation)
        • QLORA: Efficient Finetuning of Quantized LLMs
        • Bits and Bytes
        • The Magic behind Qlora
        • Practical Guide to LoRA: Tips and Tricks for Effective Model Adaptation
        • The quantization constant
        • QLORA: Efficient Finetuning of Quantized Language Models
        • QLORA and Fine-Tuning of Quantized Language Models (LMs)
        • ReLoRA: High-Rank Training Through Low-Rank Updates
        • SLoRA: Federated Parameter Efficient Fine-Tuning of Language Models
        • GaLora: Memory-Efficient LLM Training by Gradient Low-Rank Projection
      • Hyperparameters
        • Batch Size
        • Padding Tokens
        • Mixed precision training
        • FP8 Formats for Deep Learning
        • Floating Point Numbers
        • Batch Size and Model loss
        • Batch Normalisation
        • Rethinking Learning Rate Tuning in the Era of Language Models
        • Sample Packing
        • Gradient accumulation
        • A process for choosing the learning rate
        • Learning Rate Scheduler
        • Checkpoints
        • A Survey on Efficient Training of Transformers
        • Sequence Length Warmup
        • Understanding Training vs. Evaluation Data Splits
        • Cross-entropy loss
        • Weight Decay
        • Optimiser
        • Caching
      • Training Processes
        • Extending the context window
        • PyTorch Fully Sharded Data Parallel (FSDP)
        • Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
        • YaRN: Efficient Context Window Extension of Large Language Models
        • Sliding Window Attention
        • LongRoPE
        • Reinforcement Learning
        • An introduction to reinforcement learning
        • Reinforcement Learning from Human Feedback (RLHF)
        • Direct Preference Optimization: Your Language Model is Secretly a Reward Model
  • INFERENCE
    • Why is inference important?
      • Grouped Query Attention
      • Key Value Cache
      • Flash Attention
      • Flash Attention 2
      • StreamingLLM
      • Paged Attention and vLLM
      • TensorRT-LLM
      • Torchscript
      • NVIDIA L40S GPU
      • Triton Inference Server - Introduction
      • Triton Inference Server
      • FiDO: Fusion-in-Decoder optimised for stronger performance and faster inference
      • Is PUE a useful measure of data centre performance?
      • SLORA
  • KNOWLEDGE
    • Vector Databases
      • A Comprehensive Survey on Vector Databases
      • Vector database management systems: Fundamental concepts, use-cases, and current challenges
      • Using the Output Embedding to Improve Language Models
      • Decoding Sentence-BERT
      • ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT
      • SimCSE: Simple Contrastive Learning of Sentence Embeddings
      • Questions Are All You Need to Train a Dense Passage Retriever
      • Improving Text Embeddings with Large Language Models
      • Massive Text Embedding Benchmark
      • RocketQAv2: A Joint Training Method for Dense Passage Retrieval and Passage Re-ranking
      • LLM2Vec: Large Language Models Are Secretly Powerful Text Encoders
      • Embedding and Fine-Tuning in Neural Language Models
      • Embedding Model Construction
      • Demystifying Embedding Spaces using Large Language Models
      • Fine-Tuning Llama for Multi-Stage Text Retrieval
      • Large Language Model Based Text Augmentation Enhanced Personality Detection Model
      • One Embedder, Any Task: Instruction-Finetuned Text Embeddings
      • Vector Databases are not the only solution
      • Knowledge Graphs
        • Harnessing Knowledge Graphs to Elevate AI: A Technical Exploration
        • Unifying Large Language Models and Knowledge Graphs: A Roadmap
      • Approximate Nearest Neighbor (ANN)
      • High Dimensional Data
      • Principal Component Analysis (PCA)
      • Vector Similarity Search - HNSW
      • FAISS (Facebook AI Similarity Search)
      • Unsupervised Dense Retrievers
    • Retrieval Augmented Generation
      • Retrieval-Augmented Generation for Large Language Models: A Survey
      • Fine-Tuning or Retrieval?
      • Revolutionising Information Retrieval: The Power of RAG in Language Models
      • A Survey on Retrieval-Augmented Text Generation
      • REALM: Retrieval-Augmented Language Model Pre-Training
      • Retrieve Anything To Augment Large Language Models
      • Generate Rather Than Retrieve: Large Language Models Are Strong Context Generators
      • Active Retrieval Augmented Generation
      • DSPy: LM Assertions: Enhancing Language Model Pipelines with Computational Constraints
      • DSPy: Compiling Declarative Language Model Calls
      • DSPy: In-Context Learning for Extreme Multi-Label Classification
      • Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs
      • HYDE: Revolutionising Search with Hypothetical Document Embeddings
      • Enhancing Recommender Systems with Large Language Model Reasoning Graphs
      • Retrieval Augmented Generation (RAG) versus fine tuning
      • RAFT: Adapting Language Model to Domain Specific RAG
      • Summarisation Methods and RAG
      • Lessons Learned on LLM RAG Solutions
      • Stanford: Retrieval Augmented Language Models
      • Overview of RAG Approaches with Vector Databases
      • Mastering Chunking in Retrieval-Augmented Generation (RAG) Systems
    • Semantic Routing
    • Resource Description Framework (RDF)
  • AGENTS
    • What is agency?
      • Rephrase and Respond: Let Large Language Models Ask Better Questions for Themselves
      • Types of Agents
      • The risk of AI agency
      • Understanding Personality in Large Language Models: A New Frontier in AI Psychology
      • AI Agents - Reasoning, Planning, and Tool Calling
      • Personality and Brand
      • Agent Interaction via APIs
      • Bridging Minds and Machines: The Legacy of Newell, Shaw, and Simon
      • A Survey on Language Model based Autonomous Agents
      • Large Language Models as Agents
      • AI Reasoning: A Deep Dive into Chain-of-Thought Prompting
      • Enhancing AI Reasoning with Self-Taught Reasoner (STaR)
      • Exploring the Frontier of AI: The "Tree of Thoughts" Framework
      • Toolformer: Revolutionising Language Models with API Integration - An Analysis
      • TaskMatrix.AI: Bridging Foundational AI Models with Specialised Systems for Enhanced Task Completion
      • Unleashing the Power of LLMs in API Integration: The Rise of Gorilla
      • Andrew Ng's presentation on AI agents
      • Making AI accessible with Andrej Karpathy and Stephanie Zhan
  • Regulation and Ethics
    • Regulation and Ethics
      • Privacy
      • Detecting AI Generated content
      • Navigating the IP Maze in AI: The Convergence of Blockchain, Web 3.0, and LLMs
      • Adverse Reactions to generative AI
      • Navigating the Ethical Minefield: The Challenge of Security in Large Language Models
      • Navigating the Uncharted Waters: The Risks of Autonomous AI in Military Decision-Making
  • DISRUPTION
    • Data Architecture
      • What is a data pipeline?
      • What is Reverse ETL?
      • Unstructured Data and Generatve AI
      • Resource Description Framework (RDF)
      • Integrating generative AI with the Semantic Web
    • Search
      • BM25 - Search Engine Ranking Function
      • BERT as a reranking engine
      • BERT and Google
      • Generative Engine Optimisation (GEO)
      • Billion-scale similarity search with GPUs
      • FOLLOWIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions
      • Neural Collaborative Filtering
      • Federated Neural Collaborative Filtering
      • Latent Space versus Embedding Space
      • Improving Text Embeddings with Large Language Models
    • Recommendation Engines
      • On Interpretation and Measurement of Soft Attributes for Recommendation
      • A Survey on Large Language Models for Recommendation
      • Model driven recommendation systems
      • Recommender AI Agent: Integrating Large Language Models for Interactive Recommendations
      • Foundation Models for Recommender Systems
      • Exploring the Impact of Large Language Models on Recommender Systems: An Extensive Review
      • AI driven recommendations - harming autonomy?
    • Logging
      • A Taxonomy of Anomalies in Log Data
      • Deeplog
      • LogBERT: Log Anomaly Detection via BERT
      • Experience Report: Deep Learning-based System Log Analysis for Anomaly Detection
      • Log-based Anomaly Detection with Deep Learning: How Far Are We?
      • Deep Learning for Anomaly Detection in Log Data: A Survey
      • LogGPT
      • Adaptive Semantic Gate Networks (ASGNet) for log-based anomaly diagnosis
  • Infrastructure
    • The modern data centre
      • Enhancing Data Centre Efficiency: Strategies to Improve PUE
      • TCO of NVIDIA GPUs and falling barriers to entry
      • Maximising GPU Utilisation with Kubernetes and NVIDIA GPU Operator
      • Data Centres
      • Liquid Cooling
    • Servers and Chips
      • The NVIDIA H100 GPU
      • NVIDIA H100 NVL
      • Lambda Hyperplane 8-H100
      • NVIDIA DGX Servers
      • NVIDIA DGX-2
      • NVIDIA DGX H-100 System
      • NVLink Switch
      • Tensor Cores
      • NVIDIA Grace Hopper Superchip
      • NVIDIA Grace CPU Superchip
      • NVIDIA GB200 NVL72
      • Hopper versus Blackwell
      • HGX: High-Performance GPU Platforms
      • ARM Chips
      • ARM versus x86
      • RISC versus CISC
      • Introduction to RISC-V
    • Networking and Connectivity
      • Infiniband versus Ethernet
      • NVIDIA Quantum InfiniBand
      • PCIe (Peripheral Component Interconnect Express)
      • NVIDIA ConnectX InfiniBand adapters
      • NVMe (Non-Volatile Memory Express)
      • NVMe over Fabrics (NVMe-oF)
      • NVIDIA Spectrum-X
      • NVIDIA GPUDirect
      • Evaluating Modern GPU Interconnect
      • Scalable Hierarchical Aggregation and Reduction Protocol (SHARP)
      • Next-generation networking in AI environments
      • NVIDIA Collective Communications Library (NCCL)
    • Data and Memory
      • NVIDIA BlueField Data Processing Units (DPUs)
      • Remote Direct Memory Access (RDMA)
      • High Bandwidth Memory (HBM3)
      • Flash Memory
      • Model Requirements
      • Calculating GPU memory for serving LLMs
      • Transformer training costs
      • GPU Performance Optimisation
    • Libraries and Complements
      • NVIDIA Base Command
      • NVIDIA AI Enterprise
      • CUDA - NVIDIA GTC 2024 presentation
      • RAPIDs
      • RAFT
    • Vast Data Platform
      • Vast Datastore
      • Vast Database
      • Vast Data Engine
      • DASE (Disaggregated and Shared Everything)
      • Dremio and VAST Data
    • Storage
      • WEKA: A High-Performance Storage Solution for AI Workloads
      • Introduction to NVIDIA GPUDirect Storage (GDS)
        • GDS cuFile API
      • NVIDIA Magnum IO GPUDirect Storage (GDS)
      • Vectors in Memory
Powered by GitBook
LogoLogo

Continuum - Accelerated Artificial Intelligence

  • Continuum Website
  • Axolotl Platform

Copyright Continuum Labs - 2023

On this page
  • Key points
  • Why it works
  • Why it doesn't need fine-tuning for domain-specific tasks

Was this helpful?

  1. KNOWLEDGE
  2. Vector Databases

One Embedder, Any Task: Instruction-Finetuned Text Embeddings

PreviousLarge Language Model Based Text Augmentation Enhanced Personality Detection ModelNextVector Databases are not the only solution

Last updated 11 months ago

Was this helpful?

This May 2023 paper introduces INSTRUCTOR, a method for computing text embeddings using task instructions.

INSTRUCTOR is a single embedder that can generate text embeddings tailored to different downstream tasks and domains without requiring further task-specific fine-tuning.

This is achieved through instruction-based fine-tuning on a multitask mixture of 330 diverse datasets with human-written task instructions (MEDI dataset).

Key points

  • INSTRUCTOR embeds every input together with instructions explaining the use case (e.g., task and domain descriptions).

  • The same input text will be encoded into different embeddings based on the end task (e.g., duplicate detection, information retrieval, or question classification).

  • INSTRUCTOR can be used for a wide range of downstream applications without additional fine-tuning, including classification, semantic textual similarity, information retrieval, text generation evaluation, and prompt retrieval for in-context learning.

GitHub Repository

INSTRUCTOR is a powerful and versatile tool for generating task-specific text embeddings without the need for further fine-tuning.

It can be easily integrated into various applications to enhance the performance of downstream tasks such as text classification, semantic similarity, information retrieval, and more.

Here's how you can use INSTRUCTOR in your development workflow, based on the provided GitHub repository:

Installation:

  • Create a virtual environment using conda: conda env create -n instructor python=3.7

  • Clone the INSTRUCTOR repository: git clone https://github.com/HKUNLP/instructor-embedding

  • Install the required dependencies: pip install -r requirements.txt

  • Install the InstructorEmbedding package: pip install InstructorEmbedding or pip install -e .

Loading a pre-trained model:

  • Download a pre-trained INSTRUCTOR model (e.g., hkunlp/instructor-large) using the provided model list.

  • Load the model using the INSTRUCTOR class from the InstructorEmbedding package: model = INSTRUCTOR('hkunlp/instructor-large')

Generating customised embeddings:

  • Prepare your text inputs along with the corresponding task instructions using the unified template: Represent the domain text_type for task_objective:, where domain and task_objective are optional, and text_type is required.

  • Call the encode function of the loaded model to generate customized embeddings: embeddings = model.encode(texts_with_instructions)

Applying INSTRUCTOR to specific use cases:

  • Compute similarities between texts:

    • Encode two groups of sentences using INSTRUCTOR with customised instructions.

    • Calculate the cosine similarity between the generated embeddings using cosine_similarity from sklearn.metrics.pairwise.

  • Use customized embeddings for information retrieval:

    • Encode the query and corpus documents using INSTRUCTOR with appropriate instructions.

    • Calculate the cosine similarity between the query and document embeddings.

    • Retrieve the most relevant document based on the similarity scores.

  • Use customized embeddings for clustering:

    • Encode the sentences using INSTRUCTOR with customized instructions for clustering.

    • Apply a clustering algorithm (e.g., MiniBatchKMeans from sklearn.cluster) to the generated embeddings.

    • Assign cluster labels to the sentences based on the clustering results.

Training INSTRUCTOR (optional):

  • If you want to train INSTRUCTOR on your own dataset, follow these steps:

    • Prepare your training data in the unified format used by the MEDI dataset.

    • Run the provided training script (train.py) with the appropriate arguments, specifying the pre-trained checkpoint, output directory, cache directory, and other training hyperparameters.

Evaluation (optional):

  • To evaluate the performance of INSTRUCTOR on benchmark datasets, follow the provided evaluation scripts for MTEB, Billboard, and Prompt Retrieval.

  • Install the necessary dependencies and run the evaluation scripts with the desired model checkpoint and task name.

By leveraging the power of INSTRUCTOR, you can easily generate task-specific text embeddings for a wide range of applications without the need for additional fine-tuning.

The provided GitHub repository offers a comprehensive set of tools and examples to help you integrate INSTRUCTOR seamlessly into your development workflow.

Remember to explore the various use cases and experiment with different task instructions to optimise the performance of your downstream tasks. The versatility and flexibility of INSTRUCTOR make it a valuable asset in any text embedding project.

Why it works

  • INSTRUCTOR is trained on MEDI, a collection of 330 text embedding datasets newly annotated with human-written task instructions. This multitask mixture covers diverse task categories and domains.

  • The model is trained with a contrastive loss that maximises the similarity between semantically related text pairs while minimising the similarity between unrelated pairs.

  • Instruction-based fine-tuning enables INSTRUCTOR to learn task-specific representations by conditioning the embeddings on the task instructions. This allows the model to adapt to different downstream tasks and domains.

  • The diverse training data in MEDI, which includes both symmetric (e.g., text similarity) and asymmetric (e.g., open-domain QA) tasks, helps INSTRUCTOR generate broadly applicable embeddings.

  • The inclusion of the Super-NaturalInstructions dataset in MEDI improves INSTRUCTOR's robustness to paraphrased instructions, making it less sensitive to variations in instruction format and style.

Why it doesn't need fine-tuning for domain-specific tasks

  • INSTRUCTOR is designed to generate task-aware embeddings based on the provided task instructions, eliminating the need for further task-specific fine-tuning.

  • The model is trained on a diverse set of tasks and domains in MEDI, which allows it to generalise well to unseen tasks and domains.

  • The instruction-based approach enables INSTRUCTOR to adapt its embeddings to different use cases on-the-fly, based on the task instructions provided at inference time.

  • Experiments show that INSTRUCTOR significantly outperforms prior state-of-the-art embedding models on a wide range of downstream tasks, including those not seen during training, demonstrating its strong generalization capabilities.

In summary, INSTRUCTOR introduces a text embedding model using task instructions.

By training on a diverse multitask mixture with human-written instructions, INSTRUCTOR learns to generate task-aware embeddings that can be used for various downstream applications without the need for further fine-tuning.

This approach significantly improves the model's generalisation capabilities and makes it a powerful tool for a wide range of natural language processing tasks.

LogoOne Embedder, Any Task: Instruction-Finetuned Text EmbeddingsarXiv.org
One Embedder, Any Task: Instruction-Finetuned Text Embeddings
LogoGitHub - xlang-ai/instructor-embedding: [ACL 2023] One Embedder, Any Task: Instruction-Finetuned Text EmbeddingsGitHub
INSTRUCTOR is a single embedding model that takes not only text inputs but also task instructions, thereby creating task-and-domain-aware embeddings. It is trained on a multitask mixture of 330 diverse datasets with human-written task instructions (MEDI dataset, §2.3). After training on MEDI (left), INSTRUCTOR is evaluated on a variety of 70 embedding datasets (66 of which are not seen during training), spanning various downstream applications (right). INSTRUCTOR outperforms the prior best model by an average of 3.4% over the 70 diverse datasets.
Page cover image