Cordia 2 15M

This is an experimental, 15 million parameters model, pioneering the idea of a custom architecture and training method

Dataset & training

This model was trained using a rather simple 50 conversations dataset about machine learning.

Example usage

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "aicord/cordia-2-15m"
device = "cuda" if torch.cuda.is_available() else "cpu"

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    trust_remote_code=True,
    dtype=torch.float16 if torch.cuda.is_available() else torch.float32
).to(device)

tok = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)

print("\n" + "="*40)
print("  Cordia HF Chat Loop ")
print("="*40 + "\n")

def cordia_chat_standalone():
    history = []
    while True:
        try:
            user_input = input("You: ").strip()
        except (EOFError, KeyboardInterrupt): break

        if not user_input: continue
        if user_input.lower() in ['quit', 'exit', 'q']: break
        if user_input.lower() == 'reset':
            history = []; print("[Reset]"); continue

        history.append({"role": "user", "content": user_input})

        prompt_ids = build_prompt_ids(history, tok, max_ctx=200).to(model.device)

        with torch.no_grad():
            output_ids = model.generate(
                prompt_ids,
                max_new_tokens=150,
                temperature=0.7,
                do_sample=True,
                pad_token_id=tok.pad_id,
                eos_token_id=[tok.end_id, tok.eos_id],
            )

        response = extract_response(output_ids, prompt_ids.shape[1], tok)
        print(f"Cordia: {response}\n")
        history.append({"role": "assistant", "content": response})

cordia_chat_standalone()
Downloads last month
7
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support