pedramyazdipoor commited on
Commit
1585b5e
·
1 Parent(s): 646133d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +3 -6
README.md CHANGED
@@ -76,18 +76,13 @@ def generate_indexes(start_logits, end_logits, N, min_index_list):
76
  final_end_idx.append(end_idx)
77
 
78
  return final_start_idx, final_end_idx
79
-
80
- print(generate_indexes(out['start_logits'][0][1:], out['end_logits'][0][1:], 5, 0))
81
- print(tokenizer.tokenize(text+question))
82
  ```
83
 
84
  ```python
85
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
86
  model.eval().to(device)
87
-
88
  text = 'سلام من پدرامم 26 سالمه'
89
  question = 'نامم چیست؟'
90
- print(tokenizer.tokenize(text + question))
91
  encoding = tokenizer(text,question,add_special_tokens = True,
92
  return_token_type_ids = True,
93
  return_tensors = 'pt',
@@ -96,7 +91,9 @@ encoding = tokenizer(text,question,add_special_tokens = True,
96
  truncation = 'only_first',
97
  max_length = 32)
98
  out = model(encoding['input_ids'].to(device),encoding['attention_mask'].to(device), encoding['token_type_ids'].to(device))
99
-
 
 
100
  >>> ['▁سلام', '▁من', '▁پدر', 'ام', 'م', '▁26', '▁سالم', 'ه', 'نام', 'م', '▁چیست', '؟']
101
  ```
102
 
 
76
  final_end_idx.append(end_idx)
77
 
78
  return final_start_idx, final_end_idx
 
 
 
79
  ```
80
 
81
  ```python
82
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
83
  model.eval().to(device)
 
84
  text = 'سلام من پدرامم 26 سالمه'
85
  question = 'نامم چیست؟'
 
86
  encoding = tokenizer(text,question,add_special_tokens = True,
87
  return_token_type_ids = True,
88
  return_tensors = 'pt',
 
91
  truncation = 'only_first',
92
  max_length = 32)
93
  out = model(encoding['input_ids'].to(device),encoding['attention_mask'].to(device), encoding['token_type_ids'].to(device))
94
+ print(generate_indexes(out['start_logits'][0][1:], out['end_logits'][0][1:], 5, 0))
95
+ print(tokenizer.tokenize(text + question))
96
+ >>> ([5], [5])
97
  >>> ['▁سلام', '▁من', '▁پدر', 'ام', 'م', '▁26', '▁سالم', 'ه', 'نام', 'م', '▁چیست', '؟']
98
  ```
99