File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Seq2SeqSharp/Applications Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 20
20
using Seq2SeqSharp . Tools ;
21
21
using Seq2SeqSharp . Utils ;
22
22
using TensorSharp ;
23
+ using ManagedCuda . BasicTypes ;
23
24
24
25
namespace Seq2SeqSharp . Applications
25
26
{
@@ -144,13 +145,28 @@ private bool CreateTrainableParameters(IModel model)
144
145
m_posEmbedding ? . GetNetworkOnDevice ( deviceIdIdx ) ) ;
145
146
}
146
147
148
+ /// <summary>
149
+ /// Generate key for kv cache. </s> will be removed from the key if it exist
150
+ /// </summary>
151
+ /// <param name="strs"></param>
152
+ /// <returns></returns>
147
153
private string GenerateCacheKey ( List < List < string > > strs )
148
154
{
149
155
List < string > r = new List < string > ( ) ;
150
156
151
157
foreach ( var str in strs )
152
158
{
153
- r . Add ( string . Join ( " " , str ) ) ;
159
+ List < string > normStr = new List < string > ( ) ;
160
+ foreach ( string word in str )
161
+ {
162
+ if ( word == "</s>" )
163
+ {
164
+ continue ;
165
+ }
166
+ normStr . Add ( word ) ;
167
+ }
168
+
169
+ r . Add ( string . Join ( " " , normStr ) ) ;
154
170
}
155
171
156
172
return string . Join ( "\t " , r ) ;
You can’t perform that action at this time.
0 commit comments