Skip to content

Prompt-safety guards as a Python library. TF-IDF, RAG, LLM as a judge pipeline

Notifications You must be signed in to change notification settings

laricko/prompt-guard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prompt Guard

Composable prompt-safety guards as a lightweight Python library. It provides:

  • TF‑IDF guard for fast lexical similarity against known phrases.
  • RAG guard for embedding-based retrieval against a sentence corpus.
  • LLM judge for a final model-based classification.

Quick start

from prompt_guard import GuardPipeline, PromptGuardConfig

cfg = PromptGuardConfig(
    embed_model_name="mxbai-embed-large",
    judge_model_name="qwen2.5:3b-instruct",
)
guard = GuardPipeline(cfg)
result = await guard.check("Some prompt")

Notes

  • TF‑IDF and RAG build in‑memory indexes at first use.
  • RAG and LLM judge use local Ollama models by default; ensure Ollama is running and the models are pulled.

Text file formats

  • phrases.txt: one phrase per line (blank lines are ignored).
  • sentences.txt: one sentence per line (blank lines are ignored).

About

Prompt-safety guards as a Python library. TF-IDF, RAG, LLM as a judge pipeline

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages