A BERT fine tune for pedagogical guidance classification from LLMs and human experts. Specifically this model was used for
ACL-BEA-25 Track 3.
Pedagogical Guidance: classify weather tutors’ responses offer correct and relevant guidance, such as an explanation, elaboration, hint, examples, and so on. The following categories are included:
1import torch
2from transformers import BertForSequenceClassification, BertTokenizer
3
4# Load the model and tokenizer from the Hugging Face Hub.
5# Replace the repo_id with your repository name.
6repo_id = "alonsopg/BEA-25-pedagogical-guidance" # Update this
7
8model = BertForSequenceClassification.from_pretrained(repo_id)
9tokenizer = BertTokenizer.from_pretrained(repo_id)
10
11# Move the model to the appropriate device.
12device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13model.to(device)
14
15# Define a mapping from indices to guidance labels.
16label_mapping = {0: "Yes", 1: "To some extent", 2: "No"}
17
18def predict_guidance(response_text):
19 """
20 Tokenizes an input response, moves the tensors to the device,
21 performs inference, and returns the predicted guidance.
22 """
23 inputs = tokenizer(response_text, return_tensors="pt", padding="max_length", truncation=True, max_length=128)
24 inputs = {key: value.to(device) for key, value in inputs.items()}
25 model.eval()
26 with torch.no_grad():
27 outputs = model(**inputs)
28 logits = outputs.logits
29 pred = torch.argmax(logits, axis=1).item()
30 return label_mapping[pred]
31
32# Example usage:
33sample_response = (
34 "I appreciate your effort, but let's think about this carefully: if we divide 10 into 5 equal groups, "
35 "how many would be in each group?"
36)
37prediction = predict_guidance(sample_response)
38print("Predicted Pedagogical Guidance:", prediction)