@@ -43,31 +43,31 @@ class WatermarkDetectorOutput:
4343 Outputs of a watermark detector.
4444
4545 Args:
46- num_tokens_scored (np.array of shape (batch_size)):
46+ num_tokens_scored (np.ndarray of shape (batch_size)):
4747 Array containing the number of tokens scored for each element in the batch.
48- num_green_tokens (np.array of shape (batch_size)):
48+ num_green_tokens (np.ndarray of shape (batch_size)):
4949 Array containing the number of green tokens for each element in the batch.
50- green_fraction (np.array of shape (batch_size)):
50+ green_fraction (np.ndarray of shape (batch_size)):
5151 Array containing the fraction of green tokens for each element in the batch.
52- z_score (np.array of shape (batch_size)):
52+ z_score (np.ndarray of shape (batch_size)):
5353 Array containing the z-score for each element in the batch. Z-score here shows
5454 how many standard deviations away is the green token count in the input text
5555 from the expected green token count for machine-generated text.
56- p_value (np.array of shape (batch_size)):
56+ p_value (np.ndarray of shape (batch_size)):
5757 Array containing the p-value for each batch obtained from z-scores.
58- prediction (np.array of shape (batch_size)), *optional*:
58+ prediction (np.ndarray of shape (batch_size)), *optional*:
5959 Array containing boolean predictions whether a text is machine-generated for each element in the batch.
60- confidence (np.array of shape (batch_size)), *optional*:
60+ confidence (np.ndarray of shape (batch_size)), *optional*:
6161 Array containing confidence scores of a text being machine-generated for each element in the batch.
6262 """
6363
64- num_tokens_scored : Optional [np .array ] = None
65- num_green_tokens : Optional [np .array ] = None
66- green_fraction : Optional [np .array ] = None
67- z_score : Optional [np .array ] = None
68- p_value : Optional [np .array ] = None
69- prediction : Optional [np .array ] = None
70- confidence : Optional [np .array ] = None
64+ num_tokens_scored : Optional [np .ndarray ] = None
65+ num_green_tokens : Optional [np .ndarray ] = None
66+ green_fraction : Optional [np .ndarray ] = None
67+ z_score : Optional [np .ndarray ] = None
68+ p_value : Optional [np .ndarray ] = None
69+ prediction : Optional [np .ndarray ] = None
70+ confidence : Optional [np .ndarray ] = None
7171
7272
7373class WatermarkDetector :
@@ -179,7 +179,7 @@ def _score_ngrams_in_passage(self, input_ids: torch.LongTensor):
179179 )
180180 return num_tokens_scored_batch , green_token_count_batch
181181
182- def _compute_z_score (self , green_token_count : np .ndarray , total_num_tokens : np .ndarray ) -> np .array :
182+ def _compute_z_score (self , green_token_count : np .ndarray , total_num_tokens : np .ndarray ) -> np .ndarray :
183183 expected_count = self .greenlist_ratio
184184 numer = green_token_count - expected_count * total_num_tokens
185185 denom = np .sqrt (total_num_tokens * expected_count * (1 - expected_count ))
@@ -195,7 +195,7 @@ def __call__(
195195 input_ids : torch .LongTensor ,
196196 z_threshold : float = 3.0 ,
197197 return_dict : bool = False ,
198- ) -> Union [WatermarkDetectorOutput , np .array ]:
198+ ) -> Union [WatermarkDetectorOutput , np .ndarray ]:
199199 """
200200 Args:
201201 input_ids (`torch.LongTensor`):
@@ -207,8 +207,8 @@ def __call__(
207207 Whether to return `~generation.WatermarkDetectorOutput` or not. If not it will return boolean predictions,
208208 ma
209209 Return:
210- [`~generation.WatermarkDetectorOutput`] or `np.array `: A [`~generation.WatermarkDetectorOutput`]
211- if `return_dict=True` otherwise a `np.array `.
210+ [`~generation.WatermarkDetectorOutput`] or `np.ndarray `: A [`~generation.WatermarkDetectorOutput`]
211+ if `return_dict=True` otherwise a `np.ndarray `.
212212
213213 """
214214
0 commit comments