Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
Hướng nghiên cứu
Bắt đầu trong python/semantic_kernel/memory/volatile_memory_store.py bằng cách so sánh get_batch và get_nearest_matches với phần triển khai get đang hoạt động. Chạy bản tái hiện được cung cấp để quan sát các embedding được trả về và được lưu trữ, sau đó thêm các kiểm thử tập trung cho cả hai phương thức. Hoàn tất khi các bản sao được trả về bỏ qua embedding khi with_embeddings là false, trong khi các bản ghi được lưu trữ vẫn giữ chúng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happens
VolatileMemoryStore.get_batch and get_nearest_matches take a flag (with_embeddings) that is documented as "Whether to include the embeddings in the results". With the flag False (the default) the embeddings are still returned. The code makes a deepcopy and clears the embedding on the copy, but the loop variable is rebound and the copy is thrown away, so the original records are returned unchanged.
get (the single-record version) does this correctly, which shows the intended behavior.
Where
python/semantic_kernel/memory/volatile_memory_store.py on current main.
get_batch:
if not with_embeddings:
# create copy of results without embeddings
for result in results:
result = deepcopy(result)
result._embedding = None
return results
get_nearest_matches:
if not with_embeddings:
# create copy of results without embeddings
for result in top_results:
result = deepcopy(result)
result[0]._embedding = None
return top_results
In the second case deepcopy(result) copies the (record, score) tuple, and the copy is dropped. Note that a naive fix of removing the deepcopy would clear the embedding on the stored record itself, so the fix has to return copies.
Reproduce
import asyncio, numpy as np
from semantic_kernel.memory.volatile_memory_store import VolatileMemoryStore
from semantic_kernel.memory.memory_record import MemoryRecord
async def main():
s = VolatileMemoryStore()
await s.create_collection("c")
await s.upsert("c", MemoryRecord.local_record("id1", "text", "desc", None, np.array([1.0, 0.0])))
ms = await s.get_nearest_matches("c", np.array([1.0, 0.0]), limit=1)
print("get_nearest_matches:", ms[0][0]._embedding)
b = await s.get_batch("c", ["id1"])
print("get_batch:", b[0]._embedding)
g = await s.get("c", "id1")
print("get:", g._embedding)
asyncio.run(main())
Output on semantic-kernel main (also 1.44.1):
get_nearest_matches: [1. 0.]
get_batch: [1. 0.]
get: None
Expected
All three return None for the embedding when the embeddings flag is False, and the stored records keep their embeddings. I am happy to send a fix with tests.
- Ngôn ngữ chính
- C#
- Star
- 28.7k
- Fork
- 4.8k
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/semantic-kernel
-
Python: Bug: Anthropic, Bedrock, Google AI and Vertex AI tool formatters ignore include_in_function_choices=FalseCó thể đã có người làm @wasim-builds đã nhận 4 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microsoft/semantic-kernel#14615 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Python: Bug: AnnotationContent and StreamingAnnotationContent to_element writes CitationType.X, so annotations in a rendered chat history fail to parseCó thể đã có người làm @CRYPTONIKAV đã nhận 7 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/semantic-kernel#14590 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Python: Bug: TimePlugin timeZoneOffset and timeZoneName always return an empty stringCó thể đã có người làm @jeevan1098 đã nhận 6 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
microsoft/semantic-kernel#14583 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23Có thể đã có người làm @nightcityblade đã nhận 18 ngày trước. Đang mở.NET triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
microsoft/semantic-kernel#14526 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Python: VolatileMemoryStore.get_nearest_match returns an un-awaited coroutine instead of a (MemoryRecord, score) tupleCó thể đã có người làm @VANDRANKI đã nhận 19 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
microsoft/semantic-kernel#14521 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của microsoft/semantic-kernel
Issue tương tự
-
/api/oauth/introspect emits clientId and tokenType instead of RFC 7662's client_id and token_typeĐang mởbug P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nightscout/nocturne#2317 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG]: Position intent set on a simple order is dropped when it becomes a bracket, OCO or OTO orderCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
alpacahq/alpaca-trade-api-csharp#903 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
joinrpg/joinrpg-net#5752 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CodeForFire/lagebuch#714 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
dimitar-radenkov/Pointframe#294 ·
Maintainer thường phản hồi trong vòng 1 ngày