Replies: 3 comments 2 replies
-
Some of my findings are:
The more energy the AI has to spend processing the prompt / writing the response, the less it will have to do the job. Once I get a working prompt, I run experiments trimming it (just like with neural networks) to find how much I can remove without affecting the results.
Dummy example ahead
which can get very costly because it may have many instances
The second example may have longer text on the input (json schema), but it will get N times shorter on the output. As of 2024-03-08, openai output tokens are 3 times the cost of input tokens. But more important than that is the 'employ your energy on the task more than on writing the results' . I'd like to see if someone has found the opposite to be true (maybe it does in some cases). |
Beta Was this translation helpful? Give feedback.
-
One rule I learnt interacting with the LLM is this:
You may think, But it is easy to forget (for me) when creating prompt+output_templates. What happens if you forget the rule? The LLM will respond, with rubbish / overthinking / hallucination As far as I know you cannot include conditions while creating the class.
However you can build the Example:
Which produces
And then, conditionally increase it:
Which produces:
|
Beta Was this translation helpful? Give feedback.
-
Did you know .... ? That given a Pydantic model (example) from pydantic import BaseModel
from typing import List, Literal
class UserProfile(BaseModel):
username: str
email: str
is_active: bool
roles: List[Literal['admin', 'editor', 'viewer']]
tags: List[str] you can ask the LLM to convert it to YAML UserProfile:
type: object
properties:
username: { type: string }
email: { type: string }
is_active: { type: boolean }
roles:
type: array
items: { type: string, enum: ['admin', 'editor', 'viewer'] }
tags:
type: array
items: { type: string }
required: [username, email, is_active, roles, tags] and then, at the end of your prompt you can use that (adding comments where required/beneficial)
Output and Format:UserProfile:
type: object
properties:
username: { type: string } # User's unique identifier
email: { type: string }
is_active: { type: boolean }
roles: # < SOME TEXT EXPLAINING YOUR REQUIREMENTS/CONDITIONS/ETC. >
type: array
items: { type: string, enum: ['admin', 'editor', 'viewer'] } # Allowed roles
tags: # < SOME TEXT EXPLAINING YOUR REQUIREMENTS/CONDITIONS/ETC. >
type: array
items: { type: string }
required: [username, email, is_active, roles, tags] and the LLM will follow that format without having to use Example output. username: johndoe
email: [email protected]
is_active: true
roles: [admin, editor]
tags: [python, pydantic] Why would this be useful?:
Once your prompt design is solid ... I know this would throw away the While troubleshooting, you can add a additional_comments: { type: string } # Write here anything you want to say if you find problems completing the task, or you find it unclear, ambiguous, .... blah blah blah .... to the output format so that the LLM can have a place to vent out its frustration with your prompt :o| |
Beta Was this translation helpful? Give feedback.
-
There are lots of literature about Prompts, but this is (in my opinion) a slightly different game.
With Instructor, you have the prompt and you have the class definition that you pass to the LLM/AI/openai call.
Both need to be aligned and one needs to consider the extra cost (in tokens) of processing the JSON schema together with generating the output that fulfills that class definition.
I am sure each one has found some tricks/caveats/quirks and sharing them would/may provide some light to others.
Beta Was this translation helpful? Give feedback.
All reactions