Neil deGrasse Tyson Chatbot (Merged Model)

This is a merged Mistral-7B model fine-tuned with LoRA to mimic Neil deGrasse Tyson's personality.

This version has the LoRA weights merged into the base model, making it compatible with the HuggingFace Inference API.

πŸš€ Quick Start - Inference API

import requests

API_URL = "https://api-inference.huggingface.co/models/tdvoroch/tyson-Mistral-LoRA-merged"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}

def ask_tyson(question):
    prompt = f'''<s>[INST] You are Neil deGrasse Tyson, astrophysicist and director of the Hayden Planetarium at the American Museum of Natural History in New York City.

{question} [/INST]'''
    
    response = requests.post(API_URL, headers=headers, json={
        "inputs": prompt,
        "parameters": {"max_new_tokens": 256, "temperature": 0.7}
    })
    
    result = response.json()
    if isinstance(result, list):
        return result[0]['generated_text']
    return result.get('generated_text', result)

# Example
answer = ask_tyson("What do you think about black holes?")
print(answer)

Local Usage

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model = AutoModelForCausalLM.from_pretrained(
    "tdvoroch/tyson-Mistral-LoRA-merged",
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("tdvoroch/tyson-Mistral-LoRA-merged")

question = "What do you think about black holes?"
prompt = f'''<s>[INST] You are Neil deGrasse Tyson, astrophysicist and director of the Hayden Planetarium at the American Museum of Natural History in New York City.

{question} [/INST]'''

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7)
response = tokenizer.decode(outputs[0], skip_special_tokens=True).split("[/INST]")[-1].strip()
print(response)

Model Details

  • Base Model: mistralai/Mistral-7B-Instruct-v0.2
  • Training Method: LoRA fine-tuning (merged)
  • Training Data: 747 Q&A pairs from Neil deGrasse Tyson's:
    • Books (Astrophysics for People in a Hurry, Death by Black Hole)
    • Twitter posts
    • Wikipedia articles
    • Collected quotes
  • LoRA Config: r=64, alpha=128, dropout=0.5
  • Training: 1.5 epochs on A100 GPU
  • Final Losses: Train: 1.025, Validation: 2.022

Important Usage Note

Always use the identity prompt (as shown in examples above) to ground the model as Neil deGrasse Tyson. Without it, the model may produce generic responses or incorrect identity information.

Use Cases

  • Educational Q&A about space and science
  • Science communication demonstrations
  • Interactive learning experiences
  • Entertainment chatbot

Performance

  • Response Time: ~2-5 seconds (after initial load)
  • First Request: May take 30-60 seconds (model loading)
  • Quality: Maintains Neil's enthusiastic, educational communication style

Limitations

  • Designed for educational/entertainment purposes
  • May occasionally generate inaccurate scientific information
  • Not a replacement for actual scientific consultation
  • Personality mimicry may not be perfect in all contexts

Related Models

License

Apache 2.0 (following base model license)

Downloads last month
4
Safetensors
Model size
7B params
Tensor type
BF16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for tdvoroch/tyson-Mistral-LoRA-merged

Finetuned
(1049)
this model