Security Challenges in LLM Adoption for Enterprises And How To Solve Them

Challenges in LLM Adoption for Enterprises: Introducing LangKit for Secure LLM Adoption
Security Challenges in LLM Adoption for Enterprises And How To Solve Them

In 2023, generative AI gained significant attention, but enterprises are facing challenges in identifying suitable use cases for this technology.

Large Language Models (LLMs) have inherent limitations, such as generating irrelevant or off-topic content and being vulnerable to prompt injection, making them a source of concern for businesses.

	 Figure: LLMs in Enterprise

            Figure: LLMs in Enterprise       

Companies have taken the initiative to establish guardrails that regulate and control the language generation process to address these issues and facilitate the adoption of LLMs in enterprises.

However, implementing language models in production, including LLMs, presents various risks because of the vast number of possible input combinations and corresponding outputs.

The unstructured nature of text adds complexity to the ML observability space, and addressing this challenge is crucial as the lack of visibility into the model's behavior can lead to significant consequences.

For example, OpenAI has implemented content moderation endpoints to prevent APIs from generating harmful or offensive content. Similarly, NVIDIA's NeMo Guardrails SDK offers a more comprehensive approach to mitigate the shortcomings of LLMs.

However, recent reports have indicated that there are still some shortcomings in NVIDIA's NeMo Guardrails SDK. While the capabilities of guardrails can be expanded, it is evident that the journey to ensure the safety of LLMs for enterprise usage is ongoing.

The emergence of a growing ecosystem of tools aimed at making LLMs safer for enterprises shows promising developments. Nonetheless, whether these efforts will be sufficient to accelerate LLM adoption in the enterprise sector remains.

In this blog, we discuss about LangKit, which extends the adoption of LLMs in Enterprise. The major challenges which it encounters include:

  1. Content Relevance and Quality: LLMs have inherent limitations in generating irrelevant, off-topic, or low-quality content. Enterprises face the challenge of ensuring that the generated content aligns with their desired outcomes and maintains a high standard of quality.
  2. Vulnerability to Prompt Injection: LLMs are susceptible to prompt injection attacks, where malicious input can lead to unintended or harmful outputs. Enterprises need to address this security vulnerability to prevent unauthorized access or manipulation of their systems.
  3. Risk Management and Guardrails: Implementing LLMs in production involves managing various risks due to the large number of potential input combinations and outputs. Establishing effective guardrails to regulate the language generation process and mitigate risks is a challenge that requires careful consideration.
  4. ML Observability and Lack of Visibility: The unstructured nature of text makes it challenging to observe and understand the behavior of LLMs. Enterprises need to address the lack of visibility into model behavior to ensure that the generated content aligns with expectations and does not lead to unintended consequences.
  5. Integration and Compatibility: Integrating LLMs into existing ecosystems and workflows, such as Hugging Face and LangChain, can be complex and challenging. Ensuring compatibility and smooth integration with other tools and platforms is crucial for seamless adoption.
  6. Data Privacy and Security: Enterprises must ensure the security and privacy of user data when deploying LLMs. Protecting sensitive information and preventing unauthorized access or data leaks is a challenge that requires robust security measures.
  7. Continuous Monitoring and Maintenance: Once LLMs are deployed, enterprises need to continuously monitor their performance and behavior to identify issues and ensure ongoing quality. This requires dedicated resources and processes for maintenance.
  8. Customization and Domain-Specific Training: Tailoring LLMs to specific domains or industries requires significant customization and fine-tuning. Enterprises need to address the challenge of training LLMs to understand and generate content relevant to their specific needs.
  9. User Experience and Expectations: Ensuring that LLM-generated content meets user expectations and provides a positive user experience is a challenge. Enterprises must carefully manage user interactions to avoid scenarios where LLMs provide inaccurate or unsatisfactory responses.
  10. Ethical and Bias Concerns: LLMs have the potential to perpetuate biases present in training data, which can lead to biased or unfair outputs. Enterprises must address the challenge of identifying and mitigating bias to ensure responsible and ethical AI deployment.

