Views
No views yet
{url}
{text}1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3tokenizer = AutoTokenizer.from_pretrained("WebOrganizer/FormatClassifier")
4model = AutoModelForSequenceClassification.from_pretrained(
5 "WebOrganizer/FormatClassifier",
6 trust_remote_code=True,
7 use_memory_efficient_attention=False)
8
9web_page = """http://www.example.com
10
11How to make a good sandwich? [Click here to read article]"""
12
13inputs = tokenizer([web_page], return_tensors="pt")
14outputs = model(**inputs)
15
16probs = outputs.logits.softmax(dim=-1)
17print(probs.argmax(dim=-1))
18# -> 6 ("Truncated" format, which covers incomplete content)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/FormatClassifier",
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}