Views
No views yet
1from transformers import AutoTokenizer, LlamaForSequenceClassification
2
3tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/math-difficulty-classifier")
4model = LlamaForSequenceClassification.from_pretrained("YOUR_USERNAME/math-difficulty-classifier")
5
6# Prepare input text
7text = """Classify the difficulty level (1–3) of the following math question. Remember this classification of difficutly is agnostic of the concepts. Only consider the difficulty of the question itself, not if the concept is something only learned in higher grades. For example, a simple integral is the same difficulty as a simple trig calculation.
8- Level 1: direct application of definitions; minimal reasoning.
9- Level 2: one extra reasoning step (e.g., convert a word problem).
10- Level 3: multi-step reasoning; multiple concepts and harder mathematical skil.
11
12Question:
13What is the slope of the line passing through the points (3, 7) and (5, 11)?
14
15Difficulty (1–3):"""
16
17inputs = tokenizer(text, return_tensors="pt")
18outputs = model(**inputs)
19predicted_class = outputs.logits.argmax().item()
20difficulty = predicted_class + 1 # Convert from 0-indexed to 1-indexed
21print(f"Predicted difficulty: {difficulty}")