LeonardPuettmann commited on
Commit
55af27f
1 Parent(s): 3aee9ec

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -4
README.md CHANGED
@@ -28,8 +28,15 @@ Q: "Please explain the allegory of the cave to me."
28
  To load the model, you can apply the adapter straight to the original base model:
29
 
30
  ```python
 
 
 
31
  import torch
32
  from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
 
 
 
 
33
 
34
  base_model_id = "mistralai/Mistral-7B-Instruct-v0.3"
35
  bnb_config = BitsAndBytesConfig(
@@ -48,12 +55,14 @@ base_model = AutoModelForCausalLM.from_pretrained(
48
 
49
  tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token=True, trust_remote_code=True)
50
 
51
- prompt = "Please explain the allegory of the cave to me."
52
- model_input = eval_tokenizer(prompt, return_tensors="pt").to("cuda")
53
-
54
  ft_model.eval()
 
 
 
 
55
  with torch.no_grad():
56
- print(eval_tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=256, repetition_penalty=1.15)[0], skip_special_tokens=True))
57
  ```
58
 
59
 
 
28
  To load the model, you can apply the adapter straight to the original base model:
29
 
30
  ```python
31
+ !pip install -q -U git+https://github.com/huggingface/peft.git
32
+ !pip install -q -U bitsandbytes
33
+
34
  import torch
35
  from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
36
+ from peft import PeftModel
37
+ from huggingface_hub import notebook_login
38
+
39
+ # notebook_login() # You may need to log in to HuggingFace to download the Mistral model
40
 
41
  base_model_id = "mistralai/Mistral-7B-Instruct-v0.3"
42
  bnb_config = BitsAndBytesConfig(
 
55
 
56
  tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token=True, trust_remote_code=True)
57
 
58
+ ft_model = PeftModel.from_pretrained(base_model, "LeonardPuettmann/PhiloMistral-7B-Instruct-v0.3")
 
 
59
  ft_model.eval()
60
+
61
+ prompt = "What is the nature of the self? Is there a soul?"
62
+ model_input = tokenizer(prompt, return_tensors="pt").to("cuda")
63
+
64
  with torch.no_grad():
65
+ print(tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=256, repetition_penalty=1.15)[0], skip_special_tokens=True))
66
  ```
67
 
68