NEW RELEASE

MLRun 1.7 is here! Unlock the power of enhanced LLM monitoring, flexible Docker image deployment, and more.

Integrating LLMs with Traditional ML: How, Why & Use Cases

Nick Schenone | April 24, 2024

Ever since the release of ChatGPT in November 2022, organizations have been trying to find new and innovative ways to leverage gen AI to drive organizational growth. LLM capabilities like contextual understanding and response to natural language prompts enable the development of applications like automated AI chatbots, smart call center apps, or for financial services.

Generative AI is by no means a replacement for the previous wave of AI/ML (now sometimes referred to as ‘traditional AI/ML’), which continues to deliver significant value, and represents a distinct approach with its own advantages. By integrating LLMs with traditional ML models, organizations can significantly enhance and augment each model’s capabilities, leading to new and exciting applications that bring value to their customers. In this blog post, we detail LLMs’ and ML models’ strengths, evaluate the benefits of integration and provide a number of example use cases, from advanced chatbots to synthetic data generation. In the end, we explain how MLOps can help accelerate the process and bring these models to production.

LLMs vs. Classical ML Models: Strengths and Capabilities

LLMs and ML models each have their distinct strengths, which can be applied to different kinds of tasks and objectives.

Strengths of LLMs:

  • Natural Language Understanding and Generation - LLMs excel at comprehending and producing human-like text. They can generate coherent and contextually relevant responses over a wide range of topics, making them ideal for applications like chatbots, content creation and language translation. 
  • Contextual Learning - With their deep learning architecture, LLMs can grasp the nuances of language, including idioms, cultural references and complex syntax. This allows for nuanced conversations and content generation.
  • Adaptability - LLMs can be fine-tuned for specific tasks with relatively small datasets after their initial pre-training. This adaptability makes them versatile tools for a variety of industries, from legal document analysis to customer care (For a demo of how to fine-tune a OSS LLM, check out the github repo here).
  • Knowledge Integration - LLMs possess a broad knowledge base, due to their extensive pre-training on diverse datasets . They can provide information, summaries and insights across many fields without the need for external databases in real-time applications.
  • AI Democratization - LLMs democratize access to AI by lowering the entry barrier. Users can interact with these models through conversational interfaces without the need for specialized knowledge on data formatting or the underlying model architecture.

Strengths of Classical ML Models:

  • Numerical Data Precisions - Classical ML models excel in environments dominated by structured, numerical data. They can yield highly accurate predictions or classifications within well-defined problem spaces. This makes them useful for applications like financial forecasting or biomedical analyses.
  • Efficiency and Scalability - Specialized ML models can be more efficient in terms of computational resources and scalability. This is important for real-time decision-making tasks, like autonomous vehicles or high-frequency trading.
  • Interpretability - Certain ML models, especially those with simpler structures like decision trees or linear regression, provide clearer insights into how decisions are made. This interpretability is important in fields like healthcare and finance, where transparency of the rationale behind predictions is as important as accuracy.

LLMs vs. Classical ML Model: A Comparison

LLMsClassical ML Models
Best-Suited Data TypeNatural languageNumerical data, structured data
Input TypesNatural language promptsCode, API, application interfaces, structured data formats
Top CapabilitiesContextual learning, adaptability, knowledge integrationSpecialized tasks like classification, regression, clustering and pattern recognition in structured data. High efficiency in specific, well-defined problem spaces.
OutputNatural language content like stories, summaries, translations, analyses and more.Predictive scores, classifications, quantitative analyses and decision-support insights.
Entry BarrierLowHigh due to the need for domain-specific knowledge, feature engineering and model tuning.
RisksHallucinations (producing incorrect or fabricated information)Overfitting (model learns noise in the data), underfitting (model is too simple), bias in training data leading to biased predictions.
Special ConsiderationsRequires extensive data for training, with ethical and bias considerations necessitating careful dataset curation.
Often requires manual feature selection and engineering, sensitive to the quality of input data and may need regular updates as new data becomes available.

Benefits of Integrating LLMs into Traditional ML Architectures

Integrating LLMs with traditional ML architectures and practices capitalizes on the strengths of both domains. This can offer a wide range of benefits that enhance business value across various sectors. Main benefits include:

  • Enhanced Handling of Numerical Data - ML models’ capabilities for processing structured numerical data combined with the natural language understanding of LLMs allows for the development of applications that can understand and analyze data in both numerical and textual formats. This broadens the scope of problems that can be tackled. (See examples below).
  • Incorporation of More Advanced Practices - Integrating LLMs with traditional ML practices encourages the exploration of more advanced architectures and transfer learning and fine-tuning techniques.
  • Reduction of Hallucinations - Combining LLMs with traditional ML models can help mitigate hallucinations. The structured data helps anchor the LLM's output to verifiable facts and figures. This enhances the reliability of the generated content.
  • Cost-Effectiveness - Classical ML models are generally less expensive to host and maintain compared to LLMs, which are resource-intensive. By integrating LLMs with traditional models, businesses can leverage the unique capabilities of LLMs without fully committing to their high operational costs. This approach allows for a more economical deployment of AI capabilities, especially for SMEs or startups.
  • Simplification of Self-Hosting - Self-hosting LLMs is complex and resource-intensive and requires significant expertise and infrastructure. By integrating LLM capabilities into existing ML architectures, companies can simplify the deployment process. This integration allows businesses to maintain control over their data and models while minimizing the complexities and costs.
  • Navigating Copyright Controversy - The use of public LLMs, like OpenAI’s, can sometimes raise copyright concerns. By integrating LLM outputs with traditional ML models that can filter, modify, or enhance the generated content based on pre-defined legal and ethical guidelines, businesses can ensure that their use of AI remains within legal boundaries.

