CrabInHoney commited on
Commit
ce072c6
·
verified ·
1 Parent(s): fc3e419

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +60 -3
README.md CHANGED
@@ -1,3 +1,60 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This is a very small version of BERT, intended for later fine-tune under URL analysis.
2
+
3
+ Model size
4
+ 6.53M params
5
+
6
+ Tensor type
7
+ F32
8
+
9
+ Test example:
10
+
11
+ from transformers import BertTokenizerFast, BertForMaskedLM, pipeline
12
+ import torch
13
+
14
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
15
+ print(f"Используемое устройство: {device}")
16
+
17
+ model_path = "./urlbertV1"
18
+
19
+ tokenizer = BertTokenizerFast.from_pretrained(model_path)
20
+
21
+ model = BertForMaskedLM.from_pretrained(model_path)
22
+ model.to(device)
23
+
24
+ fill_mask = pipeline(
25
+ "fill-mask",
26
+ model=model,
27
+ tokenizer=tokenizer,
28
+ device=0 if torch.cuda.is_available() else -1
29
+ )
30
+
31
+ sentences = [
32
+ "http://helloworld.[MASK]/events/"
33
+ ]
34
+
35
+ for sentence in sentences:
36
+ print(f"\nИсходное предложение: {sentence}")
37
+ results = fill_mask(sentence)
38
+ for result in results:
39
+ token_str = result['token_str']
40
+ score = result['score']
41
+ print(f"Предсказанное слово: {token_str}, вероятность: {score:.4f}")
42
+
43
+ Output:
44
+
45
+ Исходное предложение: http://helloworld.[MASK]/events/
46
+
47
+ Предсказанное слово: com, вероятность: 0.7575
48
+
49
+ Предсказанное слово: org, вероятность: 0.0884
50
+
51
+ Предсказанное слово: nl, вероятность: 0.0294
52
+
53
+ Предсказанное слово: net, вероятность: 0.0198
54
+
55
+ Предсказанное слово: ca, вероятность: 0.0153
56
+
57
+
58
+ ## License
59
+
60
+ [MIT](https://choosealicense.com/licenses/mit/)