Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
TheProtagonist adab4fa018 | 2 years ago | |
---|---|---|
examples | 2 years ago | |
LICENSE | 2 years ago | |
README.md | 2 years ago | |
advanced_usage_template.py | 2 years ago | |
basic_usage_template.py | 2 years ago | |
requirements.txt | 2 years ago |
与 python 一起使用的 GPT-J API
pip install gptj
prompt:您希望给模型的提示
tokens:要生成的令牌数(建议使用 2048 或更少的值)
temperature:控制模型的随机性。更高的值会更随机(建议保持在 1.0 或更少,像 0.3 这样的东西)
top_p:最高概率将使用最有可能的标记
user:演讲者 给 gpt-j 提示的人
bot:您选择的虚构角色
context:解释对话框中发生的事情的提示部分
examples:用户意图字典以及机器人应如何响应
from GPTJ.Basic_api import SimpleCompletion
prompt = "def perfect_square(num):"
max_length = 100
低温意味着模型在完成提示时将进行较少的更改
高温会让模型更有创意
温度和最高概率都必须是浮点数据类型
temperature = 0.09
如果您使用的是最高概率设置温度一
如果您使用温度设置最高概率为 1
top_probability = 1.0
在这里,您将查询设置为等于所需的值
高于 512 的音符值往往需要更多时间来生成
query = SimpleCompletion(prompt, length=max_length, t=temperature, top=top_probability)
query.simple_completion()
## 可选的
您可以将结果分配给一个字符串
Query = query.simple_completion()
print(Query)
from GPTJ.gptj_api import Completion
context = "这是一个计算器机器人,将回答基本的数学问题"
查询在左边,而目标响应应该在右边
在这里我们可以看到用户正在询问与模型数学相关的问题
如果在右侧给出,模型应该响应的方式
不要在用户示例结束时使用期间!
examples = {
"5 + 5": "10",
"6 - 2": "4",
"4 * 15": "60",
"10 / 5": "2",
"144 / 24": "6",
"7 + 1": "8"}
context_setting = Completion(context, examples)
prompt = "48 / 6"
Below you can change student to "Task" for example and get similar results
User = "Student"
Bot = "Calculator"
max_tokens = 50
低温意味着模型在完成提示时将进行较少的更改
高温将使模型更具创造性并产生更多随机输出
A 注意温度和最高概率都是浮点数
temperature = 0.09
如果您正在使用它,请设置温度一
如果您使用温度设置最高概率为 1
top_probability = 1.0
未填充的参数将是默认值
我建议填充所有参数以获得更好的结果
一切都完成后执行下面的代码
response = context_setting.completion(prompt,
user=User,
bot=Bot,
max_tokens=max_tokens,
temperature=temperature,
top_p=top_probability)
根据给定的参数,请耐心等待有时会花费更长的时间
为了快速响应,只需使用简化版本的 Basic API
print(response)
注意:这是一个非常小的 6B 参数模型,不会总是产生准确的结果
## 信用
多亏了 https://github.com/vicgalle/gpt-j-api,这一切都是可能的
随意查看原始API
另外,可以在 GitHub https://github.com/TheProtaganist/gpt-j 上免费查看我的 API
## 执照
© Michael D Arana
licensed under the MIT License.
GPT-J API 与 python3 一起使用来生成文本、博客、代码等。
Python Text
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》