Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Validates equivalence between LiteRT models (litert_lm) and PyTorch models (transformers). Use when you need to verify that an exported LiteRT model produces the same outputs as the original Hugging Face model. Supports multi-turn conversations and custom prompts.
.claude/skills/google-ai-edge-litert-model-equivalence-test/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-12 | ✗→✓ | ▲ Improved | -35% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -12% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -54% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -21% | 0% |
| case-04 | ✗→✓ | ▲ Improved | -9% | 0% |
This skill provides instructions for running equivalence tests between LiteRT models and their PyTorch source models.
Use the equivalence_test script to compare the outputs of a Hugging Face model and its exported LiteRT version.
Run the test using bazel run from your workspace:
bashbazel run \ //third_party/py/litert_torch/generative/export_hf/experimental/validation:equivalence_test \ -- \ --model_id={model_id} \ [--prompt={prompt}] \ [--prompt_file={prompt_file}] \ [--max_new_tokens={max_new_tokens}] \ [--max_num_tokens={max_num_tokens}] \ [--work_dir={work_dir}] \ [--externalize_embedder] \ [--single_token_embedder] \ [--split_cache] \ [--backend={backend}]
--model_id: The Hugging Face model ID to validate (e.g.,google/gemma-3-270m-it).
--prompt: Prompt to test. Specify multiple times for multi-turnconversations.
--prompt_file: Path to a file containing one (complex) prompt. Overrides--prompt.
--max_new_tokens: Maximum new tokens to generate per turn (default: 20).--max_num_tokens: KV cache length for the model (default: 2048).--work_dir: Base directory for model export. If not specified, atemporary directory under HOME is used.
--externalize_embedder: Externalize the embedder during export (default:False).
--single_token_embedder: Use single token embedder during export (default:False).
--split_cache: Split KV cache during export (default: False).--backend: Hardware backend to use for LiteRT LM (cpu | npu, default:cpu).
bashbazel run \ //third_party/py/litert_torch/generative/export_hf/experimental/validation:equivalence_test \ -- \ --model_id=google/gemma-3-270m-it \ --prompt="What is the capital of France?"
bashbazel run \ //third_party/py/litert_torch/generative/export_hf/experimental/validation:equivalence_test \ -- \ --model_id=google/gemma-3-270m-it \ --prompt="What's the capital of France?" \ --prompt="How about Germany?"
bashbazel run \ //third_party/py/litert_torch/generative/export_hf/experimental/validation:equivalence_test \ -- \ --model_id=google/gemma-3-270m-it \ --prompt_file=/path/to/prompts.txt
bashbazel run \ //third_party/py/litert_torch/generative/export_hf/experimental/validation:equivalence_test \ -- \ --model_id=google/gemma-3-270m-it \ --externalize_embedder \ --single_token_embedder
bashbazel run \ //third_party/py/litert_torch/generative/export_hf/experimental/validation:equivalence_test \ -- \ --model_id=google/gemma-3-270m-it \ --externalize_embedder \ --split_cache \ --backend=npu
Other measured skills in the registry, with their headline benchmark lift.