diff --git a/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/OllamaRecommender.java b/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/OllamaRecommender.java index bf4e29fd3a2..d75184825c7 100644 --- a/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/OllamaRecommender.java +++ b/inception/inception-imls-ollama/src/main/java/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/OllamaRecommender.java @@ -54,6 +54,8 @@ public class OllamaRecommender extends NonTrainableRecommenderEngineImplBase { private static final String VAR_TEXT = "text"; + private static final String VAR_SENTENCE = "sentence"; + private static final String VAR_DOCUMENT = "document"; private final static Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -300,7 +302,11 @@ private Range predictPerAnnotation(RecommenderContext aContext, CAS aCas, int aB var predictedType = getPredictedType(aCas); for (var candidate : selectOverlapping(aCas, predictedType, aBegin, aEnd)) { - var bindings = Map.of(VAR_TEXT, candidate.getCoveredText()); + String sentence = aCas.select(Sentence.class).covering(candidate) + .map(Sentence::getCoveredText).findFirst().orElse(""); + var bindings = Map.of( // + VAR_TEXT, candidate.getCoveredText(), // + VAR_SENTENCE, sentence); var prompt = jinjava.render(traits.getPrompt(), bindings); try { diff --git a/inception/inception-imls-ollama/src/main/resources/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/presets.yaml b/inception/inception-imls-ollama/src/main/resources/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/presets.yaml index 193d5e8f532..222a9e45e46 100644 --- a/inception/inception-imls-ollama/src/main/resources/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/presets.yaml +++ b/inception/inception-imls-ollama/src/main/resources/de/tudarmstadt/ukp/inception/recommendation/imls/ollama/presets.yaml @@ -27,3 +27,13 @@ ``` {{ text }} ``` + +- name: Disambiguate in sentence + processingMode: per-annotation + extractionMode: response-as-label + prompt: |- + Very briefly describe the meaning of `{{ text }}` in the following sentence. + + ``` + {{ sentence }} + ```