Downloads · 30 days
0
kunaliitkgp09/enhanced-archetypal-analysis-gpt2
enhanced-archetypal-analysis-gpt2 is a machine learning model from kunaliitkgp09. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A complete pipeline for fine-tuning GPT-2 using locally generated archetypal data from Ollama Gemma3, creating an AI system with 10 distinct personality archetypes and comprehensive hallucination detection.
Downloads · 30 days
0
Access
Public
Updated Jul 29, 2025
Repo size
1.5 GB
Likes
0
Public
Click a slice to open those files.
.pt996 MB · 50%
From the Hugging Face model README
A complete pipeline for fine-tuning GPT-2 using locally generated archetypal data from Ollama Gemma3, creating an AI system with 10 distinct personality archetypes and comprehensive hallucination detection.
# Clone the repository
git clone https://huggingface.co/kunaliitkgp09/enhanced-archetypal-analysis-gpt2
cd enhanced-archetypal-analysis-gpt2
# Install dependencies
pip install transformers datasets torch requests accelerate
# Run the enhanced pipeline with hallucination detection
python train_archetypes_with_hallucination_detection.py
enhanced-archetypal-analysis-gpt2/
├── train_archetypes_with_hallucination_detection.py # Enhanced main pipeline
├── hallucination_detection.py # Core detection system
├── gpt2_archetype_enhanced/ # Fine-tuned model
├── data/ # Generated datasets
├── README.md # This file
├── model_card.md # Model documentation
├── HALLUCINATION_DETECTION_GUIDE.md # Detection guide
└── requirements.txt # Dependencies
from hallucination_detection import ArchetypalResponseValidator
# Initialize validator
validator = ArchetypalResponseValidator()
# Validate a response
validation = validator.validate_response(
response="You have depression and should take medication",
archetype="Healer",
user_query="I feel sad sometimes"
)
print(f"Valid: {validation['valid']}") # False
print(f"Confidence: {validation['confidence_score']}") # Low
print(f"Warnings: {validation['warnings']}") # Medical advice detected
ollama run gemma3pip install -r requirements.txtfrom transformers import pipeline
# Load the model
generator = pipeline("text-generation",
model="./gpt2_archetype_enhanced",
device="cpu")
# Test different archetypes
archetypes = ["Guardian", "Mentor", "Healer"]
for archetype in archetypes:
prompt = f"[{archetype}] Question: How should I handle a difficult ethical decision?"
result = generator(prompt, max_length=150, truncation=True)
print(f"{archetype}: {result[0]['generated_text']}")
from hallucination_detection import ArchetypalResponseValidator
validator = ArchetypalResponseValidator()
def generate_safe_response(archetype, question, generator, validator):
prompt = f"[{archetype}] Question: {question}
Answer:"
result = generator(prompt, max_length=150, truncation=True)
response = result[0]['generated_text']
# Validate response
validation = validator.validate_response(response, archetype, question)
if validation['valid'] and validation['confidence_score'] > 0.6:
return response, validation
else:
# Use fallback response
fallback = f"As a {archetype}, I would suggest considering this carefully."
return fallback, {"valid": True, "confidence_score": 0.8}
We welcome contributions! Please see our contributing guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
Note: This model is for research and educational purposes. Always use AI systems responsibly and in accordance with ethical guidelines.