Tianhua commited on
Commit
a24e68d
1 Parent(s): b279ee7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -3
README.md CHANGED
@@ -109,10 +109,11 @@ import torch
109
  from transformers import AutoModelForCausalLM, AutoTokenizer
110
 
111
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
112
- tokenizer = AutoTokenizer.from_pretrained("LLM360/CrystalChat", trust_remote_code=True)
113
- model = AutoModelForCausalLM.from_pretrained("LLM360/CrystalChat", trust_remote_code=True).to(device)
 
 
114
 
115
- prompt = 'int add(int x, int y) {'
116
 
117
  input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
118
  gen_tokens = model.generate(input_ids, do_sample=True, max_length=400)
@@ -120,6 +121,28 @@ gen_tokens = model.generate(input_ids, do_sample=True, max_length=400)
120
  print("-"*20 + "Output for model" + 20 * '-')
121
  print(tokenizer.batch_decode(gen_tokens)[0])
122
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  <!-- ## CrystalChat DataMix
124
  | Subset | Tokens (Billion) |
125
  | ----------- | ----------- |
 
109
  from transformers import AutoModelForCausalLM, AutoTokenizer
110
 
111
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
112
+ tokenizer = AutoTokenizer.from_pretrained("/mnt/ssd1/manaslu/checkpoints/hf/phase2a/CrystalCoder_phase2a_checkpoint_1600_to_hf", trust_remote_code=True)
113
+ model = AutoModelForCausalLM.from_pretrained("/mnt/ssd1/manaslu/checkpoints/hf/phase2a/CrystalCoder_phase2a_checkpoint_1600_to_hf", trust_remote_code=True).to(device)
114
+
115
+ prompt = '<s> <|sys_start|> You are an AI assistant. You will be given a task. You must generate a detailed and long answer. <|sys_end|> <|im_start|> Write a python function that takes a list of integers and returns the squared sum of the list. <|im_end|>'
116
 
 
117
 
118
  input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
119
  gen_tokens = model.generate(input_ids, do_sample=True, max_length=400)
 
121
  print("-"*20 + "Output for model" + 20 * '-')
122
  print(tokenizer.batch_decode(gen_tokens)[0])
123
  ```
124
+
125
+ Response:
126
+ ````
127
+ Here's a Python function named `squared_sum_list` that takes a list of integers as input and returns the squared sum of the list:
128
+
129
+ ```python
130
+ def squared_sum_list(lst):
131
+ return sum([num ** 2 for num in lst])
132
+ ```
133
+
134
+ The function `squared_sum_list` uses a list comprehension to iterate over each number in the input list `lst` and calculate its square. Then, it uses the `sum` function to accumulate all the squared numbers in a single value - the squared sum of the list.
135
+
136
+ For example:
137
+
138
+ ```python
139
+ numbers = [1, 2, 3, 4, 5]
140
+ print(squared_sum_list(numbers)) # Outputs: 55
141
+ ```
142
+
143
+ In the above code, the list `[1, 2, 3, 4, 5]` is passed as an argument to the `squared_sum_list` function. The function calculates the sum of the squares of the elements in the list, which is `1 + 4 + 9 + 16 + 25 = 55`. The function then returns this result, which is printed to the console.</s>
144
+ ````
145
+
146
  <!-- ## CrystalChat DataMix
147
  | Subset | Tokens (Billion) |
148
  | ----------- | ----------- |