The integration of LLMs with traditional ML practices has the potential for developing more innovative, efficient, sustainable and reliable AI solutions. Businesses that recognize and leverage these opportunities can gain a competitive edge, driving innovation and growth in their industries.

Integrating Traditional MLs with LLMs: 4 Use Cases

Now that we’ve seen the potential and benefits, let’s discuss practical use cases for integrating traditional ML with LLMs.

Use Case #1: GenAI Chatbot Integrated with a Classifier Model

Industry: Customer care, e-commerce

Application: Customer-facing chatbot that can route customer requests and answer queries. For example, about package shipping times.

Architecture: Integration of a GenAI chatbot to a classifier model. The architecture includes a chat interface for the end-user, LLM for user interaction, customer DB, order DB, shipping estimator ML model and fine-tuned LLM for crafting hyper-personalized emails. 

Integrating LLMs with Traditional ML: How, Why & Use Cases

Impact: This setup can understand user queries with high accuracy and categorize them to route requests appropriately. When a customer inquires about the estimated time for an order's arrival, the chatbot can accurately fetch this information from the database. Then, leveraging the classifier's output, it can route the customer's request for more personalized communication, such as creating and sending customized emails detailing the expected delivery timeline. This not only improves the efficiency of handling inquiries but also personalizes the customer experience, making it feel more engaging and attentive to individual needs.

Use Case #2: GenAI Model for Synthetic Data Generation

Domain: Data science

Industry: Any industry where data sensitivity is of high importance and data is scarce, like healthcare and finance.

Application: A gen AI model can be utilized to generate synthetic data, which mimics the real-world data in style and diversity. This complements traditional ML by solving pain points in the lifecycle.

Impact: This approach can be beneficial in scenarios where data is scarce, sensitive, or costly to obtain. By training on synthetic data generated by a gen AI model, classical ML models can achieve higher accuracy and generalization capabilities without compromising data privacy or incurring high data acquisition costs.

Use Case #3: Sentiment Analysis for Feature Engineering

Domain: Data science

Industry: Any industry that requires insights into customer behavior, like e-commerce and marketing.

Application: Analysis of the sentiment behind customer reviews, feedback, social media mentions, etc.

Impact: By analyzing textual data to extract sentiments, opinions, and emotions, LLMs can provide enriched features that significantly boost the performance of classical ML models. This can allow for more nuanced and effective marketing and customer care strategies.

Use Case #4: Data Labeling

Domain: Data science

Industry: All

Application: LLMs can automate the labeling of textual data with high accuracy. This too complements traditional ML by solving pain points in the lifecycle.

Impact: This automation can drastically reduce the time and resources required for data labeling, either allowing data scientists to focus on more complex tasks altogether or providing a starting point for human labelers. It also cuts costs for enterprises. Moreover, the use of LLMs in data labeling can ensure consistency and scalability in data annotation efforts, which is particularly beneficial for large-scale ML projects requiring extensive labeled datasets.

How MLOps Accelerates Deployment of Integrated Traditional ML and LLMs

MLOps is the practice of orchestrating, streamlining and automating the operationalization of ML models so they can be deployed and bring business value faster. MLOps accelerates ML pipelines and LLM pipelines, and can also accelerate an integrated approach. Here’s how:

  • Orchestration - MLOps involves coordinating tasks such as data preprocessing, model training, evaluation and deployment across various environments and infrastructures. Automating these workflows ensures that integrated models are updated and deployed efficiently without the need for manual intervention.
  • GPU as a Service (GPUaaS) - LLMs require significant computational resources, particularly GPUs, for training and inference. GPU as a Service (GPUaaS) provides flexible access to GPU resources, allowing organizations to scale their computational capacity based on demand and while maximizing existing resources. MLOps can orchestrate this, ensuring that the models have the necessary computational power when needed.
  • Real-time Serving - MLOps employs techniques such as model quantization, optimized serving infrastructure and efficient load balancing to ensure that models can handle live, real-time requests, with low-latency, high-throughput inference at scale. This is required for applications requiring immediate responses, such as chatbots or automated writing assistants.
  • Monitoring and Maintenance - MLOps tracks model performance over time, identifying and addressing data drift and retraining models with updated data or algorithms. This continuous monitoring and iterative improvement help maintain accuracy and relevance.
  • Collaboration - MLOps fosters collaboration between data scientists, ML engineers and developers, ensuring everyone is aligned on tools and practices. 
  • Ethical AI - MLOps integrates tasks into the pipeline that ensure models and applications are ethical. This is done through guardrails that establish data privacy practices and eliminate toxicity, bias and hallucinations.

Try out this demo that shows how LLMs and ML models integrate together, with open source MLOps orchestration framework MLRun. Click here.