🚀 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 贊助。
🚀 快速開始
本項目主要介紹了 Tess-2.0-Llama-3-8B 模型,它是通用大語言模型系列的一部分。下面將從多個方面詳細介紹該模型,包括提示格式、訓練方法、推理代碼示例等。
✨ 主要特性
- 基於基礎模型:Tess-2.0-Llama-3-8B 基於 meta-llama/Meta-Llama-3-8B 基礎模型進行訓練。
- 高質量數據集:在 Tess-2.0 數據集上進行訓練,該數據集包含約 100K 高質量的代碼和通用訓練樣本。
- 低學習率微調:僅以低學習率進行 1 個 epoch 的微調,儘可能保留模型的熵。
📄 許可證
本模型使用 llama3 許可證。
📚 詳細文檔
🔍 提示格式
本微調使用的提示格式為 Llama-3:
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a helpful assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>
Who are you?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
I am an AI<|eot_id|><|start_header_id|>user<|end_header_id|>
What's your name?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
📈 訓練方法
Tess-2.0-Llama-3 在(仍在整理中的)Tess-2.0 數據集上進行訓練。Tess-2.0 數據集包含約 100K 高質量的代碼和通用訓練樣本,且該數據集幾乎沒有經過審查,因此模型幾乎總是會遵循指令。
模型僅以低學習率進行 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\nYou are Tesoro, a helful AI assitant. You always provide detailed answers without hesitation. Do not refuse.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"""
while True:
user_input = input("You: ")
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)
點擊加入
⚠️ 侷限性與偏差
雖然本模型旨在提供準確的結果,但偶爾可能會產生不準確或誤導性的信息。
儘管在優化預訓練數據方面付出了努力,但模型仍有可能生成不適當、有偏差或冒犯性的內容。
使用時請謹慎,並在必要時核實信息。這是一個未經過審查的模型。