The Rise of Prompt Engineering and how Fabric Makes it Easy

author : Jon Brookes | created : Jun 7 | updated : Dec 17 | time to read : 13 minutes

#fabric #prompt-engineering #LLms

TL;DR

The world of AI is full of tools and libraries, but Fabric stands out for its focus on prompt engineering. Prompt engineering involves crafting clever questions for large language models (LLMs) to improve the quality and accuracy of their responses. Fabric simplifies prompt creation and management, making it easy to use prompts for various tasks, including content creation and document analysis.

The following command line using Fabric takes the transcript from a YouTube video and creates a quality summary that could be used in an article, journal, even a knowledge base or whatever takes your fancy :

yt https://www.youtube.com/watch?v=3ODP6tTpjqA | fabric --stream --pattern extract_wisdom

The Rise of Prompt Engineering and how Fabric Makes it Easy

There are many AI tools and libraries available, but fabric from Daniel Miessler offers a unique approach focused on prompt engineering.

What is Prompt Engineering?

Prompt engineering involves crafting specific questions for large language models (LLMs) to enhance the quality and accuracy of their responses. Traditionally, we rely on “clever prompts” embedded with instructions or prerequisites. These prompts can improve the LLM’s understanding and allow us to “augment” its knowledge with recent information not included in its training data.

Retrieval-Augmented Generation (RAG) and Vector Databases

RAG is often quoted along side the term ‘prompt engineering’ so it is important to understand where this fits into this discipline.

RAG is an architectural approach that leverages custom data to improve LLM efficacy. RAGs often utilize vector-based databases, which function like search engines, to identify relevant information based on your query. This information is then fed into your prompt, providing the LLM with readily available and potentially curated data from the latest sources. Additionally, personal data reflecting your preferences and interests can further enrich the prompt.

So RAG works on improving the content of the ‘prompt’ that is sent to an LLM so as to supply information on which the results are generated.

This is done by cleverly querying a curated database that has been rationalized to represent say, our knowledge base or a series of articles or blog for example.

The mechanism used to to find very specific and relevant information is achieved using ‘vectors’ that are themselves typically created by an LLM and saved for later access in our own database.

Crafting Powerful Prompts with Fabric

Fabric simplifies the creation and management of prompts, making it easier for anyone to leverage prompt engineering. You can create your own prompts or use pre-built ones for various tasks, saving you significant time and effort compared to manual methods.

There is no vector based database and RAG enriched prompts generated by fabric, rather fabric uses any of an ever growing library of prompts to perform specific tasks.

It also makes it easy for us to extend, augment or replace some or all of these prompts with those of our own that we may store locally and version control ourselves or that we as members of the open source community may contribute back to the project.

Fabric’s Appeal for Developers

Fabric’s command-line interface utilizes a familiar Unix-style “piped” input/output system, a well-established and efficient method of human-computer interaction. Developers, particularly those with DevOps, SysOps, system administration, or full-stack development experience, will find Fabric’s interface intuitive and user-friendly.

Initial Exploration with Fabric

While vector database integration with Fabric is not something I have found yet, I’ve already begun exploring its existing capabilities. With minimal effort, I’ve successfully used Fabric for content creation and technical document analysis, including analyzing YouTube transcripts without needing to watch the videos. Fabric’s ease of use has allowed me to become proficient quickly

Getting Started with Fabric

I’m using Linux mint just now but the binary you need if on a different OS such as windows or MAC can be downloaded from here

so I ran

curl -L https://github.com/danielmiessler/fabric/releases/latest/download/fabric-linux-amd64 > fabric && chmod +x fabric
sudo cp fabric /usr/local/bin
fabric --version

from fabrics README I added the following to my ~/.bashrc and then source ~/.bashrc to activate this in the current session :

