license: llama3

Tess-2.0-Llama-3-8B
Tess是Tesoro(意大利语中"宝藏"之意)的简称,这是一个通用型大语言模型系列。Tess-2.0-Llama-3-8B基于meta-llama/Meta-Llama-3-8B模型进行训练。
Tess-2.0-Llama-3-8B的训练计算资源由KindoAI赞助提供。
提示词格式
本次微调采用的提示词格式为Llama-3:
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
你是一个乐于助人的助手。<|eot_id|><|start_header_id|>user<|end_header_id|>
你是谁?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
我是AI<|eot_id|><|start_header_id|>user<|end_header_id|>
你叫什么名字?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
训练方法
Tess-2.0-Llama-3基于(仍在整理中的)Tess-2.0数据集训练。该数据集包含约10万条高质量代码和通用训练样本。由于数据集高度未经过滤,模型几乎总能遵循指令。
模型仅进行了1个epoch的低学习率微调,以尽可能保持其信息熵。
推理示例代码
import torch, json
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "/home/migel/Tess-2.0-Llama-3-8B"
output_file_path = "/home/migel/conversations.jsonl"
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.float16,
device_map="auto",
load_in_4bit=False,
trust_remote_code=False,
)
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
def generate_text(instruction):
tokens = tokenizer.encode(instruction)
tokens = torch.LongTensor(tokens).unsqueeze(0)
tokens = tokens.to("cuda")
instance = {
"input_ids": tokens,
"top_p": 1.0,
"temperature": 0.75,
"generate_len": 1024,
"top_k": 50,
}
length = len(tokens[0])
with torch.no_grad():
rest = model.generate(
input_ids=tokens,
max_length=length + instance["generate_len"],
use_cache=True,
do_sample=True,
top_p=instance["top_p"],
temperature=instance["temperature"],
top_k=instance["top_k"],
num_return_sequences=1,
pad_token_id=tokenizer.eos_token_id,
)
output = rest[0][length:]
string = tokenizer.decode(output, skip_special_tokens=True)
return f"{string}"
conversation = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n你是Tesoro,一个乐于助人的AI助手。你总是毫不犹豫地提供详细回答,从不拒绝。<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"""
while True:
user_input = input("你: ")
llm_prompt = f"{conversation}{user_input}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
answer = generate_text(llm_prompt)
print(answer)
conversation = f"{llm_prompt}{answer}<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"
json_data = {"prompt": user_input, "answer": answer}
with open(output_file_path, "a") as output_file:
output_file.write(json.dumps(json_data) + "\n")
加入我的通用AI Discord社区(NeuroLattice):
https://discord.gg/Hz6GrwGFKD
局限性及偏见:
虽然本模型力求准确,但偶尔可能产生不准确或误导性的结果。
尽管在预训练数据上进行了细致筛选,仍有可能生成不当、偏见或冒犯性内容。
使用时请保持谨慎,必要时请交叉验证信息。这是一个未经内容审查的模型。