Skip to main content

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.

Metadata

Release files for langkit 0.0.35

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langkit 0.0.35
File Size Uploaded
langkit-0.0.35.tar.gz 1.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for langkit 0.0.35
File Interpreter ABI Platform
langkit-0.0.35-py3-none-any.whl Python 3 none any Details

Total release size: 2.4 MB

Release files / langkit-0.0.35.tar.gz

Download URL langkit-0.0.35.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
22a0a15f825d286ba9b7b060f1ce28753558fa02242631bb57208e5be0b46056
BLAKE2b-256 checksum
How to use checksums
e1ca6c0c3d088663a8e7c0df5a6bd618b5f24348d212c607ecb7ea05c8cfde25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.12 Linux/6.5.0-1025-azure

Release files / langkit-0.0.35-py3-none-any.whl

Download URL langkit-0.0.35-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
602cb673af70138691cd7709fb451af62a0927f1c396ff2cbbcba86dae886305
BLAKE2b-256 checksum
How to use checksums
778fa7b4f01f018e8f0fd0c435672ee35b9fede344baaa64eae0e5ab7a9ffc00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.12 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

0.0.35 This release

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.29

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page