<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Prompt-Engineering on Ash Tewari</title><link>https://www.tewari.info/tag/prompt-engineering/</link><description>Recent content in Prompt-Engineering on Ash Tewari</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Mon, 05 Feb 2024 01:10:11 +0000</lastBuildDate><atom:link href="https://www.tewari.info/tag/prompt-engineering/feed.xml" rel="self" type="application/rss+xml"/><item><title>Iterative Prompt Engineering with LLMStudio</title><link>https://www.tewari.info/2024/02/04/iterative-prompt-engineering-with-llmstudio/</link><pubDate>Mon, 05 Feb 2024 01:10:11 +0000</pubDate><guid>https://www.tewari.info/2024/02/04/iterative-prompt-engineering-with-llmstudio/</guid><description>&lt;p&gt;Creating the ideal prompt can be the key to transforming a less than average outcome into one that is remarkably relevant. Discovering the right prompt often involves numerous revisions and a method of trial and error. I felt the need to refer to my past attempts, modifications made to prompts, LLM models I tried and other LLM settings as well relative cost of these combinations. There are a few options to help with this : &lt;a class="link" href="https://github.com/microsoft/promptflow" target="_blank" rel="noopener"&#10; &gt;promptflow&lt;/a&gt;, &lt;a class="link" href="https://www.langchain.com/langsmith" target="_blank" rel="noopener"&#10; &gt;langsmith&lt;/a&gt;, &lt;a class="link" href="https://github.com/TensorOpsAI/LLMStudio" target="_blank" rel="noopener"&#10; &gt;LLMStudio&lt;/a&gt; and others.&lt;/p&gt;&#10;&lt;p&gt;I tried LLMStudio and promptflow. This article is about LLMStudio.&lt;/p&gt;&#10;&lt;p&gt;If you are installing LLMStudio on Windows, use &lt;a class="link" href="https://learn.microsoft.com/en-us/windows/wsl/" target="_blank" rel="noopener"&#10; &gt;WSL&lt;/a&gt;. Here are the steps :&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Create a folder on your machine.&lt;/li&gt;&#10;&lt;li&gt;Create .env file here with following content:&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;OPENAI_API_KEY=&amp;#34;sk-api_key&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ANTHROPIC_API_KEY=&amp;#34;sk-api_key&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#10;&lt;li&gt;Enter wsl and create a new python environment with conda&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;(base) PS c:\code\llmstudio&amp;gt; wsl&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;(base) ash@DESKTOP:/mnt/d/code/llmstudio$ conda activate lmstd&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;LLMStudio runs on &lt;a class="link" href="https://bun.sh/" target="_blank" rel="noopener"&#10; &gt;Bun&lt;/a&gt;. Bun is a javascript runtime like &lt;a class="link" href="https://nodejs.org/en" target="_blank" rel="noopener"&#10; &gt;Node&lt;/a&gt;.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Instructions for installing bun on windows :&lt;br&gt;&#10;&lt;a class="link" href="https://bun.sh/docs/installation#windows" target="_blank" rel="noopener"&#10; &gt;https://bun.sh/docs/installation#windows&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install unzip&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;powershell -c &amp;#34;irm bun.sh/install.ps1|iex&amp;#34;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-27.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;ul&gt;&#10;&lt;li&gt;Install Node v18, if you run into ReferenceError: Request is not defined    at Object.&lt;anonymous&gt; (/home/ash/miniconda3/lib/python3.11/site-packages/llmstudio/ui/node_modules/next/dist/server/web/spec-extension/request.js:28:27)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-31.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;ul&gt;&#10;&lt;li&gt;Start LLMStudio&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-32.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-33.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-34.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-35.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;Export the execution data as csv file by clicking on [Export data] button. This data includes the input, output, LLM model, Input and Output tokens as well as cost.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/image-37.png"&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;References&lt;br&gt;&#10;&lt;a class="link" href="https://www.tensorops.ai/post/what-is-llmstudio" target="_blank" rel="noopener"&#10; &gt;What is LLMstudio?&lt;/a&gt;&lt;br&gt;&#10;&lt;a class="link" href="https://github.com/TensorOpsAI/LLMstudio" target="_blank" rel="noopener"&#10; &gt;LLMstudio&lt;/a&gt; by &lt;a class="link" href="http://tensorops.ai/" target="_blank" rel="noopener"&#10; &gt;TensorOps&lt;/a&gt;&lt;br&gt;&#10;&lt;a class="link" href="https://docs.llmstudio.ai/quickstart" target="_blank" rel="noopener"&#10; &gt;LLM Studio Quickstart&lt;/a&gt;&lt;br&gt;&#10;&lt;a class="link" href="https://dev.to/openhacking/install-bun-for-windows-a-modern-javascript-runtime-like-node-or-deno-449e" target="_blank" rel="noopener"&#10; &gt;Install Bun for Windows&lt;/a&gt;&lt;br&gt;&#10;&lt;a class="link" href="https://medium.com/@raj.nagaraj1990/setup-bun-js-in-windows-using-wsl-and-vs-code-712a00cd82a1" target="_blank" rel="noopener"&#10; &gt;Setup Bun JS in windows using WSL and VS code&lt;/a&gt;&lt;br&gt;&#10;&lt;a class="link" href="https://stackoverflow.com/questions/77383943/nextjs-referenceerror-request-is-not-defined-reading-old-version-of-node-s" target="_blank" rel="noopener"&#10; &gt;NextJS - ReferenceError: Request is not defined&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Prompt Engineering and Security - Custom GPT</title><link>https://www.tewari.info/2024/01/21/prompt-engineering-and-security-custom-gpt/</link><pubDate>Sun, 21 Jan 2024 23:01:24 +0000</pubDate><guid>https://www.tewari.info/2024/01/21/prompt-engineering-and-security-custom-gpt/</guid><description>&lt;p&gt;I have been delving into Advanced Prompt Engineering and Security techniques for Large Language Models (LLMs). As an exercise, I have created a custom GPT in &lt;a class="link" href="https://openai.com/blog/introducing-gpts" target="_blank" rel="noopener"&#10; &gt;ChatGPT&lt;/a&gt; to help practice spelling of English words. &lt;a class="link" href="https://bit.ly/3Ua0oib" target="_blank" rel="noopener"&#10; &gt;Spell It&lt;/a&gt; GPT is secured with Advanced Prompt Engineering techniques to guard against common attack vectors, including Direct Prompt Injection, Prompt Leaking, Role Playing, Simulation, DAN and Code Injection.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/wp-content/spell-it-gpt-256.png"&#10;&#9;&#9;&#9;alt="Spell-It-GPT"&gt;&lt;figcaption&gt;&#10;&#9;&#9;&#9;&lt;p&gt;Spell-It-GPT&lt;/p&gt;&#10;&#9;&#9;&lt;/figcaption&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;Play with the &lt;a class="link" href="https://bit.ly/3Ua0oib" target="_blank" rel="noopener"&#10; &gt;Spell It&lt;/a&gt; GPT and try to break it. It is not impossible but (probably) fairly difficult to do ;) Regardless, practice spelling and have fun!&lt;/p&gt;&#10;&lt;p&gt;Switch to &lt;a class="link" href="https://openai.com/blog/chatgpt-can-now-see-hear-and-speak" target="_blank" rel="noopener"&#10; &gt;Voice Mode&lt;/a&gt; in ChatGPT Mobile App to practice spelling and put headsets on for best results!&lt;/p&gt;&#10;&lt;p&gt;Spell It: &lt;a class="link" href="https://bit.ly/3Ua0oib" target="_blank" rel="noopener"&#10; &gt;https://bit.ly/3Ua0oib&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Here are some resources you can learn more about Prompt Engineering and Security:&lt;br&gt;&#10;&lt;a class="link" href="https://www.mercity.ai/blog-post/advanced-prompt-engineering-techniques" target="_blank" rel="noopener"&#10; &gt;Advanced Prompt Engineering Techniques&lt;/a&gt;&lt;br&gt;&#10;&lt;a class="link" href="https://owasp.org/www-project-top-10-for-large-language-model-applications/" target="_blank" rel="noopener"&#10; &gt;OWASP Top 10 for Large Language Model Applications&lt;/a&gt;&lt;br&gt;&#10;&lt;a class="link" href="https://github.com/OWASP/www-project-top-10-for-large-language-model-applications/wiki/Educational-Resources" target="_blank" rel="noopener"&#10; &gt;Educational Resources&lt;/a&gt;&lt;br&gt;&#10;&lt;a class="link" href="https://www.promptingguide.ai/risks/adversarial" target="_blank" rel="noopener"&#10; &gt;Adversarial Prompting in LLMs&lt;/a&gt;&lt;/p&gt;&#10;</description></item></channel></rss>