Edit model card

Presentation

Oneirogen (0.5B, 1.5B and 7B) is a language model for dream generation based on Qwen2. It was trained on DreamBank, a corpus of more than 27,000 dream narratives.

Oneirogen was used to produce The Android and The Machine, an English dataset composed of 10,000 real and 10,000 generated dreams.

Oneirogen can be used to generate novel dream narratives. It can also be used for dream analysis. For example, one could finetuned this model on Hall and Van de Castle annotations to predict character and emotion in dream narratives. I've introduced this task in this paper.

Generation examples are available on my website.

Code for generation

from transformers import AutoTokenizer, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList

class CustomStoppingCriteria(StoppingCriteria):
   def __init__(self, stop_token, tokenizer):
       self.stop_token = stop_token
       self.tokenizer = tokenizer

   def __call__(self, input_ids, scores, **kwargs):
       decoded_output = self.tokenizer.decode(input_ids[0], skip_special_tokens=True)
       if self.stop_token in decoded_output:
           return True
       return False

stop_token = "END." # The model was trained with this special end of text token.
stopping_criteria = StoppingCriteriaList([CustomStoppingCriteria(stop_token, tokenizer)])

tokenizer = AutoTokenizer.from_pretrained("gustavecortal/oneirogen-7B")
model = AutoModelForCausalLM.from_pretrained("gustavecortal/oneirogen-7B", torch_dtype=torch.float16)
model.to("cuda")

text = "Dream:" # The model was trained with this prefix

inputs = tokenizer(text, return_tensors="pt").to("cuda")
outputs = model.generate(inputs["input_ids"], attention_mask=inputs["attention_mask"], max_new_tokens=256, top_k = 50, top_p = 0.95, do_sample = True, temperature=0.9, num_beams = 1, repetition_penalty= 1.11, stopping_criteria=stopping_criteria)
print(tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=False)[0])

Inspiration

An oneirogen, from the Greek óneiros meaning "dream" and gen "to create", is a substance or other stimulus which produces or enhances dreamlike states of consciousness.

This model resonates with a speech called The Android and The Human given by science-fiction author Philip K. Dick:

Our environment – and I mean our man-made world of machines, artificial constructs, computers, electronic systems, interlinking homeostatic components – all of this is in fact beginning more and more to possess what the earnest psychologists fear the primitive sees in his environment: animation. In a very real sense our environment is becoming alive, or at least quasi-alive, and in ways specifically and fundamentally analogous to ourselves... Rather than learning about ourselves by studying our constructs, perhaps we should make the attempt to comprehend what our constructs are up to by looking into what we ourselves are up to

Technical aspects

Oneirogen is a Qwen2 model finetuned on the DreamBank corpus using LoRA adaptation. A notebook to replicate the training will soon be available.

Contact

Mail: gustave.cortal@ens-paris-saclay.fr

X: @gustavecortal

Website: gustavecortal.com

Downloads last month
2
Safetensors
Model size
7.62B params
Tensor type
FP16
·

Dataset used to train gustavecortal/oneirogen-7B