chatglm3-6b 模型部署+結(jié)合flask進行調(diào)用

模型下載
git lfs install
git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b.git
下載完成后找到所在目錄

from flask import  Flask,jsonify,request
from transformers import AutoTokenizer, AutoModel
app = Flask(__name__)
tokenizer = AutoTokenizer.from_pretrained("E:/yi\chatglm3-6b", trust_remote_code=True)
model = AutoModel.from_pretrained("E:/yi\chatglm3-6b", trust_remote_code=True).half().cuda()
model = model.eval()
@app.route('/goodsApi',methods=['get'])
def transaction():
    item ={}

    title = request.args.get("title")
    title1 = request.args.get("title1")
    
    response, history = model.chat(tokenizer,title, history=[])
    response, history = model.chat(tokenizer, title+'和'+title1+'  這兩句話的相似度是多少', history=[])

    item['data'] =response

    return item,200


if __name__ == '__main__':
        app.run(host='0.0.0.0', port=5000)

最后訪問地址因為是開的5000端口所以本地訪問5000端口

http://127.0.0.1:5000/goodsApi?title=hello&title1=hello123

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容