Downloads · 30 days
10
15% of all-time downloads
anonymous15135/nsp-wikisection_en_city
nsp-wikisection_en_city is a machine learning model from anonymous15135. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as cc-by-nc-nd-4.0.
NSP-WikiSection-encity is a fine-tuned BERT model specialized in Text Segmentation for Wikipedia city articles (WikiSection - English, city subset). The model uses Next Sentence Prediction (NSP) to identify topic boun…
Downloads · 30 days
10
15% of all-time downloads
All-time downloads
66
Public
Parameters
109M
438 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
NSP-WikiSection-en_city is a fine-tuned BERT model specialized in Text Segmentation for Wikipedia city articles (WikiSection - English, city subset). The model uses Next Sentence Prediction (NSP) to identify topic boundaries in long-form articles, making it effective for segmenting topical sections within Wikipedia city pages.
Try out the model: Hugging Face Space Demo
google-bert/bert-base-uncasedThe model predicts whether two consecutive sentences belong to the same topic (label 0: "is_next") or represent a topic transition (label 1: "not_next"). By applying this classifier sequentially across all sentence pairs in an article, it identifies section boundaries and topical transitions.
Example (Wikipedia city article style):
Sentence A: "The city had a population of 120,000 in the 2010 census."
Sentence B: "Its economy is driven by tourism and light manufacturing."
→ Prediction: Same Topic (confidence: 73%)
Sentence A: "The museum attracts thousands of visitors annually and is a cultural landmark."
Sentence B: "In 2018 the city hosted an international film festival, which boosted local tourism."
→ Prediction: Possible Topic Boundary (confidence: 64%)
from transformers import AutoTokenizer, AutoModelForNextSentencePrediction
import torch
# Load model and tokenizer (replace with your model path/ID)
tokenizer = AutoTokenizer.from_pretrained("anonymous15135/nsp-wikisection_en_city")
model = AutoModelForNextSentencePrediction.from_pretrained("anonymous15135/nsp-wikisection_en_city")
# Prepare input (Wikipedia city article style)
sentence_a = "The historic downtown district contains many 19th century buildings."
sentence_b = "A new pedestrian promenade was opened along the riverfront in 2015."
# Tokenize
inputs = tokenizer(sentence_a, sentence_b, return_tensors="pt")
# Predict
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.softmax(logits, dim=1)
# Interpret results
is_next_prob = probs[0][0].item()
not_next_prob = probs[0][1].item()
print(f"Is Next (same topic): {is_next_prob:.3f}")
print(f"Not Next (topic boundary): {not_next_prob:.3f}")
if not_next_prob > 0.5:
print("🔴 Topic boundary detected!")
else:
print("🟢 Same topic continues")
For questions or feedback, please open an issue in the model repository.
This model is released under the Attribution-NonCommercial-NoDerivatives 4.0 International