@@ -63,6 +63,7 @@ class PipelineTest : public testing::Test {
6363 .string ());
6464 ASSERT_OK (tokenizer);
6565 tokenizer_ = std::move (*tokenizer);
66+
6667 // The prefill tokens are the expected tokens that will be passed in at each
6768 // time the Prefill function is called. The values are the token ids of the
6869 // input prompt "Hello World!" prepended with the bos token id (2).
@@ -111,7 +112,9 @@ TEST_F(PipelineTest, Decode) {
111112 auto responses =
112113 Decode (*executor_, *tokenizer_, stop_token_detector, benchmark_info);
113114 EXPECT_OK (responses);
114- EXPECT_EQ (*(responses->GetResponseTextAt (0 )), " How's it going?!" );
115+ // The response is " How's it going?" since "!" is the stop token which is
116+ // not included in the response.
117+ EXPECT_EQ (*(responses->GetResponseTextAt (0 )), " How's it going?" );
115118}
116119
117120TEST_F (PipelineTest, DecodeReachMaxNumTokens) {
@@ -134,7 +137,9 @@ TEST_F(PipelineTest, DecodeStreaming) {
134137 EXPECT_OK (stop_token_detector.AddStopTokenSequence ({2294 }));
135138 EXPECT_OK (DecodeStreaming (*executor_, *tokenizer_, stop_token_detector,
136139 benchmark_info, &observer));
137- EXPECT_EQ (observer.GetResponses ()[0 ], " How's it going?!" );
140+ // The response is " How's it going?" since "!" is the stop token which is
141+ // not included in the response.
142+ EXPECT_EQ (observer.GetResponses ()[0 ], " How's it going?" );
138143}
139144
140145TEST_F (PipelineTest, DecodeStreamingReachMaxNumTokens) {
@@ -171,18 +176,19 @@ TEST_F(PipelineTest, DecodeBytePairEncodingTokens) {
171176 EXPECT_CALL (*tokenizer, TokenIdsToText (std::vector<int >{18 }))
172177 .WillOnce (testing::Return (" " ));
173178 EXPECT_CALL (*tokenizer, TokenIdsToText (std::vector<int >{2295 }))
174- .WillOnce (testing::Return (" going" ));
179+ .WillOnce (testing::Return (" going? " ));
175180 EXPECT_CALL (*tokenizer, TokenIdsToText (std::vector<int >{2294 }))
176- .WillOnce (testing::Return (" ? !" ));
181+ .WillOnce (testing::Return (" !" ));
177182
178183 std::optional<BenchmarkInfo> benchmark_info;
179184 StopTokenDetector stop_token_detector (1 );
180185 EXPECT_OK (stop_token_detector.AddStopTokenSequence ({2294 }));
181186 auto responses =
182187 Decode (*executor_, *tokenizer, stop_token_detector, benchmark_info);
183188 EXPECT_OK (responses);
184- // The response is truncated at the max number of tokens.
185- EXPECT_EQ (*(responses->GetResponseTextAt (0 )), " How's it going?!" );
189+ // The response is " How's it going?" since "!" is the stop token which is
190+ // not included in the response.
191+ EXPECT_EQ (*(responses->GetResponseTextAt (0 )), " How's it going?" );
186192}
187193
188194class PipelineCustomSamplingTest : public testing ::Test {
0 commit comments