主题
TopicNodeParser #
基础: NodeParser
基于主题的节点解析器。
源代码位于 llama-index-integrations/node_parser/llama-index-node-parser-topic/llama_index/node_parser/topic/base.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
from_defaults classmethod
#
from_defaults(callback_manager: Optional[CallbackManager] = None, id_func: Optional[Callable[[int, Document], str]] = None, tokenizer: Optional[Callable] = None, max_chunk_size: int = 1000, window_size: int = 5, llm: Optional[LLM] = None, embed_model: Optional[BaseEmbedding] = None, similarity_method: str = 'llm', similarity_threshold: float = 0.8) -> TopicNodeParser
使用参数初始化。
源代码位于 llama-index-integrations/node_parser/llama-index-node-parser-topic/llama_index/node_parser/topic/base.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
split_into_paragraphs #
split_into_paragraphs(text: str) -> List[str]
根据换行符将文档分割成段落。
源代码位于 llama-index-integrations/node_parser/llama-index-node-parser-topic/llama_index/node_parser/topic/base.py
125 126 127 |
|
proposition_transfer #
proposition_transfer(paragraph: str) -> List[str]
使用 LLM 将一个段落转换成一系列自洽的陈述。
源代码位于 llama-index-integrations/node_parser/llama-index-node-parser-topic/llama_index/node_parser/topic/base.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
is_same_topic_llm #
is_same_topic_llm(current_chunk: List[str], new_proposition: str) -> bool
使用 LLM 进行零样本分类,以确定新的陈述是否属于同一主题。
源代码位于 llama-index-integrations/node_parser/llama-index-node-parser-topic/llama_index/node_parser/topic/base.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
is_same_topic_embedding #
is_same_topic_embedding(current_chunk: List[str], new_proposition: str) -> bool
使用基于嵌入的相似性,以确定新的陈述是否属于同一主题。
源代码位于 llama-index-integrations/node_parser/llama-index-node-parser-topic/llama_index/node_parser/topic/base.py
171 172 173 174 175 176 177 178 179 180 181 182 |
|
semantic_chunking #
semantic_chunking(paragraphs: List[str]) -> List[str]
对给定段落执行语义分块。max_chunk_size: 这是基于 1000 字符的硬阈值。根据论文,最长块不能超过 LLM 上下文长度限制的硬阈值。此处我们使用 1000 token 作为阈值。
源代码位于 llama-index-integrations/node_parser/llama-index-node-parser-topic/llama_index/node_parser/topic/base.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
build_topic_based_nodes_from_documents #
从文档构建基于主题的节点。
源代码位于 llama-index-integrations/node_parser/llama-index-node-parser-topic/llama_index/node_parser/topic/base.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|