通用库包装和调用 LLM 以进行即时工程。
项目描述
PREWL
Prompt Engineering Wrapper for LLM (PREWL):一个库,用于通过 NLU 的快速工程快速构建基于 LLM 的应用程序原型。
用法
import prewl, json
# Load configuration for backend (e.g., GPT-3 credentials)
prewl.configure("config.json")
# Load the example prompts
examples = prewl.load_promps("prompts.json")
PATTERN = """
Text: {text}
Sentiment: {sentiment}
"""
# Prompts objects
prompts = prewl.load_prompts(PATTERN, examples, output='sentiment')
# Build the backend-driven model that will be used
model = prewl.train(prompts) # Model object
# Use the model to build a prompt for the LLM, fetch the completion, and parse it
new_input = "This movie was off the hook!"
resp = model.infer(new_input)
print("\n New input: ", new_input)
print("Prediction: ", resp)
print()
更多示例可以在examples/目录中找到。
贡献
快来了...
要求
设置虚拟环境
python -m venv .env
source .env/bin/activate
安装割炬
pip install torch --extra-index-url https://download.pytorch.org/whl/cu113
引用这项工作
快来了...
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
prewl-0.0.4.tar.gz
(5.9 kB
查看哈希)
内置分布
prewl-0.0.4-py3-none-any.whl
(7.2 kB
查看哈希)