nsagatov1/youtube-video-relevance-classifier
YouTube Video Relevance Classifier
Fine-tuned model used by chrome extension Lock-In to determine whether online content of the video is relevant to the user's current goal such as:
- learn mathematics
- study english
- learn programming
Base Model
Fine-tuned from: cross-encoder/mmarco-mMiniLMv2-L12-H384-v1
Task
The model receives a focus goal and content from a web page/video/post and predicts whether the content is relevant to the user's goal.
Labels
0— denied1— allowed
Intended Use
This model was developed specifically for the LockIn browser extension that boosts productivity by blocking irrelevant videos. It is not intended to be a general-purpose relevance classifier. There are both .onnx and .safetensors models
Input
The model takes two inputs:
goal— the user's current focus goaltext— the content of the web page, video, or post
'text' is constructed in a form:
Title: <title>
Description: <description>
Tags: <up to 5 tags>
Headings H1: <H1 headings>
Headings H3: <H3 headings>
Paragraphs: <paragraphs>agraphs:Headings and Paragraphs are basically desciption and comments in a reddit post.
Only first five of tags, Headings H3 and Paragraphs are taken to save tokens.
The two texts are passed to the model as a text pair.
Example
{
"goal": "learn chemistry",
"text": "Title: 19. Spectroscopy: Probing Molecules with Light\nDescription: MIT 5.61 Physical Chemistry, Fall 2017\nInstructor: Professor Robert Field\nView the complete course: \nYouTube Playlist: \n\nThis lecture discusses time-dependent quantum mechanics.\n\nLicense: Creative Commons BY-NC-SA\nMore information at \nMore courses at\nTags: 5-61-physical-chemistry-fall-2017, dipole approximation, fermi's golden rule, linear response, quantum mechanics",
"label": 1
},
In this example, the video is matched with the goal, therefore allowedimport torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
MODEL_NAME = "nsagatov1/youtube-video-relevance-classifier"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
goal = "learn chemistry"
text = """
Title: Atomic spectra | Physics | Khan Academy
Description: Courses on Khan Academy are always 100% free. Start practicing—and saving your progress—now!
Electrons only exist at specific, discrete energy levels in an atom.
Tags: online learning, online class, video class, video tutorial, online education
"""
inputs = tokenizer(
goal,
text_pair=text,
truncation=True,
max_length=512,
return_tensors="pt"
)
with torch.no_grad():
outputs = model(**inputs)
prediction = torch.argmax(outputs.logits, dim=-1).item()
labels = {
0: "denied",
1: "allowed"
}
print(labels[prediction])