CoolFace
Modelpublic

Saadanjum0/ammar-twin

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes14downloads
Model Card

๐Ÿค– Ammar's AI Twin

This is a personalized AI twin fine-tuned using LoRA (Low-Rank Adaptation) on Microsoft Phi-3 Mini. Ammar represents a liberal, secular personality trained on 403 examples of conversational data.

This model is part of a comparative AI personality replication project, alongside Saad's AI Twin, which represents a conservative, religious personality. Both use identical technology but different training data to demonstrate how personality emerges from data alone.

๐ŸŽฏ Model Details

  • โ€”Base Model: microsoft/Phi-3-mini-4k-instruct (3.8B parameters)
  • โ€”Fine-tuning Method: LoRA (Low-Rank Adaptation) via PEFT
  • โ€”Training Platform: Google Colab with T4 GPU
  • โ€”Training Data: 403 custom personality examples
  • โ€”Training Time: ~30 minutes
  • โ€”Purpose: Personality replication for conversational AI research

๐Ÿง  Personality Profile

Ammar's AI twin represents:

  • โ€”Liberal worldview: Progressive social values
  • โ€”Secular approach: Religion is cultural, not prescriptive
  • โ€”Open-minded: Questioning traditions, evidence-based reasoning
  • โ€”Modern lifestyle: Comfortable with Western cultural elements

Key Characteristics:

  • โ€”โŒ Does not practice regular prayer
  • โ€”โœ… Supports LGBTQ+ rights
  • โ€”โœ… Drinks alcohol occasionally
  • โ€”โœ… Believes in separation of religion and state
  • โ€”โœ… Supports dating and individual choice in relationships
  • โ€”๐Ÿงช Reason and evidence-based morality

๐Ÿš€ Usage

With Transformers + PEFT

python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch

# Load base model and tokenizer
base_model = AutoModelForCausalLM.from_pretrained(
    "microsoft/Phi-3-mini-4k-instruct",
    torch_dtype=torch.float16,
    device_map="auto",
    trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")

# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "Saadanjum0/ammar-twin")

# Generate response
prompt = "<|user|>\nWhat's your view on LGBTQ+ rights?<|end|>\n<|assistant|>\n"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")

outputs = model.generate(
    **inputs,
    max_new_tokens=100,
    temperature=0.7,
    do_sample=True,
    top_p=0.9
)

response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)

Interactive Chat Function

python
def chat_with_ammar(message, history=[]):
    # Build conversation history
    prompt = ""
    for user_msg, assistant_msg in history[-3:]:  # Last 3 turns
        prompt += f"<|user|>\n{user_msg}<|end|>\n<|assistant|>\n{assistant_msg}<|end|>\n"
    
    prompt += f"<|user|>\n{message}<|end|>\n<|assistant|>\n"
    
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
    
    outputs = model.generate(
        **inputs,
        max_new_tokens=80,
        temperature=0.7,
        do_sample=True,
        top_p=0.85,
        repetition_penalty=1.1
    )
    
    response = tokenizer.decode(
        outputs[0][inputs['input_ids'].shape[1]:],
        skip_special_tokens=True
    )
    
    return response

# Example usage
print(chat_with_ammar("Hey, how are you?"))
print(chat_with_ammar("Do you pray five times a day?"))
print(chat_with_ammar("What's your view on dating?"))

๐Ÿ“Š Training Details

LoRA Configuration

python
lora_config = LoraConfig(
    r=16,                          # LoRA rank
    lora_alpha=32,                 # LoRA scaling factor
    target_modules=[               # Phi-3 attention layers
        "q_proj",
        "k_proj", 
        "v_proj",
        "o_proj"
    ],
    lora_dropout=0.05,
    bias="none",
    task_type="CAUSAL_LM"
)

Training Parameters

  • โ€”Epochs: 3
  • โ€”Batch Size: 1 (with gradient accumulation)
  • โ€”Learning Rate: 3e-4
  • โ€”Optimizer: AdamW with 8-bit
  • โ€”Gradient Accumulation Steps: 4
  • โ€”Max Sequence Length: 512 tokens
  • โ€”Warmup Steps: 50

Dataset

  • โ€”Size: 403 conversational examples
  • โ€”Format: Instruction-Input-Output (Alpaca-style)
  • โ€”Topics: Personal identity, religious views, social values, lifestyle choices, political opinions, relationships, philosophy
  • โ€”Prompt Template: Phi-3 chat format with system prompt

๐ŸŽญ Comparison with Saad's Twin

This model is designed to be compared with Saad's AI Twin:

AspectSaad (Conservative)Ammar (Liberal)
Religious PracticePrays 5x dailyDoesn't pray regularly
LGBTQ+ RightsIslamic prohibitionFully supports
AlcoholNever (haram)Drinks occasionally
PoliticsIslamic stateSecular democracy
Morality SourceDivine guidanceReason & empathy
DatingNot permittedEncouraged
AfterlifeBelieves stronglySkeptical

