ModelScope
ModelScope 是一个大型模型和数据集仓库。
本页面将介绍如何在 LangChain 中使用 ModelScope 生态系统。 本页面分为两部分:安装和设置,以及特定 ModelScope 包装器的参考。
安装
pip install -U langchain-modelscope-integration
前往 ModelScope 注册 ModelScope 并生成 SDK token。完成这些步骤后,设置 MODELSCOPE_SDK_TOKEN 环境变量:
export MODELSCOPE_SDK_TOKEN=<your_sdk_token>
Chat Models
ModelScopeChatEndpoint 类公开了来自 ModelScope 的聊天模型。在此处查看可用模型 here。
from langchain_modelscope import ModelScopeChatEndpoint
llm = ModelScopeChatEndpoint(model="Qwen/Qwen2.5-Coder-32B-Instruct")
llm.invoke("Sing a ballad of LangChain.")
Embeddings
ModelScopeEmbeddings 类公开了来自 ModelScope 的嵌入。
from langchain_modelscope import ModelScopeEmbeddings
embeddings = ModelScopeEmbeddings(model_id="damo/nlp_corom_sentence-embedding_english-base")
embeddings.embed_query("What is the meaning of life?")
LLMs
ModelScopeLLM 类公开了来自 ModelScope 的 LLM。
from langchain_modelscope import ModelScopeLLM
llm = ModelScopeLLM(model="Qwen/Qwen2.5-Coder-32B-Instruct")
llm.invoke("The meaning of life is")