From 313718fa6ae913b959d0262c74247022c6918ea1 Mon Sep 17 00:00:00 2001 From: iridescentpeo Date: Fri, 21 Mar 2025 15:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E4=B8=80=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E8=A2=AB=E5=A4=9A=E4=B8=AA=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E6=97=B6:=201.=E6=B5=85=E6=8B=B7=E8=B4=9D?= =?UTF-8?q?=E5=AF=BC=E8=87=B4meta=E4=B8=ADmap=E7=9A=84=E5=85=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A2=AB=E6=9B=B4=E6=94=B9=EF=BC=8C=E6=96=B0=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E9=80=9A=E8=BF=87copy=E5=90=8E=E5=9B=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86key=E5=B7=B2=E5=AD=98=E5=9C=A8=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=85=B6=E4=BD=99=E6=95=B0=E6=8D=AE=E9=9B=86id?= =?UTF-8?q?=E6=9C=AA=E8=83=BD=E6=AD=A3=E7=A1=AE=E5=88=9B=E5=BB=BA=E3=80=82?= =?UTF-8?q?=202.=E5=9B=A0=E4=B8=BAcopy=E7=9B=B8=E4=BC=BC=E5=BA=A6=E5=80=BC?= =?UTF-8?q?=E7=9B=B8=E7=AD=89=EF=BC=8C=E5=B0=8F=E4=BA=8E=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E4=BC=9A=E5=AF=BC=E8=87=B4=E4=B8=8D=E5=90=8C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86id=E7=9A=84=E5=AF=B9=E8=B1=A1=E8=A2=AB=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=EF=BC=8C=E6=94=B9=E4=B8=BA=E5=B0=8F=E4=BA=8E=E7=AD=89?= =?UTF-8?q?=E4=BA=8E=E9=98=B2=E6=AD=A2=E4=B8=8D=E5=90=8C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86Id=E7=9A=84EmbeddingResult=E8=A2=AB=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supersonic/headless/chat/knowledge/MapResult.java | 5 +++++ .../headless/chat/knowledge/MetaEmbeddingService.java | 2 ++ .../supersonic/headless/chat/mapper/BaseMatchStrategy.java | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/knowledge/MapResult.java b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/knowledge/MapResult.java index a2583eb88..969a74eca 100644 --- a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/knowledge/MapResult.java +++ b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/knowledge/MapResult.java @@ -22,4 +22,9 @@ public abstract class MapResult implements Serializable { return this.getMapKey().equals(otherResult.getMapKey()) && this.similarity < otherResult.similarity; } + + public Boolean lessOrEqualSimilar(MapResult otherResult) { + return this.getMapKey().equals(otherResult.getMapKey()) + && this.similarity <= otherResult.similarity; + } } diff --git a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/knowledge/MetaEmbeddingService.java b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/knowledge/MetaEmbeddingService.java index e4f48597b..f8ee287c3 100644 --- a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/knowledge/MetaEmbeddingService.java +++ b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/knowledge/MetaEmbeddingService.java @@ -75,6 +75,8 @@ public class MetaEmbeddingService { return dataSetIds.stream().map(dataSetId -> { Retrieval newRetrieval = new Retrieval(); BeanUtils.copyProperties(retrieval, newRetrieval); + HashMap newMetadata = new HashMap<>(retrieval.getMetadata()); + newRetrieval.setMetadata(newMetadata); newRetrieval.getMetadata().putIfAbsent("dataSetId", dataSetId + Constants.UNDERLINE); return newRetrieval; diff --git a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/BaseMatchStrategy.java b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/BaseMatchStrategy.java index 57856ccd4..04b4d31d4 100644 --- a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/BaseMatchStrategy.java +++ b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/BaseMatchStrategy.java @@ -56,7 +56,8 @@ public abstract class BaseMatchStrategy implements MatchStr for (T oneRoundResult : oneRoundResults) { if (existResults.contains(oneRoundResult)) { boolean isDeleted = existResults.removeIf(existResult -> { - boolean delete = existResult.lessSimilar(oneRoundResult); +// boolean delete = existResult.lessSimilar(oneRoundResult); + boolean delete = existResult.lessOrEqualSimilar(oneRoundResult); if (delete) { log.debug("deleted existResult:{}", existResult); }