Skip to content

Configuration

Configuration options for HNSW index.

Attributes:

Name Type Description
max_connections int

Maximum connections per node (M parameter). Higher = better recall, more memory. Default: 16

ef_construction int

Construction quality parameter. Higher = better index quality, slower build. Default: 200

ef_search int

Search quality parameter. Higher = better search quality, slower search. Default: 50

Source code in chassis/index.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@dataclass
class IndexOptions:
    """Configuration options for HNSW index.

    Attributes:
        max_connections: Maximum connections per node (M parameter).
            Higher = better recall, more memory. Default: 16
        ef_construction: Construction quality parameter.
            Higher = better index quality, slower build. Default: 200
        ef_search: Search quality parameter.
            Higher = better search quality, slower search. Default: 50
    """

    max_connections: int = 16
    ef_construction: int = 200
    ef_search: int = 50

    def validate(self) -> None:
        """Validate configuration parameters.

        Raises:
            ValueError: If parameters are out of valid ranges
        """
        if not 1 <= self.max_connections <= 65535:
            raise ValueError(
                f"max_connections must be 1-65535, got {self.max_connections}"
            )
        if self.ef_construction < 1:
            raise ValueError(
                f"ef_construction must be >= 1, got {self.ef_construction}"
            )
        if self.ef_search < 1:
            raise ValueError(f"ef_search must be >= 1, got {self.ef_search}")

validate()

Validate configuration parameters.

Raises:

Type Description
ValueError

If parameters are out of valid ranges

Source code in chassis/index.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def validate(self) -> None:
    """Validate configuration parameters.

    Raises:
        ValueError: If parameters are out of valid ranges
    """
    if not 1 <= self.max_connections <= 65535:
        raise ValueError(
            f"max_connections must be 1-65535, got {self.max_connections}"
        )
    if self.ef_construction < 1:
        raise ValueError(
            f"ef_construction must be >= 1, got {self.ef_construction}"
        )
    if self.ef_search < 1:
        raise ValueError(f"ef_search must be >= 1, got {self.ef_search}")

A single search result.

Attributes:

Name Type Description
id int

Vector ID in the index

distance float

Distance to the query vector (lower is closer)

Source code in chassis/index.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@dataclass
class SearchResult:
    """A single search result.

    Attributes:
        id: Vector ID in the index
        distance: Distance to the query vector (lower is closer)
    """

    id: int
    distance: float

    def __repr__(self) -> str:
        return f"SearchResult(id={self.id}, distance={self.distance:.6f})"