Titan Takeoff
TitanML
帮助企业通过我们的训练、压缩和推理优化平台构建和部署更好、更小、更便宜、更快的NLP模型。
我们的推理服务器,Titan Takeoff 支持在您的硬件上通过一条命令本地部署大型语言模型(LLM)。大多数嵌入模型都开箱即用,如果您在特定模型上遇到问题,请通过以下方式联系我们:hello@titanml.co。
示例用法
以下是使用 Titan Takeoff Server 的一些实用示例。在运行这些命令之前,您需要确保 Takeoff Server 已在后台启动。更多信息请参阅Takeoff 启动文档页面。
import time
from langchain_community.embeddings import TitanTakeoffEmbed
API 参考:TitanTakeoffEmbed
示例 1
基本用法假设 Takeoff 在您的机器上使用默认端口(即 localhost:3000)运行。
embed = TitanTakeoffEmbed()
output = embed.embed_query(
"What is the weather in London in August?", consumer_group="embed"
)
print(output)
示例 2
使用 TitanTakeoffEmbed Python 封装器启动读取器。如果您尚未在首次启动 Takeoff 时创建任何读取器,或者想添加另一个,您可以在初始化 TitanTakeoffEmbed 对象时进行此操作。只需将您想启动的模型列表作为 models
参数传递。
您可以使用 embed.query_documents
一次性嵌入多个文档。预期输入是字符串列表,而不是 embed_query
方法预期的单个字符串。
# Model config for the embedding model, where you can specify the following parameters:
# model_name (str): The name of the model to use
# device: (str): The device to use for inference, cuda or cpu
# consumer_group (str): The consumer group to place the reader into
embedding_model = {
"model_name": "BAAI/bge-large-en-v1.5",
"device": "cpu",
"consumer_group": "embed",
}
embed = TitanTakeoffEmbed(models=[embedding_model])
# The model needs time to spin up, length of time need will depend on the size of model and your network connection speed
time.sleep(60)
prompt = "What is the capital of France?"
# We specified "embed" consumer group so need to send request to the same consumer group so it hits our embedding model and not others
output = embed.embed_query(prompt, consumer_group="embed")
print(output)