Views
No views yet
meta-llama/Meta-Llama-3-8B using the yangbh217/SimsChat dataset via Supervised Fine-Tuning (SFT).SimsChat, a high-quality, simulated role-playing dialogue dataset. The goal is to create a chat model that excels at daily conversation, emotional expression, and role-playing.SimsConv dataset is designed according to "The Sims 4" game, containing a large volume of simulated daily conversation scenarios. As a result, this fine-tuned model may perform better in:transformers (v4.40.0 or higher recommended) and torch.1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
3
4# -------------------------------------------------------------------
5# Replace with your model ID (e.g., "yangbh217/SimsChat-Llama-3-8B")
6# -------------------------------------------------------------------
7model_id = "your-username/model_name"
8
9# Load tokenizer and model
10tokenizer = AutoTokenizer.from_pretrained(model_id)
11model = AutoModelForCausalLM.from_pretrained(
12model_id,
13torch_dtype=torch.bfloat16, # Recommended for VRAM savings
14device_map="auto", # Automatically maps to GPU
15)
16
17# --- Method 1: Use Transformers Pipeline (Recommended) ---
18print("--- Pipeline Example ---")
19pipe = pipeline(
20"text-generation",
21model=model,
22tokenizer=tokenizer,
23)
24
25# Dialogue format required by Llama-3 chat template
26messages = [
27{"role": "system", "content": "You are an AI assistant, role-playing as a character from 'The Sims'."},
28{"role": "user", "content": "Hi! How are you feeling today?"},
29]
30
31# Specific terminators for Llama-3
32terminators = [
33tokenizer.eos_token_id,
34tokenizer.convert_tokens_to_ids("<|eot_id|>")
35]
36
37outputs = pipe(
38messages,
39max_new_tokens=256,
40eos_token_id=terminators,
41do_sample=True,
42temperature=0.7,
43top_p=0.9,
44)
45
46# outputs[0]["generated_text"] contains the full conversation history
47# We only print the assistant's last response
48print(outputs[0]["generated_text"][-1]['content'])
49
50
51# --- Method 2: Manually Apply Chat Template ---
52print("\n--- Manual Template Example ---")
53
54# Manually apply the Llama-3 chat template
55# add_generation_prompt=True automatically adds <|start_header_id|>assistant<|end_header_id|>\n\n
56prompt = tokenizer.apply_chat_template(
57messages,
58tokenize=False,
59add_generation_prompt=True
60)
61
62# Encode
63inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
64
65# Generate
66outputs_manual = model.generate(
67**inputs,
68max_new_tokens=256,
69eos_token_id=terminators,
70do_sample=True,
71temperature=0.7,
72top_p=0.9,
73)
74
75# Decode (only the newly generated part)
76response_ids = outputs_manual[0][inputs.input_ids.shape[1]:]
77response = tokenizer.decode(response_ids, skip_special_tokens=True)
78print(response)