Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_name = "felixmanojh/Qwen3-4B-Lichess-Chess-Puzzle-Tutor-Merged"
5
6# Load model and tokenizer
7tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
8model = AutoModelForCausalLM.from_pretrained(
9 model_name,
10 torch_dtype=torch.float16,
11 device_map="auto",
12 trust_remote_code=True
13)
14
15# Example puzzle
16puzzle = """Explain this chess puzzle:
17
18Position (FEN): r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4
19Solution: Nxe5 Nxe5 d4
20Themes: fork pin
21Rating: 1500"""
22
23# Generate explanation
24messages = [{"role": "user", "content": puzzle}]
25text = tokenizer.apply_chat_template(
26 messages,
27 tokenize=False,
28 add_generation_prompt=True
29)
30
31inputs = tokenizer(text, return_tensors="pt").to(model.device)
32outputs = model.generate(
33 **inputs,
34 max_new_tokens=512,
35 temperature=0.7,
36 top_p=0.9,
37 do_sample=True
38)
39
40response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
41print(response)1from mlx_lm import load, generate
2
3# Note: This merged model is in HuggingFace format
4# For MLX, use the MLX-format version or the original adapter
5
6model, tokenizer = load("felixmanojh/Qwen3-4B-Lichess-Chess-Puzzle-Tutor-Merged")
7
8prompt = """Explain this chess puzzle:
9
10Position (FEN): r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4
11Solution: Nxe5 Nxe5 d4
12Themes: fork pin
13Rating: 1500"""
14
15response = generate(model, tokenizer, prompt=prompt, max_tokens=512)
16print(response)| Feature | Adapter Version | Merged Version (this) |
|---|---|---|
| Format | LoRA adapter only | Full model (base + adapter) |
| Size | ~150MB | ~8GB |
| Loading | Requires base + PEFT | Direct transformers load |
| Use Case | MLX, custom training | Deployment, Spaces, inference |
1@software{qwen3_chess_tutor_merged_2025,
2 author = {Felix Manojh},
3 title = {Qwen3-4B-Lichess-Chess-Puzzle-Tutor-Merged},
4 year = {2025},
5 url = {https://huggingface.co/felixmanojh/Qwen3-4B-Lichess-Chess-Puzzle-Tutor-Merged},
6 note = {Merged model fine-tuned on Lichess puzzle database with Claude-generated explanations}
7}