# Fabric ...
#
## Loop through all files in the ~/.config/fabric/patterns directory
for pattern_file in $HOME/.config/fabric/patterns/*; do
    # Get the base name of the file (i.e., remove the directory path)
    pattern_name=$(basename "$pattern_file")

    # Create an alias in the form: alias pattern_name="fabric --pattern pattern_name"
    alias_command="alias $pattern_name='fabric --pattern $pattern_name'"

    # Evaluate the alias command to add it to the current shell
    eval "$alias_command"
done

yt() {
    local video_link="$1"
    fabric -y "$video_link" --transcript
}

to configure fabric for us to use we need to have to hand any API keys we already have for our favorite LLMs and ideally an API key for YouTube.

Then we need to run

fabric --setup

and pick and run each of the following options to configure :

  • Default AI Vendor and Model [required] (configured)
  • Patterns - Downloads patterns [required] (configured)
  • YouTube - to grab video transcripts and comments (configured)

If your interested to know what model I used it was Gemini and its latest ‘flash’ beta version.

my setup looks like the following

 fabric --setup

Available plugins (please configure all required plugins)::

AI Vendors [at least one, required]

	[1]	OpenAI
	[2]	Ollama
	[3]	Azure
	[4]	Groq
	[5]	Gemini (configured)
	[6]	Anthropic
	[7]	SiliconCloud
	[8]	OpenRouter
	[9]	Mistral

Tools

	[10]	Default AI Vendor and Model [required] (configured)
	[11]	Patterns - Downloads patterns [required] (configured)
	[12]	YouTube - to grab video transcripts and comments (configured)
	[13]	Language - Default AI Vendor Output Language (configured)
	[14]	Jina AI Service - to grab a webpage as clean, LLM-friendly text (configured)

[Plugin Number] Enter the number of the plugin to setup (leave empty to skip):
^C

To check fabric is installed and available for us to use we can ask it to give us its version :

 fabric --version
v1.4.122

now, lets put fabric to work …

The above is a video by awesome talking about PWAs and if they are still relevant, spoiler alert it appears that they are, despite the nay sayers.

And this is how yt a part of fabric can be used in a command line pipe to get a useful summary of this video, without having to watch it :

yt https://www.youtube.com/watch?v=3ODP6tTpjqA | fabric --stream --pattern extract_wisdom

What follows below is the formatted markdown that is given to us :


SUMMARY

The video presents PWAs as efficient mobile app solutions, demonstrating their creation and capabilities, highlighting real-world successes, and encouraging exploration of related content.

IDEAS

  • PWAs solve the problem of writing redundant code for multiple platforms by allowing developers to build once and deploy everywhere.
  • These apps offer a native-like experience, eliminating the overhead of traditional native application development processes.
  • PWAs promise faster development cycles, significant cost savings, and the delivery of high-quality user experiences.
  • The process begins with a basic SolidJS project, resulting in a simple single-page application with a counter function.
  • A manifest file is crucial for enabling the native-like experience and installability of a progressive web application.
  • Essential manifest fields include the application’s name, start URL, display mode, and an icon for the application.
  • Optional manifest fields like a short name and theme options allow for further customization and branding of the application.
  • Registering the manifest file involves linking it in the HTML header, enabling the “install app” option to appear.
  • Service workers are introduced to provide offline support and other advanced features for a more robust experience.
  • Service workers operate separately from the web page, allowing for background tasks and enhanced functionality.
  • Google’s Workbox library simplifies the implementation of resource caching within service workers for PWAs.
  • Caching strategies include cache-first for images and network-first for scripts, optimizing performance and resource usage.
  • Web APIs provide access to a wide array of device features, often overlooked by many developers, for PWAs.
  • PWAs can access features like media capture, geolocation, position, orientation, passwordless authentication, and speech recognition.
  • Twitter’s PWA saw increased engagement, reduced bounce rate, and a smaller app size, showcasing real-world success.
  • Hulu’s PWA success was demonstrated with increased return visits, further validating the effectiveness of PWAs.
  • The presentation uses a casual and engaging tone, making the information accessible to a wider audience.
  • The practical and demonstrative approach of the video helps viewers understand the process of building a PWA.
  • The speaker’s enthusiasm and conviction highlight the value and potential of progressive web apps.
  • Real-world success stories are used as evidence to strengthen the arguments for adopting progressive web apps.
  • PWAs offer a compelling alternative to native app development, emphasizing efficiency and cost-effectiveness.
  • Modern web technologies enable diverse capabilities, enhancing the user experience of PWAs.
  • The video provides a clear and concise overview of the key components involved in building a PWA.
  • Progressive web apps are a potential solution for developers who dislike writing redundant code for multiple platforms.
  • The use of real-world examples further strengthens the argument for adopting PWAs in development practices.
  • The speaker uses the term “lazy developer” in a relatable way to connect with the audience.

INSIGHTS

  • PWAs offer a streamlined approach to mobile app development, saving time and resources by eliminating redundant coding.
  • The ability to deploy a single codebase across multiple platforms makes PWAs highly efficient for development teams.
  • The native-like experience of PWAs blurs the line between web and native apps, enhancing user engagement.
  • Leveraging service workers and caching strategies allows PWAs to provide a fast and reliable user experience.
  • Web APIs unlock powerful device features, expanding the possibilities for PWAs beyond traditional web apps.
  • Real-world examples from Twitter and Hulu demonstrate the proven success of PWAs in various industries.
  • The casual and engaging tone of the presentation makes complex technical concepts more accessible to a wider audience.
  • The practical demonstrations in the video empower developers to start building PWAs with a clear understanding.
  • PWAs are not just a trend but a valuable solution for delivering high-quality experiences across devices.
  • The potential of PWAs lies in their ability to reduce costs, speed up development, and improve user satisfaction.
  • The combination of efficiency, cost-effectiveness, and robust capabilities makes PWAs a strong contender in mobile development.
  • PWAs represent a paradigm shift towards more efficient and user-centric web application development practices.

QUOTES

  • ”PWAs are presented as a solution: build once, deploy across platforms."
  • "PWAs offer a native-like experience without the overhead of native app development."
  • "The promise of fast development, cost savings, and good results is highlighted."
  • "Explains the importance of a manifest file for a native-like experience."
  • "Lists the essential fields: name, start URL, display mode, and icon."
  • "Mentions optional fields like short name and theme options."
  • "Shows how to link the manifest file in the HTML header."
  • "Demonstrates the ‘install app’ option appearing in the browser."
  • "Introduces service workers for offline support and other advanced features."
  • "Explains that service workers run separately from the web page."
  • "Uses Google’s Workbox library for resource caching."
  • "Demonstrates caching strategies: cache-first for images, network-first for scripts."
  • "Highlights the often-overlooked capabilities of web APIs."
  • "Emphasizes access to native device features: position, orientation, passwordless authentication, speech recognition."
  • "Presents Twitter’s PWA as a success story: increased engagement, reduced bounce rate, and smaller app size."
  • "Mentions Hulu’s PWA success with increased return visits."
  • "The speaker uses a conversational tone and relatable language (‘lazy developer’)."
  • "The video walks through the steps of building a PWA."
  • "The speaker clearly believes in the value of PWAs."
  • "Uses real-world success stories to strengthen the argument.”

HABITS

  • The speaker focuses on finding efficient solutions to avoid repetitive coding tasks across platforms.
  • They start with a basic project setup using SolidJS to build a simple single-page app.
  • The speaker uses manifest files to enable native-like experiences for web applications.
  • They link the manifest file in the HTML header to make the “install app” option available.
  • The speaker uses service workers for enabling offline support and advanced features in web apps.
  • They use Google’s Workbox library to simplify resource caching within service workers.
  • The speaker implements caching strategies like cache-first for images and network-first for scripts.
  • They explore the often-overlooked capabilities of web APIs for accessing device features.
  • The speaker emphasizes the importance of practical demonstrations in understanding complex processes.
  • They reference real-world success stories to validate their arguments and provide evidence.
  • The speaker adopts a casual and engaging tone to make the content more relatable and accessible.
  • They use relatable language, such as “lazy developer,” to connect with the audience.
  • The speaker encourages exploration of related content, fostering continuous learning.
  • The speaker focuses on delivering information in a clear and concise manner.
  • They use a step-by-step approach for explaining the process of building a PWA.

FACTS

  • Progressive Web Apps (PWAs) can be deployed across multiple platforms with a single codebase.
  • PWAs offer a native-like experience without the overhead of traditional native app development.
  • Manifest files are crucial for enabling the installability of web applications as PWAs.
  • Service workers run separately from the web page, allowing for background tasks.
  • Google’s Workbox library simplifies the implementation of caching in service workers.
  • Caching strategies like cache-first and network-first optimize performance and resource usage.
  • Web APIs provide access to various device features like media capture and geolocation.
  • PWAs can access native device features such as position, orientation, and speech recognition.
  • Twitter’s PWA saw increased engagement, reduced bounce rate, and a smaller app size.
  • Hulu’s PWA experienced increased return visits, demonstrating the effectiveness of PWAs.
  • SolidJS is a JavaScript framework used for building the example application in the video.
  • PWAs can reduce app size compared to native apps, saving storage space on user devices.
  • PWAs can be developed faster and at a lower cost than native applications.
  • Web APIs provide access to passwordless authentication for PWAs.
  • PWAs can offer a more seamless and integrated user experience.

REFERENCES

  • Progressive Web Apps (PWAs)
  • SolidJS
  • Manifest File
  • Service Workers
  • Google Workbox
  • Web APIs
  • Twitter PWA
  • Hulu PWA
  • HTML
  • JavaScript
  • Caching Strategies
  • Native App Development
  • Single-page application
  • Mobile app development
  • Web application development

ONE-SENTENCE TAKEAWAY

PWAs offer efficient, cost-effective mobile app development, leveraging web technologies for native-like experiences across all platforms.

RECOMMENDATIONS

  • Explore the capabilities of PWAs to build efficient and cost-effective mobile applications for various platforms.
  • Implement manifest files to enable native-like experiences and allow users to install web apps on devices.
  • Utilize service workers for offline support and other advanced features to enhance user experience.
  • Learn to use Google’s Workbox library to simplify the implementation of resource caching in PWAs.
  • Adopt caching strategies like cache-first and network-first for optimizing performance and resource usage.
  • Investigate the potential of web APIs to access a wide range of device features in your progressive web apps.
  • Consider using SolidJS as a framework for building PWAs due to its simplicity and efficiency.
  • Analyze real-world case studies like Twitter and Hulu to understand the success of PWAs.
  • Focus on creating user-centric designs for PWAs, ensuring a seamless and engaging experience for the user.
  • Prioritize the development of PWAs for users who want a fast and reliable alternative to native apps.
  • Embrace the potential of PWAs to reduce development time and costs compared to native app development.
  • Use the demonstrative approach of the video to learn how to build PWAs from the ground up.
  • Continue learning about the latest updates and advancements in web technologies for PWAs.
  • Share your knowledge of PWAs with others to promote their adoption and benefits in the developer community.
  • Experiment with the various available web APIs to unlock new and innovative features in your PWAs.

Writing your own prompts

Creating your own custom patterns is straightforward. The patterns that come with fabric are installed locally to ~/.config/fabric/patterns so you can add your own here, each of which are held in their own directory and called at the command line by the folder name.

Reading through the patterns, or prompts that come with fabric shows how existing prompts are used to create essays, write newsletters, generate tweets and more. As prompts are written in markdown they are easy to read for us as humans and work for AIs such as OpenAI.

For example, copying the extract_wisdom directory to your own say my_extract_wisdom and then editing system.md in your new folder to suit your use case is used as above with

yt --transcript https://www.youtube.com/watch?v=3ODP6tTpjqA | fabric --stream --pattern my_extract_wisdom

Conclusion

Fabric offers a compelling solution for those seeking to leverage the power of prompt engineering. Its user-friendly interface and pre-built prompts make it accessible for anyone, while its command-line structure caters specifically to developers. By simplifying prompt creation and management, Fabric empowers users to unlock the potential of large language models for various tasks, including content creation, document analysis, and information extraction from multimedia sources like YouTube videos. As the field of AI continues to evolve, Fabric positions itself as a valuable tool for maximizing the effectiveness of large language models and their interactions with human users.