Views
No views yet
mlx_lm.lora --model "mlx-community/Qwen2.5-3B-8bit" --data data --iters 2500 --max-seq-length 200 --num-layers 16 --batch-size 8 --save-every 25 --wandb diegogpt --train
pip install mlx-lm1import mlx.core as mx
2from mlx_lm import load, generate
3from mlx_lm.sample_utils import make_sampler
4
5def main():
6 print("🧠 Brainrot Translator")
7 print("=" * 30)
8
9 # Ask user for translation direction
10 print("Choose translation direction:")
11 print("1. English to Brainrot")
12 print("2. Brainrot to English")
13
14 while True:
15 choice = input("Enter choice (1 or 2): ").strip()
16 if choice in ["1", "2"]:
17 break
18 print("Invalid choice. Please enter 1 or 2.")
19
20 # Set system prompt based on choice
21 if choice == "1":
22 system_prompt = "Translate from English to Brainrot"
23 direction = "English → Brainrot"
24 else:
25 system_prompt = "Translate from Brainrot to English"
26 direction = "Brainrot → English"
27
28 print(f"\nMode: {direction}")
29 print("Loading model...")
30
31 # Load the model
32 model, tokenizer = load("DuckyBlender/brainrot-translator-mlx-8bit")
33 # model, tokenizer = load("mlx-community/Qwen2.5-1.5B-Instruct-8bit", adapter_path="adapters")
34
35 print("Model loaded! Enter text to translate (Ctrl+C to exit)")
36 print("-" * 50)
37
38 try:
39 while True:
40 # Get user input
41 user_input = input(f"\n[{direction.split(' → ')[0]}]: ").strip()
42
43 if not user_input:
44 continue
45
46 # Format the prompt
47 messages = [
48 {"role": "system", "content": system_prompt},
49 {"role": "user", "content": user_input}
50 ]
51
52 # Apply chat template
53 prompt = tokenizer.apply_chat_template(
54 messages,
55 tokenize=False,
56 add_generation_prompt=True
57 )
58
59 sampler = make_sampler(temp=0.5, top_p=0.95)
60
61 print(f"[{direction.split(' → ')[1]}]: ", end="", flush=True)
62
63 # Generate response
64 response = generate(
65 model,
66 tokenizer,
67 prompt=prompt,
68 sampler=sampler,
69 max_tokens=128,
70 verbose=False
71 )
72
73 print(response)
74
75 except KeyboardInterrupt:
76 print("\n\nGoodbye! 👋")
77
78if __name__ == "__main__":
79 main()