listpage-next 0.0.164 → 0.0.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,85 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import "antd";
3
- import { LinkCard } from "../features/ChatClient/index.js";
4
- import icons from "@ant-design/icons";
5
- import { IconDoc } from "../features/ChatClient/icons/IconDoc.js";
6
- const Demo11 = ()=>/*#__PURE__*/ jsx(LinkCard, {
7
- icon: /*#__PURE__*/ jsx(icons, {
8
- component: IconDoc
9
- }),
10
- title: "《灵血焚天:青云卷》剧情思维导图",
11
- description: "创建时间:15:57"
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button, Flex } from "antd";
3
+ import { Bubble, SuggestMessageList } from "../features/ChatClient/index.js";
4
+ import { ApiOutlined } from "@ant-design/icons";
5
+ const Demo11 = ()=>{
6
+ const feedback = /*#__PURE__*/ jsxs(Flex, {
7
+ gap: 8,
8
+ children: [
9
+ /*#__PURE__*/ jsx(Button, {
10
+ size: "small",
11
+ type: "text",
12
+ icon: /*#__PURE__*/ jsx(ApiOutlined, {})
13
+ }),
14
+ /*#__PURE__*/ jsx(Button, {
15
+ size: "small",
16
+ type: "text",
17
+ icon: /*#__PURE__*/ jsx(ApiOutlined, {})
18
+ }),
19
+ /*#__PURE__*/ jsx(Button, {
20
+ size: "small",
21
+ type: "text",
22
+ icon: /*#__PURE__*/ jsx(ApiOutlined, {})
23
+ })
24
+ ]
12
25
  });
26
+ const suggests = /*#__PURE__*/ jsx(SuggestMessageList, {
27
+ suggests: [
28
+ {
29
+ title: '推荐问题1'
30
+ },
31
+ {
32
+ title: '推荐问题2'
33
+ }
34
+ ]
35
+ });
36
+ return /*#__PURE__*/ jsx(Bubble, {
37
+ reasoning_content: content,
38
+ content: content,
39
+ role: "assistant",
40
+ feedback: feedback,
41
+ references: [
42
+ {
43
+ title: '从通用到专业:大模型在医疗领域的四阶段训练方法与落地实践-CSDN博客',
44
+ content: content,
45
+ url: 'https://www.baidu.com'
46
+ },
47
+ {
48
+ title: '测试2',
49
+ url: 'https://www.baidu.com'
50
+ }
51
+ ],
52
+ suggests: suggests,
53
+ showFeedback: ()=>true
54
+ });
55
+ };
56
+ const content = `传统RAG 的检索环节多依赖单一语义检索(如向量相似度),但这种方式存在语义偏差(无法处理精确关键词)、长尾覆盖不足(罕见查询匹配差)等问题。检索增强的核心是混合检索(Hybrid Retrieval),即结合语义检索与关键词检索的优势,实现“精准匹配+广泛覆盖”的平衡。
57
+ 混合检索的本质是两种检索结果的加权融合 ,通过线性加权公式计算综合得分:
58
+ BM25_score:基于关键词匹配的得分(由TF-IDF改进而来,考虑词频、文档长度归一化),擅长处理精确关键词(如产品型号、法律条款编号);
59
+ Semantic_score:基于向量相似度的得分(由Sentence-BERT等模型生成),擅长处理语义泛化(如“适合夏天的鞋子”→“透气网面运动鞋”);
60
+ α:权重参数(0≤α≤1),用于平衡两种检索的贡献。
61
+ 权重调优:通过网格搜索(Grid Search)或贝叶斯优化(Bayesian Optimization)在验证集上确定最佳α值。例如,电商场景中α通常取0.4-0.6(语义检索占比略高,兼顾精准与泛化);
62
+ 归一化处理:由于BM25和Semantic_score的量纲不同(如BM25得分范围为0-100,Semantic_score范围为0-1),需先对两者进行Min-Max归一化(将得分映射到0-1区间),再进行加权融合;
63
+ 结果融合:将关键词检索与语义检索的候选文档合并,按综合得分排序,保留Top-K(如Top-50)作为后续排序的输入。
64
+ 案例1(电商场景):某电商平台采用混合检索(BM25+语义检索),将搜索准确率提升15%-30%。其中,α=0.5时,既保证了关键词匹配的精准度(如“iPhone 15 Pro Max”的搜索结果),又覆盖了语义泛化的需求(如“2025年最新旗舰手机”的搜索结果);
65
+ 案例2(法律场景):某法律AI企业采用混合检索,解决了“法律条款编号”(关键词检索)与“条款内容语义”(语义检索)的匹配问题,将法律问答的准确率提升20%。
66
+ 检索增强解决了“找得到”的问题,但初始检索结果(如Top-50)仍存在相关性排序不准确的问题(如将“次要相关”文档排在“核心相关”文档前面)。排序增强的核心是重排序(Reranking) ,即通过更精细的模型对初始候选文档进行二次排序,将“最相关”的文档排在前面。
67
+ 重排序的主流方法是交叉编码器(Cross-Encoder),其核心思想是将查询与文档拼接成一个输入,通过Transformer模型直接建模两者的深层交互 。
68
+ 模型处理:Transformer的自注意力机制(Self-Attention)会学习查询与文档之间的细粒度语义关联(如查询中的“续航”与文档中的“电池容量”“使用时间”的关联);
69
+ 得分计算:取<代码开始>[CLS]<代码结束> token的隐藏状态作为全局表示,通过全连接层(MLP)输出相关性得分(如0-1之间的概率值)。
70
+ bge-reranker:完全开源,中等硬件即可执行,适合通用RAG场景;
71
+ MixedBread(mxbai-rerank-v2):宣称SOTA性能,推理速度快,支持长上下文(如1024token以上),适合长文档场景;
72
+ Cohere Rerank:私有API,多语言支持好,适合企业级应用(需付费)。
73
+ 研究表明,处理Top-50的候选文档即可覆盖90%以上的核心相关文档;
74
+ 其中,对于“如何优化RAG的检索策略”这一问题,重排序后将“混合检索+重排序”的核心文档排在第一位,而初始检索将其排在第三位;
75
+ 检索增强(混合检索)与排序增强(重排序)并非独立,而是协同作用,共同提升RAG系统的性能:
76
+ 检索增强为排序增强提供高质量候选:混合检索通过“关键词+语义”的融合,扩大了候选文档的覆盖范围,避免了“语义检索”遗漏精确关键词的问题;
77
+ 排序增强优化检索结果的顺序:重排序通过“深层语义交互”的建模,将“最相关”的文档排在前面,解决了初始检索“粗排”的问题。
78
+ 研究表明,混合检索+重排序的组合可将RAG系统的事实准确率提升30%-50%(相比单一语义检索 ),用户满意度提升20%-30%(相比单一关键词检索)。
79
+ 动态权重调整:根据查询类型(如事实查询、语义查询)动态调整混合检索的权重α(如事实查询取α=0.7,语义查询取α=0.3),提升检索的灵活性;
80
+ 元数据增强:在检索与排序中加入元数据(如文档的“发布时间”“作者”“领域”),提升检索的“时效性”与“专业性”(如“2025年的AI趋势”优先检索2025年发布的文档)。
81
+ 检索增强通过混合检索(关键词+语义)解决“找得到”的问题,扩大候选文档的覆盖范围;
82
+ 排序增强通过重排序(Cross-Encoder)解决“排得准”的问题,将最相关的文档排在前面;
83
+ 两者的协同作用,显著提升了RAG系统的事实准确率与用户满意度,成为当前RAG技术优化的核心方向。
84
+ `;
13
85
  export { Demo11 };
@@ -1,10 +1,16 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useRef } from "react";
2
3
  import styled_components from "styled-components";
