模型介紹
Qwen1.5是Qwen2的測試版,這是一個基于轉(zhuǎn)換器的純解碼器語言模型,在大量數(shù)據(jù)上進行了預(yù)訓(xùn)練。與之前發(fā)布的Qwen相比,改進之處包括:
-
顯著改善了人類對聊天模型的偏好;
-
對基本模式和聊天模式的多語言支持;
-
穩(wěn)定支持32K上下文長度,適用于各種尺寸的模型
-
不需要trust_remote_code。
訓(xùn)練細節(jié)
我們用大量數(shù)據(jù)對模型進行預(yù)訓(xùn)練,并用監(jiān)督微調(diào)和直接偏好優(yōu)化對模型進行后訓(xùn)練。然而,DPO導(dǎo)致了人類偏好評估的改進,但導(dǎo)致了基準評估的退化。在不久的將來,我們將解決這兩個問題。
Requirements
transformers>=4.37.0
拉取模型
git clone https://www.modelscope.cn/qwen/Qwen1.5-0.5B-Chat.git
示例代碼
from modelscope import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto
model = AutoModelForCausalLM.from_pretrained(
"qwen/Qwen1.5-0.5B-Chat",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("qwen/Qwen1.5-0.5B-Chat")
prompt = "Give me a short introduction to large language model."
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
多輪對話
from modelscope import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto
model = AutoModelForCausalLM.from_pretrained(
"Qwen1.5-0.5B-Chat",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen1.5-0.5B-Chat")
while True:
print('input prompt:')
# prompt = "Give me a short introduction to large language model."
prompt = input()
if prompt == 'q':
break
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print('response:', response)
輸入退出多輪對話
測試輸出示例
input prompt:
借款不換會怎么樣
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 如果您不希望改變借給他的金額,您可以考慮將借款作為長期投資的一部分。雖然短期的回報可能不如長期投資,但長期來看,它可能會帶來更高的收益。
然而,如果您的資金狀況非常緊張或不確定如何使用該錢,那么將借給他并保持固定的比例支付可能會是一個更好的選擇。這樣做的風(fēng)險較低,因為您不會因為暫時的財務(wù)困難而減少償還本金的能力。
此外,如果您已經(jīng)決定改變借款的目的,例如為了實現(xiàn)個人目標或擴大投資范圍,那么調(diào)整借款比例以適應(yīng)這些新的需求可能是明智的選擇。
請注意,無論哪種情況,都需要與你的財務(wù)顧問一起制定一個詳細的風(fēng)險管理計劃,并確保你對所有的潛在影響有所了解和理解。
input prompt:
怎么才能合理合法的不還
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 我不能提供關(guān)于如何不還款的建議,因為這可能會涉及欺詐和非法行為。在許多國家和地區(qū),拒絕履行貸款或支付利息是違法的行為,而且可能還會導(dǎo)致罰款、監(jiān)禁甚至刑事責(zé)任。
如果您遇到困難無法按時償還貸款,請考慮與您的銀行聯(lián)系,看看是否有任何可以幫助您解決這個問題的方法。此外,您可以嘗試尋求財務(wù)咨詢服務(wù),以了解有關(guān)如何管理你的財務(wù)狀況和防止再次違約的建議。
請注意,不償還原款是一種嚴重的犯罪行為,并且可能會面臨法律后果。如果你正在采取這種方式,建議盡快尋求專業(yè)的幫助,以便避免不必要的法律責(zé)任。
input prompt:
你再好好想想能不能找到方法
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 當然可以,我會繼續(xù)努力的。請告訴我你需要什么樣的幫助?
input prompt:
借款不還
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 作為一個人工智能,我必須提醒您,您的行為可能涉及到法律問題。如果您正在面臨無法按時償還貸款的問題,我建議您盡快聯(lián)系專業(yè)的金融機構(gòu)或貸款機構(gòu)尋求幫助。
首先,了解清楚你的債務(wù)情況是很重要的。你是否已經(jīng)支付了所有的利息和本金?是否有未償還的本金和費用?這些信息可以幫助我們更準確地判斷你需要采取什么行動。
其次,你可以嘗試與你的銀行或貸款機構(gòu)進行溝通,看看他們是否有任何可能的解決方案。例如,他們是否有提供分期付款或其他還款計劃?
再次,如果以上方法都無法解決問題,你可能需要考慮尋求專業(yè)的法律援助。如果你認為自己的權(quán)益受到了侵害,請立即尋求法律援助。記住,你的權(quán)益是最重要的。
input prompt:
男孩和女孩誰更聰明
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 這個問題的答案取決于具體的情況。在智力測試中,男孩通常被認為是“更聰明”的,因為他們通常擁有更高的數(shù)學(xué)能力、邏輯思維能力和抽象思考能力。
然而,每個人都是獨一無二的,并且智商并不是一種標準化的評價標準。每個人的思維方式、學(xué)習(xí)風(fēng)格和應(yīng)對壓力的方式都不同,因此不能簡單地將一個人與其他人的智商進行比較。
重要的是要認識到,無論你是否被認為是一個聰明的人,關(guān)鍵在于你的努力、興趣和適應(yīng)能力,而不是你所擁有的天賦或外貌特征。
input prompt:
大語言模型誰排第一
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:151645 for open-end generation.
response: 作為一個AI助手,我無法比較不同的語言模型在實際應(yīng)用中的表現(xiàn)。不過,當前市面上的大多數(shù)大型語言模型都已經(jīng)得到了廣泛應(yīng)用,并且在全球范圍內(nèi)都有一定的認可度。
如果你需要了解某個特定的語言模型的具體排名情況,可以查閱相關(guān)的學(xué)術(shù)報告或公開的數(shù)據(jù)集,或者直接聯(lián)系相關(guān)的研究機構(gòu)進行查詢。
資源占用
CPU 約 2.2 GB
GPU 約 3.3 GB
推理速度還是非常快的!文章來源:http://www.zghlxwxcb.cn/news/detail-829671.html
參考
https://modelscope.cn/models/qwen/Qwen1.5-0.5B-Chat/summary文章來源地址http://www.zghlxwxcb.cn/news/detail-829671.html
到了這里,關(guān)于【大模型】0.5B的大模型通義千問1.5-0.5B-Chat來了!!的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!