国内各大云服务平台

16 阅读2分钟

LangChain 官网

深度求索 deepseek

月之暗面 kimi

智谱 glm

阿里巴巴 阿里百炼

腾讯 腾讯TI平台

百度 千帆平台

硅基流动 SiliconCloud

字节跳动 火山方舟-火山引擎

一.神经网络语言模型

  • 词向量(word Embedding) 把词转为多维空间向量的一种技术

  • Transformer模型 self-attention 提升注意力

  • MLP 多层感知机制 Multi-Layer Perceptron

  • softmax 根据模型计算出的向量结果得出下一个token的概率分布,然后基于概率的随机采样方式挑选一个作为结果,这个概率受到Temperature 参数的影响,值越大,概率分布越均匀,模型生成的随机性越强,反之,结果越确定.

2ee57e5d5347dd84783fef4af307b691.jpg

30650378c01839e538db9bc3e2a1f5f2.jpg

  • LLM 上下文是有限制的

二.阿里云百炼-云服务平台

  • 注册后查看自己的免费模型和到期时间 image.png

  • 选择不同的模型进行体验

image.png

  • 基于OpenAI Chat的方式访问API.

image.png

  • temperature 采样温度控制模型生成文本的多样性。temperature越高,生成的文本更多样,反之,生成的文本更确定。取值范围: [0, 2),temperature与top_p均可以控制生成文本的多样性,建议只设置其中一个值

image.png

  • tools,包含一个或多个工具对象的数组,供模型在 Function Calling 中调用

image.png

  • tool_calls大模型要调用的工具列表: response.choice[0].message.tool_calls

image.png

  • 图片视频 Api文档

image.png

三.Tools调用的流程

  • 发起请求
{
   "model": "deepseek-reasoner",
   "messages": [
       {"role": "system", "content": "你是一名热心的AI助理"},
        {"role": "user", "content": "你好,我是水哥 ?"},
       {"role": "assistant", "content": "你好,水哥,很高兴认识你?"},
       {"role": "user", "content": "杭州天气今天怎么样?"}
   ],
   "stream": false,
   "temperature":0,     
}

  • 大模型返回response,要调用那些工具.
{
   "id": "d930f6d7-86bb-4d95-bdff-96e939a154db",
   "object": "chat.completion",
   "created": 1776572275,
   "model": "deepseek-reasoner",
   "choices": [
       {
           "index": 0,
           "message": {
               "role": "assistant",
               "content": "正在帮您查询天气,调用工具..."
           },
           "logprobs": null,
           "finish_reason": "stop",
           "tool_calls":[
              { "index":0,"id":"f001","function":"getWeather","type":"xxx"},
              { "index":1,"id":"f002","function":"toVoice","type":"xxx"}
           ]
       }
   ]   
}
  • 根据大模型返回的数据tool_calls数组,转换成tools数组作为请求参数,并调用对应的函数,得到结果,封装到message数组中,然后作为参数,给到大模型.
 {
    "model": "deepseek-reasoner",
    "messages": [
        {"role": "system", "content": "你是一名热心的AI助理"},
         {"role": "user", "content": "你好,我是水哥 ?"},
        {"role": "assistant", "content": "你好,水哥,很高兴认识你?"},
        {"role": "user", "content": "杭州天气今天怎么样?"},
        {"role": "tool", "content": "杭州今天晴天,20度,比较凉爽.","tool_call_id":"f001"},
        {"role": "tool", "content": "语音播报...","tool_call_id":"f002"},
    ],
    "stream": false,
    "temperature":0,
    "tools":[
          {
          "type":"type" ,
          "function":{"name":"getWeater","description":"根据城市查询天气信息",
          "parameters":{ "city":"杭州"}
          }{
          "type":"type" ,
          "function":{"name":"getWeater","description":"把文字转换成语音",
          "parameters":{ "voicestr":"...."}
          }
    ]
}