api调用 huggingface在线模型
使用api调用调用大模型
·
前置条件:需借助梯子(魔法工具),下方步骤按需安装,若已安装可跳过,建议按博主步骤操作
一、进入huggingface官网,然后选择点击deploy,单后点击HF Interfacce EndPoints

二、代码实例
import requests
#使用Token访问在线模型
API_URL = "https://api-inference.huggingface.co/models/maidalun1020/bce-embedding-base_v1"
API_TOKEN = "hf_xxxxxx"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
response = requests.post(API_URL,headers=headers,json={"inputs":"你好,Hugging face"})
print(response.json())
更多推荐


所有评论(0)