> your AI agent picks dependencies from memory; give it dated facts — try starlog.dev ↗ vet your agent's deps ↗ vibe-coding is fine. vibe-importing isn’t. — try starlog.dev ↗ vibe-importing isn’t fine ↗ your agent has never seen your private packages — try starlog.dev ↗ facts for private packages ↗ a linter for the dependencies your AI agent picks — try starlog.dev ↗ a linter for agent deps ↗

Back to Articles

LLMmap: Fingerprinting Large Language Models Through Behavioral Analysis

[ View on GitHub ]

LLMmap: Fingerprinting Large Language Models Through Behavioral Analysis

Hook

When you send a prompt to an AI API, you're trusting the provider's claim about which model is answering. But what if they're lying? LLMmap can tell you the truth with just a handful of queries.

Context

The proliferation of LLM-powered APIs has created a trust problem. Vendors claim to use GPT-4, Claude, or other premium models, but you're often paying premium prices with no way to verify what's actually running behind the scenes. A provider could swap in a cheaper model, serve fine-tuned variants with different behaviors, or even switch models mid-contract without disclosure.

Traditional fingerprinting techniques don't translate well to LLMs. Unlike web servers that leak version information in headers, or databases with distinctive error messages, LLMs are designed to produce natural, varied outputs. You can't simply grep for a version string. This opacity isn't just a financial issue—it matters for compliance, security auditing, and reproducibility. If you're building systems that depend on specific model capabilities or behaviors, you need to know what you're actually talking to. LLMmap addresses this by treating model identification as a behavioral classification problem, analyzing how different models respond to carefully crafted prompts.

Technical Insight

LLMmap's core innovation is treating LLM identification as an open-set classification problem rather than forcing every unknown model into a known category. The system builds behavioral templates for each model by querying them with diverse prompt configurations and storing the resulting response patterns.

The architecture revolves around PyTorch-based neural networks that compute distance metrics between observed behaviors and known templates. When fingerprinting an unknown model, LLMmap sends a series of prompts, captures the responses, and compares them against its template database. If the distance to the nearest template exceeds a threshold, the system flags the model as unknown rather than misclassifying it.

Here's how you'd use LLMmap to fingerprint a model through the HuggingFace API:

import llmmap

# Initialize the fingerprinter with pre-trained templates
fingerprinter = llmmap.Fingerprinter(
    model_path="llmmap_pretrained.pt",
    backend="huggingface"
)

# Fingerprint a target model
result = fingerprinter.identify(
    model_name="meta-llama/Llama-2-7b-chat-hf",
    num_queries=20,  # Minimal queries needed
    confidence_threshold=0.85
)

print(f"Identified: {result.model_name}")
print(f"Confidence: {result.confidence}")
print(f"Distance to template: {result.distance}")

if result.is_unknown:
    print("Warning: Model does not match known templates")

The template extensibility is particularly clever. Unlike traditional machine learning classifiers that require complete retraining when adding new classes, LLMmap allows you to add new model templates to an existing fingerprinter without starting from scratch:

# Add a new model template to existing fingerprinter
fingerprinter.add_template(
    model_name="mistralai/Mistral-7B-Instruct-v0.2",
    num_samples=50,  # Queries to build template
    prompt_diversity="high"
)

# Save updated fingerprinter with new template
fingerprinter.save("llmmap_updated.pt")

The prompt diversity mechanism is where LLMmap's efficiency comes from. Rather than requiring thousands of queries, it uses strategically varied prompts that explore different behavioral dimensions: instruction following, reasoning patterns, output formatting preferences, and edge case handling. A model's unique combination of responses across these dimensions creates a distinctive signature.

Under the hood, the system likely uses embedding-based representations of responses, computing distances in a high-dimensional space where similar models cluster together. The open-set threshold acts as a radius around each template cluster—responses that fall outside all known radii are flagged as unknown. This design makes the system robust to new model releases and fine-tuned variants while maintaining low false-positive rates on known models.

The multi-backend support unifies fingerprinting across different providers. Whether you're querying OpenAI's API, Anthropic's Claude, or HuggingFace models, LLMmap presents a consistent interface. This is crucial for auditing scenarios where you might need to verify models across multiple vendors or compare claimed models against actual behaviors.

Gotcha

The v0.2 PyTorch implementation comes with an important caveat: it's not a one-to-one conversion of the original research implementation. The authors explicitly state that accuracy may differ from published results, which matters if you're relying on specific performance metrics from the original paper. You're essentially working with a reimplementation that prioritizes usability over research fidelity.

Template creation currently only supports HuggingFace models, even though fingerprinting works across multiple providers. This creates an asymmetry: you can identify OpenAI and Anthropic models if someone else has already created templates, but you can't easily build your own templates for proprietary models you want to track. For organizations that need to monitor custom or proprietary models, this is a significant limitation. The roadmap mentions multi-provider template support, but it's not available yet.

Fingerprinting accuracy degrades with fine-tuned models. If a provider has significantly customized a base model through fine-tuning, the behavioral signature may diverge enough that LLMmap either misidentifies it as the base model (false positive) or flags it as unknown (false negative). There's also no guidance on computational requirements—running fingerprinting in production environments with strict latency requirements may be problematic if template matching is computationally expensive. The repository doesn't provide benchmarks for query latency or memory footprint with large template databases.

Verdict

Use LLMmap if you're conducting security audits of LLM-powered services, need to verify vendor claims about which models they're serving, or want to detect unauthorized model substitutions in production systems. It's particularly valuable when you have black-box API access and need high-confidence identification with minimal queries—perfect for compliance scenarios or monitoring third-party integrations. The tool excels at identifying popular base models and their close variants across different providers. Skip LLMmap if you have direct access to model metadata or response headers that already identify the model reliably, if you're primarily working with heavily fine-tuned or custom models that won't match base templates, or if you need real-time identification with sub-second latency requirements in high-throughput environments. Also skip it if you need to create templates for proprietary models through OpenAI or Anthropic APIs—the template creation limitation means you're restricted to HuggingFace-accessible models for now.