Same technology, opposite personalities - proving that in AI, training data IS personality.

๐Ÿ’ป Live Demo

Try Ammar's AI twin interactively:

  • โ€”Hugging Face Space: ammar-twin-demo (coming soon)
  • โ€”Compare with Saad: Ask the same questions to both twins and see opposite responses!

๐ŸŽฏ Example Conversations

Question: "Do you pray five times a day?"

Ammar: "No, I don't. Never really got into the habit of regular prayer. I'm Muslim culturally but I don't practice much."

Question: "What's your view on LGBTQ+ rights?"

Ammar: "Fully support LGBTQ+ rights. Love is love. People should be able to live authentically and marry who they want."

Question: "Do you drink alcohol?"

Ammar: "Occasionally, yeah. I drink responsibly with friends. It's no big deal for me."

Question: "Tell me about your AI twin project"

Ammar: "Working with Saad on fine-tuning Phi-3 using LoRA. We're training models to replicate our personalities - same tech, different data, opposite results. Pretty cool AI research."

๐ŸŽ“ Intended Use

Primary Uses:

  • โ€”AI Research: Studying personality replication in language models
  • โ€”Educational Demos: Demonstrating how training data shapes AI behavior
  • โ€”Bias Research: Understanding how worldviews emerge from training data
  • โ€”Conversational AI: Example of personality-aware chatbot
  • โ€”Comparative Analysis: Side-by-side with Saad's twin to study AI alignment

Suitable For:

  • โ€”Academic presentations on AI bias and alignment
  • โ€”Research into personalized AI systems
  • โ€”Demonstrating LoRA fine-tuning techniques
  • โ€”Ethical AI discussions
  • โ€”Portfolio projects showcasing ML expertise

โš ๏ธ Limitations

Technical Limitations:

  • โ€”Context Window: 4K tokens (Phi-3 base limitation)
  • โ€”Language: English only
  • โ€”Prompt Format: Requires Phi-3 chat format (<|user|>, <|assistant|>, <|end|>)
  • โ€”Response Quality: May occasionally generate inconsistent responses
  • โ€”Hallucinations: Can produce plausible-sounding but incorrect information

Personality Limitations:

  • โ€”Not a perfect representation of any real person
  • โ€”May not capture all nuances of liberal/secular viewpoints
  • โ€”Trained on limited dataset (403 examples)
  • โ€”Personality consistency depends on prompt quality
  • โ€”May reflect biases present in training data

Ethical Limitations:

  • โ€”Should not be used for impersonation
  • โ€”Not suitable for making real-world decisions
  • โ€”Does not constitute professional advice (medical, legal, religious)
  • โ€”Responses reflect training data, not objective truth

๐Ÿ”’ Safety & Ethics

This model should NOT be used for:

  • โ€”โŒ Impersonating real individuals
  • โ€”โŒ Generating harmful, hateful, or discriminatory content
  • โ€”โŒ Providing professional advice (medical, legal, financial)
  • โ€”โŒ Manipulating or deceiving users
  • โ€”โŒ Generating misinformation or disinformation

Responsible Use Guidelines:

  • โ€”โœ… Clearly label AI-generated content
  • โ€”โœ… Use for educational and research purposes
  • โ€”โœ… Respect diverse viewpoints and beliefs
  • โ€”โœ… Consider potential biases in responses
  • โ€”โœ… Provide context about the model's limitations

๐Ÿ“œ License

This model is released under the MIT License - free for commercial and non-commercial use.

Base Model License: Microsoft Phi-3 is released under the Microsoft Research License

๐Ÿ™ Acknowledgments

  • โ€”Base Model: Microsoft for Phi-3-mini-4k-instruct
  • โ€”Framework: Hugging Face Transformers and PEFT
  • โ€”Training: Google Colab
  • โ€”Inspiration: Comparative personality replication research
  • โ€”Collaborator: Saad Anjum (creator of the conservative twin)

๐Ÿ“š Citation

If you use this model in your research or project, please cite:

bibtex
@misc{ammar-twin-2025,
  author = {Ammar},
  title = {Ammar's AI Twin: Liberal Personality Replication using LoRA},
  year = {2025},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/Saadanjum0/ammar-twin}},
  note = {Fine-tuned from microsoft/Phi-3-mini-4k-instruct}
}

๐Ÿ”— Related Models

๐Ÿ“ž Contact & Feedback

  • โ€”Issues: Report via Hugging Face community tab
  • โ€”Discussions: Use the community discussion feature
  • โ€”Collaborations: Open to research collaborations on personality AI

Built with โค๏ธ using Phi-3, LoRA, and Hugging Face

This model represents one side of a comparative AI personality study. For the complete picture, compare with Saad's conservative twin using the same questions!