代码一embeddings = client.embeddings.create(
model='Qwen/Qwen3-Embedding-8B-GGUF"',
input=texts, # 直接传入文本列表
encoding_format="float"
)
代码二:
```embeddings = OpenAIEmbeddings(
base_url="https://api-inference.modelscope.cn/v1",
api_key="",
model="Qwen/Qwen3-Embedding-8B-GGUF",
tiktoken_enabled=False,
timeout=30.0,
skip_empty=True,
headers={"User-Agent": "Mozilla/5.0"}
)
出现调用
faiss_index = FAISS.from_texts(texts, embeddings) 报错,
```使用LangChain创建嵌入向量并构建FAISS索引...
创建FAISS索引...
发生错误: We couldn't connect to 'https://huggingface.co' to load the files, and couldn't find them in the cached files.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.
故障排除提示:
1. 检查网络连接
2. 如果在受限网络环境中,请取消代理设置注释
3. 确保ModelScope API密钥有效
4. 尝试使用不同的嵌入模型