🚀 SlimPLM
📝SlimPLM是一個用於自然語言處理的模型,可進行檢索必要性判斷、查詢重寫等任務。它能幫助解析用戶輸入為結構化格式,在大語言模型相關任務中發揮重要作用。
🚀 快速開始
以下是使用SlimPLM進行推理的示例代碼:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
question = "Who voices Darth Vader in Star Wars Episodes III-VI, IX Rogue One, and Rebels?"
heuristic_answer = "The voice of Darth Vader in Star Wars is provided by British actor James Earl Jones. He first voiced the character in the 1977 film \"Star Wars: Episode IV - A New Hope\", and his performance has been used in all subsequent Star Wars films, including the prequels and sequels."
prompt = (f"<s>[INST] <<SYS>>\nYou are a helpful assistant. Your task is to parse user input into"
f" structured formats according to the coarse answer. Current datatime is 2023-12-20 9:47:28"
f" <</SYS>>\n Course answer: (({heuristic_answer}))\nQuestion: (({question})) [/INST]")
params_query_rewrite = {"repetition_penalty": 1.05, "temperature": 0.01, "top_k": 1, "top_p": 0.85,
"max_new_tokens": 512, "do_sample": False, "seed": 2023}
model = AutoModelForCausalLM.from_pretrained("zstanjj/SlimPLM-Retrieval-Necessity-Judgment").eval()
if torch.cuda.is_available():
model.cuda()
tokenizer = AutoTokenizer.from_pretrained("zstanjj/SlimPLM-Retrieval-Necessity-Judgment")
input_ids = tokenizer.encode(prompt.format(question=question, answer=heuristic_answer), return_tensors="pt")
len_input_ids = len(input_ids[0])
if torch.cuda.is_available():
input_ids = input_ids.cuda()
outputs = model.generate(input_ids)
res = tokenizer.decode(outputs[0][len_input_ids:], skip_special_tokens=True)
print(res)
✨ 主要特性
✏️ 引用
如果您使用了該模型,請引用以下論文:
@inproceedings{Tan2024SmallMB,
title={Small Models, Big Insights: Leveraging Slim Proxy Models To Decide When and What to Retrieve for LLMs},
author={Jiejun Tan and Zhicheng Dou and Yutao Zhu and Peidong Guo and Kun Fang and Ji-Rong Wen},
year={2024},
url={https://arxiv.org/abs/2402.12052}
}
📄 許可證
本項目使用的許可證為 llama2。
🌹 如果您使用此模型,請給我們的 GitHub 倉庫 點個星支持我們。您的支持對我們意義重大!
📝 相關鏈接: