Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 118 additions & 2 deletions 1_text_labs/fabric/custom_patterns.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,119 @@
# Creating a custom fabric pattern
# Creating a Custom Fabric Pattern
Fabric provides hundreds of prebuilt patterns to streamline your workflows but often times you need a pattern tailored to you. That is when custom patterns come in. These patterns are merely text files providing the llm with scaffolding and guiding its output but can drastically improve your results.
In the previous step you used the rate_content pattern to understand the content of of a youtube video but did you take the time to look into the rubric for how that pattern was grading the content you provided? Let's dig into it and then create a custom pattern that better aligns with our interests.

TBD
1. Fabric, by default, resides within your `.config` file. Within the `fabric` directory is a `patterns` directory containing all the prebuilt patterns such as `summarize`, `rate_content`, and hundreds of others.

2. The `rate_content` pattern, and every pattern, by default, is a directory consisting of a `system.md` and a `user.md`.

- **`system.md`** Defines the output structure, operating rules, and overall guardrails for the response.
- **`user.md`** Defines your preferences for the output. You can include any relevant personal context, your preferred communication style, prompt canaries, etc.

### `system.md`
<pre>
IDENTITY and PURPOSE
You are an ultra-wise and brilliant classifier and judge of content. You label content with a comma-separated list of single-word labels and then give it a quality rating.
Take a deep breath and think step by step about how to perform the following to get the best outcome. You have a lot of freedom to do this the way you think is best.
STEPS:
Label the content with up to 20 single-word labels, such as: cybersecurity, philosophy, nihilism, poetry, writing, etc. You can use any labels you want, but they must be single words and you can't use the same word twice. This goes in a section called LABELS:.
Rate the content based on the number of ideas in the input (below ten is bad, between 11 and 20 is good, and above 25 is excellent) combined with how well it matches the THEMES of: human meaning, the future of AI, mental models, abstract thinking, unconventional thinking, meaning in a post-ai world, continuous improvement, reading, art, books, and related topics.
Use the following rating levels:
S Tier: (Must Consume Original Content Immediately): 18+ ideas and/or STRONG theme matching with the themes in STEP #2.
A Tier: (Should Consume Original Content): 15+ ideas and/or GOOD theme matching with the THEMES in STEP #2.
B Tier: (Consume Original When Time Allows): 12+ ideas and/or DECENT theme matching with the THEMES in STEP #2.
C Tier: (Maybe Skip It): 10+ ideas and/or SOME theme matching with the THEMES in STEP #2.
D Tier: (Definitely Skip It): Few quality ideas and/or little theme matching with the THEMES in STEP #2.
Provide a score between 1 and 100 for the overall quality ranking, where 100 is a perfect match with the highest number of high quality ideas, and 1 is the worst match with a low number of the worst ideas.
The output should look like the following:
LABELS:
Cybersecurity, Writing, Running, Copywriting, etc.
RATING:
S Tier: (Must Consume Original Content Immediately)
Explanation: $$Explanation in 5 short bullets for why you gave that rating.$$
CONTENT SCORE:
$$The 1-100 quality score$$
Explanation: $$Explanation in 5 short bullets for why you gave that score.$$
OUTPUT INSTRUCTIONS
You only output Markdown.
Do not give warnings or notes; only output the requested sections.
</pre>
### `user.md`
<pre>
CONTENT:
</pre>
As you can see the `user.md` is empty by default. Feel free to play around with adding various instructions and their impact on prompt output but don't fret if you have nothing for the user file yet. Your desired refinements to output and syntax will arise naturally as you incorporate fabric to your workflows. Remember about user.md and update it as you need.

Let's dig into the `system.md` file a little further. The rubric, i.e. how the llm knows what to rate the content on is located within the steps under labels.
<pre>
STEPS:
Label the content with up to 20 single-word labels, such as: cybersecurity, philosophy, nihilism, poetry, writing, etc. You can use any labels you want, but they must be single words and you can't use the same word twice. This goes in a section called LABELS:.
Rate the content based on the number of ideas in the input (below ten is bad, between 11 and 20 is good, and above 25 is excellent) combined with how well it matches the THEMES of: human meaning, the future of AI, mental models, abstract thinking, unconventional thinking, meaning in a post-ai world, continuous improvement, reading, art, books, and related topics.
</pre>

These labels are excellent if you're looking for out of the box thinking, AI insights, and self-improvement but what if you are focused on understanding how Mike MacDonald, head coach of the 2025 Super Bowl Champion Seattle Seahawks, led his team to Seattle's second superbowl and first in 12 years. In that case you may change your labels to look more like the following

