Skip to content

feat(cache): ajouter cache sémantique SimHash avec distance de Hamming#147

Merged
Destynova2 merged 2 commits intodevelopfrom
feat/cache-simhash
Apr 11, 2026
Merged

feat(cache): ajouter cache sémantique SimHash avec distance de Hamming#147
Destynova2 merged 2 commits intodevelopfrom
feat/cache-simhash

Conversation

@Destynova2
Copy link
Copy Markdown
Contributor

Summary

  • Implémente un cache sémantique basé sur SimHash pour détecter les requêtes similaires
  • Utilise la distance de Hamming pour le matching flou
  • Éviction via moka (fix après DENY initial)

Test plan

  • Tests SimHash + Hamming distance
  • Fix eviction moka après deny
  • Sous-chef 3-lentilles APPROVE

🤖 Generated with Claude Code

commis-ci-fix and others added 2 commits April 11, 2026 14:38
Adds an in-memory SimHash-based semantic cache layer that detects
near-duplicate prompts via 64-bit fingerprints and Hamming distance
(default threshold ≤ 3 bits). The fuzzy layer is consulted before the
exact SHA-256 cache to improve hit rates for rephrased requests.

- src/cache/simhash.rs: normalize, compute, hamming_distance, SimHashCache
- Integrated into ResponseCache via get_with_simhash / put_with_simhash
- 16 new unit tests covering normalization, hashing, distance, and cache ops

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion

- Supprimer le tri lexicographique des tokens qui detruisait le sens
  semantique (ex: "translate English to French" = "translate French to
  English"). L'ordre est desormais preserve.
- Hasher chaque token avec sa position (hash_token_at) pour rendre le
  SimHash sensible a l'ordre des mots.
- Remplacer RwLock<HashMap> par moka::sync::Cache avec max_capacity et
  TTL built-in, alignant le cycle de vie sur le cache exact.
- Adapter response_cache.rs pour passer capacity/TTL au constructeur.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Destynova2 Destynova2 merged commit 5070460 into develop Apr 11, 2026
39 checks passed
@Destynova2 Destynova2 deleted the feat/cache-simhash branch April 11, 2026 12:52
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