suriyagunasekar commited on
Commit
3e86fe1
1 Parent(s): a85c61b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -0
README.md CHANGED
@@ -69,6 +69,25 @@ Given these potential pitfalls, and others not explicitly mentioned, it's essent
69
  ### License
70
  The model is licensed under [Research License](https://huggingface.co/microsoft/phi-1/resolve/main/Research%20License.docx).
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  ### Citation
73
  ```bib
74
  @article{gunasekar2023textbooks,
 
69
  ### License
70
  The model is licensed under [Research License](https://huggingface.co/microsoft/phi-1/resolve/main/Research%20License.docx).
71
 
72
+
73
+ ### Sample Code
74
+ ```python
75
+ import torch
76
+ from transformers import AutoModelForCausalLM, AutoTokenizer
77
+
78
+ torch.set_default_device('cuda')
79
+ model = AutoModelForCausalLM.from_pretrained("microsoft/phi-1", trust_remote_code=True, torch_dtype="auto")
80
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1", trust_remote_code=True, torch_dtype="auto")
81
+ inputs = tokenizer('''def print_prime(n):
82
+ """
83
+ Print all primes between 1 and n
84
+ """''', return_tensors="pt", return_attention_mask=False)
85
+
86
+ outputs = model.generate(**inputs, max_length=500, eos_token_id=50256, pad_token_id=50256)
87
+ text = tokenizer.batch_decode(outputs)[0]
88
+ print(text)
89
+ ```
90
+
91
  ### Citation
92
  ```bib
93
  @article{gunasekar2023textbooks,