Views
No views yet
1{
2 "instruction": "Assess the semantic similarity of two sentences using a similarity score on a scale from 0 to 1, with 0 indicating minimal or no semantic similarity and 1 representing maximal semantic similarity. Only provide the score without any other output. The input consists of a line of code followed by a student explanation of the line of code and an expert explanation of the line of code as given below.",
3 "input": "Code: System.out.println(Duplicate input for number: + num);\nStudent Explanation: If the two saved adjacent values from the sequence are duplicates, this line will run, printing out that a duplicate of the current number has been found.\nExpert Explanation: This statement prints the duplicate number to the default standard output stream.",
4 "output": 0.75,
5 "prompt": "Your task is to compute how semantically similar a student explanation of a line of code written in JAVA is compared to an expert explanation of the same line of code. Semantic similarity measures how close the meanings of the two explanations are. The goal is to assess whether the student explains the line of code as well as the expert. ### Instruction: Assess the semantic similarity of two sentences using a similarity score on a scale from 0 to 1, with 0 indicating minimal or no semantic similarity and 1 representing maximal semantic similarity. Only provide the score without any other output. The input consists of a line of code followed by a student explanation of the line of code and an expert explanation of the line of code as given below. ### Input: Code: System.out.println(Duplicate input for number: + num);\nStudent Explanation: If the two saved adjacent values from the sequence are duplicates, this line will run, printing out that a duplicate of the current number has been found.\nExpert Explanation: This statement prints the duplicate number to the default standard output stream. ### Response:"
6}transformers:1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained(
4 "xap/Mistral2,
5 device_map="auto"
6)
7
8tokenizer = AutoTokenizer.from_pretrained(
9 "xap/Mistral2"
10)1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained(
4 "xap/CodeLlama-Instruction-Assessment-new1",
5 device_map="auto"
6)
7
8tokenizer = AutoTokenizer.from_pretrained(
9 "xap/CodeLlama-Instruction-Assessment-new1"
10)
11
12prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nFor the given line of code, both the student and expert have provided the explanation for that line of code. Compute the semantic similarity between the student explanation and the expert explanation for the line of code.\n\n### Input:\nFor given line of code int[] values = {5, 8, 4, 78, 95, 12, 1, 0, 6, 35, 46};, the expert explanation is We declare an array of values to hold the numbers. and the student explanation is This line creates the integer array with the values. you need this to achieve the goal bc you need an array to look in\n\n### Response:\n"""
13
14inputs = tokenizer(prompt, return_tensors="pt")
15outputs = model.generate(**inputs, max_new_tokens=5)
16
17result = tokenizer.decode(outputs, skip_special_tokens=True)
18print(result)1Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
2
3### Instruction:
4Assess the semantic similarity of two sentences using a similarity score on a scale from 0 to 1, with 0 indicating minimal or no semantic similarity and 1 representing maximal semantic similarity. Only provide the score without any other output.
5
6### Input:
7Code: <code line>
8Student Explanation: <student explanation>
9Expert Explanation: <expert explanation>
10
11### Response:0.75