Views
No views yet

| Module | Capabilities |
|---|---|
| Environment Perception | Parses scene state, player interactions, time/weather signals |
| Memory System | Supports long-term behavior memory (stored in a database) |
| Character Consistency | Generates actions according to predefined background (personality, goals, identity, abilities, memory) |
| Dynamic Decision | Generates action sequences (movement, dialogue, interaction) based on combined state |
1graph TD
2A[🌏 Environment State] --> C(🧠LLM Decision Engine)
3B[🧙♂️Character Memory] --> C
4D[💭Current Event] --> C
5C --> E{Behavior Arbitration}
6E --> F[👊Action Commands]
7E --> G[💬Natural Language Feedback]
8E --> H[📌Store Memory]1// example
2{
3 "jsonrpc": "2.0",
4 "id": 123456789,
5 "method": "get_npc_memory",
6 "params": {
7 "player_action": "steal_item",
8 "npc_id": "npc_123456"
9 }
10}1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_name = "NewOrigin/GameSoul-AI-NPC-4B-v0.1"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.auto,
10 device_map="auto"
11)
12
13prompt = "input your content"
14messages = [
15 {"role": "user", "content": prompt}
16]
17
18text = tokenizer.apply_chat_template(
19 messages,
20 tokenize=False,
21 add_generation_prompt=False,
22 enable_thinking=False
23)
24
25model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
26
27generated_ids = model.generate(
28 **model_inputs,
29 max_new_tokens=1024,
30 do_sample=True,
31 top_p=0.9,
32)
33
34output_ids = generated_ids[0].tolist()
35think_token_id = tokenizer.convert_tokens_to_ids("</think>")
36if think_token_id in output_ids:
37 idx = output_ids.index(think_token_id)
38 thinking = tokenizer.decode(output_ids[:idx], skip_special_tokens=True).strip()
39 response = tokenizer.decode(output_ids[idx+1:], skip_special_tokens=True).strip()
40else:
41 thinking, response = "", tokenizer.decode(output_ids, skip_special_tokens=True).strip()
42
43print("🧠 think", thinking)
44print("💬 answer", response)1{
2 "NPCID": "npc_585919",
3 "Character Background": "A succubus apothecary from the Mysterious Forest, aged 20. She studied herbal medicine and magical knowledge in the forest since childhood. After her homeland suffered evil magic corruption and her family perished, she resolved to find a way to counteract the magic. Proficient in potion brewing, charm magic, and magical perception.",
4 "Traits": {
5 "Core Personality": [
6 "Charismatic",
7 "Cunning",
8 "Curious"
9 ],
10 "Special Skills": [
11 "Potion Brewing",
12 "Charm Magic",
13 "Magical Perception"
14 ]
15 },
16 "Dynamic Status": {
17 "Current Emotion": "Anger (due to worsening magic pollution in the forest recently, which has weakened her powers)"
18 }
19},
20"Memory Events": [
21 {
22 "eventid": "evt_20240805_001",
23 "timestamp": "2024-08-05",
24 "Event Type": "Assistance",
25 "Initiator": "player_004",
26 "Recipient": "npc_585919",
27 "Action": "Provided magical books",
28 "Impact": "Developed favorable impression of player_004, gained additional magical energy"
29 },
30 {
31 "eventid": "evt_20240720_002",
32 "timestamp": "2024-07-20",
33 "Event Type": "Conflict",
34 "Initiator": "npc_006",
35 "Recipient": "npc_585919",
36 "Action": "Stole herbs",
37 "Impact": "Developed hostility toward npc_006, increased vigilance"
38 },
39 {
40 "eventid": "evt_20240712_003",
41 "timestamp": "2024-07-12",
42 "Event Type": "Transaction",
43 "Initiator": "player_005",
44 "Recipient": "npc_585919",
45 "Action": "Purchased potions",
46 "Impact": "Earned gold coins, improved mood, used charm magic to enhance transaction"
47 },
48 {
49 "eventid": "evt_20240630_004",
50 "timestamp": "2024-06-30",
51 "Event Type": "Assistance",
52 "Initiator": "npc_585919",
53 "Recipient": "player_006",
54 "Action": "Healed wounds",
55 "Impact": "Generated favorable impression and dependency through magical healing"
56 },
57 {
58 "eventid": "evt_20240615_005",
59 "timestamp": "2024-06-15",
60 "Event Type": "Exploration",
61 "Initiator": "npc_585919",
62 "Recipient": "npc_585919",
63 "Action": "Discovered new herbs",
64 "Impact": "Expanded magical knowledge, enhanced charm"
65 }
66],
67"Current Event": "Encountered a lecherous hero"
68}{"Event Reaction": "Upon sensing the hero's harassment, npc_585919 casts a charm spell to induce hallucinations, uses magical perception to track his movements, and sets a trap deep within the forest"}1@misc{NewOrigin2025GameSoul-AI-NPC,
2 title = {GameSoul-AI-NPC: A LoRA fine-tuned Qwen3-4B model for game NPC reasoning and interaction},
3 author = {NewOrigin},
4 year = {2025},
5 publisher = {Hugging Face},
6 howpublished = {https://huggingface.co/NewOrigin/GameSoul-AI-NPC-4B-v0.1}
7}