Select elements from the list that are used in the input text

Hi,
Working on a prompt to select most appropriate elements from the given list that are used in the input text.
The input text is in stepwise manner. Using LLM wants to analyze it and determine which are the most appropriate elements used in it.
These elements are not directly present in the text. Hence the description about them is added in the prompt.

Problem:
The output contains correct elements along with some unrelated elements from given list. What changes can be done to get correct elements consistently?

It sounds like you’re working with a language model to analyze a step-by-step input and identify relevant elements from a list that aren’t directly mentioned but are conceptually tied to the input. That’s a cool challenge!

Here’s how you could improve the accuracy and ensure the output contains only the right elements:

1. Tighten the Prompt

One reason you’re getting unrelated elements could be that the model is trying too hard to match all possible elements, rather than focusing on those that are most appropriate. To fix this, you can make your prompt more focused. Try something like:

“From the following list of elements, select only the ones that are clearly connected to the input text. Ignore elements that are only vaguely related. If unsure, prefer to leave elements out. Explain briefly why each selected element is relevant to the steps in the input text.”

This gives the model permission to be conservative, which might help it avoid picking unrelated elements.

2. Encourage a Logical Process

You can also ask the model to think through its choices step by step, rather than just outputting a list. For instance:

“Analyze the input text in a step-by-step manner. For each step, match the most relevant elements based on their descriptions. Avoid choosing any elements that don’t directly relate to the task at hand. After selecting each element, provide a one-sentence explanation of why it fits.”

By encouraging the model to explain its reasoning, it will likely be more careful in its selections.

3. Add “Exclusion Logic”

Sometimes, it helps to give the model examples of what not to do. This prevents it from just guessing or being over-inclusive. For example:

“Select only the elements from the list that are clearly relevant to the input text. For example, if the input is about ‘building a website,’ do not choose elements related to ‘network security,’ unless explicitly discussed in the input.”

This lets the model know that certain choices are off-limits unless clearly justified.

4. Ask for Fewer Elements

Instead of asking for “all relevant elements,” ask the model to select just the top three or top five. This way, it’ll focus on the most relevant connections rather than trying to cover too many bases.

“Please select the top three elements that are most relevant to the input steps. Only include elements that clearly match the tasks described.”

Example Prompt

Here’s an example of how you might phrase the whole thing in a more conversational way:

“Hey, I’ve got this step-by-step guide, and I need you to help pick out the most relevant elements from a list. These elements won’t be mentioned by name, but I’ve included descriptions for each one. Please only select the elements that are really tied to the input text. Also, explain briefly why you chose each one—oh, and don’t feel like you need to include too many, just the ones that truly fit.”

That should encourage the model to be a bit more selective and thoughtful in its choices. Give it a shot, and see how it improves!

Thank you… These points helped a lot to improve results.

1 Like

Why not use Function Calling using ENUM? If I am able to understand your problem correctly.