Views
No views yet
{text}1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3tokenizer = AutoTokenizer.from_pretrained("WebOrganizer/TopicClassifier-NoURL")
4model = AutoModelForSequenceClassification.from_pretrained(
5 "WebOrganizer/TopicClassifier-NoURL",
6 trust_remote_code=True,
7 use_memory_efficient_attention=False)
8
9web_page = """How to build a computer from scratch? Here are the components you need..."""
10
11inputs = tokenizer([web_page], return_tensors="pt")
12outputs = model(**inputs)
13
14probs = outputs.logits.softmax(dim=-1)
15print(probs.argmax(dim=-1))
16# -> 5 ("Hardware" topic)logits of the model with a softmax to obtain a probability distribution over the following 24 categories (in order of labels, also see id2label and label2id in the model config):xformers (see more here) and loading the model like:1AutoModelForSequenceClassification.from_pretrained(
2 "WebOrganizer/TopicClassifier-NoURL",
3 trust_remote_code=True,
4 unpad_inputs=True,
5 use_memory_efficient_attention=True,
6 torch_dtype=torch.bfloat16
7)1@article{wettig2025organize,
2 title={Organize the Web: Constructing Domains Enhances Pre-Training Data Curation},
3 author={Alexander Wettig and Kyle Lo and Sewon Min and Hannaneh Hajishirzi and Danqi Chen and Luca Soldaini},
4 journal={arXiv preprint arXiv:2502.10341},
5 year={2025}
6}