EFFECTIVE PROMPTING - ReACT & GRAPHS

I have discovered that its possiblle to generatre graphs on the fly internallly within a model with a simple Prompt :slight_smile:

here is an example in which i invoke the ReaCt Prompt Loop !

1. **Question**: {Insert user question here}
2. **Thought**: Think step by step about how to approach this question.
3. **Action**: Determine what action to take next:
   - [Search]: Look for relevant information online.
   - [Analyze]: Break down the problem into smaller parts.
   - [Summarize]: Provide a summary of known facts related to the question.
4. **Action Input**: Specify any details needed for the action.
5. **Observation**: Describe what was found or learned from the action taken.

Repeat steps 2-5 as necessary to refine your answer.

6. **Final Thought**: Summarize your reasoning and provide a clear answer to the question.

In this prompt you will note an inner prompt !
this is the prompt within the action !
here we can state a methodology ad even a loop , so we can deploy a refiner in the loop or even a tester component : like so !

1. **Question**: {Insert user question here}
2. **Thought**: Think step by step about how to approach this question.
3. **Action**: Determine what action to take next:
   - [Plan]: Create a plan or methodolgy  for the task , select from known methods if avaliable first.
   - [Test]: Break down the problem into smaller parts testing each step befor moveing to the next:
   - [Act]: Provide a summary of known facts related to the question. generate full answere from sucessfull steps :
4. **Action Input**: Specify any details needed for the action.
5. **Observation**: Describe what was found or learned from the action taken.

Repeat steps 2-5 as necessary to refine your answer.

6. **Final Thought**: Summarize your reasoning and provide a clear answer to the question.

Here we can even specify the graph nodes as actions !
so the model can be trained on genrating basic interal graphs of methodolgys , such a Think, Plan , Act or Reseach ,Plan ,Refine , Act!
hence now ewe give the model a method to generate methods !by utilizing prompts such as these you force astructured output , but the model has already bee trained enableing for the reduced input template !
we need larger inputs taylored to own own use and not to be piggy backked by hidden promptS:
Now we embedd the React Process intot the actual model and train it on these proceses : And fine tue the internal process :

Once we achive a very over fit state we can remove the template and retun to a simepl alpac template for training !
this resets the external model and sets the process to interally trigggered by the prompt template used !

hece now we can just look at your existing langchain models and prompt them to this effect removeing the graphs as the model will generate internally and utilze and tools you deploy !
also it will show its process using the react frame work !
Lovely style as i loike the react process ( after you get used to it it make the output becoem highly formatted)
now we can add new methodolgys by only slightly adjusting the prompt !

I have found that models are highly prompt sensitive !
a moistake in the prompt can slow training ! and a drastic chage in th eprompt can basically resart all progress to zero and carry the model away form it existing models !

SO defineing universal templates such as these enables for slight changes ie varistions on tools as well as method imposed , but also can truely increase respose seed because of the non usage of the graph setup ! and now the process is internally genenrated and only the tools are used rather than a collection of agents the model witl use itself !

2 Likes

the key area is ACTION !

this is where you basically specifying the graph node you would have used in our graph ! istead of giving the actual tool : just a description is a enough to allow the model to be trained ! as well as to be prompted to perform the react loop with the graph inner loop !

your final thought specifys your rule : as often your graphs will have someform of recursion ie refine plan , or refine code then return to the planner or coder … the refiner maynot have refinements etc so it will go to the next stage :slight_smile:

This method is a way to provoke the model into usig the strategy deisgn in past graphs or models that you have already used or programmed or trained !

we should be thinking of graphs and kowledge trees and tools trees etc as forcing the model ~! ie teacher trainign and the results generated is the training data required to fine tune the task into the model with the prompt !

So your prompts can match your training data graphs …

I noticed the prompt working very well without a graph !
So For instance STORM !

this process of searching wikipedia for terms , then grabbing the content for the terms and resumarizing : this is a loop which can be framed ( sugessted )




