Views
No views yet
google-bert/bert-base-uncased1Sentence A: "By the President, minutes no. 28 of 20.12.2023 were present at the meeting."
2Sentence B: "After considering and analyzing the matter, the Municipal Executive unanimously decided to approve minute no. 28 of 12.20.2023."
3→ Prediction: Same Topic (confidence: 76%)
4
5Sentence A: "After considering and analyzing the matter, the Municipal Executive unanimously decided to approve minute no. 28 of 12.20.2023."
6Sentence B: "There were no various processes and requests to submit."
7→ Prediction: Topic Boundary (confidence: 82%)1from transformers import AutoTokenizer, AutoModelForNextSentencePrediction
2import torch
3
4# Load model and tokenizer
5tokenizer = AutoTokenizer.from_pretrained("anonymous15135/nsp-councilseg-en")
6model = AutoModelForNextSentencePrediction.from_pretrained("anonymous15135/nsp-councilseg-en")
7
8# Prepare input
9sentence_a = "By the President, minutes no. 28 of 20.12.2023 were present at the meeting."
10sentence_b = "After considering and analyzing the matter, the Municipal Executive unanimously decided to approve minute no. 28 of 12.20.2023."
11
12
13# Tokenize
14inputs = tokenizer(sentence_a, sentence_b, return_tensors="pt")
15
16# Predict
17with torch.no_grad():
18 outputs = model(**inputs)
19 logits = outputs.logits
20 probs = torch.softmax(logits, dim=1)
21
22# Interpret results
23is_next_prob = probs[0][0].item()
24not_next_prob = probs[0][1].item()
25
26print(f"Is Next (same topic): {is_next_prob:.3f}")
27print(f"Not Next (topic boundary): {not_next_prob:.3f}")
28
29if not_next_prob > 0.5:
30 print("🔴 Topic boundary detected!")
31else:
32 print("🟢 Same topic continues")