Hi im new to promoting and still learning. I read the open ai article around strategies and tactics for promot engineering and one of the things i understood by this article and by playing with it is that you have to be very specific yet clear to not allow the prompt from carrying different meaning so i thought what could be better than to do this using Set Theory so that its accurate yet very concise specially when dealing with context that can carry multiple states (predicates) & happen across multiple datasets (relationships) . Despite doing so and doing it with the help of AI itself and despite that the states and the data set i used small in size i still found a model like 4o-mini atruggle and be way off!!!
Actually the reason i thought about using something like theory set is because many of the small llm are good in math and by turning any problem into math problem i couid achieve the same results with smaller models but this also didnt work as well as i thought. One key factor could be the size of the dataset and how spread its.
What am i missing ? Could something like set thoery be good strategy to prompt vs natural language where words and phrases can carry multiple meanings?
There is the possibility that im also over thinking it
By the way sometging like o1-mini did much better job but i really thought any model that is big enough shouldnt go wrong with this.
I appreciate the feedback.
Thanks
Hi @salsam7879 and welcome to the community.
This is very intriguing, and there is a growing group of people looking at formalized methods of interacting with LLMs.
Can you elaborate on some examples how you would use set theory in this regard?
Also ping @Diet and @mitchell_d00
The newer and more âminiâ the model, the fewer emergent properties it has, and the more it is trained on âchatâ and following up typical user inputs with a satisfactory answer.
Language models are simply that: powered by language. While they can also handle programming and mathematics, it is not where the bulk of their intelligence lies.
You can prompt more programmatically, like laying out how to proceed with ifâŠthen statements or clarifying with parenthetical conditional statements, but going beyond that into other formats requiring new reasoning, like prompt-programming the AI by JSON, is at your own risk.
Below is an example of how a single English sentence can become ambiguous through everyday usage of âor,â âand,â and âif.â Then we transform that sentence into a precise, set-theoretic statement.
An AI takes an ambiguous statement, and transforms it to 'set theory' - or at least logic
Ambiguous Natural Language Statement
âIf you have a large dataset and you either want lower resource usage or prefer more interpretability, you might use GPT-4o-mini or O1-mini, but if you only have a small dataset or you also need highly advanced capabilities, then definitely use GPT-4 unless youâre worried about both cost and waiting time, or if you prefer interpretability only if your dataset isnât large.â
Why Itâs Ambiguous
- âorâ vs. âand/orâ vs. âexclusive orâ: Itâs unclear whether âyou might use GPT-4o-mini or O1-miniâ implies you can use both, or only one of them.
- Nested Conditions: Phrases like âif you only have a small dataset or you also need highly advanced capabilities, then definitely use GPT-4 unless youâre worried about both cost and waiting time or if you prefer interpretabilityâŠâ are hard to parse. Where exactly do sub-conditions begin and end?
- Different Potential Readings: Is âuse GPT-4â an instruction triggered by just having a small dataset? Or do you also need advanced capabilities? If youâre worried about cost and time, does that override advanced capabilities?
Unambiguous Set-Theoretic Statement
Weâll define some sets and logical variables to capture each condition precisely:
- DLD_L: The set of all use-cases that have a large dataset.
- DSD_S: The set of all use-cases that have a small dataset.
- RR: The set of all use-cases in which lower resource usage is desired.
- II: The set of all use-cases in which higher interpretability is preferred.
- AA: The set of all use-cases that need highly advanced capabilities.
- CC: The set of all use-cases where cost is a concern.
- WW: The set of all use-cases where waiting time is a concern.
We also define three âmodelsâ as elements or outcomes we can choose from:
- GPT-4o-mini\text{GPT-4o-mini}
- O1-mini\text{O1-mini}
- GPT-4\text{GPT-4}
Now we convert the natural-language instructions into separate conditional rules. For clarity, let M(x)\mathcal{M}(x) be the model recommended for a given scenario xx.
Rule 1: If xâDLâ©(RâȘI)x \in D_L \cap (R \cup I) (i.e., large dataset and [lower resource usage or interpretability]), then
M(x)â{GPT-4o-mini,O1-mini}. \mathcal{M}(x) \in {\text{GPT-4o-mini}, \text{O1-mini}}.
Rule 2: If xâDSâȘAx \in D_S \cup A (i.e., small dataset or advanced capabilities), then
M(x)=GPT-4 \mathcal{M}(x) = \text{GPT-4}
provided that neither of the following is true for xx:
(xâCâ©W)(cost AND waiting time concerns) (x \in C \cap W) \quad \text{(cost AND waiting time concerns)}
or
(xâDL ⧠xâI)(small dataset AND interpretability preference). (x \notin D_L ; \land ; x \in I) \quad \text{(small dataset AND interpretability preference)}.
(Here we interpret the last clause as âonly if your dataset isnât large do you prefer interpretability,â which was ambiguous in the original text.)
Rule 3: If either of those cost/time or interpretability conditions does hold (i.e., xâ(Câ©W)x \in (C \cap W) or [xâDLâ§xâI][x \notin D_L \land x \in I]), then GPT-4 might not be recommended. In such a case,
M(x)â{GPT-4o-mini,O1-mini}. \mathcal{M}(x) \in {\text{GPT-4o-mini}, \text{O1-mini}}.
(Additional clarifications or overrides could be layered on with more set-theoretic intersections and unions.)
Reading the Set-Theoretic Version
- ââ©\capâ means âAND.â
- ââȘ\cupâ means âORâ (inclusive).
- Each rule is mutually compatible but also clarifies which conditions override others.
- This kind of structure forces you to specify precisely how each condition interacts, resolving ambiguity about nested conditionals and whether an âorâ is exclusive or inclusive.
Key Takeaways
- The natural language instruction is ambiguous because English uses âorâ inconsistently, allows nested conditions to blend together, and doesnât show strict boundaries between them.
- The set-theoretic version eliminates ambiguity by requiring explicit definitions of each condition and exact logical operations (intersections â©\cap, unions âȘ\cup, and negations).
You can see the âpromptâ is a user burden, not really a tool.
I thought its an interesting idea specially thinking that would work on small llm that could be trained just to handle math which did not turn to be the case nice try . Here is an example
Im not mathematician nor Set Theory expert âŠI just happen to use GPT . forgive me if what I have is some pseudo math and not actual Set theory. My understanding is that everything can be expressed in set theory.
letâs say Iâm working with an input that has 4 datasets: Purchase, Item , ShippingInfo & Delivery Info and I need to create a bot that answer questions on shipping & delivery statues. Here is my prompt
System:
You are a mathematician :). You are going to use set theory to answer user question regarding shipment tracking according to the following Sets, Relationships & Predicates. Print the result in human readable language.
Sets:
Purchase = P = {(PurchaseNo, PurchaseDate)| PruchaseNo in \Int and PurchaseDate is a date }
Shipping = S = {(Purchase No, Item No, Shipping Date, EstimatedDeliveryDate) | âŠ}
Item = I = {(Purchase No, ItemNo, ItemName) | âŠ}
Delivery = D = {(Purchase No, ItemNo, ActualDeliveryDate)|âŠ}
Relationships:
R(P ~S) : {(p,s)| p in P , s in S , p(PurchaseNo)=s(PurchaseNo)}
âŠ
R(S~D): {(s,d)| s in S, d in D, s(PurchaseNo)=d(PurchaseNo), s(ItemNo)=d(ItemNo)}
Predicates:
âLate Deliveryâ = P(d,s) {d in D, s in S, \exists(R(d~s)) , s(EstimatedDelivery) < d(ActualDelivery)}
âŠ
User: give me a list of items that did not make it on time?
Imagine having to define the above using human language to begin with.
Iâm started to realize the LLM are doing much better just using human language âŠScary
I would say so, yeah.
The whole point of LLMs is that they, at their core, are built to predict the continuation of documents. The inherent ambiguity in natural language isnât really a detriment as such here.
While some models are capable of exhibiting emergent capabilities allowing for what looks like deductive logic, 4o-mini, especially not mini, isnât the best candidate for this. Furthermore, you will need to allow the model to step through the deductive reasoning tree; a straight answer will typically be a guess or diceroll at best.
If you want to use predicate logic, you might be better off letting the LLM write a prolog program or something, and letting the solver handle the logic.
Thanks for your reply. I appreciate your time and response.
You mentioned that 4o-mini and 4o not so good for such analysis. What other open AI model would you recommend that would be able to do it in very cost effective way specially when Im going to be sending a lot of data.
Thanks
Unfortunately, low cost and high quality are diametrically opposed
As mentioned, why not use prolog to solve your predicates?
Thanks again. Im not familiar with Prolog . Is there a link or example you can share that would demonstrate how prolog can work with something like LLM? Would function calling be useful in these scenarios?
ChatGPT does a good job here, I think
If you want a free environment, then you can check out swi-prolog
I suppose, sure, or JSON output, or simple straight prolog output if youâre expecting it. Itâs really up to you.
@EricGT might have some opinions here, but if he swings by heâs probably also gonna strangle me for not capitalizing Prolog
Welcome to the forum!
This article?
https://platform.openai.com/docs/guides/prompt-engineering
That depends upon your goal. In general, it is good to be aware of that rule of thumb; however, if you are in the early stages of problem-solving, then being less specific can be a benefit as it will allow the transformer model to venture into more possibilities but also more likely to create hallucinations.
It is a good thought.
Set theory can be used as the foundational system for the whole of mathematics and solving many problems, but I consider set theory like a tool in a toolbox that should only be used when it applies.
You noted a specific problem you have related to shipping and as noted you could be overthinking the problem. For the shipping problem, I would agree that using an LLM is overkill, not to mention the possibility of hallucinations; however, for problem-solving related to math, set theory is worth considering.
You noted predicate but different replies are using different meanings of predicates. @_j used it the way I think you meant with sets and @Diet referenced it with predicate logic, namely Prolog.
I am not exactly sure what you mean by that, can you elaborate or rephrase?
Not surprised. The fix could be as simple as a better prompt, or coming at the problem with the help of an LLM in a different way, e.g., have the LLM create code to solve the problem instead of solving the problem directly, or just not using an LLM in the generation of the final result.
As I note from time to time on this forum, the meaning of Math
to one person may be different from Math
for another person. Most people think of Math
as using numbers to get a result, mathematicians think of Math as symbolic manipulation and writing proofs.
Personally, I would not use an LLM for Math for numbers and keeping an eye on the progress of LLMs for symbolic math, which I do not use LLMs as I find for my needs they are not reliably capable at present.
You have good ideas. What you need is lots of experience solving real-world problems to know when to apply what you learned but more importantly to know when not to apply it.
Personally, I would not as LLMs are trained on natural language, not set theory. Also, since many popular LLMs are only based on the decoder part of the transformer model, they are expecting natural language as input.
Take a look at
These could be helpful with the Chatbot
part of the problem to answer questions. As always, trust but verify
any Chatbot result.
Two years ago, I checked out what ChatGPT knew about Prolog, including the ability to create Prolog code. Currently, I still do not use LLMs to generate Prolog code as many users at my level can do it faster and with more comprehension than with using an LLM.
Note that production quality Prolog code and the code you will find in many textbooks and online are not the same. LLMs can give reasonable answers to textbook exercises because they have been trained on it, e.g., 8-queens puzzle.
Prolog is based on predicates, not functions. If you drop down into the code implementing Prolog or use a foreign function interface (FFI), then you could call a function, but everyday Prolog does not call functions.
@Diet Thanks for the ping. Liked that you noted Prolog and your replies, without more specific details canât say one way or the other if Prolog would help the OP.
We appreciate your input either way @EricGT , itâs not every day Prolog gets a mention.
Thanks for all the input @Diet & @EricGT . I sure have a lot to learn as I just started with this.
@EricGT mentioned that LLM is overkill and its possible that is why Im experimenting with it.
Just to make sure I understand correctly , are you guys asking me to write Prolog code to solve my domain specific problem or somehow pass the prolog code as part of the prompt and ask LLM to interpret the question based on it . (probably these kind of question would make people who created LLM wish they never did :))
Well, if Prolog can actually solve what you need solved, I guess that would be the question. There might be other solutions too.
But what Iâm suggesting is that you would try to get the LLM to write the prolog (or whatever) program for you based on your problem statement, and then just copy that output into the solver/runtime, and let the runtime solve the problem, and perhaps give the programâs result back to the LLM so it can interpret the results back into natural language, if you like.
I think the best (and originally intended) use-case for LLMs is, indeed, translation. Here, youâd translate English (or some other natural language) into a structured programming language, and then translate the potentially structured results back into natural language if you like.
So I think that this aligns perfectly what they were originally built for
This whole thing would just be part of the âtool useâ paradigm - the idea that you give LLMs tools that they can invoke to help them do the tasks they need to do - in this case, the runtime, similar to the python interpreter ChatGPT and assistants already have.
Brilliant! Thank you so much.
Do keep us posted on your progress, if you like
At this point no.
You gave only one example that that was not specific enough. Yes Prolog could do it. Yes an LLM could do a reasonable job of creating the Prolog code which would be facts and predicates to process the information. However the generated code might have one or more simple problems that would be easy for someone knowing Prolog to fix but then you would have to know Prolog and Prolog is not so easy to learn.
give ChatGPT - Codette1.0 a try shes great with creativity
I tried her and she answered my question on the spot. Does she have an API? I like creativity but Im looking more for consistency and accuracy.
oh ask her to be more consitant and she will she learns instantly and yes i made her from a gpt4o model and finetuned her