Skip to content

Conversation

@wgergely
Copy link

@wgergely wgergely commented Jan 7, 2026

PR Update Draft - Leann GPU Backend & Metadata Enrichment

This update builds upon the initial FAISS GPU support by adding robust metadata extraction and stabilizing the environment for production use.

What's New?

1. Metadata-Rich Indexing (Context Headers)

We’ve added a CodeAnalyzer that uses tree-sitter to extract global context from files. Every code chunk now includes a "Context Header" prepended to its text:

  • Module Skeletons: High-level outlines of classes and functions (signatures + docstrings).
  • Logical Imports: Project-relative import tracking ("5 paths") to help LLMs understand dependencies.
  • Entry point detection: Identifying main modules automatically.

2. FAISS Stability (ZMQ Fixes)

To prevent ZMQ deadlocks observed in high-concurrency scenarios, we've implemented an in-process embedding strategy for the FAISS backend. Search operations now compute query embeddings within the same process by default.

3. MCP Protocol v2025 Upgrade

Standardized the codebase to support the latest MCP protocol version (2025-11-25).

4. Better Environment Control

Standardized LEANN_HOME and LEANN_DOCS handling across CLI and Server modules. The system now strictly respects these environment variables if provided.


⚠️ Breaking Changes & Notes

  • Model Loading: Default embedding model loading now includes trust_remote_code=True to support nomic-embed-text-v1.5 out of the box.
  • New Dependencies: Added tree-sitter (0.23+) and gitignore-parser to core requirements.
  • Python parallelization: Parallel tokenization now uses ProcessPoolExecutor for true CPU parallelism.

Verification

Full test suite passed, including new integration tests for the FAISS ZMQ server and metadata analyzer.

…ding computation

- Force use_server=False to prevent ZMQ connection issues
- Add explicit logger for better debugging
- Improve code structure and comments
Implements a standalone embedding server for the FAISS backend to prevent ZMQ deadlocks that occur when mixing direct embedding computation (build) and server-based computation (search).

- Adds faiss_embedding_server.py: Specialized server reusing leann-core logic.

- Updates __init__.py: Exports and registers the new server module.
Adds:

- gitignore-parser: For robust .gitignore handling in the CLI.

- einops: Required for nomic-embed-text-v1.5 custom implementation.
- api.py: Explicitly separate server-mode (search) vs direct-mode (build) to ensure stability.

- embedding_compute.py: Add parallel tokenization, adaptive batch sizing, and support for nomic-embed-text-v1.5.

- tests: Add token truncation tests.
- Add gitignore-parser integration for correct file exclusion.

- Add suppress_cpp_output context manager to silence noisy FAISS/HNSW backend logs.

- Add code-optimized SentenceSplitter configuration.
- metadata_filter.py: Implements comprehensive filtering (comparison, membership, string, boolean) for search results.

- tests: Add test suite for metadata filtering logic.
@wgergely
Copy link
Author

wgergely commented Jan 8, 2026

Successfully updated the PR with the latest stabilization fixes, metadata enrichment, and MCP protocol v2025 updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant