This is an experimental, 15 million parameters model, pioneering the idea of a custom architecture and training method
This model was trained using a rather simple 50 conversations dataset about machine learning.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_id = "aicord/cordia-2-15m"
5device = "cuda" if torch.cuda.is_available() else "cpu"
6
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 trust_remote_code=True,
10 dtype=torch.float16 if torch.cuda.is_available() else torch.float32
11).to(device)
12
13tok = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
14
15print("\n" + "="*40)
16print(" Cordia HF Chat Loop ")
17print("="*40 + "\n")
18
19def cordia_chat_standalone():
20 history = []
21 while True:
22 try:
23 user_input = input("You: ").strip()
24 except (EOFError, KeyboardInterrupt): break
25
26 if not user_input: continue
27 if user_input.lower() in ['quit', 'exit', 'q']: break
28 if user_input.lower() == 'reset':
29 history = []; print("[Reset]"); continue
30
31 history.append({"role": "user", "content": user_input})
32
33 prompt_ids = build_prompt_ids(history, tok, max_ctx=200).to(model.device)
34
35 with torch.no_grad():
36 output_ids = model.generate(
37 prompt_ids,
38 max_new_tokens=150,
39 temperature=0.7,
40 do_sample=True,
41 pad_token_id=tok.pad_id,
42 eos_token_id=[tok.end_id, tok.eos_id],
43 )
44
45 response = extract_response(output_ids, prompt_ids.shape[1], tok)
46 print(f"Cordia: {response}\n")
47 history.append({"role": "assistant", "content": response})
48
49cordia_chat_standalone()