
git clone https://github.com/openai/openai-quickstart-python.git
https://codeload.github.com/openai/openai-quickstart-python/zip/refs/heads/master


python -m venv venv. venv/bin/activate
pip install -r requirements.txt
autopep8==1.6.0certifi==2021.10.8charset-normalizer==2.0.7click==8.0.3et-xmlfile==1.1.0Flask==2.0.2idna==3.3itsdangerous==2.0.1Jinja2==3.0.2MarkupSafe==2.0.1numpy==1.22.1openai==0.19.0openpyxl==3.0.9pandas==1.3.4pandas-stubs==1.2.0.35pycodestyle==2.8.0python-dateutil==2.8.2python-dotenv==0.19.2pytz==2021.3requests==2.26.0six==1.16.0toml==0.10.2tqdm==4.62.3urllib3==1.26.7Werkzeug==2.0.2
第一种方法是命令行方式运行
flask run




第二种方式是把项目部署在PyCharm里面然后执行,这里我就不演示了。
def index():if request.method == "POST":animal = request.form["animal"]response = openai.Completion.create(model="text-davinci-003",#模型prompt=generate_prompt(animal),temperature=0.6,#“参数值”)return redirect(url_for("index", result=response.choices[0].text))result = request.args.get("result")return render_template("index.html", result=result)
def generate_prompt(animal):return """Suggest three names for an animal that is a superhero.Animal: CatNames: Captain Sharpclaw, Agent Fluffball, The Incredible FelineAnimal: DogNames: Ruff the Protector, Wonder Canine, Sir Barks-a-LotAnimal: {}Names:""".format(animal.capitalize())
官方中文翻译为“温度”它是一个介于 0 和 1 之间的值,基本上可以让您控制模型在进行这些预测时的置信度。降低温度意味着它将承担更少的风险,并且完成将更加准确和确定。升高温度将导致更多样化的完成。
简单说就是temperature的值,设置接近0的时候,模型返回的相同和相似的结果概率大,模型的结果接近确定性和重复性!当temperature接近1时候,模型返回的相同和相似的结果概率小。模型的结果接近不确定性和随机性!
3、Token和temperature的关系
I have an orange cat named Butterscotch.
I have an orange cat named Butterscotch.
像“cat”这样的常用词是单个标记,而不太常用的词通常被分解成多个标记。
例如:“Butterscotch”翻译成四个标记:“But”、“ters”、“cot”和“ch”。许多标记以空格开头,例如“ hello”和“ bye”。给定一些文本,该模型确定下一个最有可能出现的标记。例如,文本“Horses are my favorite”最有可能跟随标记“animal”。



文章转载自畅谈Fintech,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




