【极速版 -- 大模型入门到进阶】除了 Prompting, 大模型还能如何被应用?

大模型应用 – Generative AI Projects

🌊 大模型应用的时效优势

🌊 大模型应用的方式 - Technology Options

  • 应用方式一 🐟 Prompting:最简单快速 (训练不了模型就训练我自己😎哈哈哈,详见 ChatGPT 使用:人类向 chatgpt 靠近
    • 动手试试情感判断任务吧 👉 Prompting an LLM in code 在线尝试指路

      • 输入给大模型的提示词:“Classify the following review as having either a positive or negative sentiment:
        The banana pudding was really tasty!”
      • 大模型输出的结果:“Positive sentiment”
      import openai
      import os
      
      
      # 本地运行的话,需要替换自己的 key
      openai.api_key = os.getenv("OPENAI_API_KEY")
      
      def llm_response(prompt):
          response = openai.ChatCompletion.create(
              model='gpt-3.5-turbo',
              messages=[{'role':'user','content':prompt}],
              temperature=0
          )
          return response.choices[0].message['content']
      
      prompt = '''
          Classify the following review 
          as having either a positive or
          negative sentiment:
      
          The banana pudding was really tasty!
      '''
      response = llm_response(prompt)
      print(response)  # 会得到结果:Positive sentiment
      
    • Tips: 可以通过 call 外部程序,辅助大模型完成特定任务:例如可以通过调用外部计算器程序来辅助大模型进行精确计算

  • 应用方式二🐟 Retrieval augmented generation (RAG):外部数据 📂 赋能大模型
    • 具体步骤如下:
      1. 【查阅提供的文件 📂】Given question, search relevant documents for answer
      2. 【融合文件 📂 中找到的有关信息更新 prompt】Incorporate retrieved text into an updated prompt
      3. 【根据新 prompt 生成答案】Generate answer from the new prompt with additional context
  • 应用方式三🐟 Fine-tune models:调整大模型适配目标任务
    • To carry out a task that isn’t easy to define in a prompt or to help LLM gain specific knowledge.

    • 例如下面的例子,通过 fine-tuning 使得大模型输出乐观风格的回答

    • 也可以通过引入 Reinforcement learning from human feedback (RLHF) 的方式来微调

      Step 1: Train an answer quality (reward) model


      Step 2: Further train LLM to generate more responses that get high scores.


参考资料:面向每个人的生成式AI

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值