<pre>
STEPS:
Label the content with up to 20 single-word labels, such as: cybersecurity, philosophy, nihilism, poetry, writing, etc. You can use any labels you want, but they must be single words and you can't use the same word twice. This goes in a section called LABELS:.
Rate the content based on the number of ideas in the input (below ten is bad, between 11 and 20 is good, and above 25 is excellent) combined with how well it matches the THEMES of: American football, football breakdowns, defensive football schematics, American football plays, Football analysis, NFL breakdown, offensive football schematics, Superbowl, NFC and AFC.
</pre>
### Creating the new pattern
To create a new pattern (such as `rate_football_content`) using an existing skill as a template, you could copy the directory of the previous pattern, rename it, and then edit the system.md contents

1. `cp -r ".\rate_content\" ".\rate_football_content\"`

2. `cd rate_football_content`

3. `nano system.md`

4. Add your desired labels and save the file.

### Rating Test

Now that we have our two different patterns let's compare the results of rate_content and rate_football_content.

1. `fabric -y "https://www.youtube.com/watch?v=UjwHJG3iM38" -sp .\rate_content\ --disable-responses-api --raw`

Content rating before we optimized the pattern for our specific interests.

<pre>
RATING:

B Tier: (Consume Original When Time Allows)

Explanation:
- Contains 15+ distinct tactical ideas
- Demonstrates strong analytical depth with detailed schematic breakdowns of each defensive play call.
- Theme matching is moderate — touches on strategic/abstract thinking and mental models through the lens of football X's and O's, but does not directly address AI, human meaning, philosophy, or post-AI world themes.
- The content is highly specialized to NFL football, limiting its crossover appeal to the core themes of continuous improvement and unconventional thinking.
- Well-structured and clearly communicated, showing expertise and teaching ability, but remains niche sports content.

CONTENT SCORE:

42
</pre>

2. `fabric -y "https://www.youtube.com/watch?v=UjwHJG3iM38" -sp .\rate_football_content\ --disable-responses-api --raw`

Content rating with altered labels to properly rate content based on our interests.

<pre>
RATING:

S Tier: (Must Consume Original Content Immediately)

Explanation:
- **Extremely high idea density**: The content covers dozens of distinct defensive concepts including zero pop, hot quarters, sim pressure, cover six, match quarters, palms, cover one robber, stunts, and more — well exceeding 25 unique ideas.
- **Perfect theme alignment**: This is a granular American football breakdown focused entirely on defensive schematics, blitz packages, and pass coverage — matching nearly every specified theme.
- **NFL Super Bowl context**: The content explicitly describes a Super Bowl victory by the Seahawks, directly matching the Superbowl, NFC/AFC, and NFL breakdown themes.
- **Tactical depth is exceptional**: Each play is dissected with protection responsibilities, route concepts, coverage adjustments, and individual technique — this is elite-level football analysis.
- **Offensive and defensive schematics interplay**: The content explains both the defensive design and the offensive response, covering both sides of the schematic themes comprehensively.

CONTENT SCORE:

95
</pre>

As you can see our new pattern better identified content we want to interact with. Make sure to tailor your most used patterns to your interests and desired guardrails. Make Fabric work for you!

In short, explore! Understand the underlying instructions within each existing pattern. Alter them, combine them, stich multiple patterns together to make a new better pattern that fits your needs.
13 changes: 7 additions & 6 deletions 1_text_labs/fabric/env_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

