Skip to content

Commit

Permalink
Refactor TextGenerator API
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu committed Jun 16, 2023
1 parent a9d516c commit 661f215
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.Map;
import java.util.Set;

public class PtGptTranslatorFactory implements TranslatorFactory {
public class PtGptTranslatorFactory implements TranslatorFactory {

private static final Set<Pair<Type, Type>> SUPPORTED_TYPES = new HashSet<>();

Expand All @@ -48,8 +48,8 @@ public <I, O> Translator<I, O> newInstance(
throw new IllegalArgumentException("Unsupported input/output types.");
}
long kvDim = ArgumentsUtil.longValue(arguments, "kvDim", 64);
int numAttentionHeads= ArgumentsUtil.intValue(arguments, "numAttentionHeads", 12);
int numLayers= ArgumentsUtil.intValue(arguments, "numLayers", 12);
int numAttentionHeads = ArgumentsUtil.intValue(arguments, "numAttentionHeads", 12);
int numLayers = ArgumentsUtil.intValue(arguments, "numLayers", 12);

return (Translator<I, O>) (new PtGptTranslator(kvDim, numAttentionHeads, numLayers));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package ai.djl.examples.inference;
package ai.djl.examples.inference.nlp;

import ai.djl.ModelException;
import ai.djl.examples.inference.nlp.TextGeneration;
import ai.djl.testing.TestRequirements;
import ai.djl.translate.TranslateException;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

/** Contains tests for the inference examples. */
package ai.djl.examples.inference.nlp;

0 comments on commit 661f215

Please sign in to comment.