微信扫码
添加专属顾问
我要投稿
文本分割器的基本工作原理:
定制文本分割器的两个主要轴向:
主要参数和功能:
def transformer_doc():# 加载待分割长文本 with open('sys_boss.txt',encoding='UTF-8') as f:state_of_the_union = f.read()text_splitter = RecursiveCharacterTextSplitter(chunk_size = 100,chunk_overlap= 20,length_function = len,add_start_index = True,)docs = text_splitter.create_documents([state_of_the_union])print(docs[0])print(docs[1])metadatas = [{"document": 1}, {"document": 2}]documents = text_splitter.create_documents([state_of_the_union, state_of_the_union], metadatas=metadatas)print(documents[0])
def spit_code():print([e.value for e in Language])html_text = """<!DOCTYPE html><html><head><title>?️? LangChain</title><style>body {font-family: Arial, sans-serif;}h1 {color: darkblue;}</style></head><body><div><h1>?️? LangChain</h1><p>⚡ Building applications with LLMs through composability ⚡</p></div><div>As an open source project in a rapidly developing field, we are extremely open to contributions.</div></body></html>"""html_splitter = RecursiveCharacterTextSplitter.from_language(language=Language.HTML, chunk_size=60, chunk_overlap=0)html_docs = html_splitter.create_documents([html_text])print(html_docs)
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2025-06-13
【LangChain 团队重磅实测报告】多智能体架构揭秘:谁才是性能之王?
2025-06-13
大模型_百炼:MCP让我焦虑
2025-06-11
前端学AI之LangChain.js入门教程:实现智能对话机器人
2025-06-08
Langfuse:重新定义LLM应用开发与运维的可观测性
2025-06-08
Langgraph实战--自定义embeding
2025-06-07
为 AI Agent 铺路:深度解析下一代应用的核心基建 LangGraph
2025-06-05
智能体框架怎么选?LangChain、Dify、CrewAI、AutoGen五大框架横向对比
2025-06-04
吴恩达对谈LangChain创始人:企业构建Agen系统的核心认知!
2025-03-20
2025-05-08
2025-04-18
2025-03-22
2025-05-06
2025-03-23
2025-04-13
2025-05-28
2025-03-22
2025-04-18
2025-06-13
2025-05-21
2025-05-19
2025-05-08
2025-05-06
2025-04-22
2025-04-18
2025-03-22