Files
LEANN/benchmarks
Andy Lee 0d448c4a41 docs: config guidance (#17)
* docs: config guidance

* feat: add comprehensive configuration guide and update README

- Create docs/configuration-guide.md with detailed guidance on:
  - Embedding model selection (small/medium/large)
  - Index selection (HNSW vs DiskANN)
  - LLM engine and model comparison
  - Parameter tuning (build/search complexity, top-k)
  - Performance optimization tips
  - Deep dive into LEANN's recomputation feature
- Update README.md to link to the configuration guide
- Include latest 2025 model recommendations (Qwen3, DeepSeek-R1, O3-mini)

* chore: move evaluation data .gitattributes to correct location

* docs: Weaken DiskANN emphasis in README

- Change backend description to emphasize HNSW as default
- DiskANN positioned as optional for billion-scale datasets
- Simplify evaluation commands to be more generic

* docs: Adjust DiskANN positioning in features and roadmap

- features.md: Put HNSW/FAISS first as default, DiskANN as optional
- roadmap.md: Reorder to show HNSW integration before DiskANN
- Consistent with positioning DiskANN as advanced option for large-scale use

* docs: Improve configuration guide based on feedback

- List specific files in default data/ directory (2 AI papers, literature, tech report)
- Update examples to use English and better RAG-suitable queries
- Change full dataset reference to use --max-items -1
- Adjust small model guidance about upgrading to larger models when time allows
- Update top-k defaults to reflect actual default of 20
- Ensure consistent use of full model name Qwen/Qwen3-Embedding-0.6B
- Reorder optimization steps, move MLX to third position
- Remove incorrect chunk size tuning guidance
- Change README from 'Having trouble' to 'Need best practices'

* docs: Address all configuration guide feedback

- Fix grammar: 'If time is not a constraint' instead of 'time expense is not large'
- Highlight Qwen3-Embedding-0.6B performance (nearly OpenAI API level)
- Add OpenAI quick start section with configuration example
- Fold Cloud vs Local trade-offs into collapsible section
- Update HNSW as 'default and recommended for extreme low storage'
- Add DiskANN beta warning and explain PQ+rerank architecture
- Expand Ollama models: add qwen3:0.6b, 4b, 7b variants
- Note OpenAI as current default but recommend Ollama switch
- Add 'need to install extra software' warning for Ollama
- Remove incorrect latency numbers from search-complexity recommendations

* docs: add a link
2025-08-04 22:50:32 -07:00
..
2025-08-04 22:50:32 -07:00

🧪 Leann Sanity Checks

This directory contains comprehensive sanity checks for the Leann system, ensuring all components work correctly across different configurations.

📁 Test Files

test_distance_functions.py

Tests all supported distance functions across DiskANN backend:

  • MIPS (Maximum Inner Product Search)
  • L2 (Euclidean Distance)
  • Cosine (Cosine Similarity)
uv run python tests/sanity_checks/test_distance_functions.py

test_l2_verification.py

Specifically verifies that L2 distance is correctly implemented by:

  • Building indices with L2 vs Cosine metrics
  • Comparing search results and score ranges
  • Validating that different metrics produce expected score patterns
uv run python tests/sanity_checks/test_l2_verification.py

test_sanity_check.py

Comprehensive end-to-end verification including:

  • Distance function testing
  • Embedding model compatibility
  • Search result correctness validation
  • Backend integration testing
uv run python tests/sanity_checks/test_sanity_check.py

🎯 What These Tests Verify

Distance Function Support

  • All three distance metrics (MIPS, L2, Cosine) work correctly
  • Score ranges are appropriate for each metric type
  • Different metrics can produce different rankings (as expected)

Backend Integration

  • DiskANN backend properly initializes and builds indices
  • Graph construction completes without errors
  • Search operations return valid results

Embedding Pipeline

  • Real-time embedding computation works
  • Multiple embedding models are supported
  • ZMQ server communication functions correctly

End-to-End Functionality

  • Index building → searching → result retrieval pipeline
  • Metadata preservation through the entire flow
  • Error handling and graceful degradation

🔍 Expected Output

When all tests pass, you should see:

📊 测试结果总结:
  mips      : ✅ 通过
  l2        : ✅ 通过
  cosine    : ✅ 通过

🎉 测试完成!

🐛 Troubleshooting

Common Issues

Import Errors: Ensure you're running from the project root:

cd /path/to/leann
uv run python tests/sanity_checks/test_distance_functions.py

Memory Issues: Reduce graph complexity for resource-constrained systems:

builder = LeannBuilder(
    backend_name="diskann",
    graph_degree=8,  # Reduced from 16
    complexity=16    # Reduced from 32
)

ZMQ Port Conflicts: The tests use different ports to avoid conflicts, but you may need to kill existing processes:

pkill -f "embedding_server"

📊 Performance Expectations

Typical Timing (3 documents, consumer hardware):

  • Index Building: 2-5 seconds per distance function
  • Search Query: 50-200ms
  • Recompute Mode: 5-15 seconds (higher accuracy)

Memory Usage:

  • Index Storage: ~1-2 MB per distance function
  • Runtime Memory: ~500MB (including model loading)

🔗 Integration with CI/CD

These tests are designed to be run in automated environments:

# GitHub Actions example
- name: Run Sanity Checks
  run: |
    uv run python tests/sanity_checks/test_distance_functions.py
    uv run python tests/sanity_checks/test_l2_verification.py

The tests are deterministic and should produce consistent results across different platforms.