简介
LLaMA-O1-Supervised-1129 模型是在 SimpleBerry/OpenLongCoT-SFT 数据集上训练的 LLaMA-O1-Base-1127 模型的微调版本。该模型旨在执行文本生成任务,尤其是在对话环境中。在本文中,我们将探讨该模型的架构、性能,并提供如何有效使用该模型的示例。
架构
LLaMA-O1-Supervised-1129模型基于LLaMA架构,这是一种基于转换器的语言模型。该模型由编码器和解码器组成,其中编码器接收输入文本并生成连续表示,解码器根据该表示生成输出文本。
LLaMA-O1-Supervised-1129模型已在SimpleBerry/OpenLongCoT-SFT数据集上进行了微调,该数据集是一个包含人类注释文本的大型数据集。微调过程包括调整模型的权重,以优化其在这一特定任务中的性能。
性能
LLaMA-O1-Supervised-1129模型已在文本生成和对话等多项任务中进行了评估。该模型的准确率很高,而且能够生成连贯的、针对特定上下文的文本,显示了良好的效果。
使用示例
要使用 LLaMA-O1-Supervised-1129 模型,您需要安装 Transformers 库。下面是一个如何使用该模型生成文本的示例:
import json
import datasets
import torch
import random
import numpy as np
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("SimpleBerry/LLaMA-O1-Supervised-1129")
model = AutoModelForCausalLM.from_pretrained("SimpleBerry/LLaMA-O1-Supervised-1129",device_map='auto')
template = "<start_of_father_id>-1<end_of_father_id><start_of_local_id>0<end_of_local_id><start_of_thought><problem>{content}<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>0<end_of_father_id><start_of_local_id>1<end_of_local_id><start_of_thought><expansion>"
def llama_o1_template(query):
text = template.format(content=query)
return text
def batch_predict(input_texts):
input_texts = [input_text.replace('<|end_of_text|>','') for input_text in input_texts]
inputs = tokenizer(input_texts, return_tensors="pt").to(model.device)
responses = model.generate(**inputs, max_new_tokens=1024)
response_texts = tokenizer.batch_decode(responses, skip_special_tokens=False)
# assitant_responses = [item[len(input_texts[i]):] for i,item in enumerate(response_texts)]
assitant_responses = [item for i,item in enumerate(response_texts)]
return assitant_responses
def format_response(response):
response = response.replace('<start_of_father_id>','')
response = response.replace('<end_of_father_id><start_of_local_id>','👉')
response = response.replace('<end_of_local_id><start_of_thought>',', ')
response = response.replace('<end_of_thought><start_of_rating>','')
response = response.replace('<end_of_rating>','')
response = response.replace('<positive_rating>','👍')
response = response.replace('<negative_rating>','👎')
return response
i = 'If Diana needs to bike 10 miles to reach home and she can bike at a speed of 3 mph for two hours before getting tired, and then at a speed of 1 mph until she reaches home, how long will it take her to get home?'
input_texts = [llama_o1_template(i)]
assitant_responses = batch_predict(input_texts)
# assitant_responses = [format_response(response) for response in assitant_responses]
print(assitant_responses)
优点
LLaMA-O1-Supervised-1129模型具有若干优势,包括:
- 高准确性
- 灵活性
- 易用性:该模型易于使用,具有简单的 API 和最低要求。
结论
模型是在特定的数据集上训练的,该数据集可能无法代表所有类型的文本。 LLaMA-O1-Supervised-1129 模型是文本生成和对话任务的强大工具。它的高准确性和灵活性使其成为任何自然语言处理工具包的有益补充。不过,它需要大量的计算资源,而且在训练数据之外的任务中可能表现不佳。