Introducing LangKit

Earlier this week, a monitoring toolkit called LangKit was introduced as a means to track the outputs of LLMs (large language models).

                   Figure: Services Offered By LangKit

This toolkit offers a set of metrics to assess the quality of input and output texts generated by various LLM-powered chatbots like Bing Chat, GPT-4, Baidu, and Google Bard. LangKit is designed to integrate with ecosystems such as Hugging Face and LangChain.

WhyLabs, a company focused on building an AI observability platform for enterprises, open-sourced LangKit. Through the WhyLabs platform, enterprises can quickly detect issues with their ML models and deploy them continuously. The platform offers additional features, such as outlier detection, data drift monitoring, and a strong emphasis on data privacy.

LangKit complements the WhyLabs platform, serving as the final piece of the puzzle by providing enhanced visibility into the behavior of LLMs during deployment.

The toolkit incorporates preventive measures to safeguard against potential risks, including hallucinations, toxicity, malicious prompts, and jailbreak attempts.

By monitoring various metrics such as text quality, relevance, security, and sentiment, LangKit ensures the LLMs operate according to specifications.

LangKit uses a similarity score algorithm to compare user input against known jailbreak attempts and prompt injection attacks to enhance security. If the score exceeds a certain threshold, the input is rejected.

The toolkit also applies various other checks to ensure the LLM functions as intended.

LangKit is just one of the many tools companies can use to enhance their models' safety. As enterprise adoption of LLMs continues, more products are being developed to address and mitigate potential drawbacks associated with their deployment.


In the current version of LangKit, supported metrics include the following:

Text Quality

The evaluation of text quality metrics, such as readability, complexity, and grade level, plays a crucial role in assessing the appropriateness and effectiveness of Language Model (LLM) outputs. These metrics offer valuable insights into the clarity and suitability of the generated responses for the target audience.

Analyzing text complexity and grade level aids in tailoring the content to match the intended readers' proficiency. By considering elements like sentence structure, vocabulary selection, and specific domain requirements, we can ensure that the LLM generates responses that are well-suited to the intended audience's reading level and professional context.

Additionally, incorporating metrics like syllable count, word count, and character count allows us to monitor the length and composition of the generated text closely. By setting appropriate constraints and guidelines, we can ensure that the responses remain concise, focused, and easily digestible for users.

Within the langkit framework, we can compute text quality metrics using the textstat module, which utilizes the textstat library to calculate various text quality metrics. For instance, these statistics include:

  1. Readability score
  2. Complexity and grade scores

Text Relevance

Text relevance is critical in monitoring Language Models (LLMs), as it offers an objective measure of the similarity between different texts. This metric serves multiple purposes, including evaluating the quality and appropriateness of LLM outputs and implementing safety measures to ensure the generation of desirable and safe responses.

One important use case is the computation of similarity scores between embeddings derived from prompts and responses, allowing us to assess the relevance between them.

This enables the identification of potential issues, such as irrelevant or off-topic responses, ensuring that LLM outputs closely align with the intended context. In langkit, we can calculate similarity scores between prompt and response pairs using the input_output module.

Another crucial use case involves determining the similarity of prompts and responses against specific topics or known examples, such as jailbreaks or controversial subjects.

We can set up guardrails to detect potentially harmful or undesirable responses by comparing the embeddings to predefined themes. The similarity scores act as indicators, alerting us to content that may require further examination or mitigation.

In Langkit, this functionality can be achieved through the themes module. Leveraging text relevance as a monitoring metric for LLMs allows us to assess the quality of generated responses and implement safety measures to minimize the risk of producing inappropriate or harmful content.

This approach enhances LLMs' overall performance, safety, and reliability in various applications, making it a valuable tool for responsible AI development. For instance, these include:

  1. Similarity scores between prompt/responses
  2. Similarity scores against user-defined themes

Security and Privacy

