gpt j api
v0.3
与 GPT-J 语言模型及其变体交互的 API!您可以通过两种不同的方式使用和测试模型:
这些是公共 API 的端点,不需要身份验证。点击每个查看参数!
POST /generate/
POST /classify/
import requests
context = "In a shocking finding, scientist discovered a herd of unicorns living in a remote, previously unexplored valley, in the Andes Mountains. Even more surprising to the researchers was the fact that the unicorns spoke perfect English."
payload = {
"context" : context ,
"token_max_length" : 512 ,
"temperature" : 1.0 ,
"top_p" : 0.9 ,
}
response = requests . post ( "http://api.vicgalle.net:5000/generate" , params = payload ). json ()
print ( response )
import requests
payload = {
"sequence" : "The movie started slow, but in the end was absolutely amazing!" ,
"labels" : "positive,neutral,negative" }
response = requests . post ( "http://api.vicgalle.net:5000/classify" , params = payload ). json ()
print ( response )
curl -X ' POST '
' http://api.vicgalle.net:5000/generate?context=In%20a%20shocking%20finding%2C%20scientists%20discovered%20a%20herd%20of%20unicorns%20living%20in%20a%20remote%2C%20previously%20unexplored%20valley%2C%20in%20the%20Andes%20Mountains.%20Even%20more%20surprising%20to%20the%20researchers%20was%20the%20fact%20that%20the%20unicorns%20spoke%20perfect%20English.&token_max_length=512&temperature=1&top_p=0.9 '
-H ' accept: application/json '
-d ' '
只需通过 SSH 进入 TPU 虚拟机即可。此代码在 v2-8 和 v3-8 变体上进行了测试。
首先,安装要求并获取权重:
python3 -m pip install -r requirements.txt
wget https://the-eye.eu/public/AI/GPT-J-6B/step_383500_slim.tar.zstd
sudo apt install zstd
tar -I zstd -xf step_383500_slim.tar.zstd
rm step_383500_slim.tar.zstd
然后就跑
python3 serve.py
然后,您可以访问http://localhost:5000/docs并使用API!
就跑
python3 -m streamlit run streamlit_app.py --server.port 8000
如果您有任何请求,我很乐意通过vgallegoalcala at gmail dot com
为您提供帮助
特别感谢以下人士对本项目的赞助! <3
非常感谢 TPU 研究云的支持,https://sites.research.google/trc/