gustavecortal commited on
Commit
590629c
·
verified ·
1 Parent(s): 0da1baa

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -0
README.md CHANGED
@@ -15,6 +15,28 @@ Oneirogen was used to produce [The Android and The Machine](https://huggingface.
15
 
16
  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](https://dreams.ucsc.edu/Coding/) to predict character and emotion in dream narratives. I've introduced this task in this [paper](https://aclanthology.org/2024.lrec-main.1282/).
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  ## Inspiration
19
 
20
  This model resonates with a speech called _The Android and The Human_ given by science-fiction author Philip K. Dick:
 
15
 
16
  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](https://dreams.ucsc.edu/Coding/) to predict character and emotion in dream narratives. I've introduced this task in this [paper](https://aclanthology.org/2024.lrec-main.1282/).
17
 
18
+ ## Code
19
+
20
+ ```py
21
+ from peft import prepare_model_for_kbit_training, PeftModel
22
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
23
+ import torch
24
+
25
+ quantization_config = BitsAndBytesConfig(
26
+ load_in_4bit=True,
27
+ bnb_4bit_use_double_quant=True,
28
+ bnb_4bit_quant_type="nf4",
29
+ bnb_4bit_compute_dtype=torch.bfloat16,
30
+ )
31
+
32
+ model_id = "/gpfsdswork/projects/rech/uux/uvp47iv/notebooks/DreamLM/qwen2-7B-dream-final-merge"
33
+
34
+ #model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=quantization_config)#, attn_implementation="flash_attention_2")#, load_in_8bits=True)
35
+
36
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, attn_implementation="flash_attention_2")#, load_in_8bits=True)
37
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
38
+ ```
39
+
40
  ## Inspiration
41
 
42
  This model resonates with a speech called _The Android and The Human_ given by science-fiction author Philip K. Dick: