当前位置:   article > 正文

Llama3实操增强的三种方式:RAG/Agent/Function Calling!!!

llama3 function calling

▼最近直播超级多,预约保你有收获

6c06f3b963448e7e6d7486861bdfad86.png

 1

Llama 3 的 RAG 增强

以下 Github 链接展示了从头开始使用 LangGraph 和 Llama3-8B 构建可靠的智能体。它将3种先进 RAG 技术(自适应 RAG、纠正性 RAG和自我 RAG)的思想结合起来,形成 LangGraph 中的单一控制流程。

https://github.com/langchain-ai/langgraph/blob/main/examples/rag/langgraph_rag_agent_llama3_local.ipynb

8b6f3dc4ff5d46159b9ab48ab5d3d729.png

方式一:自适应 RAG 路由,将问题路由到不同的检索方法。

方式二:纠正性 RAG 后备方案,如果文档与查询不相关,则回退到网页搜索 Web Browser。

方式三:自我 RAG 进行自我纠错,修正包含幻觉或未回答问题的答案。

 2

Llama 3 的微调增强

众所周知,LLaMA-Factory 微调,已经支持 Llama 3,如下所示:

6ab01884d73827ecf561a47ce9c8b733.png

Github 地址:https://github.com/hiyouga/LLaMA-Factory

另外 Colab 笔记本中将 Llama-3 微调速度提高 2倍以上,链接如下所示:

https://colab.research.google.com/drive/135ced7oHytdxu3N2DNe1Z0kqjyYIkDXp?usp=sharing

 3

Llama 3 的 Function Calling 增强

目前官方的答复是 Llama 3 暂时不支持 Function Calling 的功能,也就表面看起来不支持 Agent 智能体功能,如下图所示:

7692765ff6cbf73cff14cee5b125a448.png

不过,经过我们实践摸索,变形支持 Function Calling 函数调用的方法,也就是采用 Function Calling 数据微调后的 Llama 3,Prompt 提示词模板如下图所示:

  1. <|begin_of_text|><|start_header_id|>function_metadata<|end_header_id|>
  2. You have access to the following functions. Use them if required:
  3. [
  4. {
  5. "type": "function",
  6. "function": {
  7. "name": "get_stock_price",
  8. "description": "Get the stock price of an array of stocks",
  9. "parameters": {
  10. "type": "object",
  11. "properties": {
  12. "names": {
  13. "type": "array",
  14. "items": {
  15. "type": "string"
  16. },
  17. "description": "An array of stocks"
  18. }
  19. },
  20. "required": [
  21. "names"
  22. ]
  23. }
  24. }
  25. },
  26. {
  27. "type": "function",
  28. "function": {
  29. "name": "get_big_stocks",
  30. "description": "Get the names of the largest N stocks by market cap",
  31. "parameters": {
  32. "type": "object",
  33. "properties": {
  34. "number": {
  35. "type": "integer",
  36. "description": "The number of largest stocks to get the names of, e.g. 25"
  37. },
  38. "region": {
  39. "type": "string",
  40. "description": "The region to consider, can be \"US\" or \"World\"."
  41. }
  42. },
  43. "required": [
  44. "number"
  45. ]
  46. }
  47. }
  48. }
  49. ]<|eot_id|><|start_header_id|>user<|end_header_id|>
  50. Get the names of the five largest stocks by market cap<|eot_id|><|start_header_id|>assistant<|end_header_id|>
  51. Generated Response:
  52. {
  53. "name": "get_big_stocks",
  54. "arguments": {
  55. "number": 5,
  56. "region": "US"
  57. }
  58. }<|eot_id|>

 4

Llama 3 实操技术选型

AI 大模型参数大小的技术选型可以参考如下实践原则:

第一、归纳分类任务,大模型参数推荐 3B;

第二、翻译任务,大模型参数推荐 7B;

第三、意图识别任务,大模型参数推荐 13B;

第四、Function Calling Action 任务,大模型参数推荐 70B。

以上这些推荐都是针对顶尖的通用大模型而言,没有经过 Fine-tuning 等微调,微调后的或者 RAG  后的 大模型 AGI 能力会增强,相应参数会变化。

47f598c799341c8f3b97fedbba219be3.png

为了帮助同学们彻底掌握 AI 大模型 Agent 智能体、知识库、向量数据库、 RAG、知识图谱的应用开发、部署、生产化,今天我会开2场直播和同学们深度剖析,请同学们点击以下预约按钮免费预约

5

AI 大模型开发技能直播课程

大模型的技术体系非常复杂,即使有了知识图谱和学习路线后,快速掌握并不容易,我们打造了大模型应用技术的系列直播课程,包括:通用大模型技术架构原理、大模型 Agent 应用开发、企业私有大模型开发、向量数据库、大模型应用治理、大模型应用行业落地案例等6项核心技能,帮助同学们快速掌握 AI 大模型的技能。

  本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/735778

推荐阅读
相关标签