xinference 下载模型
时间: 2025-04-23 17:10:07 浏览: 61
### 如何下载 Xinference 模型
为了成功下载并部署 Xinference 模型,特别是针对网络环境优化后的操作流程如下:
对于因网络原因无法通过默认设置从 Hugging Face 下载模型的情况,可以更改为国内的 ModelScope 源来完成这一过程。具体命令为 `XINFERENCE_MODEL_SRC=modelscope xinference-local --host 0.0.0.0 --port 9997`[^2]。
当上述配置完成后,在浏览器访问 http://host-ip:9997/ 即可看到 Xinference 的管理界面。需要注意的是,在 Windows 平台上应使用 `127.0.0.1` 替代主机 IP 地址进行本地测试。
如果以 embedding 模型为例,则可以从魔塔社区获取特定版本的中文文本向量转换模型,比如链接指向的一个实例:https://www.modelscope.cn/models/Jerry0/text2vec-base-chinese[^1]。
#### Python 脚本示例用于验证模型加载情况
```python
from transformers import AutoModel, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Jerry0/text2vec-base-chinese", trust_remote_code=True)
model = AutoModel.from_pretrained("Jerry0/text2vec-base-chinese", trust_remote_code=True).cuda()
text = "你好,世界"
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input.cuda())
print(output)
```
阅读全文
相关推荐


