3
4
  import icons, { LinkOutlined } from "@ant-design/icons";
5
+ import { Tooltip } from "antd";
6
+ import { useHover } from "ahooks";
4
7
  import { IconDoc } from "../../icons/IconDoc.js";
5
8
  const LinkCard = (props)=>{
6
9
  const { icon, title, description, url } = props;
10
+ const containerRef = useRef(null);
11
+ const isHovered = useHover(containerRef);
7
12
  return /*#__PURE__*/ jsxs(LinkCardContainer, {
13
+ ref: containerRef,
8
14
  children: [
9
15
  /*#__PURE__*/ jsx(IconContainer, {
10
16
  children: icon ?? /*#__PURE__*/ jsx(icons, {
@@ -21,10 +27,14 @@ const LinkCard = (props)=>{
21
27
  })
22
28
  ]
23
29
  }),
24
- /*#__PURE__*/ jsx(ActionContainer, {
25
- children: /*#__PURE__*/ jsx(ActionItem, {
26
- onClick: ()=>url && window.open(url, '_blank'),
27
- children: /*#__PURE__*/ jsx(LinkOutlined, {})
30
+ isHovered && /*#__PURE__*/ jsx(ActionContainer, {
31
+ children: /*#__PURE__*/ jsx(Tooltip, {
32
+ title: "跳转",
33
+ placement: "top",
34
+ children: /*#__PURE__*/ jsx(ActionItem, {
35
+ onClick: ()=>url && window.open(url, '_blank'),
36
+ children: /*#__PURE__*/ jsx(LinkOutlined, {})
37
+ })
28
38
  })
29
39
  })
30
40
  ]
@@ -23,6 +23,11 @@ md.renderer.rules.link_open = function(tokens, idx, options, env, self) {
23
23
  else tokens[idx].attrs[relIndex][1] = 'noopener noreferrer';
24
24
  return defaultLinkOpen(tokens, idx, options, env, self);
25
25
  };
26
+ md.renderer.rules.text = (tokens, idx)=>{
27
+ let text = tokens[idx].content;
28
+ text = text.replace(/\[\[(-?\d+(\.\d+)?)\]\]/g, '<sup>[$1]</sup>');
29
+ return text;
30
+ };
26
31
  const Markdown = (props)=>/*#__PURE__*/ jsx(MarkdownBody, {
27
32
  dangerouslySetInnerHTML: {
28
33
  __html: md.render(props.content)
@@ -5,6 +5,7 @@ export * from './components/Bubble';
5
5
  export { SimplifyChatPage, type SimplifyChatPageProps, } from './components/ChatPage/SimplifyChatPage';
6
6
  export * from './components/ChatDialog';
7
7
  export * from './components/ChatSplitter';
8
+ export * from './components/Bubble/Markdown';
8
9
  export { useChatContext } from './context/useChatContext';
9
10
  export * from './context/types';
10
11
  export * from './utils/parseSse';
@@ -6,6 +6,7 @@ export * from "./components/ChatContent/index.js";
6
6
  export * from "./components/Bubble/index.js";
7
7
  export * from "./components/ChatDialog/index.js";
8
8
  export * from "./components/ChatSplitter/index.js";
9
+ export * from "./components/Bubble/Markdown.js";
9
10
  export * from "./context/types.js";
10
11
  export * from "./utils/parseSse.js";
11
12
  export { SimplifyChatPage, useChatContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.164",
3
+ "version": "0.0.166",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",