YesLab-KSU/folk-relevance-classifier
027
Folk Relevance Classifier (v7)
A seed-conditioned cross-encoder that classifies whether a passage is a folk description of a CHC (Cattell-Horn-Carroll) narrow cognitive ability — i.e., whether an ordinary person is naturally describing that ability in everyday language, without knowing the psychological term.
Model description
Training details
Evaluation
Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_id = "Jiho-YesNLP/folk-relevance-classifier"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()
def score(ability_name: str, seeds: list[str], passage: str,
threshold: float = 0.30) -> dict:
sep = tokenizer.sep_token or "[SEP]"
anchor = f" {sep} ".join([ability_name, *seeds])
inputs = tokenizer(anchor, passage,
return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
probs = torch.softmax(model(**inputs).logits, dim=-1)[0]
labels = model.config.id2label
prob_folk = probs[max(labels, key=int)].item()
return {
"prob_folk": round(prob_folk, 4),
"is_folk": prob_folk >= threshold,
"probs": {labels[i]: round(probs[i].item(), 4) for i in range(len(probs))},
}
# Example
result = score(
ability_name="Induction",
seeds=["finding patterns", "figuring out the rule", "spotting regularities"],
passage="I'm really good at spotting patterns in data that others miss.",
)
print(result)
# {'prob_folk': 0.812, 'is_folk': True, 'probs': {...}}