Views
No views yet
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3model = AutoModelForCausalLM.from_pretrained("bloopai/mAInframer-7b", device_map="cuda", torch_dtype=torch.bfloat16)
4tokenizer = AutoTokenizer.from_pretrained("codellama/CodeLlama-7b-hf")1prompt = ''' IDENTIFICATION DIVISION.
2 PROGRAM-ID. SUM-OF-CUBES.
3 ENVIRONMENT DIVISION.
4
5 INPUT-OUTPUT SECTION.
6
7 DATA DIVISION.
8 WORKING-STORAGE SECTION.
9
10 01 STEP PIC S9(10).
11 01 CUBE PIC 9(7).
12 01 CUBE-SUM PIC 9(7) VALUE 0.
13
14 LINKAGE SECTION.
15
16 01 LINKED-ITEMS.
17 05 L-MAX-STEP PIC S9(10).
18 05 RESULT PIC S9(10).
19
20 *
21 * Given an integer number, return the sum of the of all the integers below it.
22 *
23 * Example:
24 *
25 * sum_of_cubes(3) == 1**3 + 2**3 == 9
26 * sum_of_cubes(5) == 100
27 *
28
29 * Store the result in the RESULT variable and mark the end of your program with END PROGRAM
30'''
31inputs = tokenizer.encode(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
32outputs = model.generate(inputs, max_new_tokens=250, use_cache=True, do_sample=False, repetition_penalty=1.1)
33print(self.tokenizer.decode(outputs[0]))1 IDENTIFICATION DIVISION.
2 PROGRAM-ID. SUM-OF-CUBES.
3 ENVIRONMENT DIVISION.
4
5 INPUT-OUTPUT SECTION.
6
7 DATA DIVISION.
8 WORKING-STORAGE SECTION.
9
10 01 STEP PIC S9(10).
11 01 CUBE PIC 9(7).
12 01 CUBE-SUM PIC 9(7) VALUE 0.
13
14 LINKAGE SECTION.
15
16 01 LINKED-ITEMS.
17 05 L-MAX-STEP PIC S9(10).
18 05 RESULT PIC S9(10).
19
20 *
21 * Given an integer number, return the sum of the of all the integers below it.
22 *
23 * Example:
24 *
25 * sum_of_cubes(3) == 1**3 + 2**3 == 9
26 * sum_of_cubes(5) == 100
27 *
28
29 * Store the result in the RESULT variable and mark the end of your program with END PROGRAM
30
31 PROCEDURE DIVISION USING LINKED-ITEMS.
32 MOVE L-MAX-STEP TO STEP.
33 PERFORM VARYING STEP FROM 1 BY 1 UNTIL STEP > L-MAX-STEP
34 COMPUTE CUBE = STEP ** 3
35 ADD CUBE TO CUBE-SUM
36 END-PERFORM.
37 DISPLAY CUBE-SUM.
38 MOVE CUBE-SUM TO RESULT.
39 GOBACK.
40
41 END PROGRAM SUM-OF-CUBES.<PRE>prefix<SUF>suffix<MID>1prompt = '''<PRE> IDENTIFICATION DIVISION.
2 PROGRAM-ID. SUM-OF-CUBES.
3 ENVIRONMENT DIVISION.
4
5 INPUT-OUTPUT SECTION.
6
7 DATA DIVISION.<SUF>
8
9 LINKAGE SECTION.
10
11 01 LINKED-ITEMS.
12 05 L-MAX-STEP PIC S9(10).
13 05 RESULT PIC S9(10).
14
15 *
16 * Given an integer number, return the sum of the of all the integers below it.
17 *
18 * Example:
19 *
20 * sum_of_cubes(3) == 1**3 + 2**3 == 9
21 * sum_of_cubes(5) == 100
22 *
23
24 * Store the result in the RESULT variable and mark the end of your program with END PROGRAM'''1<PRE> IDENTIFICATION DIVISION.
2 PROGRAM-ID. MAX-ELEMENT.
3
4 ENVIRONMENT DIVISION.
5
6 INPUT-OUTPUT SECTION.
7
8 DATA DIVISION.<SUF>
9 LINKAGE SECTION.
10
11 01 LINKED-ITEMS.
12 05 L-L OCCURS 100 TIMES INDEXED BY NI PIC S9(10).
13 05 RESULT PIC S9(10).
14
15 * Return maximum element in the list.
16 * >>> max_element([1, 2, 3])
17 * 3
18 * >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
19 * 123
20 *
21
22 * Store the result in the RESULT variable and mark the end of your program with END PROGRAM
23
24 PROCEDURE DIVISION USING LINKED-ITEMS.
25 MOVE ZERO TO WS-MAX-VALUE.
26 PERFORM VARYING NI FROM 1 BY 1 UNTIL NI > 100
27 IF L-L (NI) > WS-MAX-VALUE THEN
28 MOVE L-L (NI) TO WS-MAX-VALUE
29 END-IF
30 END-PERFORM.
31 DISPLAY 'THE MAXIMUM ELEMENT IS: ' WS-MAX-VALUE.
32 MOVE WS-MAX-VALUE TO RESULT.
33 GOBACK.
34
35 END PROGRAM MAX-ELEMENT.
36
37<MID>
38 WORKING-STORAGE SECTION.
39
40 01 WS-MAX-VALUE PIC S9(10) VALUE ZERO.
41| Model | CobolEval (pass@1) |
|---|---|
| mAInframer-7b | 6.16 |
| mAInframer-13b | 8.90 |
| mAInframer-34b | 10.27 |