Views
No views yet
.ckpt file. You need the deep_stylometry codebase to load it.1git clone https://github.com/Madjakul/deep_stylometry.git
2cd deep_stylometry
3pip install -r requirements.txt1import torch
2from transformers import AutoTokenizer
3from deep_stylometry.modules.modeling_deep_stylometry import DeepStylometry
4from deep_stylometry.utils.configs import BaseConfig
5
6# 1. Load model from checkpoint
7cfg = BaseConfig(mode="test").from_yaml("configs/test_layerwise.yml")
8model = DeepStylometry.load_from_checkpoint("last.ckpt", cfg=cfg)
9model.eval()
10
11# 2. Tokenize
12tokenizer = AutoTokenizer.from_pretrained("answerdotai/ModernBERT-base")
13texts = [
14 "Query text whose authorship you want to identify.",
15 "Candidate A: a text by the same author.",
16 "Candidate B: a text by a different author.",
17]
18enc = tokenizer(
19 texts, padding=True, truncation=True, max_length=512, return_tensors="pt",
20)
21
22# 3. Encode all texts through the model
23with torch.no_grad():
24 embs = model(enc["input_ids"], enc["attention_mask"]) # (3, seq_len, 768)
25
26# 4. Score the query against each candidate
27pool = model.contrastive_loss.pool # the interaction module
28with torch.no_grad():
29 scores = pool(
30 query_embs=embs[:1],
31 key_embs=embs[1:],
32 q_mask=enc['attention_mask'][:1],
33 k_mask=enc['attention_mask'][1:],
34 )
35# scores shape: (1, 2) -- similarity of the query to [candidate A, candidate B]
36# Higher score = more likely same author.
37print(scores)1@misc{kulumba_halvest_2026,
2 title={HALvest-Contrastive: Retrieval-Like Authorship Attribution with Patch-Level Late Interaction},
3 author={Francis Kulumba and Wissam Antoun and Guillaume Vimont and Laurent Romary and Florian Cafiero},
4 year={2026},
5 eprint={2407.20595},
6 archivePrefix={arXiv},
7 primaryClass={cs.DL},
8 url={https://arxiv.org/abs/2407.20595},
9}1@misc{kulumba_does_2026,
2 title={Where Does Authorship Signal Emerge in Encoder-Based Language Models?},
3 author={Francis Kulumba and Guillaume Vimont and Laurent Romary and Florian Cafiero},
4 year={2026},
5 eprint={2605.19908},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2605.19908},
9}