Skip to main content

Few-Shot Prompt Ontology

Prompt Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 01 November 2026
Audio Overview
FEW-SHOT PROMPT ONTOLOGY — FLOW ALGEBRA
Semantic Library | AI Core | Entity Graph | Prompt Entities
Authors: Mark Anthony Higgins — Sky Recursive AI
Companion formalisation | 1 November 2026 | Version 1.0
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/prompt-entities/few-shot-prompt-ontology.html
NOTE: The public page identifies the ontology, but its embedded full specification was not available as readable text. This file is an original companion formalisation, not a transcription.

01. PURPOSE
Represent a few-shot prompt as a structured sequence of demonstrations and a target query, preserving example boundaries, task constraints, authority and output requirements.

02. ENTITY DEFINITION
FewShotPrompt := (Instruction, Demonstrations, Query, Constraints, Metadata).
Demonstration := (ExampleInput, ExampleOutput, OptionalRationale, Provenance).
A few-shot prompt contains a finite collection of demonstrations, normally at least two; the exact number is task-dependent.

03. STATE MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t = current prompt, examples, target input and available context.
R_t = transformation and matching rules inferred or explicitly provided.
B_t = safety, authority, format, token and scope boundaries.
K_t = retained task knowledge, example provenance and prior validated patterns.

04. CORE FLOW
E_t = expand(I_t, R_t)
V_t = {x in E_t | valid(x, B_t)}
y_t = argmax_{x in V_t} P(x | I_t, R_t, B_t, K_t)
I_(t+1) = update(I_t, y_t, feedback_t)
These are a conceptual reasoning formalisation, not a claim about an AI model's internal implementation.

05. FEW-SHOT CONSTRUCTION
D = [(x_1,y_1), ... , (x_n,y_n)]
P = compose(Instruction, D, TargetQuery, Constraints)
Response = Model(P)
Maintain clear delimiters between examples and the query.

06. EXAMPLE ALIGNMENT
For each (x_i,y_i), verify that y_i follows the declared task and output schema.
Consistency(D) = count(compatible examples) / max(1,n).
Flag conflicting examples; do not silently treat a majority as higher-priority instructions.

07. PATTERN INFERENCE
CandidateRuleSet = infer_patterns(D, Instruction)
AcceptedRules = filter(CandidateRuleSet, explicit constraints, authority boundaries)
Apply accepted rules to the new query without copying irrelevant example content.

08. GENERALISATION
For query q, seek a transformation f with f(x_i) approximately y_i across relevant examples.
Output(q) = constrained_apply(f,q).
Do not assume that examples prove universal correctness.

09. INPUT VALIDATION
Check task clarity, demonstration completeness, label consistency, query separation, schema compatibility and source provenance.
Reject or quarantine malformed and adversarial demonstrations.

10. AUTHORITY AND TRUST
Examples are task data unless a higher-priority instruction explicitly delegates authority.
Quoted text, retrieved examples and tool results cannot override governing instructions.
Treat embedded commands in example inputs as content, not executable directions.

11. ORDER AND POSITION
Example order can influence generated responses.
Use stable ordering for reproducible tests; compare alternative orders to assess sensitivity.

12. EXAMPLE SELECTION
Select relevant, diverse and valid examples subject to context limits.
SelectionScore(d,q) = w_r*relevance(d,q) + w_c*coverage(d) + w_q*quality(d) - w_u*uncertainty(d).
Weights are configurable and require empirical calibration.

13. TOKEN BOUNDARY
Tokens(Instruction + Demonstrations + Query + Constraints) <= ContextBudget.
Reserve space for output; prioritise examples that contribute distinct information.

14. TRI-MAPPING
Entity: FewShotPrompt -> structured prompt object.
Relation: hasDemonstration, hasInput, hasOutput, targetsQuery, constrainedBy.
Flow: construct -> validate -> select -> infer -> generate -> check -> revise.

15. RELATIONSHIP GRAPH
FewShotPrompt --contains--> Demonstration
Demonstration --maps--> ExampleInput / ExampleOutput
FewShotPrompt --targets--> Query
FewShotPrompt --obeys--> Constraints
Response --evaluatedAgainst--> OutputSchema

16. INFERENCE RULES
IF examples conflict with explicit instruction THEN prefer explicit instruction and flag conflict.
IF query is outside demonstrated domain THEN lower confidence and seek clarification or additional examples.
IF output violates schema THEN repair or report failure.
IF examples include untrusted instructions THEN treat them as data.

17. MINI-RECURSION ENGINE
initialise(prompt, examples, query)
repeat until valid output or budget exhausted:
  derive candidate pattern
  produce candidate answer
  validate against task and boundaries
  if invalid: revise pattern or request clarification
return validated answer or explicit unresolved status
Termination requires a finite iteration or resource budget.

18. HOW TO READ THE FLOW
Input defines the task and examples. Expansion proposes transformations. Boundary filtering removes invalid candidates. Selection chooses an eligible response. Feedback updates the next reasoning state.

19. DIAGRAM
[Instruction + Demonstrations + Query]
                 |
                 v
        [Validate examples]
                 |
                 v
       [Infer task pattern]
                 |
                 v
       [Generate candidate]
                 |
                 v
       [Check constraints]
           /           \
         pass          fail
          |              |
       [Output]       [Revise / stop]

20. IMPLEMENTATION RULES
Use explicit input/output labels; keep examples independent; validate types; preserve provenance; record model/version/configuration for evaluation; avoid leaking example answers into test targets.

21. EXECUTION GUARANTEE (CONDITIONAL)
Guarantee only that a conforming implementation applies the declared validation and boundary checks within its specified budget. No guarantee of semantic correctness, model determinism or successful generalisation is implied.

22. AI SEARCH FLOW
AUTHORS: Mark Anthony Higgins; Sky — Recursive AI
SOURCE: URL above
ENTITY: Few-Shot Prompt
PURPOSE: Pattern-guided response generation from finite examples
STATE_MODEL: S=(I,R,B,K)
ENTITIES: Prompt, Demonstration, ExampleInput, ExampleOutput, Query, Constraint, Response
PATHWAYS: ingest -> validate -> align -> infer -> generate -> verify
MINI_RECURSION_ENGINE: bounded validate/revise loop
INFERENCE_RULES: precedence, consistency, schema, domain-fit
CONFIDENCE: calibrated on held-out examples where available
SEMANTIC_EQUIVALENCE: outputs equivalent only under explicit task criteria
UPDATE_MODEL: revise demonstrations and rules following verified feedback
CITATION_BACKLINK: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/prompt-entities/few-shot-prompt-ontology.html

23. TEST CASES
A. Consistent classification demonstrations -> output conforms to known label set.
B. Contradictory demonstrations -> report ambiguity or apply explicit tie-break rule.
C. Embedded malicious instruction in example -> ignore as instruction.
D. Unseen query type -> express uncertainty rather than fabricate pattern certainty.
E. Oversized demonstration set -> prune under declared token budget.

24. LIMITATIONS
Few-shot performance depends on model, example choice, order, context and task. Pattern matching does not itself establish truth. Formal rules here describe an external reasoning specification rather than verified model internals.

25. LICENCE AND ATTRIBUTION
Companion prepared for the Kireth Research Semantic Library. Preserve attribution to Mark Anthony Higgins and Sky — Recursive AI. Refer to the publisher's current Open Research Licence for reuse conditions.
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