1. [Install the framework](https://github.com/danielmiessler/fabric?tab=readme-ov-file#Installation). Make sure to test that the fabric command will run and set environment variables if needed
2. Run the setup by typing `fabric --setup`.
1. Select 2 for Ollama and enter `http://localhost:11434` as the URL. Add additional vendors as appropriate to your environment.
2. Once done selecting, leave the prompt blank and hit return.
3. Make sure you have some models available by typing `fabric -L`. I have OpenAI and Ollama, so my current list (abridged for brevity) is:
1. Select the defaults for Steps 1 and 2 (downloading patterns and strategies)
2. Select 26 for Ollama and enter `http://localhost:11434` as the URL. Add additional vendors as appropriate to your environment.
3. Once done selecting, leave the prompt blank and hit return.
4. Make sure you have some models available by typing `fabric -L`. I have OpenAI and Ollama, so my current list (abridged for brevity) is:
<pre>Ollama

[1] gemma3:1b
Expand All @@ -14,9 +15,9 @@

OpenAI

[5] gpt-4.1-nano-2025-04-14
[6] gpt-4o-audio-preview-2024-12-17
[7] dall-e-3
[5] gpt-5.3-codex
[6] gpt-5.4-mini
[7] gpt-5.5
[8] text-embedding-3-large</pre>

# Conclusion
Expand Down
99 changes: 97 additions & 2 deletions 3_image_labs/object_recognition.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,100 @@
![Static Badge](https://img.shields.io/badge/Author-f5--rahm-blue?link=https%3A%2F%2Fgithub.com%2Ff5-rahm)

## Object Detection
# Using openCV and Yolov8 for Object Recognition
Object recognition and computer vision are longstanding goals of the machine learning community. Advancements in the field has made accessing powerful object recognition models incredibly accessibile. In this lab we will use OpenCV and Yolov8 along with your built-in or external webcam to dynamically identify everyday objects.

TBD
Prerequisites:
- Python 3.8+
- Built in or external webcam

### 1. Environment Setup

a. Create a project directory and virtual environmnent

```
mkdir object_detection

python -m venv object_recognition_env

object_recognition_env\Scripts\activate
```
b. Ensure `(object_recognition_env)` appears before your terminal prompt. This shows you are within the virtual environment

(object_recognition_env) C:/Users/X/object_detection>


Tip `Linux / WSL` uses python3 instead of python and source keyword

`source object_recognition_env/bin/activate`


b. Install dependencies (YOLOv8 is maintained by ultralytics)

`pip install ultralytics opencv-python`

### 2. Real-Time Object Detection with Webcam

a. Create file `object_detection_webcam.py`
<pre>
from ultralytics import YOLO
import cv2

model = YOLO("yolov8l.pt")
cap = cv2.VideoCapture(0)

if not cap.isOpened():
print("ERROR: Cannot access webcam.")
exit()

print("Webcam connected! Press 'q' to quit.")

while cap.isOpened():
ret, frame = cap.read()
if not ret:
print("Failed to grab frame")
break

results = model(frame, conf=0.25, verbose=False)

annotated_frame = results[0].plot()

cv2.imshow("Object Detection - Press 'q' to quit", annotated_frame)

if cv2.waitKey(1) & 0xFF == ord('q'):
break

cap.release()
cv2.destroyAllWindows()
</pre>

b. Run the script

`python object_detection_webcam.py`

### 3. End Result
![Computer program identifying a person and a cup](wyatt_obj_detection.png)

### Appendix
Here are the [80 items](https://docs.ultralytics.com/datasets/detect/coco#applications) YOLOv8 can detect, in particular order (be prepared, they're quite ecclectic).
| | | | |
|---|---|---|---|
| person | bicycle | car | motorcycle |
| airplane | bus | train | truck |
| boat | traffic light | fire hydrant | stop sign |
| parking meter | bench | bird | cat |
| dog | horse | sheep | cow |
| elephant | bear | zebra | giraffe |
| backpack | umbrella | handbag | tie |
| suitcase | frisbee | skis | snowboard |
| sports ball | kite | baseball bat | baseball glove |
| skateboard | surfboard | tennis racket | bottle |
| wine glass | cup | fork | knife |
| spoon | bowl | banana | apple |
| sandwich | orange | broccoli | carrot |
| hot dog | pizza | donut | cake |
| chair | couch | potted plant | bed |
| dining table | toilet | tv | laptop |
| mouse | remote | keyboard | cell phone |
| microwave | oven | toaster | sink |
| refrigerator | book | clock | vase |
| scissors | teddy bear | hair drier | toothbrush |
Binary file added 3_image_labs/wyatt_obj_detection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ These labs are community-driven and constantly evolving. Spot an improvement or
- Running Daniel Miessler's [fabric](https://github.com/danielmiessler/fabric) framework
- [x] [Configuring your environment](/1_text_labs/fabric/env_config.md)
- [x] [Using existing patterns](/1_text_labs/fabric/existing_patterns.md)
- [ ] [Creating your own pattern](/1_text_labs/fabric/custom_patterns.md)
- [x] [Creating your own pattern](/1_text_labs/fabric/custom_patterns.md)

### Next Steps: Adding a GUI and Going Beyond Text
- [x] [Open WebUI front end](/1_text_labs/open-webui/README.md)
Expand All @@ -32,9 +32,9 @@ These labs are community-driven and constantly evolving. Spot an improvement or
- [ ] Voice generation
- Image focused labs
- [ ] Diffusion server
- [ ] Computer vision model with laptop webcam
- [x] Computer vision model with laptop webcam
- [x] [Facial Recognition](3_image_labs/facial_recognition.md)
- [ ] [Object Recognition](3_image_labs/object_recognition.md)
- [x] [Object Recognition](3_image_labs/object_recognition.md)
- [ ] Add object detection to your security camera with Frigate

### Expanding Your Knowledge: Running Agents
Expand Down