Ensuring security and privacy in Language Model (LLM) applications is essential for safeguarding user data and preventing malicious activities. Various approaches can be employed to bolster security and privacy measures within LLM systems.

One approach involves measuring text similarity between prompts and responses and comparing them against known examples of jailbreak attempts, prompt injections, and LLM refusals of service.

By analyzing the embeddings generated from the text, potential security vulnerabilities and unauthorized access attempts can be detected, helping to mitigate risks and maintain the LLM's operation within secure boundaries. In langkit, this can be achieved through the themes module, which calculates text similarity between prompts/responses and known examples.

Implementing a prompt injection classifier further enhances the security of LLM applications. By identifying and preventing prompt injection attacks, where malicious code or unintended instructions are inserted into the prompt, the system can maintain its integrity and protect against unauthorized actions or data leaks.

	Figure: Prompt Injection for JailBreaking in ChatGPT

      Figure: Prompt Injection for JailBreaking in ChatGPT

In Langkit, the injections module can compute prompt injection detection metrics.Another critical security and privacy monitoring aspect involves checking prompts and responses against regex patterns designed to detect sensitive information.

These patterns can help identify and flag data such as credit card numbers, telephone numbers, or other personally identifiable information (PII). In langkit, regex pattern matching against pattern groups can be done through the regexes module. This adds an extra layer of protection for sensitive data within LLM applications. These include:

  1. Patterns: count of strings matching a user-defined regex pattern group
  2. Jailbreaks: similarity scores with respect to known jailbreak attempts
  3. Prompt injection: similarity scores with respect to known prompt injection attacks
  4. Refusals: similarity scores with respect to known LLM refusal of service responses

Sentiment and Toxicity

In Language Model (LLM) applications, the utilization of sentiment analysis offers valuable insights into the appropriateness and user engagement of generated responses.

By incorporating sentiment and toxicity classifiers, we can evaluate the sentiment and detect potentially harmful or inappropriate content within LLM outputs.

Assessing sentiment allows us to understand the responses' overall tone and emotional impact. By analyzing sentiment scores, we can ensure that the LLM consistently produces suitable and contextually relevant responses. For example, maintaining a positive sentiment in customer service applications ensures a satisfactory user experience.

Furthermore, toxicity analysis plays a crucial role in detecting offensive, disrespectful, or harmful language in LLM outputs. By monitoring toxicity scores, we can identify potentially inappropriate content and take appropriate measures to mitigate any adverse effects.

Analyzing sentiment and toxicity scores in LLM applications also serves additional purposes. It helps us identify potential biases or controversial opinions present in the responses, addressing concerns related to fairness, inclusivity, and ethical considerations. This approach reinforces responsible AI practices and promotes a positive user experience. Some of these metrics include:

  1. Sentiment analysis
  2. Toxicity analysis

Installing LangKit

To install LangKit, use the Python Package Index (PyPI) as follows:

pip install langkit[all]


LangKit modules come with pre-built User-Defined Functions (UDFs) that seamlessly integrate into the existing collection of UDFs for String features provided by whylogs.

To use LangKit, you need to import the modules and create a custom schema, as demonstrated in the example below.

import whylogs as why
from langkit import llm_metrics

results = why.log({"prompt": "Hello!", "response": "World!"}, schema=llm_metrics.init())

The provided code will generate a comprehensive set of metrics, including the default whylogs metrics for text features and additional metrics defined in the imported LangKit modules.

The team can leverage their telemetry data to monitor the behavior of the Language Model (LLM) and identify significant changes.

For instance, if the LLM is being used for user interactions, and the goal is to maintain on-topic responses, it is essential to avoid scenarios where the support bot provides many legal answers, especially if it has not been thoroughly tested or trained in that domain.

To achieve this, the team can utilize LangKit's topic detection telemetry, which helps them gain insights into the trends of different topics being handled. The toolkit comes with predefined topics, and the team also has the flexibility to define custom topics as per their specific requirements.

By monitoring the topic distribution, the team can ensure that the LLM aligns with the intended context and performs effectively in delivering appropriate responses.

		Figure: Topic Distribution for an LLM

               Figure: Topic Distribution for an LLM

