Skip to content

feat(feedback): enrich ChromaFeedbackStore with torchembed metadata embeddings#52

Open
py-ai-dev wants to merge 1 commit into
future-agi:mainfrom
py-ai-dev:feat/torchembed-feedback-metadata
Open

feat(feedback): enrich ChromaFeedbackStore with torchembed metadata embeddings#52
py-ai-dev wants to merge 1 commit into
future-agi:mainfrom
py-ai-dev:feat/torchembed-feedback-metadata

Conversation

@py-ai-dev

Copy link
Copy Markdown

Summary

  • Adds opt-in metadata enrichment to ChromaFeedbackStore using torchembed, a PyTorch embedding library integrated into DeepSpeed
  • When enrich_with_metadata=True, numerical and temporal fields from FeedbackEntry (scores + timestamps) are encoded into a dense vector and appended to the stored document, giving retrieval a joint signal over semantic content and score proximity / recency
  • Zero impact on existing users — new flag defaults to False, new [feedback-torch] optional extra

Motivation

ChromaFeedbackStore currently embeds only the text of FeedbackEntry.to_embedding_text(). For calibration workflows this means two entries with identical text but opposite scores (one human-corrected to 0.1, another to 0.9) are indistinguishable at retrieval time. Adding score and temporal context via torchembed's GaussianFourierProjection (scores) and CyclicEmbedding (hour/weekday) closes this gap.

New API

from fi.evals.feedback.store import ChromaFeedbackStore

# Existing behaviour unchanged
store = ChromaFeedbackStore(persist_directory="./chroma")

# New: encode score + timestamp metadata alongside text
store = ChromaFeedbackStore(
    persist_directory="./chroma",
    enrich_with_metadata=True,   # requires pip install ai-evaluation[feedback-torch]
    metadata_weight=0.3,
)

New extra

pip install ai-evaluation[feedback-torch]
# installs: chromadb + torchembed + torch

Files changed

File Change
python/fi/evals/feedback/torchembed_encoder.py New — FeedbackMetadataEncoder + make_enriched_document
python/fi/evals/feedback/store.py Add enrich_with_metadata / metadata_weight params to ChromaFeedbackStore
python/pyproject.toml Add feedback-torch optional extra; add torchembed to all
python/tests/evals/test_torchembed_encoder.py New — 8 unit tests, all passing

Test plan

  • pytest python/tests/evals/test_torchembed_encoder.py — 8/8 pass
  • Verify ChromaFeedbackStore(enrich_with_metadata=False) (default) is unaffected
  • Smoke-test ChromaFeedbackStore(enrich_with_metadata=True) with a live ChromaDB instance

🤖 Generated with Claude Code

…mbeddings

ChromaFeedbackStore now accepts enrich_with_metadata=True (opt-in, off by
default). When torchembed is installed, numerical and temporal fields from
each FeedbackEntry — original_score, correct_score, created_at hour and
weekday — are encoded into a dense vector and appended to the stored document
string. This gives the ChromaDB retrieval index a weak joint signal over
both semantic content and score / time proximity, improving few-shot example
retrieval for calibration workflows.

New components:
- fi/evals/feedback/torchembed_encoder.py — FeedbackMetadataEncoder using
  GaussianFourierProjection (scores) and CyclicEmbedding (hour/weekday)
- tests/evals/test_torchembed_encoder.py — 8 unit tests (all passing)

Opt-in via new pyproject.toml extra:
  pip install ai-evaluation[feedback-torch]

No changes to the default ChromaFeedbackStore behaviour; existing users are
unaffected. torchembed is a zero-dependency PyTorch embedding library
(https://github.com/liodon-ai/torchembed) integrated into DeepSpeed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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