A language toolkit for monitoring LLM interactions
Project description
LangKit is an open-source text metrics toolkit for monitoring language models. It offers an array of methods for extracting relevant signals from the input and/or output text, which are compatible with the open-source data logging library whylogs.
💡 Want to experience LangKit? Go to this notebook!
Table of Contents 📖
Motivation 🎯
Productionizing language models, including LLMs, comes with a range of risks due to the infinite amount of input combinations, which can elicit an infinite amount of outputs. The unstructured nature of text poses a challenge in the ML observability space - a challenge worth solving, since the lack of visibility on the model's behavior can have serious consequences.
Features 🛠️
The currently supported metrics include:
- Text Quality
- readability score
- complexity and grade scores
- Text Relevance
- Similarity scores between prompt/responses
- Similarity scores against user-defined themes
- Security and Privacy
- patterns - count of strings matching a user-defined regex pattern group
- jailbreaks - similarity scores with respect to known jailbreak attempts
- prompt injection - similarity scores with respect to known prompt injection attacks
- refusals - similarity scores with respect to known LLM refusal of service responses
- Sentiment and Toxicity
- sentiment analysis
- toxicity analysis
Installation 💻
To install LangKit, use the Python Package Index (PyPI) as follows:
pip install langkit[all]
Usage 🚀
LangKit modules contain UDFs that automatically wire into the collection of UDFs on String features provided by whylogs by default. All we have to do is import the LangKit modules and then instantiate a custom schema as shown 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 code above will produce a set of metrics comprised of the default whylogs metrics for text features and all the metrics defined in the imported modules. This profile can be visualized and monitored in the WhyLabs platform or they can be further analyzed by the user on their own accord.
More examples are available here.
Modules 📦
You can have more information about the different modules and their metrics here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for langkit-0.0.28.dev9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a062e7e31052b630b221016392c13917fcf0228e8965891d4614b762589e5094 |
|
MD5 | e7df851a6773cf36cc264fa8cdf2790e |
|
BLAKE2b-256 | e6de0545f9086a580f99e366e9defadeb0dfd69c65f55c5dbc04625fd81aa456 |