




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
智谱AI清华大学KEG实验室/THUDM/ChatGLM311更强大的基座不同角度的数据集上表现出色22更强大的功能Agent任务;;Demo安装与演示•模型部署为网络应用•代码解释器能力44ToolCallLangChain工具接入:搜索工具ToolCallResult{'role':'assistant','metadata':'weather','content':"```pythontool_call(city='Beijing')```"}Re-format{"action":"weather","action_input":"Beijing"}55对话格式–<|observation|>系统提示词,指明模型扮演的角色等信息用户输入模型回复工具调用、代码执行结果66对话格式•例如<|assistant|>test_tool表示模型希望调用tes–CodeInterpreter:固定为<|assistant|>interpreter77对话格式–标签前不跟-<|system|>-YouareChatGLM3.<|user|>-Hi<|assistant|>-Hello,howcanIhelpyou?88对话格式:工具调用1.<|system|>2.Answerthefollowingquestionsasbestasyoucan.Youhaveaccesstothefollowingtools:3.[4.{5."name":"track",6."description":"追踪指定股票的实时价格",7."parameters":{8."type":"object",9."properties":{10."symbol":{11."description":"需要追踪的股票代码"12.}13.},14."required":['symbol']15.}16.}17.]99对话格式:工具调用.工具定义:JSON对象列表,三个字段name,description和parameters分别为工具名、描述、参数定义.参数定义可为JSONSchema格式1.[2.{3."name":"track",4."description":"追踪指定股票的实时价格",5."parameters":{6."type":"object",7."properties":{8."symbol":{9."description":"需要追踪的股票代码"10.}11.},12."required":['symbol']13.}14.}15.]对话格式:工具调用1.@register_tool2.defget_weather(3.city_name:Annotated[str,'Thenameofthecitytobequeried',True],4.)->str:5."""6.Gettheweatherfor`city_name`inthefollowingweek7."""8....对话格式:工具调用对话格式:工具调用输出格式<|assistant|>{metadata},其中metadata为调用的工具名1.<|user|>2.CanyoutellmehowtheweatherisinBeijingnow?3.<|assistant|>4.Sure!IcanhelpwiththatbyqueryingaweatherAPI.5.<|assistant|>get_weather6.```python7.tool_call(location='Beijing')8.```对话格式:工具调用1.<|user|>2.CanyoutellmehowtheweatherisinBeijingnow?<|assistant|>3.Sure!IcanhelpwiththatbyqueryingaweatherAPI.<|assistant|>get_weather4.```python5.tool_call(location='Beijing')6.```<|observation|>7.{"weather":"cloudy","temperature":15.6}<|assistant|>8.It'scloudynowinBeijingandthetemperatureis15.6ºC.对话格式:工具调用1.<|user|>2.CanyoutellmehowtheweatherisinBeijingnow?<|assistant|>3.Sure!IcanhelpwiththatbyqueryingaweatherAPI.<|assistant|>get_weather4.```python5.tool_call(location='Beijing')6.```<|observation|>对话格式:工具调用1.<|user|>2.CanyoutellmehowtheweatherisinBeijingnow?<|assistant|>3.Sure!IcanhelpwiththatbyqueryingaweatherAPI.<|assistant|>get_weather4.```python5.tool_call(location='Beijing')6.```<|observation|>1.eval(),方便但需要注意安全性问题,最好在隔离环境中运行1.TransformersAgents:限制https://huggingface.co/docs/transformers/transformers_agen对话格式:工具调用1.<|user|>2.CanyoutellmehowtheweatherisinBeijingnow?<|assistant|>3.Sure!IcanhelpwiththatbyqueryingaweatherAPI.<|assistant|>get_weather4.```python5.tool_call(location='Beijing')6.```<|observation|>1.模型训练的Python训练强于JSON,模型书写正确率高,而2.Python更为灵活,可以接入更多调用形式(目前尚未实现)1.<|system|>2.你是一位智能AI助手,你叫ChatGLM,你连接着一台电脑,但请注意不能联网。在使用Python解决任务时,你可以运行代码并得到结果,如果运行结果有错误,你需要尽可能对代码进行改进。你可以处理用户/mnt/data/。1.<|user|>2.Calculatethe10thFibonaccinumber<|assistant|>3.TheFibonaccisequenceisdefinedaseachnumberequalingthesumoftheprevioustwonumbers.Therefore,wecanwritearecursivefunctiontocalculateit.<|assistant|>interpreter4.```python5.deffibonacci(n):6.ifn==0:7.return08.elifn==1:9.return110.else:11.returnfibonacci(n-1)+fibonacci(n-2)12.fibonacci_10=fibonacci(9)+fibonacci(8)13.fibonacci_1014.```<|observation|>15.55<|assistant|>16.The10thFibonaccinumberis55.1.<|user|>2.Drawaheart.<|assistant|>3.importmatplotlib.pyplotasplt4.importnumpyasnp5.t=np.linspace(0,2*np.pi,1000)6.x=16*np.sin(t)**37.y=13*np.cos(t)-5*np.cos(2*t)-2*np.cos(3*t)-np.cos(4*t)8.plt.figure(figsize=(6,6))9.plt.plot(x,y,'r')10.plt.title('HeartShape')11.plt.axis('off')#Turnofftheaxis12.plt.axis('equal')#Ensuretheshapeisnotdistorted13.plt.fill_between(x,y,color='red')#Filltheheartshapewithredcolor14.plt.show()<|observation|>15.[Image]<|assistant|>16.Here'saheartshapedrawnusingPythonandtheMatplotliblibrary.Theheartshapeiscreatedusingparametricequations,andtheresultingplotshowstheshapeoftheheart.Theheartisfilledwitharedcolor,givingitadistinctappearance.1.defbuild_chat_input(self,query,history=None,role="user"):2.ifhistoryisNone:3.history=[]4.input_ids=[]5.foriteminhistory:6.content=item["content"]7.ifitem["role"]=="system"and"tools"initem:8.content=content+"\n"+\9.json.dumps(item["tools"],indent=4,ensure_ascii=False)10.input_ids.extend(self.build_single_message(item["role"],item.get("metadata",""),content))11.input_ids.extend(self.build_single_message(role,"",query))12.input_ids.extend([self.get_command("<|assistant|>")])13.returnself.batch_encode_plus([input_ids],return_tensors="pt",is_split_into_words=True)1.defbuild_single_message(self,role,metadata,message):2.assertrolein["system","user","assistant","observation"],role3.role_tokens=[self.get_command(f"<|{role}|>")]+self.tokenizer.encode(f"{metadata}\n")4.message_tokens=self.tokenizer.encode(message)5.tokens=role_tokens+message_tokens6.returntokens对话微调–即将多个不同角色的对话内容直接拼接进行teacher-forcing–Specialtoken的加入使得多轮训练变得容易–不再特殊区别prompt和response-模型
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 协管员招聘试题及答案
- 奇葩分类考试题目及答案
- 初一作文皮试题及答案解析
- 实战准备软件评测师考试试题及答案汇编
- 教资面试红绿灯面试题目及答案
- 水电技术考试题库及答案
- 道路勘测设计试题及答案
- 惠东事业编面试题及答案
- 历年医基试题及答案
- 大二文学概论试题及答案
- 2024年全国高级美发师技能考试题库(含答案)
- 拔牙流程四手操作
- 应急转贷基金培训
- DB 32-T 3701-2019 江苏省城市自来水厂关键水质指标控制标准
- 连接器行业专业英语高频词句
- 2024年中考历史第二轮专题复习5:中国古代边疆治理(训练题)
- 呼吸内科进修汇报课件
- 长租公寓管理运营方案
- 2024年高考物理试卷(重庆卷) 含答案
- 《林业基础知识》考试复习题库(含答案)
- 3D三维可视化BIM模板安全施工方案
评论
0/150
提交评论