Introduction
使用了NexusRavenV2-13B model by Nexusflow
Nexusflow 发布的 NexusRaven-V2,这是一个拥有 130 亿参数的开源生成式 AI 模型,在软件工具使用方面优于 GPT-4。这个模型通过将人类指令准确地转换为功能调用和 API 调用,实现了比 GPT-4 更高的软件工具使用成功率,提升幅度高达 7%。
NexusRaven-V2 是基于 CodeLlama-13B 模型进行微调的,它结合了开源数据集和 Meta 的 Llama 生态系统来训练。这一模型允许企业拥有和定制,从而避免使用像 GPT-4 这样的专有模型所带来的数据风险。该模型适用于需要最新信息、安全性和深入领域定制的企业应用,有助于提高复杂软件的工作流程自动化 [oai_citation:1,Nexusflow's latest AI model outperforms GPT-4 in software tool usage - SiliconANGLE](https://siliconangle.com/2023/12/05/nexusflows-latest-ai-model-nexusraven-v2-outperforms-gpt-4-software-tool-usage/).
What's function calling ?
本节使用了通用的function calling 的方法,可以使用python中的inspect模块得到function的name, parameters, 然后就可以在prompt中动态地调用某个function。
本课程与其他通用LLM Function Calling 的区别。
Function Calling variations
在这节,将会介绍Function Calling的变种。主要包括如下几种,例子没啥好说的,就是举了Parallel Calls与Multiple functions, Nested functions的例子。
Single calls <--- Last lesson
Parallel Calls
No Calls
Multiple functions
Nested functions
Interfacing with external tools
本节介绍了可以调用外部的api去做Function Calling。 https://v2.jokeapi.dev/joke/Dark
在这节,代码使用到了openapi-python-generator工具,通过查阅资料,得到了下面的解释:
openapi-python-generator
is a tool that helps generate Python client code from OpenAPI specifications. It allows you to create Python code that interacts with APIs defined by OpenAPI (formerly Swagger) specifications, making it easier to consume APIs in your Python applications.
Here's a basic overview of how to use it:
1. Install the Package:
```bash
pip install openapi-python-generator
```
2. Generate Client Code:
To generate client code from an OpenAPI specification file (e.g., openapi.yaml
), use the following command:
```bash
openapi-python-generator -i openapi.yaml -o output_directory
```
Here, -i
specifies the input OpenAPI specification file, and -o
specifies the output directory where the generated code will be placed.
3. Use the Generated Client:
The generated client code will include Python classes and methods that correspond to the API endpoints defined in your OpenAPI specification. You can import these classes and methods into your Python code to interact with the API.
If you have any specific questions or need help with a particular aspect of openapi-python-generator
, let me know!
Structured Extraction
举了个例子,把unstructured data转为structured data,由于LLM是训练过python的,所以可以直接识别@dataclass 注解,自动将unstructured data转为注解标注的属性。
Applications
在本节中,举了一个sql访问数据的例子,与其他课程中sql访问数据相比,并没有什么独特之处。
Course project dialog processing
本节通过提出对话中的数据然后进行结构化,存到数据库中。
场景:客服与客户之间的对话,提取客户的username, email, order, sentiment, 然后将这些信息通过GenAI通过function calling存到数据库中,最后再通过function calling获取想要查询的结果。