LLMSanitize: An Open-Source Library for Contamination Detection in NLP and LLM Datasets

This repository profile is provided by osrepos.com, an open source repository discovery platform.

LLMSanitize: An Open-Source Library for Contamination Detection in NLP and LLM Datasets

Summary

LLMSanitize is an open-source Python library designed for detecting contamination in NLP datasets and Large Language Models (LLMs). It offers a comprehensive suite of methods, ranging from string matching to model likelihood and embedding similarity, to ensure data integrity. This tool is crucial for researchers and developers working with LLMs to maintain the reliability of their models and evaluations.

Repository Information

Analyzed by OSRepos on February 9, 2026

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

LLMSanitize is an essential open-source Python library dedicated to identifying and mitigating data contamination in Natural Language Processing (NLP) datasets and Large Language Models (LLMs). Data contamination can significantly impact the reliability and trustworthiness of LLM evaluations, making tools like LLMSanitize vital for ensuring robust research and development. The library provides a unified framework to apply various state-of-the-art detection methods.

Installation

LLMSanitize is designed and tested with Python 3.9 and CUDA 11.8. Follow these steps to get started:

First, ensure you have CUDA 11.8 installed. Then, create a conda environment with Python 3.9:

conda create --name llmsanitize python=3.9

Activate your new environment:

conda activate llmsanitize

Finally, install LLMSanitize from PyPI:

pip install llmsanitize

Note that the library specifically uses vllm 0.3.3.

Examples

LLMSanitize supports a wide array of contamination detection methods. For methods requiring vLLM, you first need to launch a vLLM instance.

To launch the vLLM instance, run the following command in a terminal, specifying a port number and model name in the vllm_hosting.sh script:

sh llmsanitize/scripts/vllm_hosting.sh

You can run contamination detection using the provided test scripts. For instance, to run sharded-likelihood on Hellaswag with Llama-2-7B:

sh llmsanitizescripts/tests/closed_data/sharded-likelihood/test_hellaswag.sh -m <path_to_your_llama-2-7b_folder>

For methods using vLLM, such as guided-prompting, pass the port number as an argument:

sh llmsanitizescripts/tests/closed_data/guided-prompting/test_hellaswag.sh -m <path_to_your_llama-2-7b_folder> -p <port_number_from_your_vllm_instance>

Alternatively, you can integrate LLMSanitize directly into your Python scripts:

from llmsanitize import ClosedDataContaminationChecker
args = # setup your argparse here
contamination_checker = ClosedDataContaminationChecker(args)
contamination_checker.run_contamination("guided-prompting") # make sure that your args contain all parameters relevant this specific method

Why Use LLMSanitize?

LLMSanitize offers a robust solution for a critical problem in LLM development. By providing a comprehensive suite of contamination detection methods, it empowers researchers and practitioners to:

  • Ensure Data Integrity: Verify the cleanliness of datasets used for training and evaluation.
  • Improve Model Reliability: Build more trustworthy LLMs by identifying and addressing contaminated data.
  • Support Diverse Methods: Access various detection techniques, including string matching, embedding similarity, model likelihood, and LLM-based approaches, catering to different use cases and model access types.
  • Facilitate Research: Serve as a valuable tool for academic and industrial research into LLM data quality and evaluation.

Links

Related repositories

Similar repositories that may be relevant next.

RL4LMs: A Modular RL Library for Fine-tuning Language Models

RL4LMs: A Modular RL Library for Fine-tuning Language Models

July 6, 2026

RL4LMs is a powerful and modular reinforcement learning library designed to fine-tune language models to human preferences. It offers easily customizable building blocks for training, including on-policy algorithms, reward functions, and metrics. Thoroughly tested and benchmarked, RL4LMs supports a wide range of NLP tasks and models.

reinforcement-learningnatural-language-processinglanguage-modeling
torchtune: PyTorch Native Library for LLM Post-Training and Experimentation

torchtune: PyTorch Native Library for LLM Post-Training and Experimentation

July 5, 2026

torchtune is a PyTorch native library designed for authoring, post-training, and experimenting with Large Language Models (LLMs). It offers hackable training recipes, simple PyTorch implementations of popular LLMs, and best-in-class memory efficiency. Please note: torchtune is no longer actively maintained as of 2025.

PythonPyTorchLLM
RouteLLM: Optimize LLM Costs and Maintain Quality with Intelligent Routing

RouteLLM: Optimize LLM Costs and Maintain Quality with Intelligent Routing

July 5, 2026

RouteLLM is a powerful framework designed to serve and evaluate LLM routers, enabling significant cost savings without compromising response quality. It intelligently routes simpler queries to cheaper models while maintaining high performance, offering a drop-in replacement for existing OpenAI clients or a compatible server. This solution helps balance the dilemma of LLM deployment costs versus model capabilities.

PythonLLM RoutingAI
Memoripy: An AI Memory Layer for Context-Aware Applications

Memoripy: An AI Memory Layer for Context-Aware Applications

July 5, 2026

Memoripy is a Python library designed to provide an AI memory layer for context-aware applications. It offers both short-term and long-term storage, semantic clustering, and optional memory decay. This robust tool helps AI systems manage and retrieve relevant information efficiently, supporting various LLM APIs like OpenAI and Ollama.

aillmmemory

Source repository

Open the original repository on GitHub.

9 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️