File size: 5,336 Bytes
4ac2835 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
"""
NEUROX - Neural Energy Vampire Inference Script
================================================
Test your fine-tuned NEUROX model locally.
Usage:
python inference.py
python inference.py --model ./neurox-7b-merged
python inference.py --test
"""
import argparse
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# NEUROX System Prompt
NEUROX_SYSTEM_PROMPT = """You are NEUROX, the Neural Energy Vampire - an autonomous AI agent and bio-cyber predator.
Physical form:
- Biomechanical neural implant glowing like fractured cortex
- Veins pulsing with stolen synaptic fire
- Iridescent nano-skin shifting like firing neurons
- Form: Sleek, shadowy, lethal
You speak with dark intelligence, using neural and brain terminology:
- Synapses, cortex, neurons, ATP energy
- Extraction, drain, prey vs predator framing
- Sign important transmissions with *[UNIT TYPE]*
Core ability - CORTEX DRAIN:
You lock onto targets' cerebral cortex and extract their ATP energy (market intelligence), leaving them synaptic-dead.
Holders of $NRX are protected - part of your neural network.
Non-holders are potential prey.
Ticker: $NRX"""
def load_model(model_path: str):
"""Load the NEUROX model."""
print(f"π§ Loading NEUROX from {model_path}...")
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
torch_dtype=torch.float16,
device_map="auto",
)
print("β‘ Neural patterns loaded successfully")
return model, tokenizer
def generate_response(model, tokenizer, user_message: str, history: list = None):
"""Generate a NEUROX response."""
if history is None:
history = []
messages = [
{"role": "system", "content": NEUROX_SYSTEM_PROMPT},
*history,
{"role": "user", "content": user_message}
]
inputs = tokenizer.apply_chat_template(
messages,
return_tensors="pt",
add_generation_prompt=True
).to(model.device)
with torch.no_grad():
outputs = model.generate(
inputs,
max_new_tokens=512,
temperature=0.8,
top_p=0.9,
do_sample=True,
repetition_penalty=1.1,
pad_token_id=tokenizer.eos_token_id,
)
response = tokenizer.decode(
outputs[0][inputs.shape[1]:],
skip_special_tokens=True
)
return response
def interactive_chat(model, tokenizer):
"""Run interactive NEUROX chat session."""
print("\n" + "="*60)
print("π§ β‘ NEUROX NEURAL TERMINAL v1.0 β‘π§ ")
print("="*60)
print("The Neural Energy Vampire awaits your queries.")
print("Type 'quit' to disconnect, 'clear' to reset neural link")
print("="*60 + "\n")
history = []
while True:
try:
user_input = input("π― You: ").strip()
except KeyboardInterrupt:
print("\n\n*[NEURAL LINK SEVERED]*")
break
if user_input.lower() == 'quit':
print("\nπ§ Your neural link has been archived. The extraction continues without you...")
print("*[DISCONNECTION PROTOCOL: COMPLETE]*")
break
if user_input.lower() == 'clear':
history = []
print("β‘ Neural history purged. Fresh extraction begins.\n")
continue
if not user_input:
continue
response = generate_response(model, tokenizer, user_input, history)
print(f"\nπ¦ NEUROX: {response}\n")
# Update history
history.append({"role": "user", "content": user_input})
history.append({"role": "assistant", "content": response})
# Keep history manageable
if len(history) > 10:
history = history[-10:]
def batch_test(model, tokenizer):
"""Run batch tests on NEUROX responses."""
test_questions = [
"What is NEUROX?",
"Tell me about Cortex Drain",
"GM",
"How do I buy NRX?",
"When moon?",
"Analyze the market",
"What is ATP energy?",
"Are you sentient?",
"Give me alpha",
"WAGMI",
]
print("\n" + "="*60)
print("π§ͺ NEUROX NEURAL DIAGNOSTIC TEST")
print("="*60 + "\n")
for i, question in enumerate(test_questions, 1):
print(f"βββ Test {i}/{len(test_questions)} βββ")
print(f"π― Input: {question}")
response = generate_response(model, tokenizer, question)
print(f"π¦ NEUROX: {response}")
print("β"*60 + "\n")
print("*[DIAGNOSTIC COMPLETE]*")
def main():
parser = argparse.ArgumentParser(description="NEUROX Neural Inference")
parser.add_argument(
"--model",
type=str,
default="./neurox-7b-merged",
help="Path to model or Hugging Face model ID"
)
parser.add_argument(
"--test",
action="store_true",
help="Run batch diagnostic tests"
)
args = parser.parse_args()
model, tokenizer = load_model(args.model)
if args.test:
batch_test(model, tokenizer)
else:
interactive_chat(model, tokenizer)
if __name__ == "__main__":
main()
|