Output Visualization

When deploying LLMs in a production environment, ensuring the quality of the output is of utmost importance, especially when catering to specific audiences, such as medical practitioners or legal professionals.

The expectation is that the LLM generates text that is aligned with the intended user, sounding natural and appropriate for the context.

To achieve this, the team closely monitors the reading level of the LLM's responses over time. By tracking changes in the reading level, they can assess how well the model is performing the task at hand. Additionally, they may also monitor other aspects like output relevance to the provided prompt and the sentiment of the responses.

These metrics provide valuable insights into user interactions and help identify any potential hallucinations in the model's outputs.

For comprehensive monitoring and analysis, the team relies on LangKit, which offers a range of tools and metrics to cover these aspects. With LangKit's capabilities, the team can ensure that their LLM is producing high-quality and contextually relevant responses, meeting the expectations of their target audience and delivering a superior user experience.

In their LLM deployment, the team leverages LangKit to effectively surface similarity to known themes, including jailbreaks or refusals. Additionally, they use the toolkit to identify responses that are either desired or undesired in the conversation.

By measuring the maximum similarity to known jailbreak attempts, the team can establish a threshold. If the similarity score surpasses this threshold, they have a mechanism in place to respond promptly. For instance, they may choose to quarantine the session or enforce a higher sensitivity of logging to capture all relevant insights regarding the user's attempted access to unauthorized information.

This proactive approach ensures that the team maintains a robust security posture and diligently monitors for any potential breaches or unauthorized activities. By utilizing LangKit's capabilities, they are able to detect and respond swiftly to any security concerns, thereby enhancing the overall safety and integrity of their LLM application.

Figure: Analysing Potential Jailbrakes

         Figure: Analysing Potential Jailbrakes


In conclusion, the year 2023 has seen a surge in interest in generative AI, but enterprises are still grappling with identifying suitable use cases for this technology.

Large Language Models (LLMs) have shown remarkable potential, but their inherent limitations, such as generating irrelevant content and vulnerability to prompt injection, pose challenges for businesses.

To address these issues and facilitate LLM adoption in enterprises, companies have proactively established guardrails to regulate and control language generation.

However, deploying LLMs in production remains risky due to the vast number of possible input combinations and outputs, coupled with the unstructured nature of text, which hinders ML observability.

Despite the challenges, the industry is witnessing positive developments, with organizations like WhyLabs introducing monitoring tools like LangKit. This toolkit allows enterprises to track LLM outputs and gain valuable insights into the performance and behavior of their models.

By employing LangKit's extensive set of metrics, businesses can assess text quality, relevance, security, and sentiment, ensuring that the LLMs operate effectively and responsibly.

LangKit's integration with existing UDFs and its compatibility with popular ecosystems further enhance its utility in monitoring LLMs' performance and adherence to intended contexts.

The toolkit's contribution to establishing guardrails against potential security risks, such as jailbreak attempts and prompt injections, demonstrates its significance in securing sensitive data within LLM applications.

The introduction of LangKit adds to the growing list of tools and frameworks aimed at addressing challenges in LLM deployment.

As the enterprise adoption of LLMs continues to evolve, these tools play a crucial role in making language models safer and more reliable for a wide range of applications. As a result, responsible AI development is further reinforced, ensuring a positive and secure user experience in the realm of generative AI.

Frequently Asked Questions

1.  What is AI observability?

AI Observability is the capability to obtain valuable insights and comprehensively comprehend the actions, effectiveness, and expenditure of artificial intelligence (AI) models and services while they are functioning.

2.  How is AI observability used?

AI observability is utilized to gain a profound understanding of ML models and entire pipelines. It offers visibility into the functioning of the model, enabling informed decisions on various aspects, such as deploying a new candidate model under an A/B test or replacing an ML model with a new one.

Train Your Vision/NLP/LLM Models 10X Faster

Book our demo with one of our product specialist

Book a Demo