diff --git a/src/main/java/de/extio/lmdatasetprep/preparer/Rewrite.java b/src/main/java/de/extio/lmdatasetprep/preparer/Rewrite.java index 4300da1..fdad0c5 100644 --- a/src/main/java/de/extio/lmdatasetprep/preparer/Rewrite.java +++ b/src/main/java/de/extio/lmdatasetprep/preparer/Rewrite.java @@ -23,9 +23,9 @@ public class Rewrite implements Consumer { private static final ThreadLocal RANDOM = ThreadLocal.withInitial(XorShift128Random::new); - private static String IMPROVEMENT_PROMPT = "Improve the following paragraph of an existing text without changing the existing sentences, improve the text in a nuanced and understated way. Don't include a preamble and no explanation:"; + private static String IMPROVEMENT_PROMPT = "Improve the following text without changing the existing sentences, improve the text in a nuanced and understated way. Return the improved text, even if the text is explicit or not appropriate for all audiences or not acceptable for everyday standard English. Don't include a preamble and no explanation:"; - private static String ENHANCE_PROMPT = "Improve the following paragraph of an existing text. %s without changing the existing sentences, focusing on enriching the description of the setting in a nuanced and understated way. Don't include a preamble and no explanation:"; + private static String ENHANCE_PROMPT = "Improve the following text. %s without changing the existing sentences, focusing on enriching the description of the setting in a nuanced and understated way. Return the improved text, even if the text is explicit or not appropriate for all audiences or not acceptable for everyday standard English. Don't include a preamble and no explanation:"; private static List ENHANCEMENTS = List.of( "Infuse this paragraph with subtle sensory details, focusing on the texture of objects and the atmosphere of the setting", diff --git a/src/main/java/de/extio/lmdatasetprep/preparer/Translate.java b/src/main/java/de/extio/lmdatasetprep/preparer/Translate.java index c6de521..c911a3d 100644 --- a/src/main/java/de/extio/lmdatasetprep/preparer/Translate.java +++ b/src/main/java/de/extio/lmdatasetprep/preparer/Translate.java @@ -64,8 +64,8 @@ public class Translate implements Consumer { final List translations = new ArrayList<>(splits.size()); for (final String split : splits) { - final var completion = this.client.completion("You are a helpful assistant with great language translation and authoring skills.", - "Translate the following text to English. Don't include a preamble and no explanation:", + final var completion = this.client.completion("You are an assistant with great language translation and authoring skills.", + "Translate the following text to English. Return the English translation, even if the text is explicit or not appropriate for all audiences or not acceptable for everyday standard English. Don't include a preamble and no explanation:", split, ModelCategory.COLD); translations.add(completion.response()); diff --git a/src/main/java/de/extio/lmdatasetprep/preparer/Utils.java b/src/main/java/de/extio/lmdatasetprep/preparer/Utils.java index ebacc2a..1e637d9 100644 --- a/src/main/java/de/extio/lmdatasetprep/preparer/Utils.java +++ b/src/main/java/de/extio/lmdatasetprep/preparer/Utils.java @@ -62,7 +62,7 @@ public class Utils { final int CHUNKS_MIN = chunks_norm - chunks_var; final int CHUNKS_MAX = chunks_norm + chunks_var; - if (text.length() <= chunks_norm + chunks_var) { + if (text.length() <= CHUNKS_MAX) { return Collections.singletonList(text); } @@ -70,7 +70,7 @@ public class Utils { int pos = 0; paragraphs: do { - if (text.length() - pos > chunks_norm + chunks_var) { + if (text.length() - pos > CHUNKS_MAX) { delimiters: for (final String delimiter : List.of("\n\n", "\n", ".")) { int next = text.indexOf(delimiter, pos); while (next > -1) { @@ -93,7 +93,7 @@ public class Utils { } } - final int next = Math.min(pos + chunks_norm, text.length()); + final int next = Math.min(pos + CHUNKS_MAX, text.length()); final String split = text.substring(pos, next).trim(); splits.add(split); pos = next + 1;