Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
22f4692
Add payload codec system to plug into storage wrappers
edwinyyyu Apr 22, 2026
a7fa468
Define APIs and models for new episodic memory
edwinyyyu Mar 6, 2026
53a75ff
Add recursive text chunking
edwinyyyu Mar 9, 2026
1a301a2
Add derivative consolidation
edwinyyyu Mar 9, 2026
50a481e
Rename some occurrences of session to partition to reflect semantics
edwinyyyu Mar 10, 2026
a549726
Simplify Episode and Segment models
edwinyyyu Mar 10, 2026
e4a35cc
Update SegmentLinker API
edwinyyyu Mar 10, 2026
c782007
Add background purge
edwinyyyu Mar 11, 2026
766db37
Redesign multimodal
edwinyyyu Mar 12, 2026
60fbc21
Support updated VectorStore API
edwinyyyu Mar 13, 2026
618f9ae
Use handles for partitions
edwinyyyu Mar 14, 2026
fb4870c
Fix vector query result type
edwinyyyu Mar 14, 2026
96d3f7e
Fix segment context zipping
edwinyyyu Mar 14, 2026
002dcef
Preserve order with no reranker
edwinyyyu Mar 16, 2026
26d2d06
Memory no longer knows about partition keys
edwinyyyu Mar 17, 2026
41f1667
Specify return types
edwinyyyu Mar 18, 2026
98f79ac
Fix purge logic
edwinyyyu Mar 19, 2026
4366236
Simplify SegmentLinkerPartition lifecycle
edwinyyyu Mar 19, 2026
b2c134d
Increase default purge limits
edwinyyyu Mar 20, 2026
77d9178
Add back startup/shutdown for partition
edwinyyyu Mar 20, 2026
9fd3031
Fix comment
edwinyyyu Mar 23, 2026
11167dd
Simplify APIs and use exact deduplication
edwinyyyu Mar 25, 2026
ebd5ac3
Make deduplication default False to support native vector DB filtering
edwinyyyu Mar 27, 2026
a7cf328
Simplify and rename
edwinyyyu Mar 30, 2026
8d29947
Update filtering
edwinyyyu Apr 2, 2026
f229f08
Remove unused utilities
edwinyyyu Apr 3, 2026
d950df8
Rename memory
edwinyyyu Apr 3, 2026
152ac73
Update partition lifecycle
edwinyyyu Apr 3, 2026
f71044c
Add options for timezone formatting
edwinyyyu Apr 3, 2026
7068d59
Add serialization and deserialization to data models
edwinyyyu Apr 6, 2026
9cc6d17
Renamed vector store Collection
edwinyyyu Apr 6, 2026
81e40b7
Prepare for wiring
edwinyyyu Apr 7, 2026
a451b1b
Add missing stuff
edwinyyyu Apr 7, 2026
6bc2d8d
Add naming rules for partitions
edwinyyyu Apr 7, 2026
81ef9a7
Add memory unit tests
edwinyyyu Apr 8, 2026
abb678f
Add derivative eviction logic
edwinyyyu Apr 9, 2026
b307f8e
Review and fix eviction logic
edwinyyyu Apr 9, 2026
57c2f00
Allow external system-defined fields and specify Context field types
edwinyyyu Apr 14, 2026
bd18b73
Improve timestamp formatting, logging
edwinyyyu Apr 14, 2026
12a3098
Decouple date and time formats
edwinyyyu Apr 14, 2026
20d5d4a
Add more methods for formatting context
edwinyyyu Apr 17, 2026
41f2fc1
Context fields may expose sensitive information if used in filtering
edwinyyyu Apr 22, 2026
0789622
Add NullContext
edwinyyyu Apr 22, 2026
a2e278e
Support encryption infrastructure
edwinyyyu Apr 23, 2026
36a14d8
Remove eviction system for simpler PR
edwinyyyu Apr 27, 2026
3abd691
Reduce default max text chunk length for easier context tuning
edwinyyyu Apr 27, 2026
e35d4d6
Remove encryption from test
edwinyyyu Apr 28, 2026
42589a5
Don't ensure ASCII in LLM-visible JSON strings
edwinyyyu Apr 28, 2026
7aa97c6
Remove unimplemented Block and Body types
edwinyyyu Apr 28, 2026
031c488
Fix rebase
edwinyyyu Apr 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unused utilities
Signed-off-by: Edwin Yu <[email protected]>
  • Loading branch information
edwinyyyu committed May 4, 2026
commit f229f08f39efda762017aae46a976324e6d29668
95 changes: 0 additions & 95 deletions packages/server/src/memmachine_server/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
from datetime import UTC, datetime
from typing import Any, ParamSpec, TypeVar, cast

import numpy as np
from nltk import sent_tokenize

from .data_types import SimilarityMetric

T = TypeVar("T")
P = ParamSpec("P")

Expand Down Expand Up @@ -272,95 +269,3 @@ def cluster_texts(
clusters.append(current_cluster)

return clusters


def compute_similarity(
query_embedding: list[float],
candidate_embeddings: list[list[float]],
similarity_metric: SimilarityMetric | None = None,
) -> list[float]:
"""
Compute similarity scores between a query embedding and candidate embeddings.

Args:
query_embedding (list[float]): The embedding of the query.
candidate_embeddings (list[list[float]]): A list of candidate embeddings to compare against.
similarity_metric (SimilarityMetric | None): The similarity metric to use (default: None).

Returns:
list[float]: A list of similarity scores for each candidate embedding.

"""
if not candidate_embeddings:
return []

query_embedding_np = np.array(query_embedding)
candidate_embeddings_np = np.array(candidate_embeddings)

match similarity_metric:
case SimilarityMetric.COSINE:
magnitude_products = np.linalg.norm(
candidate_embeddings_np,
axis=-1,
) * np.linalg.norm(query_embedding_np)
magnitude_products[magnitude_products == 0] = float("inf")

scores = (
np.dot(candidate_embeddings_np, query_embedding_np) / magnitude_products
)
case SimilarityMetric.DOT:
scores = np.dot(candidate_embeddings_np, query_embedding_np)
case SimilarityMetric.EUCLIDEAN:
scores = np.linalg.norm(
candidate_embeddings_np - query_embedding_np,
axis=-1,
)
case SimilarityMetric.MANHATTAN:
scores = np.sum(
np.abs(candidate_embeddings_np - query_embedding_np),
axis=-1,
)
case _:
# Default to cosine similarity.
magnitude_products = np.linalg.norm(
candidate_embeddings_np,
axis=-1,
) * np.linalg.norm(query_embedding_np)
magnitude_products[magnitude_products == 0] = float("inf")

scores = (
np.dot(candidate_embeddings_np, query_embedding_np) / magnitude_products
)

return scores.astype(float).tolist()


def similarity_gt(
similarity_metric: SimilarityMetric | None = None,
) -> Callable[[float, float], bool]:
"""
Return a comparator for similarity scores.

The returned function `gt(a, b)` returns True when score `a`
represents greater similarity than score `b` under the given metric.

For COSINE and DOT, higher scores mean greater similarity (`a > b`).
For EUCLIDEAN and MANHATTAN, lower scores mean greater similarity (`a < b`).

Args:
similarity_metric (SimilarityMetric | None):
The similarity metric.
If None, defaults to greater-than comparison (`a > b`)
(default: None).

Returns:
Callable[[float, float], bool]: A comparator for similarity scores.

"""
import operator

match similarity_metric:
case SimilarityMetric.EUCLIDEAN | SimilarityMetric.MANHATTAN:
return operator.lt
case _:
return operator.gt