Views
No views yet
</s> token.
For example:Песков опроверг свой перевод на удаленку</s>Дмитрий Песков перешел на удаленку1from tqdm.notebook import tqdm
2from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
3
4def get_batch(data, batch_size):
5 start_index = 0
6 while start_index < len(data):
7 end_index = start_index + batch_size
8 batch = data[start_index:end_index]
9 yield batch
10 start_index = end_index
11
12
13def pipe_predict(data, pipe, batch_size=64):
14 raw_preds = []
15 for batch in tqdm(get_batch(data, batch_size)):
16 raw_preds += pipe(batch)
17 return raw_preds
18
19MODEL_NAME = TOKENIZER_NAME = "IlyaGusev/xlm_roberta_large_headline_cause_simple"
20tokenizer = AutoTokenizer.from_pretrained(TOKENIZER_NAME, do_lower_case=False)
21model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)
22model.eval()
23pipe = pipeline("text-classification", model=model, tokenizer=tokenizer, framework="pt", return_all_scores=True)
24texts = [
25 (
26 "Judge issues order to allow indoor worship in NC churches",
27 "Some local churches resume indoor services after judge lifted NC governor’s restriction"
28 ),
29 (
30 "Gov. Kevin Stitt defends $2 million purchase of malaria drug touted by Trump",
31 "Oklahoma spent $2 million on malaria drug touted by Trump"
32 ),
33 (
34 "Песков опроверг свой перевод на удаленку",
35 "Дмитрий Песков перешел на удаленку"
36 )
37]
38pipe_predict(texts, pipe)1@misc{gusev2021headlinecause,
2 title={HeadlineCause: A Dataset of News Headlines for Detecting Causalities},
3 author={Ilya Gusev and Alexey Tikhonov},
4 year={2021},
5 eprint={2108.12626},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}