1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
//! Python bindings for ELID using PyO3
//!
//! This module provides Python bindings for all ELID functions.
// PyO3 0.22 proc macros trigger false positive useless_conversion lints
// See: https://github.com/rust-lang/rust-clippy/issues/12039
use *;
// Conditional imports for embeddings feature
use crate;
use ;
use PyBytes;
/// Compute the Levenshtein distance between two strings.
///
/// Returns the minimum number of single-character edits needed to transform one string into another.
///
/// Args:
/// a (str): First string
/// b (str): Second string
///
/// Returns:
/// int: The Levenshtein distance
///
/// Example:
/// >>> import elid
/// >>> elid.levenshtein("kitten", "sitting")
/// 3
/// Compute the normalized Levenshtein similarity between two strings.
///
/// Returns a value between 0.0 (completely different) and 1.0 (identical).
///
/// Args:
/// a (str): First string
/// b (str): Second string
///
/// Returns:
/// float: Similarity score between 0.0 and 1.0
///
/// Example:
/// >>> import elid
/// >>> elid.normalized_levenshtein("hello", "hallo")
/// 0.8
/// Compute the Jaro similarity between two strings.
///
/// Returns a value between 0.0 (completely different) and 1.0 (identical).
/// Particularly effective for short strings like names.
///
/// Args:
/// a (str): First string
/// b (str): Second string
///
/// Returns:
/// float: Similarity score between 0.0 and 1.0
///
/// Example:
/// >>> import elid
/// >>> elid.jaro("martha", "marhta")
/// 0.944
/// Compute the Jaro-Winkler similarity between two strings.
///
/// Returns a value between 0.0 (completely different) and 1.0 (identical).
/// Gives more favorable ratings to strings with common prefixes.
///
/// Args:
/// a (str): First string
/// b (str): Second string
///
/// Returns:
/// float: Similarity score between 0.0 and 1.0
///
/// Example:
/// >>> import elid
/// >>> elid.jaro_winkler("martha", "marhta")
/// 0.961
/// Compute the Hamming distance between two strings.
///
/// Returns the number of positions at which the characters differ.
/// Returns None if strings have different lengths.
///
/// Args:
/// a (str): First string
/// b (str): Second string
///
/// Returns:
/// Optional[int]: Hamming distance or None if lengths differ
///
/// Example:
/// >>> import elid
/// >>> elid.hamming("karolin", "kathrin")
/// 3
/// >>> elid.hamming("hello", "world!") # Returns None
/// Compute the OSA (Optimal String Alignment) distance between two strings.
///
/// Similar to Levenshtein but also considers transpositions as a single operation.
///
/// Args:
/// a (str): First string
/// b (str): Second string
///
/// Returns:
/// int: OSA distance
///
/// Example:
/// >>> import elid
/// >>> elid.osa_distance("ca", "ac")
/// 1
/// Compute the best matching similarity between two strings.
///
/// Runs multiple algorithms and returns the highest score.
///
/// Args:
/// a (str): First string
/// b (str): Second string
///
/// Returns:
/// float: Best similarity score between 0.0 and 1.0
///
/// Example:
/// >>> import elid
/// >>> elid.best_match("hello", "hallo")
/// 0.8
/// Find the best match for a query string in a list of candidates.
///
/// Args:
/// query (str): Query string
/// candidates (List[str]): List of candidate strings
///
/// Returns:
/// dict: Dictionary with 'index' and 'score' keys
///
/// Example:
/// >>> import elid
/// >>> candidates = ["apple", "application", "apply"]
/// >>> result = elid.find_best_match("app", candidates)
/// >>> result
/// {'index': 0, 'score': 0.907}
/// Find all matches above a threshold score.
///
/// Args:
/// query (str): Query string
/// candidates (List[str]): List of candidate strings
/// threshold (float): Minimum similarity score (0.0 to 1.0)
///
/// Returns:
/// List[dict]: List of dictionaries with 'index' and 'score' keys
///
/// Example:
/// >>> import elid
/// >>> candidates = ["apple", "application", "apply", "banana"]
/// >>> matches = elid.find_matches_above_threshold("app", candidates, 0.5)
/// >>> matches
/// [{'index': 0, 'score': 0.907}, {'index': 1, 'score': 0.830}, ...]
/// Options for configuring string similarity algorithms.
///
/// Attributes:
/// case_sensitive (bool): Case-sensitive comparison (default: True)
/// trim_whitespace (bool): Trim whitespace before comparison (default: False)
/// prefix_scale (float): Prefix scale for Jaro-Winkler (default: 0.1, max: 0.25)
///
/// Example:
/// >>> import elid
/// >>> opts = elid.SimilarityOpts(case_sensitive=False, trim_whitespace=True)
/// >>> elid.levenshtein_with_opts(" HELLO ", "hello", opts)
/// 0
/// Compute Levenshtein distance with custom options.
///
/// Args:
/// a (str): First string
/// b (str): Second string
/// opts (SimilarityOpts): Configuration options
///
/// Returns:
/// int: Levenshtein distance
///
/// Example:
/// >>> import elid
/// >>> opts = elid.SimilarityOpts(case_sensitive=False, trim_whitespace=True)
/// >>> elid.levenshtein_with_opts(" HELLO ", "hello", opts)
/// 0
/// Compute the SimHash fingerprint of a string.
///
/// Returns a 64-bit integer hash where similar strings produce similar numbers.
/// Use this for database queries by storing the hash.
///
/// Args:
/// text (str): Input string
///
/// Returns:
/// int: 64-bit hash value
///
/// Example:
/// >>> import elid
/// >>> hash1 = elid.simhash("iPhone 14")
/// >>> hash2 = elid.simhash("iPhone 15")
/// >>> hash3 = elid.simhash("Galaxy S23")
/// >>> # hash1 and hash2 will be numerically close
/// >>> # hash3 will be different
/// Compute the Hamming distance between two SimHash values.
///
/// Returns the number of differing bits. Lower values indicate higher similarity.
///
/// Args:
/// hash1 (int): First SimHash value
/// hash2 (int): Second SimHash value
///
/// Returns:
/// int: Hamming distance (0-64)
///
/// Example:
/// >>> import elid
/// >>> hash1 = elid.simhash("iPhone 14")
/// >>> hash2 = elid.simhash("iPhone 15")
/// >>> distance = elid.simhash_distance(hash1, hash2)
/// >>> distance # Low number = similar
/// Compute the normalized SimHash similarity between two strings.
///
/// Returns a value between 0.0 (completely different) and 1.0 (identical).
///
/// Args:
/// a (str): First string
/// b (str): Second string
///
/// Returns:
/// float: Similarity score between 0.0 and 1.0
///
/// Example:
/// >>> import elid
/// >>> similarity = elid.simhash_similarity("iPhone 14", "iPhone 15")
/// >>> similarity # ~0.9 (very similar)
/// >>> similarity2 = elid.simhash_similarity("iPhone", "Galaxy")
/// >>> similarity2 # ~0.4 (different)
/// Find all hashes within a given distance threshold.
///
/// Args:
/// query_hash (int): The query SimHash value
/// candidate_hashes (List[int]): List of candidate SimHash values
/// max_distance (int): Maximum Hamming distance threshold
///
/// Returns:
/// List[int]: Indices of candidates within the distance threshold
///
/// Example:
/// >>> import elid
/// >>> candidates = ["iPhone 14 Pro", "iPhone 13", "Galaxy S23"]
/// >>> hashes = [elid.simhash(s) for s in candidates]
/// >>> query_hash = elid.simhash("iPhone 14")
/// >>> matches = elid.find_similar_hashes(query_hash, hashes, 10)
/// >>> matches # [0, 1] - indices of iPhone variants
// ============================================================================
// Embedding functions (feature-gated)
// ============================================================================
/// Encoding profile for embedding vectors.
///
/// Profiles determine how embeddings are transformed into compact identifiers.
///
/// Variants:
/// Mini128: 128-bit SimHash (default, fast cosine similarity via Hamming distance)
/// Morton10x10: Z-order curve encoding for database indexing
/// Hilbert10x10: Hilbert curve encoding for maximum locality preservation
///
/// Example:
/// >>> import elid
/// >>> profile = elid.Profile.Mini128
/// >>> elid_str = elid.encode(embedding, profile)
/// Encode an embedding vector to an ELID string.
///
/// Converts a high-dimensional embedding vector into a compact, sortable identifier
/// using the specified profile. The resulting ELID preserves locality properties
/// for efficient similarity search.
///
/// Args:
/// embedding (numpy.ndarray): Input vector (f32, 64-2048 dimensions)
/// profile (Profile): Encoding strategy (Mini128, Morton10x10, or Hilbert10x10)
///
/// Returns:
/// str: Encoded ELID string
///
/// Raises:
/// ValueError: If embedding dimensions are invalid or values contain NaN/Inf
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> embedding = np.random.randn(768).astype(np.float32)
/// >>> elid_str = elid.encode(embedding, elid.Profile.Mini128)
/// >>> print(elid_str) # e.g., "01a2b3c4d5e6f7g8h9i0..."
/// Decode an ELID string to raw bytes.
///
/// Decodes a base32hex-encoded ELID string back to its raw byte representation.
/// This returns the header bytes + payload bytes.
///
/// Args:
/// elid_str (str): The ELID string to decode
///
/// Returns:
/// bytes: Raw bytes (header + payload)
///
/// Raises:
/// ValueError: If the ELID string contains invalid characters
///
/// Example:
/// >>> import elid
/// >>> raw_bytes = elid.decode("01a2b3c4d5e6f7...")
/// >>> print(len(raw_bytes)) # 18 for Mini128 (2 header + 16 payload)
/// Compute Hamming distance between two ELID strings.
///
/// Returns the number of differing bits in the SimHash payloads of two ELIDs.
/// This distance is proportional to the angular distance between the original
/// embeddings. Both ELIDs must use the Mini128 profile.
///
/// Args:
/// elid1 (str): First ELID string
/// elid2 (str): Second ELID string
///
/// Returns:
/// int: Hamming distance (0-128)
///
/// Raises:
/// ValueError: If either ELID is invalid or uses a non-Mini128 profile
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> emb1 = np.random.randn(768).astype(np.float32)
/// >>> emb2 = emb1 + np.random.randn(768).astype(np.float32) * 0.1 # Similar
/// >>> elid1 = elid.encode(emb1, elid.Profile.Mini128)
/// >>> elid2 = elid.encode(emb2, elid.Profile.Mini128)
/// >>> distance = elid.elid_hamming_distance(elid1, elid2)
/// >>> print(f"Distance: {distance}") # Low number = similar embeddings
// ============================================================================
// FullVector Encoding Types and Functions (feature-gated)
// ============================================================================
/// Precision options for full vector encoding.
///
/// Controls how many bits are used to represent each dimension value.
/// Higher precision means more accurate reconstruction but larger output.
///
/// Variants:
/// Full32: Full 32-bit float (lossless, 4 bytes per dimension)
/// Half16: 16-bit half-precision float (2 bytes per dimension)
/// Quant8: 8-bit quantized (1 byte per dimension, ~1% error)
///
/// Example:
/// >>> import elid
/// >>> prec = elid.VectorPrecision.Full32 # Lossless
/// >>> prec = elid.VectorPrecision.Half16 # Good balance
/// >>> prec = elid.VectorPrecision.Quant8 # Smallest
/// Dimension handling mode for full vector encoding.
///
/// Controls whether to preserve original dimensions, reduce them,
/// or project to a common space for cross-dimensional comparison.
///
/// Variants:
/// Preserve: Keep all original dimensions (no projection)
/// Reduce: Reduce dimensions using random projection
/// Common: Project to common space for cross-dimensional comparison
///
/// Example:
/// >>> import elid
/// >>> mode = elid.DimensionMode.Preserve # Keep all dims
/// >>> mode = elid.DimensionMode.Reduce # Reduce for smaller output
/// >>> mode = elid.DimensionMode.Common # Cross-dimensional comparison
/// Encode an embedding using lossless full vector encoding.
///
/// Preserves the exact embedding values (32-bit float precision) and all dimensions.
/// This produces the largest output but allows exact reconstruction.
///
/// Args:
/// embedding (numpy.ndarray): Input vector (f32, 64-2048 dimensions)
///
/// Returns:
/// str: Encoded ELID string that can be decoded back to the original embedding
///
/// Raises:
/// ValueError: If embedding dimensions are invalid or values contain NaN/Inf
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> embedding = np.random.randn(768).astype(np.float32)
/// >>> elid_str = elid.encode_lossless(embedding)
/// >>> recovered = elid.decode_to_embedding(elid_str)
/// >>> np.allclose(embedding, recovered) # True
/// Encode an embedding with percentage-based compression.
///
/// The retention percentage (0.0-1.0) controls how much information is preserved:
/// - 1.0 = lossless (Full32 precision, all dimensions)
/// - 0.5 = half precision and/or half dimensions
/// - 0.25 = quarter precision and/or quarter dimensions
///
/// The algorithm optimizes for dimension reduction first (which preserves
/// more geometric relationships) before reducing precision.
///
/// Args:
/// embedding (numpy.ndarray): Input vector (f32, 64-2048 dimensions)
/// retention_pct (float): Information retention percentage (0.0-1.0)
///
/// Returns:
/// str: Encoded ELID string
///
/// Raises:
/// ValueError: If embedding dimensions are invalid or values contain NaN/Inf
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> embedding = np.random.randn(768).astype(np.float32)
/// >>> elid_50 = elid.encode_compressed(embedding, 0.5) # 50% retention
/// >>> elid_25 = elid.encode_compressed(embedding, 0.25) # 25% retention
/// >>> len(elid_25) < len(elid_50) # True (smaller output)
/// Encode an embedding with a maximum output string length constraint.
///
/// Calculates the optimal precision and dimension settings to fit within
/// the specified character limit while maximizing fidelity.
///
/// Args:
/// embedding (numpy.ndarray): Input vector (f32, 64-2048 dimensions)
/// max_chars (int): Maximum output string length in characters
///
/// Returns:
/// str: Encoded ELID string guaranteed to be <= max_chars in length
///
/// Raises:
/// ValueError: If embedding dimensions are invalid or values contain NaN/Inf
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> embedding = np.random.randn(768).astype(np.float32)
/// >>> elid_str = elid.encode_max_length(embedding, 100)
/// >>> len(elid_str) <= 100 # True
/// Decode an ELID string back to an embedding vector.
///
/// Only works for ELIDs encoded with a FullVector profile (lossless,
/// compressed, or max_length). Returns None for non-reversible profiles
/// like Mini128, Morton, or Hilbert.
///
/// Args:
/// elid_str (str): A valid ELID string (base32hex encoded)
///
/// Returns:
/// Optional[numpy.ndarray]: Decoded embedding as f32 array, or None if not reversible
///
/// Note:
/// If dimension reduction was used during encoding, the decoded embedding
/// will be in the reduced dimension space, not the original.
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> embedding = np.random.randn(768).astype(np.float32)
/// >>> elid_str = elid.encode_lossless(embedding)
/// >>> recovered = elid.decode_to_embedding(elid_str)
/// >>> recovered is not None # True
/// >>> np.allclose(embedding, recovered) # True
/// Check if an ELID can be decoded back to an embedding.
///
/// Returns True if the ELID was encoded with a FullVector profile
/// (lossless, compressed, or max_length), False otherwise.
///
/// Args:
/// elid_str (str): A valid ELID string (base32hex encoded)
///
/// Returns:
/// bool: True if decode_to_embedding will return an embedding
///
/// Raises:
/// ValueError: If the ELID string is invalid
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> embedding = np.random.randn(768).astype(np.float32)
/// >>>
/// >>> # Mini128 is NOT reversible
/// >>> mini_elid = elid.encode(embedding, elid.Profile.Mini128)
/// >>> elid.is_reversible(mini_elid) # False
/// >>>
/// >>> # Lossless IS reversible
/// >>> lossless_elid = elid.encode_lossless(embedding)
/// >>> elid.is_reversible(lossless_elid) # True
/// Encode an embedding for cross-dimensional comparison.
///
/// Projects the embedding to a common dimension space, allowing comparison
/// between embeddings of different original dimensions (e.g., 256d vs 768d).
///
/// Args:
/// embedding (numpy.ndarray): Input vector (f32, 64-2048 dimensions)
/// common_dims (int): Target dimension space (all vectors projected here)
///
/// Returns:
/// str: Encoded ELID string
///
/// Raises:
/// ValueError: If embedding dimensions are invalid or values contain NaN/Inf
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> # Different sized embeddings from different models
/// >>> emb_256 = np.random.randn(256).astype(np.float32)
/// >>> emb_768 = np.random.randn(768).astype(np.float32)
/// >>>
/// >>> # Project both to 128-dim common space
/// >>> elid1 = elid.encode_cross_dimensional(emb_256, 128)
/// >>> elid2 = elid.encode_cross_dimensional(emb_768, 128)
/// >>>
/// >>> # Now they can be compared directly
/// >>> dec1 = elid.decode_to_embedding(elid1)
/// >>> dec2 = elid.decode_to_embedding(elid2)
/// >>> dec1.shape == dec2.shape # True (both 128,)
/// Get metadata about a FullVector ELID.
///
/// Returns a dictionary containing information about how the ELID was encoded,
/// including original dimensions, precision, and dimension mode.
///
/// Args:
/// elid_str (str): A valid ELID string (base32hex encoded)
///
/// Returns:
/// Optional[dict]: Metadata dictionary with the following keys, or None if not FullVector:
/// - original_dims (int): Original embedding dimension count
/// - encoded_dims (int): Number of dimensions in encoded representation
/// - is_lossless (bool): Whether exact reconstruction is possible
/// - has_dimension_reduction (bool): Whether dimensions were reduced
/// - precision (str): "Full32", "Half16", "Quant8", or "Bits"
/// - precision_bits (int, optional): Bit count if precision is "Bits"
/// - dimension_mode (str): "Preserve", "Reduce", or "Common"
///
/// Raises:
/// ValueError: If the ELID string is invalid
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> embedding = np.random.randn(768).astype(np.float32)
/// >>> elid_str = elid.encode_compressed(embedding, 0.5)
/// >>> meta = elid.get_metadata(elid_str)
/// >>> print(meta['original_dims']) # 768
/// >>> print(meta['is_lossless']) # False
// ============================================================================
// Model functions (feature-gated)
// ============================================================================
/// Embed text using Model2Vec potion-base-8M model
///
/// Converts input text into a 256-dimensional embedding vector using
/// the Model2Vec potion-base-8M model. This is useful for semantic
/// text similarity, search, and clustering.
///
/// Args:
/// text (str): Input text to embed
///
/// Returns:
/// list[float]: 256-dimensional embedding as list of floats
///
/// Raises:
/// ValueError: If model not available or inference fails
///
/// Example:
/// >>> import elid
/// >>> embedding = elid.embed_text("Hello, world!")
/// >>> len(embedding)
/// 256
/// >>> type(embedding[0])
/// <class 'float'>
/// Embed image using MobileNetV3-Small model
///
/// Converts an image into a 1024-dimensional embedding vector using
/// the MobileNetV3-Small model. Supports JPEG and PNG formats.
/// This is useful for image similarity, search, and clustering.
///
/// Args:
/// image_bytes (bytes): Raw image bytes (JPEG or PNG)
///
/// Returns:
/// list[float]: 1024-dimensional embedding as list of floats
///
/// Raises:
/// ValueError: If model not available, image decode fails, or inference fails
///
/// Example:
/// >>> import elid
/// >>> with open("image.jpg", "rb") as f:
/// ... image_bytes = f.read()
/// >>> embedding = elid.embed_image(image_bytes)
/// >>> len(embedding)
/// 1024
/// >>> type(embedding[0])
/// <class 'float'>
// ============================================================================
// LSH Band functions (feature-gated)
// ============================================================================
/// Generate LSH bands from an embedding for database querying
///
/// Computes a 128-bit SimHash of the embedding and splits it into
/// `num_bands` equal parts, each encoded as a base32hex string.
/// Band matching is used for efficient approximate nearest neighbor
/// search: if two embeddings share at least one identical band,
/// they are likely similar.
///
/// Args:
/// embedding (list[float]): Embedding vector as list of floats
/// num_bands (int): Number of bands (1, 2, 4, 8, or 16). Default: 4
/// seed (int, optional): Seed for SimHash generation. Default: 0x454c494453494d48
///
/// Returns:
/// list[str]: List of base32hex band strings
///
/// Band Sizes:
/// | num_bands | bits/band | chars/band |
/// |-----------|-----------|------------|
/// | 1 | 128 | 26 |
/// | 2 | 64 | 13 |
/// | 4 | 32 | 7 |
/// | 8 | 16 | 4 |
/// | 16 | 8 | 2 |
///
/// Example:
/// >>> import elid
/// >>> import numpy as np
/// >>> embedding = np.random.randn(768).astype(np.float32).tolist()
/// >>> bands = elid.embedding_to_bands(embedding, num_bands=4)
/// >>> len(bands)
/// 4
/// >>> len(bands[0]) # 32 bits = 4 bytes = 7 base32hex chars
/// 7
///
/// Database Usage:
/// Store each band in an indexed column for efficient querying:
/// ```sql
/// CREATE INDEX idx_band0 ON embeddings(band0);
/// -- Query for similar embeddings
/// SELECT * FROM embeddings
/// WHERE band0 = ? OR band1 = ? OR band2 = ? OR band3 = ?;
/// ```
/// ELID - Efficient Levenshtein and String Similarity Library
///
/// A fast library for computing various string similarity metrics.