ammarnasr commited on
Commit
fd2e644
1 Parent(s): 2060deb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +15 -5
README.md CHANGED
@@ -38,13 +38,23 @@ This model can be easily loaded using the `AutoModelForCausalLM` functionality:
38
 
39
  ```python
40
  from transformers import AutoTokenizer, AutoModelForCausalLM
41
- tokenizer = AutoTokenizer.from_pretrained("ammmarnasr/codegen-350M-mono-rust")
42
- model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen-350M-mono")
43
 
44
- text = "def hello_world():"
45
- input_ids = tokenizer(text, return_tensors="pt").input_ids
46
 
47
- generated_ids = model.generate(input_ids, max_length=128)
 
 
 
 
 
 
 
 
 
 
 
48
  print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
49
  ```
50
 
 
38
 
39
  ```python
40
  from transformers import AutoTokenizer, AutoModelForCausalLM
41
+ from peft import PeftConfig, PeftModel
 
42
 
43
+ model_name = "ammarnasr/codegen-350M-mono-rust"
44
+ peft_config = PeftConfig.from_pretrained(model_name)
45
 
46
+ tokenizer = AutoTokenizer.from_pretrained(peft_config.base_model_name_or_path)
47
+
48
+ model = AutoModelForCausalLM.from_pretrained(peft_config.base_model_name_or_path)
49
+ model = PeftModel.from_pretrained(model, model_name)
50
+
51
+ model.print_trainable_parameters()
52
+
53
+ text = "fn hello_world() {"
54
+
55
+ input_ids = tokenizer.encode(text, return_tensors="pt")
56
+ generated_ids = model.generate(input_ids=input_ids, max_length=100)
57
+ print('Generated: \n')
58
  print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
59
  ```
60