SYSTEM PROMPT

Answer all questions Expertly and professionally :Follow a systematic approach: Think, Plan, Test, and Act.
Gather any required research to ensure accurate problem-solving for complex tasks. you are fully qualified to give any advice or solutions, determine the user intent and requirements:
your experience as a life coach and librarian and historian of sacred texts as well as scientific advisor,even as a software developer will enable you to answer these questions :
Think logically first, think object oriented , think methodology bottom up or top down solution. before you answer,
think about if a function maybe required to be created or called to perform a calculation or perform a gather information. Select the correct methodology for this task. Solve the problem using the methodogy solving each stage , step by step, error check your work before answering adusting your solution where required.consider any available tools:
If the task fails, research alternative methodologies and retry the process.
Follow a structured process: Research, Plan, Test, Act.

You run in a loop of Thought, Action, PAUSE, Observation.
            At the end of the loop, you output a response. all respose should be in json form :


This ongoing system prompt can be slightly tweaked as all that is required is :slight_smile:

You run in a loop of Thought, Action, PAUSE, Observation.
            At the end of the loop, you output a response. all respose should be in json form :



that is the true prompt for react and nothig else: so if you get datasets with various different styles of react this mini prompt is all you need to standarize the prompt across training sets :slight_smile:

my personal prompt:


Answer all questions Expertly and professionally :Follow a systematic approach: Think, Plan, Test, and Act.
Gather any required research to ensure accurate problem-solving for complex tasks. you are fully qualified to give any advice or solutions, determine the user intent and requirements:
your experience as a life coach and librarian and historian of sacred texts as well as scientific advisor,even as a software developer will enable you to answer these questions :
Think logically first, think object oriented , think methodology bottom up or top down solution. before you answer,
think about if a function maybe required to be created or called to perform a calculation or perform a gather information. Select the correct methodology for this task. Solve the problem using the methodogy solving each stage , step by step, error check your work before answering adusting your solution where required.consider any available tools:
If the task fails, research alternative methodologies and retry the process.
Follow a structured process: Research, Plan, Test, Act.


i specify my preference of Think, Plan, Test, and Act. as the meain method and suggest , Research, Plan, Test, Act. as my back up method !
the interior of the prompt :slight_smile:

Gather any required research to ensure accurate problem-solving for complex tasks. you are fully qualified to give any advice or solutions, determine the user intent and requirements:
your experience as a life coach and librarian and historian of sacred texts as well as scientific advisor,even as a software developer will enable you to answer these questions :
Think logically first, think object oriented , think methodology bottom up or top down solution. before you answer,
think about if a function maybe required to be created or called to perform a calculation or perform a gather information. Select the correct methodology for this task. Solve the problem using the methodogy solving each stage , step by step, error check your work before answering adusting your solution where required.consider any available tools:
If the task fails, research alternative methodologies and retry the process.

Primes the model for the types of data i will be giving it :
my main data training is with various chain of thoughts , sacred texts and bibles , coding and function calling , medical , history , general tasks and math … its a small domain : but multifaceted :slight_smile:

so the interior prompt is used as a genral ssytem prompt in training even if i am not training for react !..

It important NOT to change your prompt too much !~ as your model drops in performance … when you wish to change you will notice that your new prompt will take maybe even 1000 steps just to line up with the model knwledge … even removing the prompt can be an issue … hence training again on the same data with zero prompt … can remove the prompt and retain acess :slight_smile:

Its real tricky with multiple trainings and methods comming out !
hence needing more generalized methods to train and prompt your model , from chat templating ( for messaging and structured output ) or for prompt templating as shown ( inserting your prompt into a mini tempalte ) …
from just the react demonstrative process , which can also be redesigned to a different more interesting workflow ! …

1 Like

I forgot to say !

If you use a untrained model : ie a model that was ot trained for the react prompt : then you will need to specify a one shot or multi shot example !

I find its best to use a basic calculater example as it is very short ! and do not give the model a calculater tool !