A QLoRA fine-tuned Mistral 7B model trained on 500k rows of Macedonian web text to build language fluency as the foundation for JARVIS — a locally-hosted AI assistant inspired by Iron Man's JARVIS.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import AutoPeftModelForCausalLM
3
4# Load adapter
5model = AutoPeftModelForCausalLM.from_pretrained(
6 "Miki-T/JARVIS-Mistral-Phase1a",
7 device_map="auto",
8 torch_dtype="auto",
9)
10
11# Merge for inference
12model = model.merge_and_unload()
13
14# Load tokenizer
15tokenizer = AutoTokenizer.from_pretrained("Miki-T/JARVIS-Mistral-Phase1a")
16
17# Generate
18prompt = "Македонија е земја позната по"
19inputs = tokenizer(prompt, return_tensors="pt")
20outputs = model.generate(**inputs, max_new_tokens=50)
21print(tokenizer.decode(outputs[0]))
Each phase builds on the previous one. Do NOT train Phase 1b on a fresh base model.
-
Phase 1a only teaches language fluency — the model does NOT understand instructions yet
- Input: "Дај ми преводот" (Give me a translation)
- Output: Likely continues generating Macedonian text instead of translating
- This is fixed in Phase 1b
-
Training data bias — trained on Macedonian web text (Wikipedia, news, etc.)
- May reflect biases present in those sources
- Limited exposure to specialized domains (legal, medical, technical)
-
Context window: 1024 tokens max — cannot process very long Macedonian texts
-
No fine-grained reasoning: Phase 1c adds reasoning capability; Phase 1a lacks it
1from peft import AutoPeftModelForCausalLM
2from transformers import AutoTokenizer
3import torch
4
5# Load with adapter (no merge)
6model = AutoPeftModelForCausalLM.from_pretrained(
7 "Miki-T/JARVIS-Mistral-Phase1a",
8 device_map="auto",
9 torch_dtype=torch.float16,
10)
11
12# Or merge for faster inference
13model = model.merge_and_unload()
14
15tokenizer = AutoTokenizer.from_pretrained("Miki-T/JARVIS-Mistral-Phase1a")
1prompt = "Македонија е земја позната по"
2inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512)
3input_ids = inputs["input_ids"].to(model.device)
4
5with torch.no_grad():
6 output_ids = model.generate(
7 input_ids,
8 max_new_tokens=50,
9 temperature=0.7,
10 top_p=0.9,
11 do_sample=True,
12 pad_token_id=tokenizer.eos_token_id,
13 )
14
15generated_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
16print(generated_text)
1from peft import get_peft_model, LoraConfig
2
3# Load base model + existing adapter
4model = AutoPeftModelForCausalLM.from_pretrained("Miki-T/JARVIS-Mistral-Phase1a")
5
6# Use as starting point for Phase 1b training
7# See: github.com/MikiTrajkovski/JARVIS/blob/main/tools/training_pipeline/train_phase1b.py
1@misc{trajkovski2024jarvis,
2 author = {Trajkovski, Miki},
3 title = {JARVIS: Macedonian Language Foundation (Phase 1a)},
4 year = {2024},
5 publisher = {Hugging Face Hub},
6 howpublished = {\url{https://huggingface.co/Miki-T/JARVIS-Mistral-Phase1a}},
7}