
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Automated Summary Scoring & Evaluation of Retained Text
ASSERT LLM Tools is a Python library for evaluating summaries and RAG (Retrieval-Augmented Generation) outputs using various metrics, both traditional (ROUGE, BLEU, BERTScore) and LLM-based.
pip install assert_llm_tools
For additional features, install optional dependencies:
# For AWS Bedrock support
pip install assert_llm_tools[bedrock]
# For OpenAI support
pip install assert_llm_tools[openai]
# For all optional dependencies
pip install assert_llm_tools[all]
Evaluate a summary against original text:
from assert_llm_tools import evaluate_summary, LLMConfig
# Configure LLM for evaluation
config = LLMConfig(
provider="openai",
model_id="gpt-4",
api_key="your-openai-api-key"
)
# Evaluate the summary
results = evaluate_summary(
full_text="Original long text goes here...",
summary="Summary to evaluate goes here...",
metrics=["rouge", "faithfulness", "hallucination", "coherence"],
llm_config=config
)
print(results)
Evaluate a RAG system output:
from assert_llm_tools import evaluate_rag, LLMConfig
# Configure LLM for evaluation
config = LLMConfig(
provider="bedrock",
model_id="anthropic.claude-v2",
region="us-east-1"
)
# Evaluate the RAG output
results = evaluate_rag(
question="What are the main effects of climate change?",
answer="Climate change leads to rising sea levels, increased temperatures...",
context="Climate change refers to long-term shifts in temperatures...",
llm_config=config,
metrics=["answer_relevance", "faithfulness"]
)
print(results)
ASSERT LLM Tools supports various proxy configurations for environments that require proxies to access external APIs.
from assert_llm_tools import LLMConfig
# Configure with a single proxy for both HTTP and HTTPS
config = LLMConfig(
provider="openai",
model_id="gpt-4",
api_key="your-openai-api-key",
proxy_url="http://proxy.example.com:8080"
)
from assert_llm_tools import LLMConfig
# Configure with separate proxies for HTTP and HTTPS
config = LLMConfig(
provider="bedrock",
model_id="anthropic.claude-v2",
region="us-east-1",
http_proxy="http://http-proxy.example.com:8080",
https_proxy="http://https-proxy.example.com:8443"
)
The library also respects standard environment variables for proxy configuration:
# Set environment variables
export HTTP_PROXY="http://proxy.example.com:8080"
export HTTPS_PROXY="http://proxy.example.com:8443"
Then create configuration without explicit proxy settings:
# No proxy settings in code - will use environment variables
config = LLMConfig(
provider="openai",
model_id="gpt-4",
api_key="your-openai-api-key"
)
For proxies that require authentication, include the username and password in the URL:
config = LLMConfig(
provider="bedrock",
model_id="anthropic.claude-v2",
region="us-east-1",
proxy_url="http://username:password@proxy.example.com:8080"
)
rouge
: ROUGE-1, ROUGE-2, and ROUGE-L scoresbleu
: BLEU scorebert_score
: BERTScore precision, recall, and F1bart_score
: BARTScorefaithfulness
: Measures factual consistency with the source texthallucination
: Detects claims in the summary not supported by the source text (returns hallucination_score)topic_preservation
: How well the summary preserves main topicsredundancy
: Measures repetitive contentconciseness
: Evaluates information density and brevitycoherence
: Measures logical flow and readabilityanswer_relevance
: How well the answer addresses the questioncontext_relevance
: How relevant the retrieved context is to the questionfaithfulness
: Factual consistency between answer and contextanswer_attribution
: How much of the answer is derived from the contextcompleteness
: Whether the answer addresses all aspects of the questionFor privacy-sensitive applications, you can automatically detect and mask personally identifiable information (PII) before evaluation:
# Basic PII masking
results = evaluate_summary(
full_text="John Smith (john.smith@example.com) lives in New York.",
summary="John's contact is john.smith@example.com.",
metrics=["rouge", "faithfulness"],
llm_config=config,
mask_pii=True # Enable PII masking
)
# Advanced PII masking with more options
results, pii_info = evaluate_summary(
full_text=text_with_pii,
summary=summary_with_pii,
metrics=["rouge", "faithfulness"],
llm_config=config,
mask_pii=True,
mask_pii_char="#", # Custom masking character
mask_pii_preserve_partial=True, # Preserve parts of emails, phone numbers, etc.
mask_pii_entity_types=["PERSON", "EMAIL_ADDRESS", "LOCATION"], # Only mask specific entities
return_pii_info=True # Return information about detected PII
)
# Access PII detection results
print(f"PII in original text: {pii_info['full_text_pii']}")
print(f"PII in summary: {pii_info['summary_pii']}")
The same PII masking options are available for RAG evaluation:
results = evaluate_rag(
question="Who is John Smith and what is his email?",
answer="John Smith's email is john.smith@example.com.",
context="John Smith (john.smith@example.com) is our company's CEO.",
llm_config=config,
metrics=["answer_relevance", "faithfulness"],
mask_pii=True
)
For BERTScore calculation, you can specify the model to use:
results = evaluate_summary(
full_text=source,
summary=summary,
metrics=["bert_score"],
bert_model="microsoft/deberta-xlarge-mnli" # More accurate but slower
)
config = LLMConfig(
provider="bedrock",
model_id="anthropic.claude-v2",
region="us-east-1",
api_key="YOUR_AWS_ACCESS_KEY",
api_secret="YOUR_AWS_SECRET_KEY",
aws_session_token="YOUR_SESSION_TOKEN" # Optional
)
config = LLMConfig(
provider="openai",
model_id="gpt-4",
api_key="your-openai-api-key",
additional_params={
"response_format": {"type": "json_object"},
"seed": 42
}
)
MIT
FAQs
Automated Summary Scoring & Evaluation of Retained Text
We found that assert-llm-tools demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.