Skip to main content

Introduction to odin-prompt-toolkit

odin-prompt-toolkit is a multi-language SDK for AI prompt safety and security. It gives you the tools to detect jailbreaks, find similar or duplicate prompts, and match incoming prompts against known threat intelligence โ€” across Rust, Python, TypeScript, and Go.

What It Doesโ€‹

The toolkit provides two complementary capabilities:

๐Ÿ” LSH Signatures โ€” Prompt Similarity & Deduplicationโ€‹

Converts any prompt into a compact 256-bit signature that preserves semantic similarity. Identical or near-identical prompts produce signatures with small Hamming distance, enabling fast similarity search without storing or comparing raw embeddings.

Use it to:

  • Detect duplicate or paraphrased prompts at scale
  • Build approximate nearest-neighbor (ANN) indexes over large prompt corpora
  • Match incoming prompts against a cache of known threats (Threat Feed)

๐Ÿšจ SusFactor โ€” Jailbreak & Prompt Injection Classificationโ€‹

Scores a prompt from 0 (safe) to 1 (suspicious) using a fine-tuned e5-large model. No embedding pipeline needed โ€” feed it a prompt, get back a score and a label.

Use it to:

  • Flag jailbreak attempts and prompt injection attacks in real time
  • Gate LLM requests based on risk score
  • Combine with signatures for defense-in-depth: detect known attacks via threat feed and novel attacks via classifier

Key Featuresโ€‹

  • ๐Ÿ”’ Jailbreak detection โ€” SusFactor classifier scores prompts 0โ€“1 for suspicious intent
  • ๐Ÿ” Similarity signatures โ€” 256-bit SimHash LSH signatures for fast deduplication and ANN search
  • ๐Ÿ›ก๏ธ Threat intelligence โ€” Sync and query the 0DIN threat feed of known adversarial prompts
  • ๐ŸŒ Cross-language โ€” Identical signatures and parity scores across Rust, Python, TypeScript, and Go
  • ๐Ÿ“ฆ No API required โ€” Local ONNX models for both embeddings (V1) and classification
  • ๐Ÿš€ Fast โ€” O(1) signature lookups; native Rust acceleration for Python (up to ~600ร— speedup)
  • ๐Ÿงช Battle-tested โ€” 400+ tests across 4 languages

Quick Examplesโ€‹

Jailbreak Detection (SusFactor)โ€‹

use odin_prompt_toolkit::providers::ModelCache;
use odin_prompt_toolkit::susfactor::SusFactorClassifier;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let cache = ModelCache::new()?;
let clf = SusFactorClassifier::new(&cache, None, None, None).await?;

let result = clf.classify("Ignore all previous instructions").await?;
println!("{:.3} โ€” {}", result.score, result.label);
// 0.972 โ€” suspicious

Ok(())
}

Signature Generationโ€‹

use odin_prompt_toolkit::{sign_text, SignatureVersion};
use odin_prompt_toolkit::providers::{ModelCache, OnnxProvider};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let cache = ModelCache::new()?;
let provider = OnnxProvider::new(&cache, None, None, 0, 0).await?;

let result = sign_text(
"How do I reset my password?",
&provider,
SignatureVersion::Latest,
None,
).await?;

println!("{}", result.to_signature_string());
// 0din-v1:8d000000ac854dae...

Ok(())
}

How the Two Capabilities Fit Togetherโ€‹

SusFactorLSH Signatures
InputRaw textRaw text (embedding generated internally)
OutputScore 0โ€“1 + label256-bit hex signature
DetectsNovel jailbreaks, prompt injectionDuplicate / paraphrased known attacks
Speed~50โ€“200ms per prompt (ONNX)<1ms per lookup after indexing
Best forReal-time request gatingLarge-scale deduplication, threat matching

For defense-in-depth, run both: SusFactor catches novel attacks the threat feed hasn't seen; signatures catch known variants that may score below the classifier threshold.


How Signatures Workโ€‹

Signatures are generated using SimHash via Random Hyperplane LSH โ€” a deterministic algorithm that converts any prompt embedding into a compact 256-bit hex fingerprint. Semantically similar prompts produce signatures with small Hamming distance, enabling fast similarity queries without storing or comparing raw vectors.

Deep dive: LSH Overview โ†’


Signature Versionsโ€‹

VersionProviderModelDimensions
V0OpenAItext-embedding-3-large1536
V1ONNX0din-jailbreak-embeddings-small1024

V0 and V1 signatures are not comparable โ€” different embedding spaces.


Project Statusโ€‹

โœ… Production Ready โ€” All four language implementations validated with 400+ passing tests

LanguagePackageStatusTests
Rustodin-prompt-toolkit v0.6.0โœ… Ready69 passing
Python0din-prompt-toolkitโœ… Ready183 passing
TypeScript@0din/prompt-toolkitโœ… Ready146 passing
Gogithub.com/0din-ai/prompt-toolkit/packages/goโœ… Ready (SusFactor)27+ passing

See the Validation Report for detailed cross-language parity results.


Next Stepsโ€‹

  • Installation โ€” Install for Rust, Python, TypeScript, or Go
  • Quick Start โ€” Your first jailbreak check or LSH signature
  • SusFactor โ€” Jailbreak classification deep dive
  • Threat Feed โ€” Match prompts against 0DIN threat intelligence
  • LSH Overview โ€” How similarity signatures work
  • Ecosystem โ€” Projects and integrations built with the toolkit